babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152
  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. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Normalize the current Vector3 with the given input length.
  2082. * Please note that this is an in place operation.
  2083. * @param len the length of the vector
  2084. * @returns the current updated Vector3
  2085. */
  2086. normalizeFromLength(len: number): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to a new vector
  2089. * @returns the new Vector3
  2090. */
  2091. normalizeToNew(): Vector3;
  2092. /**
  2093. * Normalize the current Vector3 to the reference
  2094. * @param reference define the Vector3 to update
  2095. * @returns the updated Vector3
  2096. */
  2097. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2098. /**
  2099. * Creates a new Vector3 copied from the current Vector3
  2100. * @returns the new Vector3
  2101. */
  2102. clone(): Vector3;
  2103. /**
  2104. * Copies the given vector coordinates to the current Vector3 ones
  2105. * @param source defines the source Vector3
  2106. * @returns the current updated Vector3
  2107. */
  2108. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2109. /**
  2110. * Copies the given floats to the current Vector3 coordinates
  2111. * @param x defines the x coordinate of the operand
  2112. * @param y defines the y coordinate of the operand
  2113. * @param z defines the z coordinate of the operand
  2114. * @returns the current updated Vector3
  2115. */
  2116. copyFromFloats(x: number, y: number, z: number): Vector3;
  2117. /**
  2118. * Copies the given floats to the current Vector3 coordinates
  2119. * @param x defines the x coordinate of the operand
  2120. * @param y defines the y coordinate of the operand
  2121. * @param z defines the z coordinate of the operand
  2122. * @returns the current updated Vector3
  2123. */
  2124. set(x: number, y: number, z: number): Vector3;
  2125. /**
  2126. * Copies the given float to the current Vector3 coordinates
  2127. * @param v defines the x, y and z coordinates of the operand
  2128. * @returns the current updated Vector3
  2129. */
  2130. setAll(v: number): Vector3;
  2131. /**
  2132. * Get the clip factor between two vectors
  2133. * @param vector0 defines the first operand
  2134. * @param vector1 defines the second operand
  2135. * @param axis defines the axis to use
  2136. * @param size defines the size along the axis
  2137. * @returns the clip factor
  2138. */
  2139. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2140. /**
  2141. * Get angle between two vectors
  2142. * @param vector0 angle between vector0 and vector1
  2143. * @param vector1 angle between vector0 and vector1
  2144. * @param normal direction of the normal
  2145. * @return the angle between vector0 and vector1
  2146. */
  2147. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2148. /**
  2149. * Returns a new Vector3 set from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @returns the new Vector3
  2153. */
  2154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArray instead
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @returns the new Vector3
  2161. */
  2162. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2163. /**
  2164. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @param result defines the Vector3 where to store the result
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2172. * This function is deprecated. Use FromArrayToRef instead.
  2173. * @param array defines the source array
  2174. * @param offset defines the offset in the source array
  2175. * @param result defines the Vector3 where to store the result
  2176. */
  2177. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2178. /**
  2179. * Sets the given vector "result" with the given floats.
  2180. * @param x defines the x coordinate of the source
  2181. * @param y defines the y coordinate of the source
  2182. * @param z defines the z coordinate of the source
  2183. * @param result defines the Vector3 where to store the result
  2184. */
  2185. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2188. * @returns a new empty Vector3
  2189. */
  2190. static Zero(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2193. * @returns a new unit Vector3
  2194. */
  2195. static One(): Vector3;
  2196. /**
  2197. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2198. * @returns a new up Vector3
  2199. */
  2200. static Up(): Vector3;
  2201. /**
  2202. * Gets a up Vector3 that must not be updated
  2203. */
  2204. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2205. /**
  2206. * Gets a zero Vector3 that must not be updated
  2207. */
  2208. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2211. * @returns a new down Vector3
  2212. */
  2213. static Down(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Forward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2221. * @returns a new forward Vector3
  2222. */
  2223. static Backward(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2226. * @returns a new right Vector3
  2227. */
  2228. static Right(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2231. * @returns a new left Vector3
  2232. */
  2233. static Left(): Vector3;
  2234. /**
  2235. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2237. * @param vector defines the Vector3 to transform
  2238. * @param transformation defines the transformation matrix
  2239. * @returns the transformed Vector3
  2240. */
  2241. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2242. /**
  2243. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2244. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2245. * @param vector defines the Vector3 to transform
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2252. * This method computes tranformed coordinates only, not transformed direction vectors
  2253. * @param x define the x coordinate of the source vector
  2254. * @param y define the y coordinate of the source vector
  2255. * @param z define the z coordinate of the source vector
  2256. * @param transformation defines the transformation matrix
  2257. * @param result defines the Vector3 where to store the result
  2258. */
  2259. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2260. /**
  2261. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2263. * @param vector defines the Vector3 to transform
  2264. * @param transformation defines the transformation matrix
  2265. * @returns the new Vector3
  2266. */
  2267. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2268. /**
  2269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2271. * @param vector defines the Vector3 to transform
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2279. * @param x define the x coordinate of the source vector
  2280. * @param y define the y coordinate of the source vector
  2281. * @param z define the z coordinate of the source vector
  2282. * @param transformation defines the transformation matrix
  2283. * @param result defines the Vector3 where to store the result
  2284. */
  2285. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2286. /**
  2287. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2288. * @param value1 defines the first control point
  2289. * @param value2 defines the second control point
  2290. * @param value3 defines the third control point
  2291. * @param value4 defines the fourth control point
  2292. * @param amount defines the amount on the spline to use
  2293. * @returns the new Vector3
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @returns the new Vector3
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2306. /**
  2307. * 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"
  2308. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2309. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2310. * @param value defines the current value
  2311. * @param min defines the lower range value
  2312. * @param max defines the upper range value
  2313. * @param result defines the Vector3 where to store the result
  2314. */
  2315. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2316. /**
  2317. * Checks if a given vector is inside a specific range
  2318. * @param v defines the vector to test
  2319. * @param min defines the minimum range
  2320. * @param max defines the maximum range
  2321. */
  2322. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2325. * @param value1 defines the first control point
  2326. * @param tangent1 defines the first tangent vector
  2327. * @param value2 defines the second control point
  2328. * @param tangent2 defines the second tangent vector
  2329. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2330. * @returns the new Vector3
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2333. /**
  2334. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2335. * @param start defines the start value
  2336. * @param end defines the end value
  2337. * @param amount max defines amount between both (between 0 and 1)
  2338. * @returns the new Vector3
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2341. /**
  2342. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2343. * @param start defines the start value
  2344. * @param end defines the end value
  2345. * @param amount max defines amount between both (between 0 and 1)
  2346. * @param result defines the Vector3 where to store the result
  2347. */
  2348. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2349. /**
  2350. * Returns the dot product (float) between the vectors "left" and "right"
  2351. * @param left defines the left operand
  2352. * @param right defines the right operand
  2353. * @returns the dot product
  2354. */
  2355. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2356. /**
  2357. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2358. * The cross product is then orthogonal to both "left" and "right"
  2359. * @param left defines the left operand
  2360. * @param right defines the right operand
  2361. * @returns the cross product
  2362. */
  2363. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Sets the given vector "result" with the cross product of "left" and "right"
  2366. * The cross product is then orthogonal to both "left" and "right"
  2367. * @param left defines the left operand
  2368. * @param right defines the right operand
  2369. * @param result defines the Vector3 where to store the result
  2370. */
  2371. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2372. /**
  2373. * Returns a new Vector3 as the normalization of the given vector
  2374. * @param vector defines the Vector3 to normalize
  2375. * @returns the new Vector3
  2376. */
  2377. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Sets the given vector "result" with the normalization of the given first vector
  2380. * @param vector defines the Vector3 to normalize
  2381. * @param result defines the Vector3 where to store the result
  2382. */
  2383. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2384. /**
  2385. * Project a Vector3 onto screen space
  2386. * @param vector defines the Vector3 to project
  2387. * @param world defines the world matrix to use
  2388. * @param transform defines the transform (view x projection) matrix to use
  2389. * @param viewport defines the screen viewport to use
  2390. * @returns the new Vector3
  2391. */
  2392. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2393. /** @hidden */
  2394. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param transform defines the transform (view x projection) matrix to use
  2402. * @returns the new Vector3
  2403. */
  2404. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2405. /**
  2406. * Unproject from screen space to object space
  2407. * @param source defines the screen space Vector3 to use
  2408. * @param viewportWidth defines the current width of the viewport
  2409. * @param viewportHeight defines the current height of the viewport
  2410. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2411. * @param view defines the view matrix to use
  2412. * @param projection defines the projection matrix to use
  2413. * @returns the new Vector3
  2414. */
  2415. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2416. /**
  2417. * Unproject from screen space to object space
  2418. * @param source defines the screen space Vector3 to use
  2419. * @param viewportWidth defines the current width of the viewport
  2420. * @param viewportHeight defines the current height of the viewport
  2421. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2422. * @param view defines the view matrix to use
  2423. * @param projection defines the projection matrix to use
  2424. * @param result defines the Vector3 where to store the result
  2425. */
  2426. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2427. /**
  2428. * Unproject from screen space to object space
  2429. * @param sourceX defines the screen space x coordinate to use
  2430. * @param sourceY defines the screen space y coordinate to use
  2431. * @param sourceZ defines the screen space z coordinate to use
  2432. * @param viewportWidth defines the current width of the viewport
  2433. * @param viewportHeight defines the current height of the viewport
  2434. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2435. * @param view defines the view matrix to use
  2436. * @param projection defines the projection matrix to use
  2437. * @param result defines the Vector3 where to store the result
  2438. */
  2439. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2440. /**
  2441. * Gets the minimal coordinate values between two Vector3
  2442. * @param left defines the first operand
  2443. * @param right defines the second operand
  2444. * @returns the new Vector3
  2445. */
  2446. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2447. /**
  2448. * Gets the maximal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Returns the distance between the vectors "value1" and "value2"
  2456. * @param value1 defines the first operand
  2457. * @param value2 defines the second operand
  2458. * @returns the distance
  2459. */
  2460. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2461. /**
  2462. * Returns the squared distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the squared distance
  2466. */
  2467. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns a new Vector3 located at the center between "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the new Vector3
  2473. */
  2474. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2477. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2478. * to something in order to rotate it from its local system to the given target system
  2479. * Note: axis1, axis2 and axis3 are normalized during this operation
  2480. * @param axis1 defines the first axis
  2481. * @param axis2 defines the second axis
  2482. * @param axis3 defines the third axis
  2483. * @returns a new Vector3
  2484. */
  2485. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2488. * @param axis1 defines the first axis
  2489. * @param axis2 defines the second axis
  2490. * @param axis3 defines the third axis
  2491. * @param ref defines the Vector3 where to store the result
  2492. */
  2493. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2494. }
  2495. /**
  2496. * Vector4 class created for EulerAngle class conversion to Quaternion
  2497. */
  2498. export class Vector4 {
  2499. /** x value of the vector */
  2500. x: number;
  2501. /** y value of the vector */
  2502. y: number;
  2503. /** z value of the vector */
  2504. z: number;
  2505. /** w value of the vector */
  2506. w: number;
  2507. /**
  2508. * Creates a Vector4 object from the given floats.
  2509. * @param x x value of the vector
  2510. * @param y y value of the vector
  2511. * @param z z value of the vector
  2512. * @param w w value of the vector
  2513. */
  2514. constructor(
  2515. /** x value of the vector */
  2516. x: number,
  2517. /** y value of the vector */
  2518. y: number,
  2519. /** z value of the vector */
  2520. z: number,
  2521. /** w value of the vector */
  2522. w: number);
  2523. /**
  2524. * Returns the string with the Vector4 coordinates.
  2525. * @returns a string containing all the vector values
  2526. */
  2527. toString(): string;
  2528. /**
  2529. * Returns the string "Vector4".
  2530. * @returns "Vector4"
  2531. */
  2532. getClassName(): string;
  2533. /**
  2534. * Returns the Vector4 hash code.
  2535. * @returns a unique hash code
  2536. */
  2537. getHashCode(): number;
  2538. /**
  2539. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2540. * @returns the resulting array
  2541. */
  2542. asArray(): number[];
  2543. /**
  2544. * Populates the given array from the given index with the Vector4 coordinates.
  2545. * @param array array to populate
  2546. * @param index index of the array to start at (default: 0)
  2547. * @returns the Vector4.
  2548. */
  2549. toArray(array: FloatArray, index?: number): Vector4;
  2550. /**
  2551. * Adds the given vector to the current Vector4.
  2552. * @param otherVector the vector to add
  2553. * @returns the updated Vector4.
  2554. */
  2555. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2556. /**
  2557. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2558. * @param otherVector the vector to add
  2559. * @returns the resulting vector
  2560. */
  2561. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2562. /**
  2563. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2564. * @param otherVector the vector to add
  2565. * @param result the vector to store the result
  2566. * @returns the current Vector4.
  2567. */
  2568. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2569. /**
  2570. * Subtract in place the given vector from the current Vector4.
  2571. * @param otherVector the vector to subtract
  2572. * @returns the updated Vector4.
  2573. */
  2574. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2575. /**
  2576. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2577. * @param otherVector the vector to add
  2578. * @returns the new vector with the result
  2579. */
  2580. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2581. /**
  2582. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2583. * @param otherVector the vector to subtract
  2584. * @param result the vector to store the result
  2585. * @returns the current Vector4.
  2586. */
  2587. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. */
  2591. /**
  2592. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2593. * @param x value to subtract
  2594. * @param y value to subtract
  2595. * @param z value to subtract
  2596. * @param w value to subtract
  2597. * @returns new vector containing the result
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2600. /**
  2601. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2602. * @param x value to subtract
  2603. * @param y value to subtract
  2604. * @param z value to subtract
  2605. * @param w value to subtract
  2606. * @param result the vector to store the result in
  2607. * @returns the current Vector4.
  2608. */
  2609. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2610. /**
  2611. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2612. * @returns a new vector with the negated values
  2613. */
  2614. negate(): Vector4;
  2615. /**
  2616. * Multiplies the current Vector4 coordinates by scale (float).
  2617. * @param scale the number to scale with
  2618. * @returns the updated Vector4.
  2619. */
  2620. scaleInPlace(scale: number): Vector4;
  2621. /**
  2622. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2623. * @param scale the number to scale with
  2624. * @returns a new vector with the result
  2625. */
  2626. scale(scale: number): Vector4;
  2627. /**
  2628. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2629. * @param scale the number to scale with
  2630. * @param result a vector to store the result in
  2631. * @returns the current Vector4.
  2632. */
  2633. scaleToRef(scale: number, result: Vector4): Vector4;
  2634. /**
  2635. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2636. * @param scale defines the scale factor
  2637. * @param result defines the Vector4 object where to store the result
  2638. * @returns the unmodified current Vector4
  2639. */
  2640. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2643. * @param otherVector the vector to compare against
  2644. * @returns true if they are equal
  2645. */
  2646. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2647. /**
  2648. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2649. * @param otherVector vector to compare against
  2650. * @param epsilon (Default: very small number)
  2651. * @returns true if they are equal
  2652. */
  2653. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2654. /**
  2655. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2656. * @param x x value to compare against
  2657. * @param y y value to compare against
  2658. * @param z z value to compare against
  2659. * @param w w value to compare against
  2660. * @returns true if equal
  2661. */
  2662. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2663. /**
  2664. * Multiplies in place the current Vector4 by the given one.
  2665. * @param otherVector vector to multiple with
  2666. * @returns the updated Vector4.
  2667. */
  2668. multiplyInPlace(otherVector: Vector4): Vector4;
  2669. /**
  2670. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2671. * @param otherVector vector to multiple with
  2672. * @returns resulting new vector
  2673. */
  2674. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2675. /**
  2676. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2677. * @param otherVector vector to multiple with
  2678. * @param result vector to store the result
  2679. * @returns the current Vector4.
  2680. */
  2681. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2682. /**
  2683. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2684. * @param x x value multiply with
  2685. * @param y y value multiply with
  2686. * @param z z value multiply with
  2687. * @param w w value multiply with
  2688. * @returns resulting new vector
  2689. */
  2690. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2691. /**
  2692. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2693. * @param otherVector vector to devide with
  2694. * @returns resulting new vector
  2695. */
  2696. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2697. /**
  2698. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2699. * @param otherVector vector to devide with
  2700. * @param result vector to store the result
  2701. * @returns the current Vector4.
  2702. */
  2703. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2704. /**
  2705. * Divides the current Vector3 coordinates by the given ones.
  2706. * @param otherVector vector to devide with
  2707. * @returns the updated Vector3.
  2708. */
  2709. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2710. /**
  2711. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2712. * @param other defines the second operand
  2713. * @returns the current updated Vector4
  2714. */
  2715. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2716. /**
  2717. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2718. * @param other defines the second operand
  2719. * @returns the current updated Vector4
  2720. */
  2721. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector4 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. floor(): Vector4;
  2727. /**
  2728. * Gets a new Vector4 from current Vector3 floored values
  2729. * @returns a new Vector4
  2730. */
  2731. fract(): Vector4;
  2732. /**
  2733. * Returns the Vector4 length (float).
  2734. * @returns the length
  2735. */
  2736. length(): number;
  2737. /**
  2738. * Returns the Vector4 squared length (float).
  2739. * @returns the length squared
  2740. */
  2741. lengthSquared(): number;
  2742. /**
  2743. * Normalizes in place the Vector4.
  2744. * @returns the updated Vector4.
  2745. */
  2746. normalize(): Vector4;
  2747. /**
  2748. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2749. * @returns this converted to a new vector3
  2750. */
  2751. toVector3(): Vector3;
  2752. /**
  2753. * Returns a new Vector4 copied from the current one.
  2754. * @returns the new cloned vector
  2755. */
  2756. clone(): Vector4;
  2757. /**
  2758. * Updates the current Vector4 with the given one coordinates.
  2759. * @param source the source vector to copy from
  2760. * @returns the updated Vector4.
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2763. /**
  2764. * Updates the current Vector4 coordinates with the given floats.
  2765. * @param x float to copy from
  2766. * @param y float to copy from
  2767. * @param z float to copy from
  2768. * @param w float to copy from
  2769. * @returns the updated Vector4.
  2770. */
  2771. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2772. /**
  2773. * Updates the current Vector4 coordinates with the given floats.
  2774. * @param x float to set from
  2775. * @param y float to set from
  2776. * @param z float to set from
  2777. * @param w float to set from
  2778. * @returns the updated Vector4.
  2779. */
  2780. set(x: number, y: number, z: number, w: number): Vector4;
  2781. /**
  2782. * Copies the given float to the current Vector3 coordinates
  2783. * @param v defines the x, y, z and w coordinates of the operand
  2784. * @returns the current updated Vector3
  2785. */
  2786. setAll(v: number): Vector4;
  2787. /**
  2788. * Returns a new Vector4 set from the starting index of the given array.
  2789. * @param array the array to pull values from
  2790. * @param offset the offset into the array to start at
  2791. * @returns the new vector
  2792. */
  2793. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2794. /**
  2795. * Updates the given vector "result" from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @param result the vector to store the result in
  2799. */
  2800. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given Float32Array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" coordinates from the given floats.
  2810. * @param x float to set from
  2811. * @param y float to set from
  2812. * @param z float to set from
  2813. * @param w float to set from
  2814. * @param result the vector to the floats in
  2815. */
  2816. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2817. /**
  2818. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2819. * @returns the new vector
  2820. */
  2821. static Zero(): Vector4;
  2822. /**
  2823. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2824. * @returns the new vector
  2825. */
  2826. static One(): Vector4;
  2827. /**
  2828. * Returns a new normalized Vector4 from the given one.
  2829. * @param vector the vector to normalize
  2830. * @returns the vector
  2831. */
  2832. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2833. /**
  2834. * Updates the given vector "result" from the normalization of the given one.
  2835. * @param vector the vector to normalize
  2836. * @param result the vector to store the result in
  2837. */
  2838. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2839. /**
  2840. * Returns a vector with the minimum values from the left and right vectors
  2841. * @param left left vector to minimize
  2842. * @param right right vector to minimize
  2843. * @returns a new vector with the minimum of the left and right vector values
  2844. */
  2845. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2846. /**
  2847. * Returns a vector with the maximum values from the left and right vectors
  2848. * @param left left vector to maximize
  2849. * @param right right vector to maximize
  2850. * @returns a new vector with the maximum of the left and right vector values
  2851. */
  2852. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns the distance (float) between the vectors "value1" and "value2".
  2855. * @param value1 value to calulate the distance between
  2856. * @param value2 value to calulate the distance between
  2857. * @return the distance between the two vectors
  2858. */
  2859. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2860. /**
  2861. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors squared
  2865. */
  2866. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the center between
  2870. * @param value2 value to calulate the center between
  2871. * @return the center between the two vectors
  2872. */
  2873. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2874. /**
  2875. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param vector the vector to transform
  2878. * @param transformation the transformation matrix to apply
  2879. * @returns the new vector
  2880. */
  2881. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2882. /**
  2883. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2884. * This methods computes transformed normalized direction vectors only.
  2885. * @param vector the vector to transform
  2886. * @param transformation the transformation matrix to apply
  2887. * @param result the vector to store the result in
  2888. */
  2889. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2890. /**
  2891. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2892. * This methods computes transformed normalized direction vectors only.
  2893. * @param x value to transform
  2894. * @param y value to transform
  2895. * @param z value to transform
  2896. * @param w value to transform
  2897. * @param transformation the transformation matrix to apply
  2898. * @param result the vector to store the results in
  2899. */
  2900. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2901. /**
  2902. * Creates a new Vector4 from a Vector3
  2903. * @param source defines the source data
  2904. * @param w defines the 4th component (default is 0)
  2905. * @returns a new Vector4
  2906. */
  2907. static FromVector3(source: Vector3, w?: number): Vector4;
  2908. }
  2909. /**
  2910. * Class used to store quaternion data
  2911. * @see https://en.wikipedia.org/wiki/Quaternion
  2912. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2913. */
  2914. export class Quaternion {
  2915. /** defines the first component (0 by default) */
  2916. x: number;
  2917. /** defines the second component (0 by default) */
  2918. y: number;
  2919. /** defines the third component (0 by default) */
  2920. z: number;
  2921. /** defines the fourth component (1.0 by default) */
  2922. w: number;
  2923. /**
  2924. * Creates a new Quaternion from the given floats
  2925. * @param x defines the first component (0 by default)
  2926. * @param y defines the second component (0 by default)
  2927. * @param z defines the third component (0 by default)
  2928. * @param w defines the fourth component (1.0 by default)
  2929. */
  2930. constructor(
  2931. /** defines the first component (0 by default) */
  2932. x?: number,
  2933. /** defines the second component (0 by default) */
  2934. y?: number,
  2935. /** defines the third component (0 by default) */
  2936. z?: number,
  2937. /** defines the fourth component (1.0 by default) */
  2938. w?: number);
  2939. /**
  2940. * Gets a string representation for the current quaternion
  2941. * @returns a string with the Quaternion coordinates
  2942. */
  2943. toString(): string;
  2944. /**
  2945. * Gets the class name of the quaternion
  2946. * @returns the string "Quaternion"
  2947. */
  2948. getClassName(): string;
  2949. /**
  2950. * Gets a hash code for this quaternion
  2951. * @returns the quaternion hash code
  2952. */
  2953. getHashCode(): number;
  2954. /**
  2955. * Copy the quaternion to an array
  2956. * @returns a new array populated with 4 elements from the quaternion coordinates
  2957. */
  2958. asArray(): number[];
  2959. /**
  2960. * Check if two quaternions are equals
  2961. * @param otherQuaternion defines the second operand
  2962. * @return true if the current quaternion and the given one coordinates are strictly equals
  2963. */
  2964. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2965. /**
  2966. * Clone the current quaternion
  2967. * @returns a new quaternion copied from the current one
  2968. */
  2969. clone(): Quaternion;
  2970. /**
  2971. * Copy a quaternion to the current one
  2972. * @param other defines the other quaternion
  2973. * @returns the updated current quaternion
  2974. */
  2975. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2976. /**
  2977. * Updates the current quaternion with the given float coordinates
  2978. * @param x defines the x coordinate
  2979. * @param y defines the y coordinate
  2980. * @param z defines the z coordinate
  2981. * @param w defines the w coordinate
  2982. * @returns the updated current quaternion
  2983. */
  2984. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2985. /**
  2986. * Updates the current quaternion from the given float coordinates
  2987. * @param x defines the x coordinate
  2988. * @param y defines the y coordinate
  2989. * @param z defines the z coordinate
  2990. * @param w defines the w coordinate
  2991. * @returns the updated current quaternion
  2992. */
  2993. set(x: number, y: number, z: number, w: number): Quaternion;
  2994. /**
  2995. * Adds two quaternions
  2996. * @param other defines the second operand
  2997. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2998. */
  2999. add(other: DeepImmutable<Quaternion>): Quaternion;
  3000. /**
  3001. * Add a quaternion to the current one
  3002. * @param other defines the quaternion to add
  3003. * @returns the current quaternion
  3004. */
  3005. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3006. /**
  3007. * Subtract two quaternions
  3008. * @param other defines the second operand
  3009. * @returns a new quaternion as the subtraction result of the given one from the current one
  3010. */
  3011. subtract(other: Quaternion): Quaternion;
  3012. /**
  3013. * Multiplies the current quaternion by a scale factor
  3014. * @param value defines the scale factor
  3015. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3016. */
  3017. scale(value: number): Quaternion;
  3018. /**
  3019. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3020. * @param scale defines the scale factor
  3021. * @param result defines the Quaternion object where to store the result
  3022. * @returns the unmodified current quaternion
  3023. */
  3024. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3025. /**
  3026. * Multiplies in place the current quaternion by a scale factor
  3027. * @param value defines the scale factor
  3028. * @returns the current modified quaternion
  3029. */
  3030. scaleInPlace(value: number): Quaternion;
  3031. /**
  3032. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3033. * @param scale defines the scale factor
  3034. * @param result defines the Quaternion object where to store the result
  3035. * @returns the unmodified current quaternion
  3036. */
  3037. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3038. /**
  3039. * Multiplies two quaternions
  3040. * @param q1 defines the second operand
  3041. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3042. */
  3043. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3044. /**
  3045. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3046. * @param q1 defines the second operand
  3047. * @param result defines the target quaternion
  3048. * @returns the current quaternion
  3049. */
  3050. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3051. /**
  3052. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @returns the currentupdated quaternion
  3055. */
  3056. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3057. /**
  3058. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3059. * @param ref defines the target quaternion
  3060. * @returns the current quaternion
  3061. */
  3062. conjugateToRef(ref: Quaternion): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. conjugateInPlace(): Quaternion;
  3068. /**
  3069. * Conjugates in place (1-q) the current quaternion
  3070. * @returns a new quaternion
  3071. */
  3072. conjugate(): Quaternion;
  3073. /**
  3074. * Gets length of current quaternion
  3075. * @returns the quaternion length (float)
  3076. */
  3077. length(): number;
  3078. /**
  3079. * Normalize in place the current quaternion
  3080. * @returns the current updated quaternion
  3081. */
  3082. normalize(): Quaternion;
  3083. /**
  3084. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3085. * @param order is a reserved parameter and is ignore for now
  3086. * @returns a new Vector3 containing the Euler angles
  3087. */
  3088. toEulerAngles(order?: string): Vector3;
  3089. /**
  3090. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3091. * @param result defines the vector which will be filled with the Euler angles
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns the current unchanged quaternion
  3094. */
  3095. toEulerAnglesToRef(result: Vector3): Quaternion;
  3096. /**
  3097. * Updates the given rotation matrix with the current quaternion values
  3098. * @param result defines the target matrix
  3099. * @returns the current unchanged quaternion
  3100. */
  3101. toRotationMatrix(result: Matrix): Quaternion;
  3102. /**
  3103. * Updates the current quaternion from the given rotation matrix values
  3104. * @param matrix defines the source matrix
  3105. * @returns the current updated quaternion
  3106. */
  3107. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3108. /**
  3109. * Creates a new quaternion from a rotation matrix
  3110. * @param matrix defines the source matrix
  3111. * @returns a new quaternion created from the given rotation matrix values
  3112. */
  3113. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3114. /**
  3115. * Updates the given quaternion with the given rotation matrix values
  3116. * @param matrix defines the source matrix
  3117. * @param result defines the target quaternion
  3118. */
  3119. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3120. /**
  3121. * Returns the dot product (float) between the quaternions "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3127. /**
  3128. * Checks if the two quaternions are close to each other
  3129. * @param quat0 defines the first quaternion to check
  3130. * @param quat1 defines the second quaternion to check
  3131. * @returns true if the two quaternions are close to each other
  3132. */
  3133. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3134. /**
  3135. * Creates an empty quaternion
  3136. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3137. */
  3138. static Zero(): Quaternion;
  3139. /**
  3140. * Inverse a given quaternion
  3141. * @param q defines the source quaternion
  3142. * @returns a new quaternion as the inverted current quaternion
  3143. */
  3144. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3145. /**
  3146. * Inverse a given quaternion
  3147. * @param q defines the source quaternion
  3148. * @param result the quaternion the result will be stored in
  3149. * @returns the result quaternion
  3150. */
  3151. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3152. /**
  3153. * Creates an identity quaternion
  3154. * @returns the identity quaternion
  3155. */
  3156. static Identity(): Quaternion;
  3157. /**
  3158. * Gets a boolean indicating if the given quaternion is identity
  3159. * @param quaternion defines the quaternion to check
  3160. * @returns true if the quaternion is identity
  3161. */
  3162. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3163. /**
  3164. * Creates a quaternion from a rotation around an axis
  3165. * @param axis defines the axis to use
  3166. * @param angle defines the angle to use
  3167. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3168. */
  3169. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3170. /**
  3171. * Creates a rotation around an axis and stores it into the given quaternion
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @param result defines the target quaternion
  3175. * @returns the target quaternion
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3178. /**
  3179. * Creates a new quaternion from data stored into an array
  3180. * @param array defines the data source
  3181. * @param offset defines the offset in the source array where the data starts
  3182. * @returns a new quaternion
  3183. */
  3184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3185. /**
  3186. * Create a quaternion from Euler rotation angles
  3187. * @param x Pitch
  3188. * @param y Yaw
  3189. * @param z Roll
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation angles
  3195. * @param x Pitch
  3196. * @param y Yaw
  3197. * @param z Roll
  3198. * @param result the quaternion to store the result
  3199. * @returns the updated quaternion
  3200. */
  3201. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3202. /**
  3203. * Create a quaternion from Euler rotation vector
  3204. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3205. * @returns the new Quaternion
  3206. */
  3207. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3208. /**
  3209. * Updates a quaternion from Euler rotation vector
  3210. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3211. * @param result the quaternion to store the result
  3212. * @returns the updated quaternion
  3213. */
  3214. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3217. * @param yaw defines the rotation around Y axis
  3218. * @param pitch defines the rotation around X axis
  3219. * @param roll defines the rotation around Z axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3223. /**
  3224. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3225. * @param yaw defines the rotation around Y axis
  3226. * @param pitch defines the rotation around X axis
  3227. * @param roll defines the rotation around Z axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3231. /**
  3232. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3233. * @param alpha defines the rotation around first axis
  3234. * @param beta defines the rotation around second axis
  3235. * @param gamma defines the rotation around third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3239. /**
  3240. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3241. * @param alpha defines the rotation around first axis
  3242. * @param beta defines the rotation around second axis
  3243. * @param gamma defines the rotation around third axis
  3244. * @param result defines the target quaternion
  3245. */
  3246. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3247. /**
  3248. * 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)
  3249. * @param axis1 defines the first axis
  3250. * @param axis2 defines the second axis
  3251. * @param axis3 defines the third axis
  3252. * @returns the new quaternion
  3253. */
  3254. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3255. /**
  3256. * 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
  3257. * @param axis1 defines the first axis
  3258. * @param axis2 defines the second axis
  3259. * @param axis3 defines the third axis
  3260. * @param ref defines the target quaternion
  3261. */
  3262. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3263. /**
  3264. * Interpolates between two quaternions
  3265. * @param left defines first quaternion
  3266. * @param right defines second quaternion
  3267. * @param amount defines the gradient to use
  3268. * @returns the new interpolated quaternion
  3269. */
  3270. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3271. /**
  3272. * Interpolates between two quaternions and stores it into a target quaternion
  3273. * @param left defines first quaternion
  3274. * @param right defines second quaternion
  3275. * @param amount defines the gradient to use
  3276. * @param result defines the target quaternion
  3277. */
  3278. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3279. /**
  3280. * Interpolate between two quaternions using Hermite interpolation
  3281. * @param value1 defines first quaternion
  3282. * @param tangent1 defines the incoming tangent
  3283. * @param value2 defines second quaternion
  3284. * @param tangent2 defines the outgoing tangent
  3285. * @param amount defines the target quaternion
  3286. * @returns the new interpolated quaternion
  3287. */
  3288. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3289. }
  3290. /**
  3291. * Class used to store matrix data (4x4)
  3292. */
  3293. export class Matrix {
  3294. private static _updateFlagSeed;
  3295. private static _identityReadOnly;
  3296. private _isIdentity;
  3297. private _isIdentityDirty;
  3298. private _isIdentity3x2;
  3299. private _isIdentity3x2Dirty;
  3300. /**
  3301. * Gets the update flag of the matrix which is an unique number for the matrix.
  3302. * It will be incremented every time the matrix data change.
  3303. * You can use it to speed the comparison between two versions of the same matrix.
  3304. */
  3305. updateFlag: number;
  3306. private readonly _m;
  3307. /**
  3308. * Gets the internal data of the matrix
  3309. */
  3310. readonly m: DeepImmutable<Float32Array>;
  3311. /** @hidden */
  3312. _markAsUpdated(): void;
  3313. /** @hidden */
  3314. private _updateIdentityStatus;
  3315. /**
  3316. * Creates an empty matrix (filled with zeros)
  3317. */
  3318. constructor();
  3319. /**
  3320. * Check if the current matrix is identity
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentity(): boolean;
  3324. /**
  3325. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3326. * @returns true is the matrix is the identity matrix
  3327. */
  3328. isIdentityAs3x2(): boolean;
  3329. /**
  3330. * Gets the determinant of the matrix
  3331. * @returns the matrix determinant
  3332. */
  3333. determinant(): number;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array
  3337. */
  3338. toArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Returns the matrix as a Float32Array
  3341. * @returns the matrix underlying array.
  3342. */
  3343. asArray(): DeepImmutable<Float32Array>;
  3344. /**
  3345. * Inverts the current matrix in place
  3346. * @returns the current inverted matrix
  3347. */
  3348. invert(): Matrix;
  3349. /**
  3350. * Sets all the matrix elements to zero
  3351. * @returns the current matrix
  3352. */
  3353. reset(): Matrix;
  3354. /**
  3355. * Adds the current matrix with a second one
  3356. * @param other defines the matrix to add
  3357. * @returns a new matrix as the addition of the current matrix and the given one
  3358. */
  3359. add(other: DeepImmutable<Matrix>): Matrix;
  3360. /**
  3361. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3362. * @param other defines the matrix to add
  3363. * @param result defines the target matrix
  3364. * @returns the current matrix
  3365. */
  3366. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3367. /**
  3368. * Adds in place the given matrix to the current matrix
  3369. * @param other defines the second operand
  3370. * @returns the current updated matrix
  3371. */
  3372. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3373. /**
  3374. * Sets the given matrix to the current inverted Matrix
  3375. * @param other defines the target matrix
  3376. * @returns the unmodified current matrix
  3377. */
  3378. invertToRef(other: Matrix): Matrix;
  3379. /**
  3380. * add a value at the specified position in the current Matrix
  3381. * @param index the index of the value within the matrix. between 0 and 15.
  3382. * @param value the value to be added
  3383. * @returns the current updated matrix
  3384. */
  3385. addAtIndex(index: number, value: number): Matrix;
  3386. /**
  3387. * mutiply the specified position in the current Matrix by a value
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. multiplyAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * Inserts the translation vector (using 3 floats) in the current matrix
  3395. * @param x defines the 1st component of the translation
  3396. * @param y defines the 2nd component of the translation
  3397. * @param z defines the 3rd component of the translation
  3398. * @returns the current updated matrix
  3399. */
  3400. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3401. /**
  3402. * Adds the translation vector (using 3 floats) in the current matrix
  3403. * @param x defines the 1st component of the translation
  3404. * @param y defines the 2nd component of the translation
  3405. * @param z defines the 3rd component of the translation
  3406. * @returns the current updated matrix
  3407. */
  3408. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3409. /**
  3410. * Inserts the translation vector in the current matrix
  3411. * @param vector3 defines the translation to insert
  3412. * @returns the current updated matrix
  3413. */
  3414. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3415. /**
  3416. * Gets the translation value of the current matrix
  3417. * @returns a new Vector3 as the extracted translation from the matrix
  3418. */
  3419. getTranslation(): Vector3;
  3420. /**
  3421. * Fill a Vector3 with the extracted translation from the matrix
  3422. * @param result defines the Vector3 where to store the translation
  3423. * @returns the current matrix
  3424. */
  3425. getTranslationToRef(result: Vector3): Matrix;
  3426. /**
  3427. * Remove rotation and scaling part from the matrix
  3428. * @returns the updated matrix
  3429. */
  3430. removeRotationAndScaling(): Matrix;
  3431. /**
  3432. * Multiply two matrices
  3433. * @param other defines the second operand
  3434. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3435. */
  3436. multiply(other: DeepImmutable<Matrix>): Matrix;
  3437. /**
  3438. * Copy the current matrix from the given one
  3439. * @param other defines the source matrix
  3440. * @returns the current updated matrix
  3441. */
  3442. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3443. /**
  3444. * Populates the given array from the starting index with the current matrix values
  3445. * @param array defines the target array
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. copyToArray(array: Float32Array, offset?: number): Matrix;
  3450. /**
  3451. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3452. * @param other defines the second operand
  3453. * @param result defines the matrix where to store the multiplication
  3454. * @returns the current matrix
  3455. */
  3456. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3457. /**
  3458. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the array where to store the multiplication
  3461. * @param offset defines the offset in the target array where to start storing values
  3462. * @returns the current matrix
  3463. */
  3464. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3465. /**
  3466. * Check equality between this matrix and a second one
  3467. * @param value defines the second matrix to compare
  3468. * @returns true is the current matrix and the given one values are strictly equal
  3469. */
  3470. equals(value: DeepImmutable<Matrix>): boolean;
  3471. /**
  3472. * Clone the current matrix
  3473. * @returns a new matrix from the current matrix
  3474. */
  3475. clone(): Matrix;
  3476. /**
  3477. * Returns the name of the current matrix class
  3478. * @returns the string "Matrix"
  3479. */
  3480. getClassName(): string;
  3481. /**
  3482. * Gets the hash code of the current matrix
  3483. * @returns the hash code
  3484. */
  3485. getHashCode(): number;
  3486. /**
  3487. * Decomposes the current Matrix into a translation, rotation and scaling components
  3488. * @param scale defines the scale vector3 given as a reference to update
  3489. * @param rotation defines the rotation quaternion given as a reference to update
  3490. * @param translation defines the translation vector3 given as a reference to update
  3491. * @returns true if operation was successful
  3492. */
  3493. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3494. /**
  3495. * Gets specific row of the matrix
  3496. * @param index defines the number of the row to get
  3497. * @returns the index-th row of the current matrix as a new Vector4
  3498. */
  3499. getRow(index: number): Nullable<Vector4>;
  3500. /**
  3501. * Sets the index-th row of the current matrix to the vector4 values
  3502. * @param index defines the number of the row to set
  3503. * @param row defines the target vector4
  3504. * @returns the updated current matrix
  3505. */
  3506. setRow(index: number, row: Vector4): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix
  3509. * @returns the new transposed matrix
  3510. */
  3511. transpose(): Matrix;
  3512. /**
  3513. * Compute the transpose of the matrix and store it in a given matrix
  3514. * @param result defines the target matrix
  3515. * @returns the current matrix
  3516. */
  3517. transposeToRef(result: Matrix): Matrix;
  3518. /**
  3519. * Sets the index-th row of the current matrix with the given 4 x float values
  3520. * @param index defines the row index
  3521. * @param x defines the x component to set
  3522. * @param y defines the y component to set
  3523. * @param z defines the z component to set
  3524. * @param w defines the w component to set
  3525. * @returns the updated current matrix
  3526. */
  3527. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3528. /**
  3529. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3530. * @param scale defines the scale factor
  3531. * @returns a new matrix
  3532. */
  3533. scale(scale: number): Matrix;
  3534. /**
  3535. * Scale the current matrix values by a factor to a given result matrix
  3536. * @param scale defines the scale factor
  3537. * @param result defines the matrix to store the result
  3538. * @returns the current matrix
  3539. */
  3540. scaleToRef(scale: number, result: Matrix): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor and add the result to a given matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the Matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3550. * @param ref matrix to store the result
  3551. */
  3552. toNormalMatrix(ref: Matrix): void;
  3553. /**
  3554. * Gets only rotation part of the current matrix
  3555. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3556. */
  3557. getRotationMatrix(): Matrix;
  3558. /**
  3559. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3560. * @param result defines the target matrix to store data to
  3561. * @returns the current matrix
  3562. */
  3563. getRotationMatrixToRef(result: Matrix): Matrix;
  3564. /**
  3565. * Toggles model matrix from being right handed to left handed in place and vice versa
  3566. */
  3567. toggleModelMatrixHandInPlace(): void;
  3568. /**
  3569. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3570. */
  3571. toggleProjectionMatrixHandInPlace(): void;
  3572. /**
  3573. * Creates a matrix from an array
  3574. * @param array defines the source array
  3575. * @param offset defines an offset in the source array
  3576. * @returns a new Matrix set from the starting index of the given array
  3577. */
  3578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3579. /**
  3580. * Copy the content of an array into a given matrix
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @param result defines the target matrix
  3584. */
  3585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3586. /**
  3587. * Stores an array into a matrix after having multiplied each component by a given factor
  3588. * @param array defines the source array
  3589. * @param offset defines the offset in the source array
  3590. * @param scale defines the scaling factor
  3591. * @param result defines the target matrix
  3592. */
  3593. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3594. /**
  3595. * Gets an identity matrix that must not be updated
  3596. */
  3597. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3598. /**
  3599. * Stores a list of values (16) inside a given matrix
  3600. * @param initialM11 defines 1st value of 1st row
  3601. * @param initialM12 defines 2nd value of 1st row
  3602. * @param initialM13 defines 3rd value of 1st row
  3603. * @param initialM14 defines 4th value of 1st row
  3604. * @param initialM21 defines 1st value of 2nd row
  3605. * @param initialM22 defines 2nd value of 2nd row
  3606. * @param initialM23 defines 3rd value of 2nd row
  3607. * @param initialM24 defines 4th value of 2nd row
  3608. * @param initialM31 defines 1st value of 3rd row
  3609. * @param initialM32 defines 2nd value of 3rd row
  3610. * @param initialM33 defines 3rd value of 3rd row
  3611. * @param initialM34 defines 4th value of 3rd row
  3612. * @param initialM41 defines 1st value of 4th row
  3613. * @param initialM42 defines 2nd value of 4th row
  3614. * @param initialM43 defines 3rd value of 4th row
  3615. * @param initialM44 defines 4th value of 4th row
  3616. * @param result defines the target matrix
  3617. */
  3618. 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;
  3619. /**
  3620. * Creates new matrix from a list of values (16)
  3621. * @param initialM11 defines 1st value of 1st row
  3622. * @param initialM12 defines 2nd value of 1st row
  3623. * @param initialM13 defines 3rd value of 1st row
  3624. * @param initialM14 defines 4th value of 1st row
  3625. * @param initialM21 defines 1st value of 2nd row
  3626. * @param initialM22 defines 2nd value of 2nd row
  3627. * @param initialM23 defines 3rd value of 2nd row
  3628. * @param initialM24 defines 4th value of 2nd row
  3629. * @param initialM31 defines 1st value of 3rd row
  3630. * @param initialM32 defines 2nd value of 3rd row
  3631. * @param initialM33 defines 3rd value of 3rd row
  3632. * @param initialM34 defines 4th value of 3rd row
  3633. * @param initialM41 defines 1st value of 4th row
  3634. * @param initialM42 defines 2nd value of 4th row
  3635. * @param initialM43 defines 3rd value of 4th row
  3636. * @param initialM44 defines 4th value of 4th row
  3637. * @returns the new matrix
  3638. */
  3639. 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;
  3640. /**
  3641. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3642. * @param scale defines the scale vector3
  3643. * @param rotation defines the rotation quaternion
  3644. * @param translation defines the translation vector3
  3645. * @returns a new matrix
  3646. */
  3647. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3648. /**
  3649. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3650. * @param scale defines the scale vector3
  3651. * @param rotation defines the rotation quaternion
  3652. * @param translation defines the translation vector3
  3653. * @param result defines the target matrix
  3654. */
  3655. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3656. /**
  3657. * Creates a new identity matrix
  3658. * @returns a new identity matrix
  3659. */
  3660. static Identity(): Matrix;
  3661. /**
  3662. * Creates a new identity matrix and stores the result in a given matrix
  3663. * @param result defines the target matrix
  3664. */
  3665. static IdentityToRef(result: Matrix): void;
  3666. /**
  3667. * Creates a new zero matrix
  3668. * @returns a new zero matrix
  3669. */
  3670. static Zero(): Matrix;
  3671. /**
  3672. * Creates a new rotation matrix for "angle" radians around the X axis
  3673. * @param angle defines the angle (in radians) to use
  3674. * @return the new matrix
  3675. */
  3676. static RotationX(angle: number): Matrix;
  3677. /**
  3678. * Creates a new matrix as the invert of a given matrix
  3679. * @param source defines the source matrix
  3680. * @returns the new matrix
  3681. */
  3682. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3683. /**
  3684. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3685. * @param angle defines the angle (in radians) to use
  3686. * @param result defines the target matrix
  3687. */
  3688. static RotationXToRef(angle: number, result: Matrix): void;
  3689. /**
  3690. * Creates a new rotation matrix for "angle" radians around the Y axis
  3691. * @param angle defines the angle (in radians) to use
  3692. * @return the new matrix
  3693. */
  3694. static RotationY(angle: number): Matrix;
  3695. /**
  3696. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3697. * @param angle defines the angle (in radians) to use
  3698. * @param result defines the target matrix
  3699. */
  3700. static RotationYToRef(angle: number, result: Matrix): void;
  3701. /**
  3702. * Creates a new rotation matrix for "angle" radians around the Z axis
  3703. * @param angle defines the angle (in radians) to use
  3704. * @return the new matrix
  3705. */
  3706. static RotationZ(angle: number): Matrix;
  3707. /**
  3708. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3709. * @param angle defines the angle (in radians) to use
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationZToRef(angle: number, result: Matrix): void;
  3713. /**
  3714. * Creates a new rotation matrix for "angle" radians around the given axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle (in radians) to use
  3717. * @return the new matrix
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @param result defines the target matrix
  3725. */
  3726. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3727. /**
  3728. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3729. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3730. * @param from defines the vector to align
  3731. * @param to defines the vector to align to
  3732. * @param result defines the target matrix
  3733. */
  3734. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3735. /**
  3736. * Creates a rotation matrix
  3737. * @param yaw defines the yaw angle in radians (Y axis)
  3738. * @param pitch defines the pitch angle in radians (X axis)
  3739. * @param roll defines the roll angle in radians (X axis)
  3740. * @returns the new rotation matrix
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3743. /**
  3744. * Creates a rotation matrix and stores it in a given matrix
  3745. * @param yaw defines the yaw angle in radians (Y axis)
  3746. * @param pitch defines the pitch angle in radians (X axis)
  3747. * @param roll defines the roll angle in radians (X axis)
  3748. * @param result defines the target matrix
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3751. /**
  3752. * Creates a scaling matrix
  3753. * @param x defines the scale factor on X axis
  3754. * @param y defines the scale factor on Y axis
  3755. * @param z defines the scale factor on Z axis
  3756. * @returns the new matrix
  3757. */
  3758. static Scaling(x: number, y: number, z: number): Matrix;
  3759. /**
  3760. * Creates a scaling matrix and stores it in a given matrix
  3761. * @param x defines the scale factor on X axis
  3762. * @param y defines the scale factor on Y axis
  3763. * @param z defines the scale factor on Z axis
  3764. * @param result defines the target matrix
  3765. */
  3766. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3767. /**
  3768. * Creates a translation matrix
  3769. * @param x defines the translation on X axis
  3770. * @param y defines the translation on Y axis
  3771. * @param z defines the translationon Z axis
  3772. * @returns the new matrix
  3773. */
  3774. static Translation(x: number, y: number, z: number): Matrix;
  3775. /**
  3776. * Creates a translation matrix and stores it in a given matrix
  3777. * @param x defines the translation on X axis
  3778. * @param y defines the translation on Y axis
  3779. * @param z defines the translationon Z axis
  3780. * @param result defines the target matrix
  3781. */
  3782. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3783. /**
  3784. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3785. * @param startValue defines the start value
  3786. * @param endValue defines the end value
  3787. * @param gradient defines the gradient factor
  3788. * @returns the new matrix
  3789. */
  3790. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3791. /**
  3792. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3793. * @param startValue defines the start value
  3794. * @param endValue defines the end value
  3795. * @param gradient defines the gradient factor
  3796. * @param result defines the Matrix object where to store data
  3797. */
  3798. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * Builds a new matrix whose values are computed by:
  3801. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3802. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3803. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3804. * @param startValue defines the first matrix
  3805. * @param endValue defines the second matrix
  3806. * @param gradient defines the gradient between the two matrices
  3807. * @returns the new matrix
  3808. */
  3809. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3810. /**
  3811. * Update a matrix to values which are computed by:
  3812. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3813. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3814. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3815. * @param startValue defines the first matrix
  3816. * @param endValue defines the second matrix
  3817. * @param gradient defines the gradient between the two matrices
  3818. * @param result defines the target matrix
  3819. */
  3820. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3821. /**
  3822. * 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"
  3823. * This function works in left handed mode
  3824. * @param eye defines the final position of the entity
  3825. * @param target defines where the entity should look at
  3826. * @param up defines the up vector for the entity
  3827. * @returns the new matrix
  3828. */
  3829. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3830. /**
  3831. * 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".
  3832. * This function works in left handed mode
  3833. * @param eye defines the final position of the entity
  3834. * @param target defines where the entity should look at
  3835. * @param up defines the up vector for the entity
  3836. * @param result defines the target matrix
  3837. */
  3838. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3839. /**
  3840. * 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"
  3841. * This function works in right handed mode
  3842. * @param eye defines the final position of the entity
  3843. * @param target defines where the entity should look at
  3844. * @param up defines the up vector for the entity
  3845. * @returns the new matrix
  3846. */
  3847. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3848. /**
  3849. * 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".
  3850. * This function works in right handed mode
  3851. * @param eye defines the final position of the entity
  3852. * @param target defines where the entity should look at
  3853. * @param up defines the up vector for the entity
  3854. * @param result defines the target matrix
  3855. */
  3856. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3857. /**
  3858. * Create a left-handed orthographic projection matrix
  3859. * @param width defines the viewport width
  3860. * @param height defines the viewport height
  3861. * @param znear defines the near clip plane
  3862. * @param zfar defines the far clip plane
  3863. * @returns a new matrix as a left-handed orthographic projection matrix
  3864. */
  3865. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3866. /**
  3867. * Store a left-handed orthographic projection to a given matrix
  3868. * @param width defines the viewport width
  3869. * @param height defines the viewport height
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Create a left-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a left-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a left-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a right-handed orthographic projection matrix
  3899. * @param left defines the viewport left coordinate
  3900. * @param right defines the viewport right coordinate
  3901. * @param bottom defines the viewport bottom coordinate
  3902. * @param top defines the viewport top coordinate
  3903. * @param znear defines the near clip plane
  3904. * @param zfar defines the far clip plane
  3905. * @returns a new matrix as a right-handed orthographic projection matrix
  3906. */
  3907. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3908. /**
  3909. * Stores a right-handed orthographic projection into a given matrix
  3910. * @param left defines the viewport left coordinate
  3911. * @param right defines the viewport right coordinate
  3912. * @param bottom defines the viewport bottom coordinate
  3913. * @param top defines the viewport top coordinate
  3914. * @param znear defines the near clip plane
  3915. * @param zfar defines the far clip plane
  3916. * @param result defines the target matrix
  3917. */
  3918. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3919. /**
  3920. * Creates a left-handed perspective projection matrix
  3921. * @param width defines the viewport width
  3922. * @param height defines the viewport height
  3923. * @param znear defines the near clip plane
  3924. * @param zfar defines the far clip plane
  3925. * @returns a new matrix as a left-handed perspective projection matrix
  3926. */
  3927. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3928. /**
  3929. * Creates a left-handed perspective projection matrix
  3930. * @param fov defines the horizontal field of view
  3931. * @param aspect defines the aspect ratio
  3932. * @param znear defines the near clip plane
  3933. * @param zfar defines the far clip plane
  3934. * @returns a new matrix as a left-handed perspective projection matrix
  3935. */
  3936. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3937. /**
  3938. * Stores a left-handed perspective projection into a given matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @param result defines the target matrix
  3944. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3945. */
  3946. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3947. /**
  3948. * Creates a right-handed perspective projection matrix
  3949. * @param fov defines the horizontal field of view
  3950. * @param aspect defines the aspect ratio
  3951. * @param znear defines the near clip plane
  3952. * @param zfar defines the far clip plane
  3953. * @returns a new matrix as a right-handed perspective projection matrix
  3954. */
  3955. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3956. /**
  3957. * Stores a right-handed perspective projection into a given matrix
  3958. * @param fov defines the horizontal field of view
  3959. * @param aspect defines the aspect ratio
  3960. * @param znear defines the near clip plane
  3961. * @param zfar defines the far clip plane
  3962. * @param result defines the target matrix
  3963. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3964. */
  3965. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3966. /**
  3967. * Stores a perspective projection for WebVR info a given matrix
  3968. * @param fov defines the field of view
  3969. * @param znear defines the near clip plane
  3970. * @param zfar defines the far clip plane
  3971. * @param result defines the target matrix
  3972. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3973. */
  3974. static PerspectiveFovWebVRToRef(fov: {
  3975. upDegrees: number;
  3976. downDegrees: number;
  3977. leftDegrees: number;
  3978. rightDegrees: number;
  3979. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3980. /**
  3981. * Computes a complete transformation matrix
  3982. * @param viewport defines the viewport to use
  3983. * @param world defines the world matrix
  3984. * @param view defines the view matrix
  3985. * @param projection defines the projection matrix
  3986. * @param zmin defines the near clip plane
  3987. * @param zmax defines the far clip plane
  3988. * @returns the transformation matrix
  3989. */
  3990. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3991. /**
  3992. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3993. * @param matrix defines the matrix to use
  3994. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3995. */
  3996. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3997. /**
  3998. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3999. * @param matrix defines the matrix to use
  4000. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4001. */
  4002. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4003. /**
  4004. * Compute the transpose of a given matrix
  4005. * @param matrix defines the matrix to transpose
  4006. * @returns the new matrix
  4007. */
  4008. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Compute the transpose of a matrix and store it in a target matrix
  4011. * @param matrix defines the matrix to transpose
  4012. * @param result defines the target matrix
  4013. */
  4014. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4015. /**
  4016. * Computes a reflection matrix from a plane
  4017. * @param plane defines the reflection plane
  4018. * @returns a new matrix
  4019. */
  4020. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4021. /**
  4022. * Computes a reflection matrix from a plane
  4023. * @param plane defines the reflection plane
  4024. * @param result defines the target matrix
  4025. */
  4026. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4027. /**
  4028. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4029. * @param xaxis defines the value of the 1st axis
  4030. * @param yaxis defines the value of the 2nd axis
  4031. * @param zaxis defines the value of the 3rd axis
  4032. * @param result defines the target matrix
  4033. */
  4034. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4035. /**
  4036. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4037. * @param quat defines the quaternion to use
  4038. * @param result defines the target matrix
  4039. */
  4040. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4041. }
  4042. /**
  4043. * @hidden
  4044. */
  4045. export class TmpVectors {
  4046. static Vector2: Vector2[];
  4047. static Vector3: Vector3[];
  4048. static Vector4: Vector4[];
  4049. static Quaternion: Quaternion[];
  4050. static Matrix: Matrix[];
  4051. }
  4052. }
  4053. declare module "babylonjs/Engines/constants" {
  4054. /** Defines the cross module used constants to avoid circular dependncies */
  4055. export class Constants {
  4056. /** Defines that alpha blending is disabled */
  4057. static readonly ALPHA_DISABLE: number;
  4058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4059. static readonly ALPHA_ADD: number;
  4060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_COMBINE: number;
  4062. /** Defines that alpha blending to DEST - SRC * DEST */
  4063. static readonly ALPHA_SUBTRACT: number;
  4064. /** Defines that alpha blending to SRC * DEST */
  4065. static readonly ALPHA_MULTIPLY: number;
  4066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4067. static readonly ALPHA_MAXIMIZED: number;
  4068. /** Defines that alpha blending to SRC + DEST */
  4069. static readonly ALPHA_ONEONE: number;
  4070. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4071. static readonly ALPHA_PREMULTIPLIED: number;
  4072. /**
  4073. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4074. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4075. */
  4076. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4077. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4078. static readonly ALPHA_INTERPOLATE: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4081. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_SCREENMODE: number;
  4084. /** Defines that the ressource is not delayed*/
  4085. static readonly DELAYLOADSTATE_NONE: number;
  4086. /** Defines that the ressource was successfully delay loaded */
  4087. static readonly DELAYLOADSTATE_LOADED: number;
  4088. /** Defines that the ressource is currently delay loading */
  4089. static readonly DELAYLOADSTATE_LOADING: number;
  4090. /** Defines that the ressource is delayed and has not started loading */
  4091. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4093. static readonly NEVER: number;
  4094. /** 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 */
  4095. static readonly ALWAYS: number;
  4096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4097. static readonly LESS: number;
  4098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4099. static readonly EQUAL: number;
  4100. /** 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 */
  4101. static readonly LEQUAL: number;
  4102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4103. static readonly GREATER: number;
  4104. /** 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 */
  4105. static readonly GEQUAL: number;
  4106. /** 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 */
  4107. static readonly NOTEQUAL: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be kept */
  4109. static readonly KEEP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4111. static readonly REPLACE: number;
  4112. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4113. static readonly INCR: number;
  4114. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4115. static readonly DECR: number;
  4116. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4117. static readonly INVERT: number;
  4118. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4119. static readonly INCR_WRAP: number;
  4120. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4121. static readonly DECR_WRAP: number;
  4122. /** Texture is not repeating outside of 0..1 UVs */
  4123. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4124. /** Texture is repeating outside of 0..1 UVs */
  4125. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4126. /** Texture is repeating and mirrored */
  4127. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4128. /** ALPHA */
  4129. static readonly TEXTUREFORMAT_ALPHA: number;
  4130. /** LUMINANCE */
  4131. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4132. /** LUMINANCE_ALPHA */
  4133. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4134. /** RGB */
  4135. static readonly TEXTUREFORMAT_RGB: number;
  4136. /** RGBA */
  4137. static readonly TEXTUREFORMAT_RGBA: number;
  4138. /** RED */
  4139. static readonly TEXTUREFORMAT_RED: number;
  4140. /** RED (2nd reference) */
  4141. static readonly TEXTUREFORMAT_R: number;
  4142. /** RG */
  4143. static readonly TEXTUREFORMAT_RG: number;
  4144. /** RED_INTEGER */
  4145. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4146. /** RED_INTEGER (2nd reference) */
  4147. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4148. /** RG_INTEGER */
  4149. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4150. /** RGB_INTEGER */
  4151. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4152. /** RGBA_INTEGER */
  4153. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4154. /** UNSIGNED_BYTE */
  4155. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4156. /** UNSIGNED_BYTE (2nd reference) */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4158. /** FLOAT */
  4159. static readonly TEXTURETYPE_FLOAT: number;
  4160. /** HALF_FLOAT */
  4161. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4162. /** BYTE */
  4163. static readonly TEXTURETYPE_BYTE: number;
  4164. /** SHORT */
  4165. static readonly TEXTURETYPE_SHORT: number;
  4166. /** UNSIGNED_SHORT */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4168. /** INT */
  4169. static readonly TEXTURETYPE_INT: number;
  4170. /** UNSIGNED_INT */
  4171. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4172. /** UNSIGNED_SHORT_4_4_4_4 */
  4173. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4174. /** UNSIGNED_SHORT_5_5_5_1 */
  4175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4176. /** UNSIGNED_SHORT_5_6_5 */
  4177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4178. /** UNSIGNED_INT_2_10_10_10_REV */
  4179. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4180. /** UNSIGNED_INT_24_8 */
  4181. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4182. /** UNSIGNED_INT_10F_11F_11F_REV */
  4183. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4184. /** UNSIGNED_INT_5_9_9_9_REV */
  4185. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4186. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4187. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4188. /** nearest is mag = nearest and min = nearest and mip = linear */
  4189. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4191. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4192. /** Trilinear is mag = linear and min = linear and mip = linear */
  4193. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4194. /** nearest is mag = nearest and min = nearest and mip = linear */
  4195. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4197. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4198. /** Trilinear is mag = linear and min = linear and mip = linear */
  4199. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4200. /** mag = nearest and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4202. /** mag = nearest and min = linear and mip = nearest */
  4203. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4204. /** mag = nearest and min = linear and mip = linear */
  4205. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4206. /** mag = nearest and min = linear and mip = none */
  4207. static readonly TEXTURE_NEAREST_LINEAR: number;
  4208. /** mag = nearest and min = nearest and mip = none */
  4209. static readonly TEXTURE_NEAREST_NEAREST: number;
  4210. /** mag = linear and min = nearest and mip = nearest */
  4211. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4212. /** mag = linear and min = nearest and mip = linear */
  4213. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4214. /** mag = linear and min = linear and mip = none */
  4215. static readonly TEXTURE_LINEAR_LINEAR: number;
  4216. /** mag = linear and min = nearest and mip = none */
  4217. static readonly TEXTURE_LINEAR_NEAREST: number;
  4218. /** Explicit coordinates mode */
  4219. static readonly TEXTURE_EXPLICIT_MODE: number;
  4220. /** Spherical coordinates mode */
  4221. static readonly TEXTURE_SPHERICAL_MODE: number;
  4222. /** Planar coordinates mode */
  4223. static readonly TEXTURE_PLANAR_MODE: number;
  4224. /** Cubic coordinates mode */
  4225. static readonly TEXTURE_CUBIC_MODE: number;
  4226. /** Projection coordinates mode */
  4227. static readonly TEXTURE_PROJECTION_MODE: number;
  4228. /** Skybox coordinates mode */
  4229. static readonly TEXTURE_SKYBOX_MODE: number;
  4230. /** Inverse Cubic coordinates mode */
  4231. static readonly TEXTURE_INVCUBIC_MODE: number;
  4232. /** Equirectangular coordinates mode */
  4233. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4234. /** Equirectangular Fixed coordinates mode */
  4235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4236. /** Equirectangular Fixed Mirrored coordinates mode */
  4237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4238. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4239. static readonly SCALEMODE_FLOOR: number;
  4240. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4241. static readonly SCALEMODE_NEAREST: number;
  4242. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4243. static readonly SCALEMODE_CEILING: number;
  4244. /**
  4245. * The dirty texture flag value
  4246. */
  4247. static readonly MATERIAL_TextureDirtyFlag: number;
  4248. /**
  4249. * The dirty light flag value
  4250. */
  4251. static readonly MATERIAL_LightDirtyFlag: number;
  4252. /**
  4253. * The dirty fresnel flag value
  4254. */
  4255. static readonly MATERIAL_FresnelDirtyFlag: number;
  4256. /**
  4257. * The dirty attribute flag value
  4258. */
  4259. static readonly MATERIAL_AttributesDirtyFlag: number;
  4260. /**
  4261. * The dirty misc flag value
  4262. */
  4263. static readonly MATERIAL_MiscDirtyFlag: number;
  4264. /**
  4265. * The all dirty flag value
  4266. */
  4267. static readonly MATERIAL_AllDirtyFlag: number;
  4268. /**
  4269. * Returns the triangle fill mode
  4270. */
  4271. static readonly MATERIAL_TriangleFillMode: number;
  4272. /**
  4273. * Returns the wireframe mode
  4274. */
  4275. static readonly MATERIAL_WireFrameFillMode: number;
  4276. /**
  4277. * Returns the point fill mode
  4278. */
  4279. static readonly MATERIAL_PointFillMode: number;
  4280. /**
  4281. * Returns the point list draw mode
  4282. */
  4283. static readonly MATERIAL_PointListDrawMode: number;
  4284. /**
  4285. * Returns the line list draw mode
  4286. */
  4287. static readonly MATERIAL_LineListDrawMode: number;
  4288. /**
  4289. * Returns the line loop draw mode
  4290. */
  4291. static readonly MATERIAL_LineLoopDrawMode: number;
  4292. /**
  4293. * Returns the line strip draw mode
  4294. */
  4295. static readonly MATERIAL_LineStripDrawMode: number;
  4296. /**
  4297. * Returns the triangle strip draw mode
  4298. */
  4299. static readonly MATERIAL_TriangleStripDrawMode: number;
  4300. /**
  4301. * Returns the triangle fan draw mode
  4302. */
  4303. static readonly MATERIAL_TriangleFanDrawMode: number;
  4304. /**
  4305. * Stores the clock-wise side orientation
  4306. */
  4307. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4308. /**
  4309. * Stores the counter clock-wise side orientation
  4310. */
  4311. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4312. /**
  4313. * Nothing
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_NothingTrigger: number;
  4317. /**
  4318. * On pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnPickTrigger: number;
  4322. /**
  4323. * On left pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnLeftPickTrigger: number;
  4327. /**
  4328. * On right pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnRightPickTrigger: number;
  4332. /**
  4333. * On center pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnCenterPickTrigger: number;
  4337. /**
  4338. * On pick down
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickDownTrigger: number;
  4342. /**
  4343. * On double pick
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnDoublePickTrigger: number;
  4347. /**
  4348. * On pick up
  4349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4350. */
  4351. static readonly ACTION_OnPickUpTrigger: number;
  4352. /**
  4353. * On pick out.
  4354. * This trigger will only be raised if you also declared a OnPickDown
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPickOutTrigger: number;
  4358. /**
  4359. * On long press
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnLongPressTrigger: number;
  4363. /**
  4364. * On pointer over
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOverTrigger: number;
  4368. /**
  4369. * On pointer out
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnPointerOutTrigger: number;
  4373. /**
  4374. * On every frame
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnEveryFrameTrigger: number;
  4378. /**
  4379. * On intersection enter
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4383. /**
  4384. * On intersection exit
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnIntersectionExitTrigger: number;
  4388. /**
  4389. * On key down
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyDownTrigger: number;
  4393. /**
  4394. * On key up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnKeyUpTrigger: number;
  4398. /**
  4399. * Billboard mode will only apply to Y axis
  4400. */
  4401. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4402. /**
  4403. * Billboard mode will apply to all axes
  4404. */
  4405. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4406. /**
  4407. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4408. */
  4409. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4410. /**
  4411. * Gets or sets base Assets URL
  4412. */
  4413. static PARTICLES_BaseAssetsUrl: string;
  4414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4415. * Test order :
  4416. * Is the bounding sphere outside the frustum ?
  4417. * If not, are the bounding box vertices outside the frustum ?
  4418. * It not, then the cullable object is in the frustum.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4421. /** Culling strategy : Bounding Sphere Only.
  4422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4423. * It's also less accurate than the standard because some not visible objects can still be selected.
  4424. * Test : is the bounding sphere outside the frustum ?
  4425. * If not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4428. /** Culling strategy : Optimistic Inclusion.
  4429. * This in an inclusion test first, then the standard exclusion test.
  4430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * Anyway, it's as accurate as the standard strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the default culling strategy.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4441. * 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.
  4442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4443. * Test :
  4444. * Is the cullable object bounding sphere center in the frustum ?
  4445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4446. */
  4447. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4448. /**
  4449. * No logging while loading
  4450. */
  4451. static readonly SCENELOADER_NO_LOGGING: number;
  4452. /**
  4453. * Minimal logging while loading
  4454. */
  4455. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4456. /**
  4457. * Summary logging while loading
  4458. */
  4459. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4460. /**
  4461. * Detailled logging while loading
  4462. */
  4463. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4464. }
  4465. }
  4466. declare module "babylonjs/Engines/IPipelineContext" {
  4467. /**
  4468. * Class used to store and describe the pipeline context associated with an effect
  4469. */
  4470. export interface IPipelineContext {
  4471. /**
  4472. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4473. */
  4474. isAsync: boolean;
  4475. /**
  4476. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4477. */
  4478. isReady: boolean;
  4479. /** @hidden */
  4480. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4481. }
  4482. }
  4483. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4484. /** @hidden */
  4485. export interface IShaderProcessor {
  4486. attributeProcessor?: (attribute: string) => string;
  4487. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4488. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4489. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4490. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4491. lineProcessor?: (line: string, isFragment: boolean) => string;
  4492. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4493. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4494. }
  4495. }
  4496. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4497. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4498. /** @hidden */
  4499. export interface ProcessingOptions {
  4500. defines: string[];
  4501. indexParameters: any;
  4502. isFragment: boolean;
  4503. shouldUseHighPrecisionShader: boolean;
  4504. supportsUniformBuffers: boolean;
  4505. shadersRepository: string;
  4506. includesShadersStore: {
  4507. [key: string]: string;
  4508. };
  4509. processor?: IShaderProcessor;
  4510. version: string;
  4511. platformName: string;
  4512. lookForClosingBracketForUniformBuffer?: boolean;
  4513. }
  4514. }
  4515. declare module "babylonjs/Misc/stringTools" {
  4516. /**
  4517. * Helper to manipulate strings
  4518. */
  4519. export class StringTools {
  4520. /**
  4521. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4522. * @param str Source string
  4523. * @param suffix Suffix to search for in the source string
  4524. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4525. */
  4526. static EndsWith(str: string, suffix: string): boolean;
  4527. /**
  4528. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static StartsWith(str: string, suffix: string): boolean;
  4534. }
  4535. }
  4536. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4537. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4538. /** @hidden */
  4539. export class ShaderCodeNode {
  4540. line: string;
  4541. children: ShaderCodeNode[];
  4542. additionalDefineKey?: string;
  4543. additionalDefineValue?: string;
  4544. isValid(preprocessors: {
  4545. [key: string]: string;
  4546. }): boolean;
  4547. process(preprocessors: {
  4548. [key: string]: string;
  4549. }, options: ProcessingOptions): string;
  4550. }
  4551. }
  4552. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4553. /** @hidden */
  4554. export class ShaderCodeCursor {
  4555. private _lines;
  4556. lineIndex: number;
  4557. readonly currentLine: string;
  4558. readonly canRead: boolean;
  4559. lines: string[];
  4560. }
  4561. }
  4562. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4563. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4564. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4565. /** @hidden */
  4566. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4567. process(preprocessors: {
  4568. [key: string]: string;
  4569. }, options: ProcessingOptions): string;
  4570. }
  4571. }
  4572. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4573. /** @hidden */
  4574. export class ShaderDefineExpression {
  4575. isTrue(preprocessors: {
  4576. [key: string]: string;
  4577. }): boolean;
  4578. }
  4579. }
  4580. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4581. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4582. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4583. /** @hidden */
  4584. export class ShaderCodeTestNode extends ShaderCodeNode {
  4585. testExpression: ShaderDefineExpression;
  4586. isValid(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4593. /** @hidden */
  4594. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4595. define: string;
  4596. not: boolean;
  4597. constructor(define: string, not?: boolean);
  4598. isTrue(preprocessors: {
  4599. [key: string]: string;
  4600. }): boolean;
  4601. }
  4602. }
  4603. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4604. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4605. /** @hidden */
  4606. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4607. leftOperand: ShaderDefineExpression;
  4608. rightOperand: ShaderDefineExpression;
  4609. isTrue(preprocessors: {
  4610. [key: string]: string;
  4611. }): boolean;
  4612. }
  4613. }
  4614. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4615. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4616. /** @hidden */
  4617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4618. leftOperand: ShaderDefineExpression;
  4619. rightOperand: ShaderDefineExpression;
  4620. isTrue(preprocessors: {
  4621. [key: string]: string;
  4622. }): boolean;
  4623. }
  4624. }
  4625. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4626. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4627. /** @hidden */
  4628. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4629. define: string;
  4630. operand: string;
  4631. testValue: string;
  4632. constructor(define: string, operand: string, testValue: string);
  4633. isTrue(preprocessors: {
  4634. [key: string]: string;
  4635. }): boolean;
  4636. }
  4637. }
  4638. declare module "babylonjs/Misc/loadFileError" {
  4639. import { WebRequest } from "babylonjs/Misc/webRequest";
  4640. /**
  4641. * @ignore
  4642. * Application error to support additional information when loading a file
  4643. */
  4644. export class LoadFileError extends Error {
  4645. /** defines the optional web request */
  4646. request?: WebRequest | undefined;
  4647. private static _setPrototypeOf;
  4648. /**
  4649. * Creates a new LoadFileError
  4650. * @param message defines the message of the error
  4651. * @param request defines the optional web request
  4652. */
  4653. constructor(message: string,
  4654. /** defines the optional web request */
  4655. request?: WebRequest | undefined);
  4656. }
  4657. }
  4658. declare module "babylonjs/Offline/IOfflineProvider" {
  4659. /**
  4660. * Class used to enable access to offline support
  4661. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4662. */
  4663. export interface IOfflineProvider {
  4664. /**
  4665. * Gets a boolean indicating if scene must be saved in the database
  4666. */
  4667. enableSceneOffline: boolean;
  4668. /**
  4669. * Gets a boolean indicating if textures must be saved in the database
  4670. */
  4671. enableTexturesOffline: boolean;
  4672. /**
  4673. * Open the offline support and make it available
  4674. * @param successCallback defines the callback to call on success
  4675. * @param errorCallback defines the callback to call on error
  4676. */
  4677. open(successCallback: () => void, errorCallback: () => void): void;
  4678. /**
  4679. * Loads an image from the offline support
  4680. * @param url defines the url to load from
  4681. * @param image defines the target DOM image
  4682. */
  4683. loadImage(url: string, image: HTMLImageElement): void;
  4684. /**
  4685. * Loads a file from offline support
  4686. * @param url defines the URL to load from
  4687. * @param sceneLoaded defines a callback to call on success
  4688. * @param progressCallBack defines a callback to call when progress changed
  4689. * @param errorCallback defines a callback to call on error
  4690. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4691. */
  4692. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4693. }
  4694. }
  4695. declare module "babylonjs/Misc/filesInputStore" {
  4696. /**
  4697. * Class used to help managing file picking and drag'n'drop
  4698. * File Storage
  4699. */
  4700. export class FilesInputStore {
  4701. /**
  4702. * List of files ready to be loaded
  4703. */
  4704. static FilesToLoad: {
  4705. [key: string]: File;
  4706. };
  4707. }
  4708. }
  4709. declare module "babylonjs/Misc/retryStrategy" {
  4710. import { WebRequest } from "babylonjs/Misc/webRequest";
  4711. /**
  4712. * Class used to define a retry strategy when error happens while loading assets
  4713. */
  4714. export class RetryStrategy {
  4715. /**
  4716. * Function used to defines an exponential back off strategy
  4717. * @param maxRetries defines the maximum number of retries (3 by default)
  4718. * @param baseInterval defines the interval between retries
  4719. * @returns the strategy function to use
  4720. */
  4721. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4722. }
  4723. }
  4724. declare module "babylonjs/Misc/fileTools" {
  4725. import { WebRequest } from "babylonjs/Misc/webRequest";
  4726. import { Nullable } from "babylonjs/types";
  4727. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4728. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4729. /**
  4730. * @hidden
  4731. */
  4732. export class FileTools {
  4733. /**
  4734. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4735. */
  4736. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4737. /**
  4738. * Gets or sets the base URL to use to load assets
  4739. */
  4740. static BaseUrl: string;
  4741. /**
  4742. * Default behaviour for cors in the application.
  4743. * It can be a string if the expected behavior is identical in the entire app.
  4744. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4745. */
  4746. static CorsBehavior: string | ((url: string | string[]) => string);
  4747. /**
  4748. * Gets or sets a function used to pre-process url before using them to load assets
  4749. */
  4750. static PreprocessUrl: (url: string) => string;
  4751. /**
  4752. * Removes unwanted characters from an url
  4753. * @param url defines the url to clean
  4754. * @returns the cleaned url
  4755. */
  4756. private static _CleanUrl;
  4757. /**
  4758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4759. * @param url define the url we are trying
  4760. * @param element define the dom element where to configure the cors policy
  4761. */
  4762. static SetCorsBehavior(url: string | string[], element: {
  4763. crossOrigin: string | null;
  4764. }): void;
  4765. /**
  4766. * Loads an image as an HTMLImageElement.
  4767. * @param input url string, ArrayBuffer, or Blob to load
  4768. * @param onLoad callback called when the image successfully loads
  4769. * @param onError callback called when the image fails to load
  4770. * @param offlineProvider offline provider for caching
  4771. * @returns the HTMLImageElement of the loaded image
  4772. */
  4773. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4774. /**
  4775. * Loads a file
  4776. * @param fileToLoad defines the file to load
  4777. * @param callback defines the callback to call when data is loaded
  4778. * @param progressCallBack defines the callback to call during loading process
  4779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4780. * @returns a file request object
  4781. */
  4782. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4783. /**
  4784. * Loads a file
  4785. * @param url url string, ArrayBuffer, or Blob to load
  4786. * @param onSuccess callback called when the file successfully loads
  4787. * @param onProgress callback called while file is loading (if the server supports this mode)
  4788. * @param offlineProvider defines the offline provider for caching
  4789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4790. * @param onError callback called when the file fails to load
  4791. * @returns a file request object
  4792. */
  4793. 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;
  4794. /**
  4795. * Checks if the loaded document was accessed via `file:`-Protocol.
  4796. * @returns boolean
  4797. */
  4798. static IsFileURL(): boolean;
  4799. }
  4800. }
  4801. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4802. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4803. /** @hidden */
  4804. export class ShaderProcessor {
  4805. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4806. private static _ProcessPrecision;
  4807. private static _ExtractOperation;
  4808. private static _BuildSubExpression;
  4809. private static _BuildExpression;
  4810. private static _MoveCursorWithinIf;
  4811. private static _MoveCursor;
  4812. private static _EvaluatePreProcessors;
  4813. private static _PreparePreProcessors;
  4814. private static _ProcessShaderConversion;
  4815. private static _ProcessIncludes;
  4816. }
  4817. }
  4818. declare module "babylonjs/Maths/math.color" {
  4819. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4820. /**
  4821. * Class used to hold a RBG color
  4822. */
  4823. export class Color3 {
  4824. /**
  4825. * Defines the red component (between 0 and 1, default is 0)
  4826. */
  4827. r: number;
  4828. /**
  4829. * Defines the green component (between 0 and 1, default is 0)
  4830. */
  4831. g: number;
  4832. /**
  4833. * Defines the blue component (between 0 and 1, default is 0)
  4834. */
  4835. b: number;
  4836. /**
  4837. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4838. * @param r defines the red component (between 0 and 1, default is 0)
  4839. * @param g defines the green component (between 0 and 1, default is 0)
  4840. * @param b defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. constructor(
  4843. /**
  4844. * Defines the red component (between 0 and 1, default is 0)
  4845. */
  4846. r?: number,
  4847. /**
  4848. * Defines the green component (between 0 and 1, default is 0)
  4849. */
  4850. g?: number,
  4851. /**
  4852. * Defines the blue component (between 0 and 1, default is 0)
  4853. */
  4854. b?: number);
  4855. /**
  4856. * Creates a string with the Color3 current values
  4857. * @returns the string representation of the Color3 object
  4858. */
  4859. toString(): string;
  4860. /**
  4861. * Returns the string "Color3"
  4862. * @returns "Color3"
  4863. */
  4864. getClassName(): string;
  4865. /**
  4866. * Compute the Color3 hash code
  4867. * @returns an unique number that can be used to hash Color3 objects
  4868. */
  4869. getHashCode(): number;
  4870. /**
  4871. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4872. * @param array defines the array where to store the r,g,b components
  4873. * @param index defines an optional index in the target array to define where to start storing values
  4874. * @returns the current Color3 object
  4875. */
  4876. toArray(array: FloatArray, index?: number): Color3;
  4877. /**
  4878. * Returns a new Color4 object from the current Color3 and the given alpha
  4879. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4880. * @returns a new Color4 object
  4881. */
  4882. toColor4(alpha?: number): Color4;
  4883. /**
  4884. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4885. * @returns the new array
  4886. */
  4887. asArray(): number[];
  4888. /**
  4889. * Returns the luminance value
  4890. * @returns a float value
  4891. */
  4892. toLuminance(): number;
  4893. /**
  4894. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4895. * @param otherColor defines the second operand
  4896. * @returns the new Color3 object
  4897. */
  4898. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4899. /**
  4900. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4901. * @param otherColor defines the second operand
  4902. * @param result defines the Color3 object where to store the result
  4903. * @returns the current Color3
  4904. */
  4905. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4906. /**
  4907. * Determines equality between Color3 objects
  4908. * @param otherColor defines the second operand
  4909. * @returns true if the rgb values are equal to the given ones
  4910. */
  4911. equals(otherColor: DeepImmutable<Color3>): boolean;
  4912. /**
  4913. * Determines equality between the current Color3 object and a set of r,b,g values
  4914. * @param r defines the red component to check
  4915. * @param g defines the green component to check
  4916. * @param b defines the blue component to check
  4917. * @returns true if the rgb values are equal to the given ones
  4918. */
  4919. equalsFloats(r: number, g: number, b: number): boolean;
  4920. /**
  4921. * Multiplies in place each rgb value by scale
  4922. * @param scale defines the scaling factor
  4923. * @returns the updated Color3
  4924. */
  4925. scale(scale: number): Color3;
  4926. /**
  4927. * Multiplies the rgb values by scale and stores the result into "result"
  4928. * @param scale defines the scaling factor
  4929. * @param result defines the Color3 object where to store the result
  4930. * @returns the unmodified current Color3
  4931. */
  4932. scaleToRef(scale: number, result: Color3): Color3;
  4933. /**
  4934. * Scale the current Color3 values by a factor and add the result to a given Color3
  4935. * @param scale defines the scale factor
  4936. * @param result defines color to store the result into
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Clamps the rgb values by the min and max values and stores the result into "result"
  4942. * @param min defines minimum clamping value (default is 0)
  4943. * @param max defines maximum clamping value (default is 1)
  4944. * @param result defines color to store the result into
  4945. * @returns the original Color3
  4946. */
  4947. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4948. /**
  4949. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4950. * @param otherColor defines the second operand
  4951. * @returns the new Color3
  4952. */
  4953. add(otherColor: DeepImmutable<Color3>): Color3;
  4954. /**
  4955. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4956. * @param otherColor defines the second operand
  4957. * @param result defines Color3 object to store the result into
  4958. * @returns the unmodified current Color3
  4959. */
  4960. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4961. /**
  4962. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4963. * @param otherColor defines the second operand
  4964. * @returns the new Color3
  4965. */
  4966. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4967. /**
  4968. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4969. * @param otherColor defines the second operand
  4970. * @param result defines Color3 object to store the result into
  4971. * @returns the unmodified current Color3
  4972. */
  4973. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4974. /**
  4975. * Copy the current object
  4976. * @returns a new Color3 copied the current one
  4977. */
  4978. clone(): Color3;
  4979. /**
  4980. * Copies the rgb values from the source in the current Color3
  4981. * @param source defines the source Color3 object
  4982. * @returns the updated Color3 object
  4983. */
  4984. copyFrom(source: DeepImmutable<Color3>): Color3;
  4985. /**
  4986. * Updates the Color3 rgb values from the given floats
  4987. * @param r defines the red component to read from
  4988. * @param g defines the green component to read from
  4989. * @param b defines the blue component to read from
  4990. * @returns the current Color3 object
  4991. */
  4992. copyFromFloats(r: number, g: number, b: number): Color3;
  4993. /**
  4994. * Updates the Color3 rgb values from the given floats
  4995. * @param r defines the red component to read from
  4996. * @param g defines the green component to read from
  4997. * @param b defines the blue component to read from
  4998. * @returns the current Color3 object
  4999. */
  5000. set(r: number, g: number, b: number): Color3;
  5001. /**
  5002. * Compute the Color3 hexadecimal code as a string
  5003. * @returns a string containing the hexadecimal representation of the Color3 object
  5004. */
  5005. toHexString(): string;
  5006. /**
  5007. * Computes a new Color3 converted from the current one to linear space
  5008. * @returns a new Color3 object
  5009. */
  5010. toLinearSpace(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @returns a new color3 representing the HSV values
  5014. */
  5015. toHSV(): Color3;
  5016. /**
  5017. * Converts current color in rgb space to HSV values
  5018. * @param result defines the Color3 where to store the HSV values
  5019. */
  5020. toHSVToRef(result: Color3): void;
  5021. /**
  5022. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5023. * @param convertedColor defines the Color3 object where to store the linear space version
  5024. * @returns the unmodified Color3
  5025. */
  5026. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5027. /**
  5028. * Computes a new Color3 converted from the current one to gamma space
  5029. * @returns a new Color3 object
  5030. */
  5031. toGammaSpace(): Color3;
  5032. /**
  5033. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5034. * @param convertedColor defines the Color3 object where to store the gamma space version
  5035. * @returns the unmodified Color3
  5036. */
  5037. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5038. private static _BlackReadOnly;
  5039. /**
  5040. * Convert Hue, saturation and value to a Color3 (RGB)
  5041. * @param hue defines the hue
  5042. * @param saturation defines the saturation
  5043. * @param value defines the value
  5044. * @param result defines the Color3 where to store the RGB values
  5045. */
  5046. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5047. /**
  5048. * Creates a new Color3 from the string containing valid hexadecimal values
  5049. * @param hex defines a string containing valid hexadecimal values
  5050. * @returns a new Color3 object
  5051. */
  5052. static FromHexString(hex: string): Color3;
  5053. /**
  5054. * Creates a new Color3 from the starting index of the given array
  5055. * @param array defines the source array
  5056. * @param offset defines an offset in the source array
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5060. /**
  5061. * Creates a new Color3 from integer values (< 256)
  5062. * @param r defines the red component to read from (value between 0 and 255)
  5063. * @param g defines the green component to read from (value between 0 and 255)
  5064. * @param b defines the blue component to read from (value between 0 and 255)
  5065. * @returns a new Color3 object
  5066. */
  5067. static FromInts(r: number, g: number, b: number): Color3;
  5068. /**
  5069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5070. * @param start defines the start Color3 value
  5071. * @param end defines the end Color3 value
  5072. * @param amount defines the gradient value between start and end
  5073. * @returns a new Color3 object
  5074. */
  5075. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5076. /**
  5077. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5078. * @param left defines the start value
  5079. * @param right defines the end value
  5080. * @param amount defines the gradient factor
  5081. * @param result defines the Color3 object where to store the result
  5082. */
  5083. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5084. /**
  5085. * Returns a Color3 value containing a red color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Red(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a green color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Green(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a blue color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Blue(): Color3;
  5099. /**
  5100. * Returns a Color3 value containing a black color
  5101. * @returns a new Color3 object
  5102. */
  5103. static Black(): Color3;
  5104. /**
  5105. * Gets a Color3 value containing a black color that must not be updated
  5106. */
  5107. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5108. /**
  5109. * Returns a Color3 value containing a white color
  5110. * @returns a new Color3 object
  5111. */
  5112. static White(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a purple color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Purple(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a magenta color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Magenta(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a yellow color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Yellow(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a gray color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Gray(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a teal color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Teal(): Color3;
  5138. /**
  5139. * Returns a Color3 value containing a random color
  5140. * @returns a new Color3 object
  5141. */
  5142. static Random(): Color3;
  5143. }
  5144. /**
  5145. * Class used to hold a RBGA color
  5146. */
  5147. export class Color4 {
  5148. /**
  5149. * Defines the red component (between 0 and 1, default is 0)
  5150. */
  5151. r: number;
  5152. /**
  5153. * Defines the green component (between 0 and 1, default is 0)
  5154. */
  5155. g: number;
  5156. /**
  5157. * Defines the blue component (between 0 and 1, default is 0)
  5158. */
  5159. b: number;
  5160. /**
  5161. * Defines the alpha component (between 0 and 1, default is 1)
  5162. */
  5163. a: number;
  5164. /**
  5165. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5166. * @param r defines the red component (between 0 and 1, default is 0)
  5167. * @param g defines the green component (between 0 and 1, default is 0)
  5168. * @param b defines the blue component (between 0 and 1, default is 0)
  5169. * @param a defines the alpha component (between 0 and 1, default is 1)
  5170. */
  5171. constructor(
  5172. /**
  5173. * Defines the red component (between 0 and 1, default is 0)
  5174. */
  5175. r?: number,
  5176. /**
  5177. * Defines the green component (between 0 and 1, default is 0)
  5178. */
  5179. g?: number,
  5180. /**
  5181. * Defines the blue component (between 0 and 1, default is 0)
  5182. */
  5183. b?: number,
  5184. /**
  5185. * Defines the alpha component (between 0 and 1, default is 1)
  5186. */
  5187. a?: number);
  5188. /**
  5189. * Adds in place the given Color4 values to the current Color4 object
  5190. * @param right defines the second operand
  5191. * @returns the current updated Color4 object
  5192. */
  5193. addInPlace(right: DeepImmutable<Color4>): Color4;
  5194. /**
  5195. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5196. * @returns the new array
  5197. */
  5198. asArray(): number[];
  5199. /**
  5200. * Stores from the starting index in the given array the Color4 successive values
  5201. * @param array defines the array where to store the r,g,b components
  5202. * @param index defines an optional index in the target array to define where to start storing values
  5203. * @returns the current Color4 object
  5204. */
  5205. toArray(array: number[], index?: number): Color4;
  5206. /**
  5207. * Determines equality between Color4 objects
  5208. * @param otherColor defines the second operand
  5209. * @returns true if the rgba values are equal to the given ones
  5210. */
  5211. equals(otherColor: DeepImmutable<Color4>): boolean;
  5212. /**
  5213. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5214. * @param right defines the second operand
  5215. * @returns a new Color4 object
  5216. */
  5217. add(right: DeepImmutable<Color4>): Color4;
  5218. /**
  5219. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5220. * @param right defines the second operand
  5221. * @returns a new Color4 object
  5222. */
  5223. subtract(right: DeepImmutable<Color4>): Color4;
  5224. /**
  5225. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5226. * @param right defines the second operand
  5227. * @param result defines the Color4 object where to store the result
  5228. * @returns the current Color4 object
  5229. */
  5230. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5231. /**
  5232. * Creates a new Color4 with the current Color4 values multiplied by scale
  5233. * @param scale defines the scaling factor to apply
  5234. * @returns a new Color4 object
  5235. */
  5236. scale(scale: number): Color4;
  5237. /**
  5238. * Multiplies the current Color4 values by scale and stores the result in "result"
  5239. * @param scale defines the scaling factor to apply
  5240. * @param result defines the Color4 object where to store the result
  5241. * @returns the current unmodified Color4
  5242. */
  5243. scaleToRef(scale: number, result: Color4): Color4;
  5244. /**
  5245. * Scale the current Color4 values by a factor and add the result to a given Color4
  5246. * @param scale defines the scale factor
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the unmodified current Color4
  5249. */
  5250. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Clamps the rgb values by the min and max values and stores the result into "result"
  5253. * @param min defines minimum clamping value (default is 0)
  5254. * @param max defines maximum clamping value (default is 1)
  5255. * @param result defines color to store the result into.
  5256. * @returns the cuurent Color4
  5257. */
  5258. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5259. /**
  5260. * Multipy an Color4 value by another and return a new Color4 object
  5261. * @param color defines the Color4 value to multiply by
  5262. * @returns a new Color4 object
  5263. */
  5264. multiply(color: Color4): Color4;
  5265. /**
  5266. * Multipy a Color4 value by another and push the result in a reference value
  5267. * @param color defines the Color4 value to multiply by
  5268. * @param result defines the Color4 to fill the result in
  5269. * @returns the result Color4
  5270. */
  5271. multiplyToRef(color: Color4, result: Color4): Color4;
  5272. /**
  5273. * Creates a string with the Color4 current values
  5274. * @returns the string representation of the Color4 object
  5275. */
  5276. toString(): string;
  5277. /**
  5278. * Returns the string "Color4"
  5279. * @returns "Color4"
  5280. */
  5281. getClassName(): string;
  5282. /**
  5283. * Compute the Color4 hash code
  5284. * @returns an unique number that can be used to hash Color4 objects
  5285. */
  5286. getHashCode(): number;
  5287. /**
  5288. * Creates a new Color4 copied from the current one
  5289. * @returns a new Color4 object
  5290. */
  5291. clone(): Color4;
  5292. /**
  5293. * Copies the given Color4 values into the current one
  5294. * @param source defines the source Color4 object
  5295. * @returns the current updated Color4 object
  5296. */
  5297. copyFrom(source: Color4): Color4;
  5298. /**
  5299. * Copies the given float values into the current one
  5300. * @param r defines the red component to read from
  5301. * @param g defines the green component to read from
  5302. * @param b defines the blue component to read from
  5303. * @param a defines the alpha component to read from
  5304. * @returns the current updated Color4 object
  5305. */
  5306. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5307. /**
  5308. * Copies the given float values into the current one
  5309. * @param r defines the red component to read from
  5310. * @param g defines the green component to read from
  5311. * @param b defines the blue component to read from
  5312. * @param a defines the alpha component to read from
  5313. * @returns the current updated Color4 object
  5314. */
  5315. set(r: number, g: number, b: number, a: number): Color4;
  5316. /**
  5317. * Compute the Color4 hexadecimal code as a string
  5318. * @returns a string containing the hexadecimal representation of the Color4 object
  5319. */
  5320. toHexString(): string;
  5321. /**
  5322. * Computes a new Color4 converted from the current one to linear space
  5323. * @returns a new Color4 object
  5324. */
  5325. toLinearSpace(): Color4;
  5326. /**
  5327. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color4 object where to store the linear space version
  5329. * @returns the unmodified Color4
  5330. */
  5331. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5332. /**
  5333. * Computes a new Color4 converted from the current one to gamma space
  5334. * @returns a new Color4 object
  5335. */
  5336. toGammaSpace(): Color4;
  5337. /**
  5338. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5339. * @param convertedColor defines the Color4 object where to store the gamma space version
  5340. * @returns the unmodified Color4
  5341. */
  5342. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5343. /**
  5344. * Creates a new Color4 from the string containing valid hexadecimal values
  5345. * @param hex defines a string containing valid hexadecimal values
  5346. * @returns a new Color4 object
  5347. */
  5348. static FromHexString(hex: string): Color4;
  5349. /**
  5350. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5351. * @param left defines the start value
  5352. * @param right defines the end value
  5353. * @param amount defines the gradient factor
  5354. * @returns a new Color4 object
  5355. */
  5356. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5357. /**
  5358. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color4 object where to store data
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5365. /**
  5366. * Creates a new Color4 from a Color3 and an alpha value
  5367. * @param color3 defines the source Color3 to read from
  5368. * @param alpha defines the alpha component (1.0 by default)
  5369. * @returns a new Color4 object
  5370. */
  5371. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5372. /**
  5373. * Creates a new Color4 from the starting index element of the given array
  5374. * @param array defines the source array to read from
  5375. * @param offset defines the offset in the source array
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5379. /**
  5380. * Creates a new Color3 from integer values (< 256)
  5381. * @param r defines the red component to read from (value between 0 and 255)
  5382. * @param g defines the green component to read from (value between 0 and 255)
  5383. * @param b defines the blue component to read from (value between 0 and 255)
  5384. * @param a defines the alpha component to read from (value between 0 and 255)
  5385. * @returns a new Color3 object
  5386. */
  5387. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5388. /**
  5389. * Check the content of a given array and convert it to an array containing RGBA data
  5390. * If the original array was already containing count * 4 values then it is returned directly
  5391. * @param colors defines the array to check
  5392. * @param count defines the number of RGBA data to expect
  5393. * @returns an array containing count * 4 values (RGBA)
  5394. */
  5395. static CheckColors4(colors: number[], count: number): number[];
  5396. }
  5397. /**
  5398. * @hidden
  5399. */
  5400. export class TmpColors {
  5401. static Color3: Color3[];
  5402. static Color4: Color4[];
  5403. }
  5404. }
  5405. declare module "babylonjs/Maths/sphericalPolynomial" {
  5406. import { Vector3 } from "babylonjs/Maths/math.vector";
  5407. import { Color3 } from "babylonjs/Maths/math.color";
  5408. /**
  5409. * Class representing spherical harmonics coefficients to the 3rd degree
  5410. */
  5411. export class SphericalHarmonics {
  5412. /**
  5413. * Defines whether or not the harmonics have been prescaled for rendering.
  5414. */
  5415. preScaled: boolean;
  5416. /**
  5417. * The l0,0 coefficients of the spherical harmonics
  5418. */
  5419. l00: Vector3;
  5420. /**
  5421. * The l1,-1 coefficients of the spherical harmonics
  5422. */
  5423. l1_1: Vector3;
  5424. /**
  5425. * The l1,0 coefficients of the spherical harmonics
  5426. */
  5427. l10: Vector3;
  5428. /**
  5429. * The l1,1 coefficients of the spherical harmonics
  5430. */
  5431. l11: Vector3;
  5432. /**
  5433. * The l2,-2 coefficients of the spherical harmonics
  5434. */
  5435. l2_2: Vector3;
  5436. /**
  5437. * The l2,-1 coefficients of the spherical harmonics
  5438. */
  5439. l2_1: Vector3;
  5440. /**
  5441. * The l2,0 coefficients of the spherical harmonics
  5442. */
  5443. l20: Vector3;
  5444. /**
  5445. * The l2,1 coefficients of the spherical harmonics
  5446. */
  5447. l21: Vector3;
  5448. /**
  5449. * The l2,2 coefficients of the spherical harmonics
  5450. */
  5451. l22: Vector3;
  5452. /**
  5453. * Adds a light to the spherical harmonics
  5454. * @param direction the direction of the light
  5455. * @param color the color of the light
  5456. * @param deltaSolidAngle the delta solid angle of the light
  5457. */
  5458. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5459. /**
  5460. * Scales the spherical harmonics by the given amount
  5461. * @param scale the amount to scale
  5462. */
  5463. scaleInPlace(scale: number): void;
  5464. /**
  5465. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5466. *
  5467. * ```
  5468. * E_lm = A_l * L_lm
  5469. * ```
  5470. *
  5471. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5472. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5473. * the scaling factors are given in equation 9.
  5474. */
  5475. convertIncidentRadianceToIrradiance(): void;
  5476. /**
  5477. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5478. *
  5479. * ```
  5480. * L = (1/pi) * E * rho
  5481. * ```
  5482. *
  5483. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5484. */
  5485. convertIrradianceToLambertianRadiance(): void;
  5486. /**
  5487. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5488. * required operations at run time.
  5489. *
  5490. * This is simply done by scaling back the SH with Ylm constants parameter.
  5491. * The trigonometric part being applied by the shader at run time.
  5492. */
  5493. preScaleForRendering(): void;
  5494. /**
  5495. * Constructs a spherical harmonics from an array.
  5496. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5497. * @returns the spherical harmonics
  5498. */
  5499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5500. /**
  5501. * Gets the spherical harmonics from polynomial
  5502. * @param polynomial the spherical polynomial
  5503. * @returns the spherical harmonics
  5504. */
  5505. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5506. }
  5507. /**
  5508. * Class representing spherical polynomial coefficients to the 3rd degree
  5509. */
  5510. export class SphericalPolynomial {
  5511. private _harmonics;
  5512. /**
  5513. * The spherical harmonics used to create the polynomials.
  5514. */
  5515. readonly preScaledHarmonics: SphericalHarmonics;
  5516. /**
  5517. * The x coefficients of the spherical polynomial
  5518. */
  5519. x: Vector3;
  5520. /**
  5521. * The y coefficients of the spherical polynomial
  5522. */
  5523. y: Vector3;
  5524. /**
  5525. * The z coefficients of the spherical polynomial
  5526. */
  5527. z: Vector3;
  5528. /**
  5529. * The xx coefficients of the spherical polynomial
  5530. */
  5531. xx: Vector3;
  5532. /**
  5533. * The yy coefficients of the spherical polynomial
  5534. */
  5535. yy: Vector3;
  5536. /**
  5537. * The zz coefficients of the spherical polynomial
  5538. */
  5539. zz: Vector3;
  5540. /**
  5541. * The xy coefficients of the spherical polynomial
  5542. */
  5543. xy: Vector3;
  5544. /**
  5545. * The yz coefficients of the spherical polynomial
  5546. */
  5547. yz: Vector3;
  5548. /**
  5549. * The zx coefficients of the spherical polynomial
  5550. */
  5551. zx: Vector3;
  5552. /**
  5553. * Adds an ambient color to the spherical polynomial
  5554. * @param color the color to add
  5555. */
  5556. addAmbient(color: Color3): void;
  5557. /**
  5558. * Scales the spherical polynomial by the given amount
  5559. * @param scale the amount to scale
  5560. */
  5561. scaleInPlace(scale: number): void;
  5562. /**
  5563. * Gets the spherical polynomial from harmonics
  5564. * @param harmonics the spherical harmonics
  5565. * @returns the spherical polynomial
  5566. */
  5567. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5568. /**
  5569. * Constructs a spherical polynomial from an array.
  5570. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5571. * @returns the spherical polynomial
  5572. */
  5573. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5574. }
  5575. }
  5576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5577. /**
  5578. * Define options used to create a render target texture
  5579. */
  5580. export class RenderTargetCreationOptions {
  5581. /**
  5582. * Specifies is mipmaps must be generated
  5583. */
  5584. generateMipMaps?: boolean;
  5585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5586. generateDepthBuffer?: boolean;
  5587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5588. generateStencilBuffer?: boolean;
  5589. /** Defines texture type (int by default) */
  5590. type?: number;
  5591. /** Defines sampling mode (trilinear by default) */
  5592. samplingMode?: number;
  5593. /** Defines format (RGBA by default) */
  5594. format?: number;
  5595. }
  5596. }
  5597. declare module "babylonjs/States/alphaCullingState" {
  5598. /**
  5599. * @hidden
  5600. **/
  5601. export class _AlphaState {
  5602. private _isAlphaBlendDirty;
  5603. private _isBlendFunctionParametersDirty;
  5604. private _isBlendEquationParametersDirty;
  5605. private _isBlendConstantsDirty;
  5606. private _alphaBlend;
  5607. private _blendFunctionParameters;
  5608. private _blendEquationParameters;
  5609. private _blendConstants;
  5610. /**
  5611. * Initializes the state.
  5612. */
  5613. constructor();
  5614. readonly isDirty: boolean;
  5615. alphaBlend: boolean;
  5616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module "babylonjs/States/depthCullingState" {
  5624. import { Nullable } from "babylonjs/types";
  5625. /**
  5626. * @hidden
  5627. **/
  5628. export class _DepthCullingState {
  5629. private _isDepthTestDirty;
  5630. private _isDepthMaskDirty;
  5631. private _isDepthFuncDirty;
  5632. private _isCullFaceDirty;
  5633. private _isCullDirty;
  5634. private _isZOffsetDirty;
  5635. private _isFrontFaceDirty;
  5636. private _depthTest;
  5637. private _depthMask;
  5638. private _depthFunc;
  5639. private _cull;
  5640. private _cullFace;
  5641. private _zOffset;
  5642. private _frontFace;
  5643. /**
  5644. * Initializes the state.
  5645. */
  5646. constructor();
  5647. readonly isDirty: boolean;
  5648. zOffset: number;
  5649. cullFace: Nullable<number>;
  5650. cull: Nullable<boolean>;
  5651. depthFunc: Nullable<number>;
  5652. depthMask: boolean;
  5653. depthTest: boolean;
  5654. frontFace: Nullable<number>;
  5655. reset(): void;
  5656. apply(gl: WebGLRenderingContext): void;
  5657. }
  5658. }
  5659. declare module "babylonjs/States/stencilState" {
  5660. /**
  5661. * @hidden
  5662. **/
  5663. export class _StencilState {
  5664. /** 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 */
  5665. static readonly ALWAYS: number;
  5666. /** Passed to stencilOperation to specify that stencil value must be kept */
  5667. static readonly KEEP: number;
  5668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5669. static readonly REPLACE: number;
  5670. private _isStencilTestDirty;
  5671. private _isStencilMaskDirty;
  5672. private _isStencilFuncDirty;
  5673. private _isStencilOpDirty;
  5674. private _stencilTest;
  5675. private _stencilMask;
  5676. private _stencilFunc;
  5677. private _stencilFuncRef;
  5678. private _stencilFuncMask;
  5679. private _stencilOpStencilFail;
  5680. private _stencilOpDepthFail;
  5681. private _stencilOpStencilDepthPass;
  5682. readonly isDirty: boolean;
  5683. stencilFunc: number;
  5684. stencilFuncRef: number;
  5685. stencilFuncMask: number;
  5686. stencilOpStencilFail: number;
  5687. stencilOpDepthFail: number;
  5688. stencilOpStencilDepthPass: number;
  5689. stencilMask: number;
  5690. stencilTest: boolean;
  5691. constructor();
  5692. reset(): void;
  5693. apply(gl: WebGLRenderingContext): void;
  5694. }
  5695. }
  5696. declare module "babylonjs/States/index" {
  5697. export * from "babylonjs/States/alphaCullingState";
  5698. export * from "babylonjs/States/depthCullingState";
  5699. export * from "babylonjs/States/stencilState";
  5700. }
  5701. declare module "babylonjs/Instrumentation/timeToken" {
  5702. import { Nullable } from "babylonjs/types";
  5703. /**
  5704. * @hidden
  5705. **/
  5706. export class _TimeToken {
  5707. _startTimeQuery: Nullable<WebGLQuery>;
  5708. _endTimeQuery: Nullable<WebGLQuery>;
  5709. _timeElapsedQuery: Nullable<WebGLQuery>;
  5710. _timeElapsedQueryEnded: boolean;
  5711. }
  5712. }
  5713. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5714. /**
  5715. * Class used to evalaute queries containing `and` and `or` operators
  5716. */
  5717. export class AndOrNotEvaluator {
  5718. /**
  5719. * Evaluate a query
  5720. * @param query defines the query to evaluate
  5721. * @param evaluateCallback defines the callback used to filter result
  5722. * @returns true if the query matches
  5723. */
  5724. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5725. private static _HandleParenthesisContent;
  5726. private static _SimplifyNegation;
  5727. }
  5728. }
  5729. declare module "babylonjs/Misc/tags" {
  5730. /**
  5731. * Class used to store custom tags
  5732. */
  5733. export class Tags {
  5734. /**
  5735. * Adds support for tags on the given object
  5736. * @param obj defines the object to use
  5737. */
  5738. static EnableFor(obj: any): void;
  5739. /**
  5740. * Removes tags support
  5741. * @param obj defines the object to use
  5742. */
  5743. static DisableFor(obj: any): void;
  5744. /**
  5745. * Gets a boolean indicating if the given object has tags
  5746. * @param obj defines the object to use
  5747. * @returns a boolean
  5748. */
  5749. static HasTags(obj: any): boolean;
  5750. /**
  5751. * Gets the tags available on a given object
  5752. * @param obj defines the object to use
  5753. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5754. * @returns the tags
  5755. */
  5756. static GetTags(obj: any, asString?: boolean): any;
  5757. /**
  5758. * Adds tags to an object
  5759. * @param obj defines the object to use
  5760. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5761. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5762. */
  5763. static AddTagsTo(obj: any, tagsString: string): void;
  5764. /**
  5765. * @hidden
  5766. */
  5767. static _AddTagTo(obj: any, tag: string): void;
  5768. /**
  5769. * Removes specific tags from a specific object
  5770. * @param obj defines the object to use
  5771. * @param tagsString defines the tags to remove
  5772. */
  5773. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5774. /**
  5775. * @hidden
  5776. */
  5777. static _RemoveTagFrom(obj: any, tag: string): void;
  5778. /**
  5779. * Defines if tags hosted on an object match a given query
  5780. * @param obj defines the object to use
  5781. * @param tagsQuery defines the tag query
  5782. * @returns a boolean
  5783. */
  5784. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5785. }
  5786. }
  5787. declare module "babylonjs/Maths/math.path" {
  5788. import { DeepImmutable, Nullable } from "babylonjs/types";
  5789. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5790. /**
  5791. * Defines potential orientation for back face culling
  5792. */
  5793. export enum Orientation {
  5794. /**
  5795. * Clockwise
  5796. */
  5797. CW = 0,
  5798. /** Counter clockwise */
  5799. CCW = 1
  5800. }
  5801. /** Class used to represent a Bezier curve */
  5802. export class BezierCurve {
  5803. /**
  5804. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5805. * @param t defines the time
  5806. * @param x1 defines the left coordinate on X axis
  5807. * @param y1 defines the left coordinate on Y axis
  5808. * @param x2 defines the right coordinate on X axis
  5809. * @param y2 defines the right coordinate on Y axis
  5810. * @returns the interpolated value
  5811. */
  5812. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5813. }
  5814. /**
  5815. * Defines angle representation
  5816. */
  5817. export class Angle {
  5818. private _radians;
  5819. /**
  5820. * Creates an Angle object of "radians" radians (float).
  5821. * @param radians the angle in radians
  5822. */
  5823. constructor(radians: number);
  5824. /**
  5825. * Get value in degrees
  5826. * @returns the Angle value in degrees (float)
  5827. */
  5828. degrees(): number;
  5829. /**
  5830. * Get value in radians
  5831. * @returns the Angle value in radians (float)
  5832. */
  5833. radians(): number;
  5834. /**
  5835. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5836. * @param a defines first vector
  5837. * @param b defines second vector
  5838. * @returns a new Angle
  5839. */
  5840. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5841. /**
  5842. * Gets a new Angle object from the given float in radians
  5843. * @param radians defines the angle value in radians
  5844. * @returns a new Angle
  5845. */
  5846. static FromRadians(radians: number): Angle;
  5847. /**
  5848. * Gets a new Angle object from the given float in degrees
  5849. * @param degrees defines the angle value in degrees
  5850. * @returns a new Angle
  5851. */
  5852. static FromDegrees(degrees: number): Angle;
  5853. }
  5854. /**
  5855. * This represents an arc in a 2d space.
  5856. */
  5857. export class Arc2 {
  5858. /** Defines the start point of the arc */
  5859. startPoint: Vector2;
  5860. /** Defines the mid point of the arc */
  5861. midPoint: Vector2;
  5862. /** Defines the end point of the arc */
  5863. endPoint: Vector2;
  5864. /**
  5865. * Defines the center point of the arc.
  5866. */
  5867. centerPoint: Vector2;
  5868. /**
  5869. * Defines the radius of the arc.
  5870. */
  5871. radius: number;
  5872. /**
  5873. * Defines the angle of the arc (from mid point to end point).
  5874. */
  5875. angle: Angle;
  5876. /**
  5877. * Defines the start angle of the arc (from start point to middle point).
  5878. */
  5879. startAngle: Angle;
  5880. /**
  5881. * Defines the orientation of the arc (clock wise/counter clock wise).
  5882. */
  5883. orientation: Orientation;
  5884. /**
  5885. * Creates an Arc object from the three given points : start, middle and end.
  5886. * @param startPoint Defines the start point of the arc
  5887. * @param midPoint Defines the midlle point of the arc
  5888. * @param endPoint Defines the end point of the arc
  5889. */
  5890. constructor(
  5891. /** Defines the start point of the arc */
  5892. startPoint: Vector2,
  5893. /** Defines the mid point of the arc */
  5894. midPoint: Vector2,
  5895. /** Defines the end point of the arc */
  5896. endPoint: Vector2);
  5897. }
  5898. /**
  5899. * Represents a 2D path made up of multiple 2D points
  5900. */
  5901. export class Path2 {
  5902. private _points;
  5903. private _length;
  5904. /**
  5905. * If the path start and end point are the same
  5906. */
  5907. closed: boolean;
  5908. /**
  5909. * Creates a Path2 object from the starting 2D coordinates x and y.
  5910. * @param x the starting points x value
  5911. * @param y the starting points y value
  5912. */
  5913. constructor(x: number, y: number);
  5914. /**
  5915. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5916. * @param x the added points x value
  5917. * @param y the added points y value
  5918. * @returns the updated Path2.
  5919. */
  5920. addLineTo(x: number, y: number): Path2;
  5921. /**
  5922. * 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.
  5923. * @param midX middle point x value
  5924. * @param midY middle point y value
  5925. * @param endX end point x value
  5926. * @param endY end point y value
  5927. * @param numberOfSegments (default: 36)
  5928. * @returns the updated Path2.
  5929. */
  5930. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5931. /**
  5932. * Closes the Path2.
  5933. * @returns the Path2.
  5934. */
  5935. close(): Path2;
  5936. /**
  5937. * Gets the sum of the distance between each sequential point in the path
  5938. * @returns the Path2 total length (float).
  5939. */
  5940. length(): number;
  5941. /**
  5942. * Gets the points which construct the path
  5943. * @returns the Path2 internal array of points.
  5944. */
  5945. getPoints(): Vector2[];
  5946. /**
  5947. * Retreives the point at the distance aways from the starting point
  5948. * @param normalizedLengthPosition the length along the path to retreive the point from
  5949. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5950. */
  5951. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5952. /**
  5953. * Creates a new path starting from an x and y position
  5954. * @param x starting x value
  5955. * @param y starting y value
  5956. * @returns a new Path2 starting at the coordinates (x, y).
  5957. */
  5958. static StartingAt(x: number, y: number): Path2;
  5959. }
  5960. /**
  5961. * Represents a 3D path made up of multiple 3D points
  5962. */
  5963. export class Path3D {
  5964. /**
  5965. * an array of Vector3, the curve axis of the Path3D
  5966. */
  5967. path: Vector3[];
  5968. private _curve;
  5969. private _distances;
  5970. private _tangents;
  5971. private _normals;
  5972. private _binormals;
  5973. private _raw;
  5974. /**
  5975. * new Path3D(path, normal, raw)
  5976. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5977. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5978. * @param path an array of Vector3, the curve axis of the Path3D
  5979. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5980. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5981. */
  5982. constructor(
  5983. /**
  5984. * an array of Vector3, the curve axis of the Path3D
  5985. */
  5986. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5987. /**
  5988. * Returns the Path3D array of successive Vector3 designing its curve.
  5989. * @returns the Path3D array of successive Vector3 designing its curve.
  5990. */
  5991. getCurve(): Vector3[];
  5992. /**
  5993. * Returns an array populated with tangent vectors on each Path3D curve point.
  5994. * @returns an array populated with tangent vectors on each Path3D curve point.
  5995. */
  5996. getTangents(): Vector3[];
  5997. /**
  5998. * Returns an array populated with normal vectors on each Path3D curve point.
  5999. * @returns an array populated with normal vectors on each Path3D curve point.
  6000. */
  6001. getNormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with binormal vectors on each Path3D curve point.
  6004. * @returns an array populated with binormal vectors on each Path3D curve point.
  6005. */
  6006. getBinormals(): Vector3[];
  6007. /**
  6008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6009. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6010. */
  6011. getDistances(): number[];
  6012. /**
  6013. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6014. * @param path path which all values are copied into the curves points
  6015. * @param firstNormal which should be projected onto the curve
  6016. * @returns the same object updated.
  6017. */
  6018. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6019. private _compute;
  6020. private _getFirstNonNullVector;
  6021. private _getLastNonNullVector;
  6022. private _normalVector;
  6023. }
  6024. /**
  6025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6026. * A Curve3 is designed from a series of successive Vector3.
  6027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6028. */
  6029. export class Curve3 {
  6030. private _points;
  6031. private _length;
  6032. /**
  6033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6035. * @param v1 (Vector3) the control point
  6036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6037. * @param nbPoints (integer) the wanted number of points in the curve
  6038. * @returns the created Curve3
  6039. */
  6040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6041. /**
  6042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6044. * @param v1 (Vector3) the first control point
  6045. * @param v2 (Vector3) the second control point
  6046. * @param v3 (Vector3) the end point of the Cubic Bezier
  6047. * @param nbPoints (integer) the wanted number of points in the curve
  6048. * @returns the created Curve3
  6049. */
  6050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6051. /**
  6052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6053. * @param p1 (Vector3) the origin point of the Hermite Spline
  6054. * @param t1 (Vector3) the tangent vector at the origin point
  6055. * @param p2 (Vector3) the end point of the Hermite Spline
  6056. * @param t2 (Vector3) the tangent vector at the end point
  6057. * @param nbPoints (integer) the wanted number of points in the curve
  6058. * @returns the created Curve3
  6059. */
  6060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6061. /**
  6062. * Returns a Curve3 object along a CatmullRom Spline curve :
  6063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6064. * @param nbPoints (integer) the wanted number of points between each curve control points
  6065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6066. * @returns the created Curve3
  6067. */
  6068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6069. /**
  6070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6071. * A Curve3 is designed from a series of successive Vector3.
  6072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6073. * @param points points which make up the curve
  6074. */
  6075. constructor(points: Vector3[]);
  6076. /**
  6077. * @returns the Curve3 stored array of successive Vector3
  6078. */
  6079. getPoints(): Vector3[];
  6080. /**
  6081. * @returns the computed length (float) of the curve.
  6082. */
  6083. length(): number;
  6084. /**
  6085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6087. * curveA and curveB keep unchanged.
  6088. * @param curve the curve to continue from this curve
  6089. * @returns the newly constructed curve
  6090. */
  6091. continue(curve: DeepImmutable<Curve3>): Curve3;
  6092. private _computeLength;
  6093. }
  6094. }
  6095. declare module "babylonjs/Animations/easing" {
  6096. /**
  6097. * This represents the main contract an easing function should follow.
  6098. * Easing functions are used throughout the animation system.
  6099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6100. */
  6101. export interface IEasingFunction {
  6102. /**
  6103. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6104. * of the easing function.
  6105. * The link below provides some of the most common examples of easing functions.
  6106. * @see https://easings.net/
  6107. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6108. * @returns the corresponding value on the curve defined by the easing function
  6109. */
  6110. ease(gradient: number): number;
  6111. }
  6112. /**
  6113. * Base class used for every default easing function.
  6114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class EasingFunction implements IEasingFunction {
  6117. /**
  6118. * Interpolation follows the mathematical formula associated with the easing function.
  6119. */
  6120. static readonly EASINGMODE_EASEIN: number;
  6121. /**
  6122. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6123. */
  6124. static readonly EASINGMODE_EASEOUT: number;
  6125. /**
  6126. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6127. */
  6128. static readonly EASINGMODE_EASEINOUT: number;
  6129. private _easingMode;
  6130. /**
  6131. * Sets the easing mode of the current function.
  6132. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6133. */
  6134. setEasingMode(easingMode: number): void;
  6135. /**
  6136. * Gets the current easing mode.
  6137. * @returns the easing mode
  6138. */
  6139. getEasingMode(): number;
  6140. /**
  6141. * @hidden
  6142. */
  6143. easeInCore(gradient: number): number;
  6144. /**
  6145. * Given an input gradient between 0 and 1, this returns the corresponding value
  6146. * of the easing function.
  6147. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6148. * @returns the corresponding value on the curve defined by the easing function
  6149. */
  6150. ease(gradient: number): number;
  6151. }
  6152. /**
  6153. * Easing function with a circle shape (see link below).
  6154. * @see https://easings.net/#easeInCirc
  6155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6156. */
  6157. export class CircleEase extends EasingFunction implements IEasingFunction {
  6158. /** @hidden */
  6159. easeInCore(gradient: number): number;
  6160. }
  6161. /**
  6162. * Easing function with a ease back shape (see link below).
  6163. * @see https://easings.net/#easeInBack
  6164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6165. */
  6166. export class BackEase extends EasingFunction implements IEasingFunction {
  6167. /** Defines the amplitude of the function */
  6168. amplitude: number;
  6169. /**
  6170. * Instantiates a back ease easing
  6171. * @see https://easings.net/#easeInBack
  6172. * @param amplitude Defines the amplitude of the function
  6173. */
  6174. constructor(
  6175. /** Defines the amplitude of the function */
  6176. amplitude?: number);
  6177. /** @hidden */
  6178. easeInCore(gradient: number): number;
  6179. }
  6180. /**
  6181. * Easing function with a bouncing shape (see link below).
  6182. * @see https://easings.net/#easeInBounce
  6183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6184. */
  6185. export class BounceEase extends EasingFunction implements IEasingFunction {
  6186. /** Defines the number of bounces */
  6187. bounces: number;
  6188. /** Defines the amplitude of the bounce */
  6189. bounciness: number;
  6190. /**
  6191. * Instantiates a bounce easing
  6192. * @see https://easings.net/#easeInBounce
  6193. * @param bounces Defines the number of bounces
  6194. * @param bounciness Defines the amplitude of the bounce
  6195. */
  6196. constructor(
  6197. /** Defines the number of bounces */
  6198. bounces?: number,
  6199. /** Defines the amplitude of the bounce */
  6200. bounciness?: number);
  6201. /** @hidden */
  6202. easeInCore(gradient: number): number;
  6203. }
  6204. /**
  6205. * Easing function with a power of 3 shape (see link below).
  6206. * @see https://easings.net/#easeInCubic
  6207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6208. */
  6209. export class CubicEase extends EasingFunction implements IEasingFunction {
  6210. /** @hidden */
  6211. easeInCore(gradient: number): number;
  6212. }
  6213. /**
  6214. * Easing function with an elastic shape (see link below).
  6215. * @see https://easings.net/#easeInElastic
  6216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6217. */
  6218. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6219. /** Defines the number of oscillations*/
  6220. oscillations: number;
  6221. /** Defines the amplitude of the oscillations*/
  6222. springiness: number;
  6223. /**
  6224. * Instantiates an elastic easing function
  6225. * @see https://easings.net/#easeInElastic
  6226. * @param oscillations Defines the number of oscillations
  6227. * @param springiness Defines the amplitude of the oscillations
  6228. */
  6229. constructor(
  6230. /** Defines the number of oscillations*/
  6231. oscillations?: number,
  6232. /** Defines the amplitude of the oscillations*/
  6233. springiness?: number);
  6234. /** @hidden */
  6235. easeInCore(gradient: number): number;
  6236. }
  6237. /**
  6238. * Easing function with an exponential shape (see link below).
  6239. * @see https://easings.net/#easeInExpo
  6240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6241. */
  6242. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6243. /** Defines the exponent of the function */
  6244. exponent: number;
  6245. /**
  6246. * Instantiates an exponential easing function
  6247. * @see https://easings.net/#easeInExpo
  6248. * @param exponent Defines the exponent of the function
  6249. */
  6250. constructor(
  6251. /** Defines the exponent of the function */
  6252. exponent?: number);
  6253. /** @hidden */
  6254. easeInCore(gradient: number): number;
  6255. }
  6256. /**
  6257. * Easing function with a power shape (see link below).
  6258. * @see https://easings.net/#easeInQuad
  6259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6260. */
  6261. export class PowerEase extends EasingFunction implements IEasingFunction {
  6262. /** Defines the power of the function */
  6263. power: number;
  6264. /**
  6265. * Instantiates an power base easing function
  6266. * @see https://easings.net/#easeInQuad
  6267. * @param power Defines the power of the function
  6268. */
  6269. constructor(
  6270. /** Defines the power of the function */
  6271. power?: number);
  6272. /** @hidden */
  6273. easeInCore(gradient: number): number;
  6274. }
  6275. /**
  6276. * Easing function with a power of 2 shape (see link below).
  6277. * @see https://easings.net/#easeInQuad
  6278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6279. */
  6280. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6281. /** @hidden */
  6282. easeInCore(gradient: number): number;
  6283. }
  6284. /**
  6285. * Easing function with a power of 4 shape (see link below).
  6286. * @see https://easings.net/#easeInQuart
  6287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6288. */
  6289. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6290. /** @hidden */
  6291. easeInCore(gradient: number): number;
  6292. }
  6293. /**
  6294. * Easing function with a power of 5 shape (see link below).
  6295. * @see https://easings.net/#easeInQuint
  6296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6297. */
  6298. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a sin shape (see link below).
  6304. * @see https://easings.net/#easeInSine
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class SineEase extends EasingFunction implements IEasingFunction {
  6308. /** @hidden */
  6309. easeInCore(gradient: number): number;
  6310. }
  6311. /**
  6312. * Easing function with a bezier shape (see link below).
  6313. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6315. */
  6316. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6317. /** Defines the x component of the start tangent in the bezier curve */
  6318. x1: number;
  6319. /** Defines the y component of the start tangent in the bezier curve */
  6320. y1: number;
  6321. /** Defines the x component of the end tangent in the bezier curve */
  6322. x2: number;
  6323. /** Defines the y component of the end tangent in the bezier curve */
  6324. y2: number;
  6325. /**
  6326. * Instantiates a bezier function
  6327. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6328. * @param x1 Defines the x component of the start tangent in the bezier curve
  6329. * @param y1 Defines the y component of the start tangent in the bezier curve
  6330. * @param x2 Defines the x component of the end tangent in the bezier curve
  6331. * @param y2 Defines the y component of the end tangent in the bezier curve
  6332. */
  6333. constructor(
  6334. /** Defines the x component of the start tangent in the bezier curve */
  6335. x1?: number,
  6336. /** Defines the y component of the start tangent in the bezier curve */
  6337. y1?: number,
  6338. /** Defines the x component of the end tangent in the bezier curve */
  6339. x2?: number,
  6340. /** Defines the y component of the end tangent in the bezier curve */
  6341. y2?: number);
  6342. /** @hidden */
  6343. easeInCore(gradient: number): number;
  6344. }
  6345. }
  6346. declare module "babylonjs/Animations/animationKey" {
  6347. /**
  6348. * Defines an interface which represents an animation key frame
  6349. */
  6350. export interface IAnimationKey {
  6351. /**
  6352. * Frame of the key frame
  6353. */
  6354. frame: number;
  6355. /**
  6356. * Value at the specifies key frame
  6357. */
  6358. value: any;
  6359. /**
  6360. * The input tangent for the cubic hermite spline
  6361. */
  6362. inTangent?: any;
  6363. /**
  6364. * The output tangent for the cubic hermite spline
  6365. */
  6366. outTangent?: any;
  6367. /**
  6368. * The animation interpolation type
  6369. */
  6370. interpolation?: AnimationKeyInterpolation;
  6371. }
  6372. /**
  6373. * Enum for the animation key frame interpolation type
  6374. */
  6375. export enum AnimationKeyInterpolation {
  6376. /**
  6377. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6378. */
  6379. STEP = 1
  6380. }
  6381. }
  6382. declare module "babylonjs/Animations/animationRange" {
  6383. /**
  6384. * Represents the range of an animation
  6385. */
  6386. export class AnimationRange {
  6387. /**The name of the animation range**/
  6388. name: string;
  6389. /**The starting frame of the animation */
  6390. from: number;
  6391. /**The ending frame of the animation*/
  6392. to: number;
  6393. /**
  6394. * Initializes the range of an animation
  6395. * @param name The name of the animation range
  6396. * @param from The starting frame of the animation
  6397. * @param to The ending frame of the animation
  6398. */
  6399. constructor(
  6400. /**The name of the animation range**/
  6401. name: string,
  6402. /**The starting frame of the animation */
  6403. from: number,
  6404. /**The ending frame of the animation*/
  6405. to: number);
  6406. /**
  6407. * Makes a copy of the animation range
  6408. * @returns A copy of the animation range
  6409. */
  6410. clone(): AnimationRange;
  6411. }
  6412. }
  6413. declare module "babylonjs/Animations/animationEvent" {
  6414. /**
  6415. * Composed of a frame, and an action function
  6416. */
  6417. export class AnimationEvent {
  6418. /** The frame for which the event is triggered **/
  6419. frame: number;
  6420. /** The event to perform when triggered **/
  6421. action: (currentFrame: number) => void;
  6422. /** Specifies if the event should be triggered only once**/
  6423. onlyOnce?: boolean | undefined;
  6424. /**
  6425. * Specifies if the animation event is done
  6426. */
  6427. isDone: boolean;
  6428. /**
  6429. * Initializes the animation event
  6430. * @param frame The frame for which the event is triggered
  6431. * @param action The event to perform when triggered
  6432. * @param onlyOnce Specifies if the event should be triggered only once
  6433. */
  6434. constructor(
  6435. /** The frame for which the event is triggered **/
  6436. frame: number,
  6437. /** The event to perform when triggered **/
  6438. action: (currentFrame: number) => void,
  6439. /** Specifies if the event should be triggered only once**/
  6440. onlyOnce?: boolean | undefined);
  6441. /** @hidden */
  6442. _clone(): AnimationEvent;
  6443. }
  6444. }
  6445. declare module "babylonjs/Behaviors/behavior" {
  6446. import { Nullable } from "babylonjs/types";
  6447. /**
  6448. * Interface used to define a behavior
  6449. */
  6450. export interface Behavior<T> {
  6451. /** gets or sets behavior's name */
  6452. name: string;
  6453. /**
  6454. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6455. */
  6456. init(): void;
  6457. /**
  6458. * Called when the behavior is attached to a target
  6459. * @param target defines the target where the behavior is attached to
  6460. */
  6461. attach(target: T): void;
  6462. /**
  6463. * Called when the behavior is detached from its target
  6464. */
  6465. detach(): void;
  6466. }
  6467. /**
  6468. * Interface implemented by classes supporting behaviors
  6469. */
  6470. export interface IBehaviorAware<T> {
  6471. /**
  6472. * Attach a behavior
  6473. * @param behavior defines the behavior to attach
  6474. * @returns the current host
  6475. */
  6476. addBehavior(behavior: Behavior<T>): T;
  6477. /**
  6478. * Remove a behavior from the current object
  6479. * @param behavior defines the behavior to detach
  6480. * @returns the current host
  6481. */
  6482. removeBehavior(behavior: Behavior<T>): T;
  6483. /**
  6484. * Gets a behavior using its name to search
  6485. * @param name defines the name to search
  6486. * @returns the behavior or null if not found
  6487. */
  6488. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6489. }
  6490. }
  6491. declare module "babylonjs/Misc/smartArray" {
  6492. /**
  6493. * Defines an array and its length.
  6494. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6495. */
  6496. export interface ISmartArrayLike<T> {
  6497. /**
  6498. * The data of the array.
  6499. */
  6500. data: Array<T>;
  6501. /**
  6502. * The active length of the array.
  6503. */
  6504. length: number;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. */
  6509. export class SmartArray<T> implements ISmartArrayLike<T> {
  6510. /**
  6511. * The full set of data from the array.
  6512. */
  6513. data: Array<T>;
  6514. /**
  6515. * The active length of the array.
  6516. */
  6517. length: number;
  6518. protected _id: number;
  6519. /**
  6520. * Instantiates a Smart Array.
  6521. * @param capacity defines the default capacity of the array.
  6522. */
  6523. constructor(capacity: number);
  6524. /**
  6525. * Pushes a value at the end of the active data.
  6526. * @param value defines the object to push in the array.
  6527. */
  6528. push(value: T): void;
  6529. /**
  6530. * Iterates over the active data and apply the lambda to them.
  6531. * @param func defines the action to apply on each value.
  6532. */
  6533. forEach(func: (content: T) => void): void;
  6534. /**
  6535. * Sorts the full sets of data.
  6536. * @param compareFn defines the comparison function to apply.
  6537. */
  6538. sort(compareFn: (a: T, b: T) => number): void;
  6539. /**
  6540. * Resets the active data to an empty array.
  6541. */
  6542. reset(): void;
  6543. /**
  6544. * Releases all the data from the array as well as the array.
  6545. */
  6546. dispose(): void;
  6547. /**
  6548. * Concats the active data with a given array.
  6549. * @param array defines the data to concatenate with.
  6550. */
  6551. concat(array: any): void;
  6552. /**
  6553. * Returns the position of a value in the active data.
  6554. * @param value defines the value to find the index for
  6555. * @returns the index if found in the active data otherwise -1
  6556. */
  6557. indexOf(value: T): number;
  6558. /**
  6559. * Returns whether an element is part of the active data.
  6560. * @param value defines the value to look for
  6561. * @returns true if found in the active data otherwise false
  6562. */
  6563. contains(value: T): boolean;
  6564. private static _GlobalId;
  6565. }
  6566. /**
  6567. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6568. * The data in this array can only be present once
  6569. */
  6570. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6571. private _duplicateId;
  6572. /**
  6573. * Pushes a value at the end of the active data.
  6574. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6575. * @param value defines the object to push in the array.
  6576. */
  6577. push(value: T): void;
  6578. /**
  6579. * Pushes a value at the end of the active data.
  6580. * If the data is already present, it won t be added again
  6581. * @param value defines the object to push in the array.
  6582. * @returns true if added false if it was already present
  6583. */
  6584. pushNoDuplicate(value: T): boolean;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Concats the active data with a given array.
  6591. * This ensures no dupplicate will be present in the result.
  6592. * @param array defines the data to concatenate with.
  6593. */
  6594. concatWithNoDuplicate(array: any): void;
  6595. }
  6596. }
  6597. declare module "babylonjs/Cameras/cameraInputsManager" {
  6598. import { Nullable } from "babylonjs/types";
  6599. import { Camera } from "babylonjs/Cameras/camera";
  6600. /**
  6601. * @ignore
  6602. * This is a list of all the different input types that are available in the application.
  6603. * Fo instance: ArcRotateCameraGamepadInput...
  6604. */
  6605. export var CameraInputTypes: {};
  6606. /**
  6607. * This is the contract to implement in order to create a new input class.
  6608. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6609. */
  6610. export interface ICameraInput<TCamera extends Camera> {
  6611. /**
  6612. * Defines the camera the input is attached to.
  6613. */
  6614. camera: Nullable<TCamera>;
  6615. /**
  6616. * Gets the class name of the current intput.
  6617. * @returns the class name
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * Get the friendly name associated with the input class.
  6622. * @returns the input friendly name
  6623. */
  6624. getSimpleName(): string;
  6625. /**
  6626. * Attach the input controls to a specific dom element to get the input from.
  6627. * @param element Defines the element the controls should be listened from
  6628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6629. */
  6630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6631. /**
  6632. * Detach the current controls from the specified dom element.
  6633. * @param element Defines the element to stop listening the inputs from
  6634. */
  6635. detachControl(element: Nullable<HTMLElement>): void;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs?: () => void;
  6641. }
  6642. /**
  6643. * Represents a map of input types to input instance or input index to input instance.
  6644. */
  6645. export interface CameraInputsMap<TCamera extends Camera> {
  6646. /**
  6647. * Accessor to the input by input type.
  6648. */
  6649. [name: string]: ICameraInput<TCamera>;
  6650. /**
  6651. * Accessor to the input by input index.
  6652. */
  6653. [idx: number]: ICameraInput<TCamera>;
  6654. }
  6655. /**
  6656. * This represents the input manager used within a camera.
  6657. * It helps dealing with all the different kind of input attached to a camera.
  6658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6659. */
  6660. export class CameraInputsManager<TCamera extends Camera> {
  6661. /**
  6662. * Defines the list of inputs attahed to the camera.
  6663. */
  6664. attached: CameraInputsMap<TCamera>;
  6665. /**
  6666. * Defines the dom element the camera is collecting inputs from.
  6667. * This is null if the controls have not been attached.
  6668. */
  6669. attachedElement: Nullable<HTMLElement>;
  6670. /**
  6671. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6672. */
  6673. noPreventDefault: boolean;
  6674. /**
  6675. * Defined the camera the input manager belongs to.
  6676. */
  6677. camera: TCamera;
  6678. /**
  6679. * Update the current camera state depending on the inputs that have been used this frame.
  6680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6681. */
  6682. checkInputs: () => void;
  6683. /**
  6684. * Instantiate a new Camera Input Manager.
  6685. * @param camera Defines the camera the input manager blongs to
  6686. */
  6687. constructor(camera: TCamera);
  6688. /**
  6689. * Add an input method to a camera
  6690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6691. * @param input camera input method
  6692. */
  6693. add(input: ICameraInput<TCamera>): void;
  6694. /**
  6695. * Remove a specific input method from a camera
  6696. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6697. * @param inputToRemove camera input method
  6698. */
  6699. remove(inputToRemove: ICameraInput<TCamera>): void;
  6700. /**
  6701. * Remove a specific input type from a camera
  6702. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6703. * @param inputType the type of the input to remove
  6704. */
  6705. removeByType(inputType: string): void;
  6706. private _addCheckInputs;
  6707. /**
  6708. * Attach the input controls to the currently attached dom element to listen the events from.
  6709. * @param input Defines the input to attach
  6710. */
  6711. attachInput(input: ICameraInput<TCamera>): void;
  6712. /**
  6713. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6714. * @param element Defines the dom element to collect the events from
  6715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6716. */
  6717. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6718. /**
  6719. * Detach the current manager inputs controls from a specific dom element.
  6720. * @param element Defines the dom element to collect the events from
  6721. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6722. */
  6723. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6724. /**
  6725. * Rebuild the dynamic inputCheck function from the current list of
  6726. * defined inputs in the manager.
  6727. */
  6728. rebuildInputCheck(): void;
  6729. /**
  6730. * Remove all attached input methods from a camera
  6731. */
  6732. clear(): void;
  6733. /**
  6734. * Serialize the current input manager attached to a camera.
  6735. * This ensures than once parsed,
  6736. * the input associated to the camera will be identical to the current ones
  6737. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6738. */
  6739. serialize(serializedCamera: any): void;
  6740. /**
  6741. * Parses an input manager serialized JSON to restore the previous list of inputs
  6742. * and states associated to a camera.
  6743. * @param parsedCamera Defines the JSON to parse
  6744. */
  6745. parse(parsedCamera: any): void;
  6746. }
  6747. }
  6748. declare module "babylonjs/Collisions/intersectionInfo" {
  6749. import { Nullable } from "babylonjs/types";
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module "babylonjs/Maths/math.plane" {
  6763. import { DeepImmutable } from "babylonjs/types";
  6764. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6765. /**
  6766. * Represens a plane by the equation ax + by + cz + d = 0
  6767. */
  6768. export class Plane {
  6769. private static _TmpMatrix;
  6770. /**
  6771. * Normal of the plane (a,b,c)
  6772. */
  6773. normal: Vector3;
  6774. /**
  6775. * d component of the plane
  6776. */
  6777. d: number;
  6778. /**
  6779. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6780. * @param a a component of the plane
  6781. * @param b b component of the plane
  6782. * @param c c component of the plane
  6783. * @param d d component of the plane
  6784. */
  6785. constructor(a: number, b: number, c: number, d: number);
  6786. /**
  6787. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6788. */
  6789. asArray(): number[];
  6790. /**
  6791. * @returns a new plane copied from the current Plane.
  6792. */
  6793. clone(): Plane;
  6794. /**
  6795. * @returns the string "Plane".
  6796. */
  6797. getClassName(): string;
  6798. /**
  6799. * @returns the Plane hash code.
  6800. */
  6801. getHashCode(): number;
  6802. /**
  6803. * Normalize the current Plane in place.
  6804. * @returns the updated Plane.
  6805. */
  6806. normalize(): Plane;
  6807. /**
  6808. * Applies a transformation the plane and returns the result
  6809. * @param transformation the transformation matrix to be applied to the plane
  6810. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6811. */
  6812. transform(transformation: DeepImmutable<Matrix>): Plane;
  6813. /**
  6814. * Calcualtte the dot product between the point and the plane normal
  6815. * @param point point to calculate the dot product with
  6816. * @returns the dot product (float) of the point coordinates and the plane normal.
  6817. */
  6818. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6819. /**
  6820. * Updates the current Plane from the plane defined by the three given points.
  6821. * @param point1 one of the points used to contruct the plane
  6822. * @param point2 one of the points used to contruct the plane
  6823. * @param point3 one of the points used to contruct the plane
  6824. * @returns the updated Plane.
  6825. */
  6826. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6827. /**
  6828. * Checks if the plane is facing a given direction
  6829. * @param direction the direction to check if the plane is facing
  6830. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6831. * @returns True is the vector "direction" is the same side than the plane normal.
  6832. */
  6833. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6834. /**
  6835. * Calculates the distance to a point
  6836. * @param point point to calculate distance to
  6837. * @returns the signed distance (float) from the given point to the Plane.
  6838. */
  6839. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6840. /**
  6841. * Creates a plane from an array
  6842. * @param array the array to create a plane from
  6843. * @returns a new Plane from the given array.
  6844. */
  6845. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6846. /**
  6847. * Creates a plane from three points
  6848. * @param point1 point used to create the plane
  6849. * @param point2 point used to create the plane
  6850. * @param point3 point used to create the plane
  6851. * @returns a new Plane defined by the three given points.
  6852. */
  6853. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6854. /**
  6855. * Creates a plane from an origin point and a normal
  6856. * @param origin origin of the plane to be constructed
  6857. * @param normal normal of the plane to be constructed
  6858. * @returns a new Plane the normal vector to this plane at the given origin point.
  6859. * Note : the vector "normal" is updated because normalized.
  6860. */
  6861. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6862. /**
  6863. * Calculates the distance from a plane and a point
  6864. * @param origin origin of the plane to be constructed
  6865. * @param normal normal of the plane to be constructed
  6866. * @param point point to calculate distance to
  6867. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6868. */
  6869. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingSphere" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { Plane } from "babylonjs/Maths/math.plane";
  6876. /**
  6877. * Class used to store bounding sphere information
  6878. */
  6879. export class BoundingSphere {
  6880. /**
  6881. * Gets the center of the bounding sphere in local space
  6882. */
  6883. readonly center: Vector3;
  6884. /**
  6885. * Radius of the bounding sphere in local space
  6886. */
  6887. radius: number;
  6888. /**
  6889. * Gets the center of the bounding sphere in world space
  6890. */
  6891. readonly centerWorld: Vector3;
  6892. /**
  6893. * Radius of the bounding sphere in world space
  6894. */
  6895. radiusWorld: number;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * Creates a new bounding sphere
  6908. * @param min defines the minimum vector (in local space)
  6909. * @param max defines the maximum vector (in local space)
  6910. * @param worldMatrix defines the new world matrix
  6911. */
  6912. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6913. /**
  6914. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6915. * @param min defines the new minimum vector (in local space)
  6916. * @param max defines the new maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6920. /**
  6921. * Scale the current bounding sphere by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding box
  6924. */
  6925. scale(factor: number): BoundingSphere;
  6926. /**
  6927. * Gets the world matrix of the bounding box
  6928. * @returns a matrix
  6929. */
  6930. getWorldMatrix(): DeepImmutable<Matrix>;
  6931. /** @hidden */
  6932. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Tests if the bounding sphere is intersecting the frustum planes
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @returns true if there is an intersection
  6937. */
  6938. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if the bounding sphere center is in between the frustum planes.
  6941. * Used for optimistic fast inclusion.
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if the sphere center is in between the frustum planes
  6944. */
  6945. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a point is inside the bounding sphere
  6948. * @param point defines the point to test
  6949. * @returns true if the point is inside the bounding sphere
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if two sphere intersct
  6954. * @param sphere0 sphere 0
  6955. * @param sphere1 sphere 1
  6956. * @returns true if the speres intersect
  6957. */
  6958. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Culling/boundingBox" {
  6962. import { DeepImmutable } from "babylonjs/types";
  6963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6964. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6966. import { Plane } from "babylonjs/Maths/math.plane";
  6967. /**
  6968. * Class used to store bounding box information
  6969. */
  6970. export class BoundingBox implements ICullable {
  6971. /**
  6972. * Gets the 8 vectors representing the bounding box in local space
  6973. */
  6974. readonly vectors: Vector3[];
  6975. /**
  6976. * Gets the center of the bounding box in local space
  6977. */
  6978. readonly center: Vector3;
  6979. /**
  6980. * Gets the center of the bounding box in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Gets the extend size in local space
  6985. */
  6986. readonly extendSize: Vector3;
  6987. /**
  6988. * Gets the extend size in world space
  6989. */
  6990. readonly extendSizeWorld: Vector3;
  6991. /**
  6992. * Gets the OBB (object bounding box) directions
  6993. */
  6994. readonly directions: Vector3[];
  6995. /**
  6996. * Gets the 8 vectors representing the bounding box in world space
  6997. */
  6998. readonly vectorsWorld: Vector3[];
  6999. /**
  7000. * Gets the minimum vector in world space
  7001. */
  7002. readonly minimumWorld: Vector3;
  7003. /**
  7004. * Gets the maximum vector in world space
  7005. */
  7006. readonly maximumWorld: Vector3;
  7007. /**
  7008. * Gets the minimum vector in local space
  7009. */
  7010. readonly minimum: Vector3;
  7011. /**
  7012. * Gets the maximum vector in local space
  7013. */
  7014. readonly maximum: Vector3;
  7015. private _worldMatrix;
  7016. private static readonly TmpVector3;
  7017. /**
  7018. * @hidden
  7019. */
  7020. _tag: number;
  7021. /**
  7022. * Creates a new bounding box
  7023. * @param min defines the minimum vector (in local space)
  7024. * @param max defines the maximum vector (in local space)
  7025. * @param worldMatrix defines the new world matrix
  7026. */
  7027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7028. /**
  7029. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7030. * @param min defines the new minimum vector (in local space)
  7031. * @param max defines the new maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Scale the current bounding box by applying a scale factor
  7037. * @param factor defines the scale factor to apply
  7038. * @returns the current bounding box
  7039. */
  7040. scale(factor: number): BoundingBox;
  7041. /**
  7042. * Gets the world matrix of the bounding box
  7043. * @returns a matrix
  7044. */
  7045. getWorldMatrix(): DeepImmutable<Matrix>;
  7046. /** @hidden */
  7047. _update(world: DeepImmutable<Matrix>): void;
  7048. /**
  7049. * Tests if the bounding box is intersecting the frustum planes
  7050. * @param frustumPlanes defines the frustum planes to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7054. /**
  7055. * Tests if the bounding box is entirely inside the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an inclusion
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if a point is inside the bounding box
  7062. * @param point defines the point to test
  7063. * @returns true if the point is inside the bounding box
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if the bounding box intersects with a bounding sphere
  7068. * @param sphere defines the sphere to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7074. * @param min defines the min vector to use
  7075. * @param max defines the max vector to use
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7079. /**
  7080. * Tests if two bounding boxes are intersections
  7081. * @param box0 defines the first box to test
  7082. * @param box1 defines the second box to test
  7083. * @returns true if there is an intersection
  7084. */
  7085. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7086. /**
  7087. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7088. * @param minPoint defines the minimum vector of the bounding box
  7089. * @param maxPoint defines the maximum vector of the bounding box
  7090. * @param sphereCenter defines the sphere center
  7091. * @param sphereRadius defines the sphere radius
  7092. * @returns true if there is an intersection
  7093. */
  7094. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7095. /**
  7096. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7098. * @param frustumPlanes defines the frustum planes to test
  7099. * @return true if there is an inclusion
  7100. */
  7101. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an intersection
  7107. */
  7108. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. }
  7110. }
  7111. declare module "babylonjs/Collisions/collider" {
  7112. import { Nullable, IndicesArray } from "babylonjs/types";
  7113. import { Vector3 } from "babylonjs/Maths/math.vector";
  7114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7115. import { Plane } from "babylonjs/Maths/math.plane";
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingInfo" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7180. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7181. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. import { Collider } from "babylonjs/Collisions/collider";
  7184. /**
  7185. * Interface for cullable objects
  7186. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7187. */
  7188. export interface ICullable {
  7189. /**
  7190. * Checks if the object or part of the object is in the frustum
  7191. * @param frustumPlanes Camera near/planes
  7192. * @returns true if the object is in frustum otherwise false
  7193. */
  7194. isInFrustum(frustumPlanes: Plane[]): boolean;
  7195. /**
  7196. * Checks if a cullable object (mesh...) is in the camera frustum
  7197. * Unlike isInFrustum this cheks the full bounding box
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7202. }
  7203. /**
  7204. * Info for a bounding data of a mesh
  7205. */
  7206. export class BoundingInfo implements ICullable {
  7207. /**
  7208. * Bounding box for the mesh
  7209. */
  7210. readonly boundingBox: BoundingBox;
  7211. /**
  7212. * Bounding sphere for the mesh
  7213. */
  7214. readonly boundingSphere: BoundingSphere;
  7215. private _isLocked;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Constructs bounding info
  7219. * @param minimum min vector of the bounding box/sphere
  7220. * @param maximum max vector of the bounding box/sphere
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * min vector of the bounding box/sphere
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * max vector of the bounding box/sphere
  7237. */
  7238. readonly maximum: Vector3;
  7239. /**
  7240. * If the info is locked and won't be updated to avoid perf overhead
  7241. */
  7242. isLocked: boolean;
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. readonly diagonalLength: number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module "babylonjs/Maths/math.functions" {
  7299. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7301. /**
  7302. * Extracts minimum and maximum values from a list of indexed positions
  7303. * @param positions defines the positions to use
  7304. * @param indices defines the indices to the positions
  7305. * @param indexStart defines the start index
  7306. * @param indexCount defines the end index
  7307. * @param bias defines bias value to add to the result
  7308. * @return minimum and maximum values
  7309. */
  7310. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7311. minimum: Vector3;
  7312. maximum: Vector3;
  7313. };
  7314. /**
  7315. * Extracts minimum and maximum values from a list of positions
  7316. * @param positions defines the positions to use
  7317. * @param start defines the start index in the positions array
  7318. * @param count defines the number of positions to handle
  7319. * @param bias defines bias value to add to the result
  7320. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7321. * @return minimum and maximum values
  7322. */
  7323. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7324. minimum: Vector3;
  7325. maximum: Vector3;
  7326. };
  7327. }
  7328. declare module "babylonjs/Misc/iInspectable" {
  7329. /**
  7330. * Enum that determines the text-wrapping mode to use.
  7331. */
  7332. export enum InspectableType {
  7333. /**
  7334. * Checkbox for booleans
  7335. */
  7336. Checkbox = 0,
  7337. /**
  7338. * Sliders for numbers
  7339. */
  7340. Slider = 1,
  7341. /**
  7342. * Vector3
  7343. */
  7344. Vector3 = 2,
  7345. /**
  7346. * Quaternions
  7347. */
  7348. Quaternion = 3,
  7349. /**
  7350. * Color3
  7351. */
  7352. Color3 = 4,
  7353. /**
  7354. * String
  7355. */
  7356. String = 5
  7357. }
  7358. /**
  7359. * Interface used to define custom inspectable properties.
  7360. * This interface is used by the inspector to display custom property grids
  7361. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7362. */
  7363. export interface IInspectable {
  7364. /**
  7365. * Gets the label to display
  7366. */
  7367. label: string;
  7368. /**
  7369. * Gets the name of the property to edit
  7370. */
  7371. propertyName: string;
  7372. /**
  7373. * Gets the type of the editor to use
  7374. */
  7375. type: InspectableType;
  7376. /**
  7377. * Gets the minimum value of the property when using in "slider" mode
  7378. */
  7379. min?: number;
  7380. /**
  7381. * Gets the maximum value of the property when using in "slider" mode
  7382. */
  7383. max?: number;
  7384. /**
  7385. * Gets the setp to use when using in "slider" mode
  7386. */
  7387. step?: number;
  7388. }
  7389. }
  7390. declare module "babylonjs/Misc/timingTools" {
  7391. /**
  7392. * Class used to provide helper for timing
  7393. */
  7394. export class TimingTools {
  7395. /**
  7396. * Polyfill for setImmediate
  7397. * @param action defines the action to execute after the current execution block
  7398. */
  7399. static SetImmediate(action: () => void): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/instantiationTools" {
  7403. /**
  7404. * Class used to enable instatition of objects by class name
  7405. */
  7406. export class InstantiationTools {
  7407. /**
  7408. * Use this object to register external classes like custom textures or material
  7409. * to allow the laoders to instantiate them
  7410. */
  7411. static RegisteredExternalClasses: {
  7412. [key: string]: Object;
  7413. };
  7414. /**
  7415. * Tries to instantiate a new object from a given class name
  7416. * @param className defines the class name to instantiate
  7417. * @returns the new object or null if the system was not able to do the instantiation
  7418. */
  7419. static Instantiate(className: string): any;
  7420. }
  7421. }
  7422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7423. import { Nullable } from "babylonjs/types";
  7424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7425. /**
  7426. * This represents the required contract to create a new type of texture loader.
  7427. */
  7428. export interface IInternalTextureLoader {
  7429. /**
  7430. * Defines wether the loader supports cascade loading the different faces.
  7431. */
  7432. supportCascades: boolean;
  7433. /**
  7434. * This returns if the loader support the current file information.
  7435. * @param extension defines the file extension of the file being loaded
  7436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7437. * @param fallback defines the fallback internal texture if any
  7438. * @param isBase64 defines whether the texture is encoded as a base64
  7439. * @param isBuffer defines whether the texture data are stored as a buffer
  7440. * @returns true if the loader can load the specified file
  7441. */
  7442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7443. /**
  7444. * Transform the url before loading if required.
  7445. * @param rootUrl the url of the texture
  7446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7447. * @returns the transformed texture
  7448. */
  7449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7450. /**
  7451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the fallback texture
  7455. */
  7456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7457. /**
  7458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7459. * @param data contains the texture data
  7460. * @param texture defines the BabylonJS internal texture
  7461. * @param createPolynomials will be true if polynomials have been requested
  7462. * @param onLoad defines the callback to trigger once the texture is ready
  7463. * @param onError defines the callback to trigger in case of error
  7464. */
  7465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /**
  7467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7468. * @param data contains the texture data
  7469. * @param texture defines the BabylonJS internal texture
  7470. * @param callback defines the method to call once ready to upload
  7471. */
  7472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7473. }
  7474. }
  7475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7477. import { Nullable } from "babylonjs/types";
  7478. import { Scene } from "babylonjs/scene";
  7479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7480. module "babylonjs/Engines/engine" {
  7481. interface Engine {
  7482. /**
  7483. * Creates a depth stencil cube texture.
  7484. * This is only available in WebGL 2.
  7485. * @param size The size of face edge in the cube texture.
  7486. * @param options The options defining the cube texture.
  7487. * @returns The cube texture
  7488. */
  7489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7490. /**
  7491. * Creates a cube texture
  7492. * @param rootUrl defines the url where the files to load is located
  7493. * @param scene defines the current scene
  7494. * @param files defines the list of files to load (1 per face)
  7495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7496. * @param onLoad defines an optional callback raised when the texture is loaded
  7497. * @param onError defines an optional callback raised if there is an issue to load the texture
  7498. * @param format defines the format of the data
  7499. * @param forcedExtension defines the extension to use to pick the right loader
  7500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7505. * @returns the cube texture as an InternalTexture
  7506. */
  7507. 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;
  7508. /**
  7509. * Creates a cube texture
  7510. * @param rootUrl defines the url where the files to load is located
  7511. * @param scene defines the current scene
  7512. * @param files defines the list of files to load (1 per face)
  7513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7514. * @param onLoad defines an optional callback raised when the texture is loaded
  7515. * @param onError defines an optional callback raised if there is an issue to load the texture
  7516. * @param format defines the format of the data
  7517. * @param forcedExtension defines the extension to use to pick the right loader
  7518. * @returns the cube texture as an InternalTexture
  7519. */
  7520. 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;
  7521. /**
  7522. * Creates a cube texture
  7523. * @param rootUrl defines the url where the files to load is located
  7524. * @param scene defines the current scene
  7525. * @param files defines the list of files to load (1 per face)
  7526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7527. * @param onLoad defines an optional callback raised when the texture is loaded
  7528. * @param onError defines an optional callback raised if there is an issue to load the texture
  7529. * @param format defines the format of the data
  7530. * @param forcedExtension defines the extension to use to pick the right loader
  7531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7534. * @returns the cube texture as an InternalTexture
  7535. */
  7536. 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;
  7537. /** @hidden */
  7538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7539. /** @hidden */
  7540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7541. /** @hidden */
  7542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7543. /** @hidden */
  7544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7545. }
  7546. }
  7547. }
  7548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7549. import { Nullable } from "babylonjs/types";
  7550. import { Scene } from "babylonjs/scene";
  7551. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7554. /**
  7555. * Class for creating a cube texture
  7556. */
  7557. export class CubeTexture extends BaseTexture {
  7558. private _delayedOnLoad;
  7559. /**
  7560. * The url of the texture
  7561. */
  7562. url: string;
  7563. /**
  7564. * Gets or sets the center of the bounding box associated with the cube texture.
  7565. * It must define where the camera used to render the texture was set
  7566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7567. */
  7568. boundingBoxPosition: Vector3;
  7569. private _boundingBoxSize;
  7570. /**
  7571. * Gets or sets the size of the bounding box associated with the cube texture
  7572. * When defined, the cubemap will switch to local mode
  7573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7574. * @example https://www.babylonjs-playground.com/#RNASML
  7575. */
  7576. /**
  7577. * Returns the bounding box size
  7578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7579. */
  7580. boundingBoxSize: Vector3;
  7581. protected _rotationY: number;
  7582. /**
  7583. * Sets texture matrix rotation angle around Y axis in radians.
  7584. */
  7585. /**
  7586. * Gets texture matrix rotation angle around Y axis radians.
  7587. */
  7588. rotationY: number;
  7589. /**
  7590. * Are mip maps generated for this texture or not.
  7591. */
  7592. readonly noMipmap: boolean;
  7593. private _noMipmap;
  7594. private _files;
  7595. private _extensions;
  7596. private _textureMatrix;
  7597. private _format;
  7598. private _createPolynomials;
  7599. /** @hidden */
  7600. _prefiltered: boolean;
  7601. /**
  7602. * Creates a cube texture from an array of image urls
  7603. * @param files defines an array of image urls
  7604. * @param scene defines the hosting scene
  7605. * @param noMipmap specifies if mip maps are not used
  7606. * @returns a cube texture
  7607. */
  7608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7609. /**
  7610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7611. * @param url defines the url of the prefiltered texture
  7612. * @param scene defines the scene the texture is attached to
  7613. * @param forcedExtension defines the extension of the file if different from the url
  7614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7615. * @return the prefiltered texture
  7616. */
  7617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7618. /**
  7619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7620. * as prefiltered data.
  7621. * @param rootUrl defines the url of the texture or the root name of the six images
  7622. * @param scene defines the scene the texture is attached to
  7623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7624. * @param noMipmap defines if mipmaps should be created or not
  7625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7627. * @param onError defines a callback triggered in case of error during load
  7628. * @param format defines the internal format to use for the texture once loaded
  7629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @return the cube texture
  7635. */
  7636. 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);
  7637. /**
  7638. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7639. */
  7640. readonly isPrefiltered: boolean;
  7641. /**
  7642. * Get the current class name of the texture useful for serialization or dynamic coding.
  7643. * @returns "CubeTexture"
  7644. */
  7645. getClassName(): string;
  7646. /**
  7647. * Update the url (and optional buffer) of this texture if url was null during construction.
  7648. * @param url the url of the texture
  7649. * @param forcedExtension defines the extension to use
  7650. * @param onLoad callback called when the texture is loaded (defaults to null)
  7651. */
  7652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7653. /**
  7654. * Delays loading of the cube texture
  7655. * @param forcedExtension defines the extension to use
  7656. */
  7657. delayLoad(forcedExtension?: string): void;
  7658. /**
  7659. * Returns the reflection texture matrix
  7660. * @returns the reflection texture matrix
  7661. */
  7662. getReflectionTextureMatrix(): Matrix;
  7663. /**
  7664. * Sets the reflection texture matrix
  7665. * @param value Reflection texture matrix
  7666. */
  7667. setReflectionTextureMatrix(value: Matrix): void;
  7668. /**
  7669. * Parses text to create a cube texture
  7670. * @param parsedTexture define the serialized text to read from
  7671. * @param scene defines the hosting scene
  7672. * @param rootUrl defines the root url of the cube texture
  7673. * @returns a cube texture
  7674. */
  7675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7676. /**
  7677. * Makes a clone, or deep copy, of the cube texture
  7678. * @returns a new cube texture
  7679. */
  7680. clone(): CubeTexture;
  7681. }
  7682. }
  7683. declare module "babylonjs/Materials/materialDefines" {
  7684. /**
  7685. * Manages the defines for the Material
  7686. */
  7687. export class MaterialDefines {
  7688. /** @hidden */
  7689. protected _keys: string[];
  7690. private _isDirty;
  7691. /** @hidden */
  7692. _renderId: number;
  7693. /** @hidden */
  7694. _areLightsDirty: boolean;
  7695. /** @hidden */
  7696. _areLightsDisposed: boolean;
  7697. /** @hidden */
  7698. _areAttributesDirty: boolean;
  7699. /** @hidden */
  7700. _areTexturesDirty: boolean;
  7701. /** @hidden */
  7702. _areFresnelDirty: boolean;
  7703. /** @hidden */
  7704. _areMiscDirty: boolean;
  7705. /** @hidden */
  7706. _areImageProcessingDirty: boolean;
  7707. /** @hidden */
  7708. _normals: boolean;
  7709. /** @hidden */
  7710. _uvs: boolean;
  7711. /** @hidden */
  7712. _needNormals: boolean;
  7713. /** @hidden */
  7714. _needUVs: boolean;
  7715. [id: string]: any;
  7716. /**
  7717. * Specifies if the material needs to be re-calculated
  7718. */
  7719. readonly isDirty: boolean;
  7720. /**
  7721. * Marks the material to indicate that it has been re-calculated
  7722. */
  7723. markAsProcessed(): void;
  7724. /**
  7725. * Marks the material to indicate that it needs to be re-calculated
  7726. */
  7727. markAsUnprocessed(): void;
  7728. /**
  7729. * Marks the material to indicate all of its defines need to be re-calculated
  7730. */
  7731. markAllAsDirty(): void;
  7732. /**
  7733. * Marks the material to indicate that image processing needs to be re-calculated
  7734. */
  7735. markAsImageProcessingDirty(): void;
  7736. /**
  7737. * Marks the material to indicate the lights need to be re-calculated
  7738. * @param disposed Defines whether the light is dirty due to dispose or not
  7739. */
  7740. markAsLightDirty(disposed?: boolean): void;
  7741. /**
  7742. * Marks the attribute state as changed
  7743. */
  7744. markAsAttributesDirty(): void;
  7745. /**
  7746. * Marks the texture state as changed
  7747. */
  7748. markAsTexturesDirty(): void;
  7749. /**
  7750. * Marks the fresnel state as changed
  7751. */
  7752. markAsFresnelDirty(): void;
  7753. /**
  7754. * Marks the misc state as changed
  7755. */
  7756. markAsMiscDirty(): void;
  7757. /**
  7758. * Rebuilds the material defines
  7759. */
  7760. rebuild(): void;
  7761. /**
  7762. * Specifies if two material defines are equal
  7763. * @param other - A material define instance to compare to
  7764. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7765. */
  7766. isEqual(other: MaterialDefines): boolean;
  7767. /**
  7768. * Clones this instance's defines to another instance
  7769. * @param other - material defines to clone values to
  7770. */
  7771. cloneTo(other: MaterialDefines): void;
  7772. /**
  7773. * Resets the material define values
  7774. */
  7775. reset(): void;
  7776. /**
  7777. * Converts the material define values to a string
  7778. * @returns - String of material define information
  7779. */
  7780. toString(): string;
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/colorCurves" {
  7784. import { Effect } from "babylonjs/Materials/effect";
  7785. /**
  7786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7788. * 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;
  7789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7790. */
  7791. export class ColorCurves {
  7792. private _dirty;
  7793. private _tempColor;
  7794. private _globalCurve;
  7795. private _highlightsCurve;
  7796. private _midtonesCurve;
  7797. private _shadowsCurve;
  7798. private _positiveCurve;
  7799. private _negativeCurve;
  7800. private _globalHue;
  7801. private _globalDensity;
  7802. private _globalSaturation;
  7803. private _globalExposure;
  7804. /**
  7805. * Gets the global Hue value.
  7806. * 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).
  7807. */
  7808. /**
  7809. * Sets the global Hue value.
  7810. * 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).
  7811. */
  7812. globalHue: number;
  7813. /**
  7814. * Gets the global Density value.
  7815. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the global Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. globalDensity: number;
  7824. /**
  7825. * Gets the global Saturation value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the global Saturation value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7831. */
  7832. globalSaturation: number;
  7833. /**
  7834. * Gets the global Exposure value.
  7835. * 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.
  7836. */
  7837. /**
  7838. * Sets the global Exposure value.
  7839. * 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.
  7840. */
  7841. globalExposure: number;
  7842. private _highlightsHue;
  7843. private _highlightsDensity;
  7844. private _highlightsSaturation;
  7845. private _highlightsExposure;
  7846. /**
  7847. * Gets the highlights Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the highlights Hue value.
  7852. * 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).
  7853. */
  7854. highlightsHue: number;
  7855. /**
  7856. * Gets the highlights Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the highlights Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. highlightsDensity: number;
  7866. /**
  7867. * Gets the highlights Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the highlights Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. highlightsSaturation: number;
  7875. /**
  7876. * Gets the highlights Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the highlights Exposure value.
  7881. * 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.
  7882. */
  7883. highlightsExposure: number;
  7884. private _midtonesHue;
  7885. private _midtonesDensity;
  7886. private _midtonesSaturation;
  7887. private _midtonesExposure;
  7888. /**
  7889. * Gets the midtones Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the midtones Hue value.
  7894. * 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).
  7895. */
  7896. midtonesHue: number;
  7897. /**
  7898. * Gets the midtones Density value.
  7899. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the midtones Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. midtonesDensity: number;
  7908. /**
  7909. * Gets the midtones Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the midtones Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. midtonesSaturation: number;
  7917. /**
  7918. * Gets the midtones Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the midtones Exposure value.
  7923. * 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.
  7924. */
  7925. midtonesExposure: number;
  7926. private _shadowsHue;
  7927. private _shadowsDensity;
  7928. private _shadowsSaturation;
  7929. private _shadowsExposure;
  7930. /**
  7931. * Gets the shadows Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the shadows Hue value.
  7936. * 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).
  7937. */
  7938. shadowsHue: number;
  7939. /**
  7940. * Gets the shadows Density value.
  7941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the shadows Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. shadowsDensity: number;
  7950. /**
  7951. * Gets the shadows Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the shadows Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. shadowsSaturation: number;
  7959. /**
  7960. * Gets the shadows Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the shadows Exposure value.
  7965. * 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.
  7966. */
  7967. shadowsExposure: number;
  7968. /**
  7969. * Returns the class name
  7970. * @returns The class name
  7971. */
  7972. getClassName(): string;
  7973. /**
  7974. * Binds the color curves to the shader.
  7975. * @param colorCurves The color curve to bind
  7976. * @param effect The effect to bind to
  7977. * @param positiveUniform The positive uniform shader parameter
  7978. * @param neutralUniform The neutral uniform shader parameter
  7979. * @param negativeUniform The negative uniform shader parameter
  7980. */
  7981. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7982. /**
  7983. * Prepare the list of uniforms associated with the ColorCurves effects.
  7984. * @param uniformsList The list of uniforms used in the effect
  7985. */
  7986. static PrepareUniforms(uniformsList: string[]): void;
  7987. /**
  7988. * Returns color grading data based on a hue, density, saturation and exposure value.
  7989. * @param filterHue The hue of the color filter.
  7990. * @param filterDensity The density of the color filter.
  7991. * @param saturation The saturation.
  7992. * @param exposure The exposure.
  7993. * @param result The result data container.
  7994. */
  7995. private getColorGradingDataToRef;
  7996. /**
  7997. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7998. * @param value The input slider value in range [-100,100].
  7999. * @returns Adjusted value.
  8000. */
  8001. private static applyColorGradingSliderNonlinear;
  8002. /**
  8003. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8004. * @param hue The hue (H) input.
  8005. * @param saturation The saturation (S) input.
  8006. * @param brightness The brightness (B) input.
  8007. * @result An RGBA color represented as Vector4.
  8008. */
  8009. private static fromHSBToRef;
  8010. /**
  8011. * Returns a value clamped between min and max
  8012. * @param value The value to clamp
  8013. * @param min The minimum of value
  8014. * @param max The maximum of value
  8015. * @returns The clamped value.
  8016. */
  8017. private static clamp;
  8018. /**
  8019. * Clones the current color curve instance.
  8020. * @return The cloned curves
  8021. */
  8022. clone(): ColorCurves;
  8023. /**
  8024. * Serializes the current color curve instance to a json representation.
  8025. * @return a JSON representation
  8026. */
  8027. serialize(): any;
  8028. /**
  8029. * Parses the color curve from a json representation.
  8030. * @param source the JSON source to parse
  8031. * @return The parsed curves
  8032. */
  8033. static Parse(source: any): ColorCurves;
  8034. }
  8035. }
  8036. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8037. import { Observable } from "babylonjs/Misc/observable";
  8038. import { Nullable } from "babylonjs/types";
  8039. import { Color4 } from "babylonjs/Maths/math.color";
  8040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8041. import { Effect } from "babylonjs/Materials/effect";
  8042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8043. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8044. /**
  8045. * Interface to follow in your material defines to integrate easily the
  8046. * Image proccessing functions.
  8047. * @hidden
  8048. */
  8049. export interface IImageProcessingConfigurationDefines {
  8050. IMAGEPROCESSING: boolean;
  8051. VIGNETTE: boolean;
  8052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8053. VIGNETTEBLENDMODEOPAQUE: boolean;
  8054. TONEMAPPING: boolean;
  8055. TONEMAPPING_ACES: boolean;
  8056. CONTRAST: boolean;
  8057. EXPOSURE: boolean;
  8058. COLORCURVES: boolean;
  8059. COLORGRADING: boolean;
  8060. COLORGRADING3D: boolean;
  8061. SAMPLER3DGREENDEPTH: boolean;
  8062. SAMPLER3DBGRMAP: boolean;
  8063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8064. }
  8065. /**
  8066. * @hidden
  8067. */
  8068. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8069. IMAGEPROCESSING: boolean;
  8070. VIGNETTE: boolean;
  8071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8072. VIGNETTEBLENDMODEOPAQUE: boolean;
  8073. TONEMAPPING: boolean;
  8074. TONEMAPPING_ACES: boolean;
  8075. CONTRAST: boolean;
  8076. COLORCURVES: boolean;
  8077. COLORGRADING: boolean;
  8078. COLORGRADING3D: boolean;
  8079. SAMPLER3DGREENDEPTH: boolean;
  8080. SAMPLER3DBGRMAP: boolean;
  8081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8082. EXPOSURE: boolean;
  8083. constructor();
  8084. }
  8085. /**
  8086. * This groups together the common properties used for image processing either in direct forward pass
  8087. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8088. * or not.
  8089. */
  8090. export class ImageProcessingConfiguration {
  8091. /**
  8092. * Default tone mapping applied in BabylonJS.
  8093. */
  8094. static readonly TONEMAPPING_STANDARD: number;
  8095. /**
  8096. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8097. * to other engines rendering to increase portability.
  8098. */
  8099. static readonly TONEMAPPING_ACES: number;
  8100. /**
  8101. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8102. */
  8103. colorCurves: Nullable<ColorCurves>;
  8104. private _colorCurvesEnabled;
  8105. /**
  8106. * Gets wether the color curves effect is enabled.
  8107. */
  8108. /**
  8109. * Sets wether the color curves effect is enabled.
  8110. */
  8111. colorCurvesEnabled: boolean;
  8112. private _colorGradingTexture;
  8113. /**
  8114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8115. */
  8116. /**
  8117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8118. */
  8119. colorGradingTexture: Nullable<BaseTexture>;
  8120. private _colorGradingEnabled;
  8121. /**
  8122. * Gets wether the color grading effect is enabled.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is enabled.
  8126. */
  8127. colorGradingEnabled: boolean;
  8128. private _colorGradingWithGreenDepth;
  8129. /**
  8130. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8131. */
  8132. /**
  8133. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8134. */
  8135. colorGradingWithGreenDepth: boolean;
  8136. private _colorGradingBGR;
  8137. /**
  8138. * Gets wether the color grading texture contains BGR values.
  8139. */
  8140. /**
  8141. * Sets wether the color grading texture contains BGR values.
  8142. */
  8143. colorGradingBGR: boolean;
  8144. /** @hidden */
  8145. _exposure: number;
  8146. /**
  8147. * Gets the Exposure used in the effect.
  8148. */
  8149. /**
  8150. * Sets the Exposure used in the effect.
  8151. */
  8152. exposure: number;
  8153. private _toneMappingEnabled;
  8154. /**
  8155. * Gets wether the tone mapping effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the tone mapping effect is enabled.
  8159. */
  8160. toneMappingEnabled: boolean;
  8161. private _toneMappingType;
  8162. /**
  8163. * Gets the type of tone mapping effect.
  8164. */
  8165. /**
  8166. * Sets the type of tone mapping effect used in BabylonJS.
  8167. */
  8168. toneMappingType: number;
  8169. protected _contrast: number;
  8170. /**
  8171. * Gets the contrast used in the effect.
  8172. */
  8173. /**
  8174. * Sets the contrast used in the effect.
  8175. */
  8176. contrast: number;
  8177. /**
  8178. * Vignette stretch size.
  8179. */
  8180. vignetteStretch: number;
  8181. /**
  8182. * Vignette centre X Offset.
  8183. */
  8184. vignetteCentreX: number;
  8185. /**
  8186. * Vignette centre Y Offset.
  8187. */
  8188. vignetteCentreY: number;
  8189. /**
  8190. * Vignette weight or intensity of the vignette effect.
  8191. */
  8192. vignetteWeight: number;
  8193. /**
  8194. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8195. * if vignetteEnabled is set to true.
  8196. */
  8197. vignetteColor: Color4;
  8198. /**
  8199. * Camera field of view used by the Vignette effect.
  8200. */
  8201. vignetteCameraFov: number;
  8202. private _vignetteBlendMode;
  8203. /**
  8204. * Gets the vignette blend mode allowing different kind of effect.
  8205. */
  8206. /**
  8207. * Sets the vignette blend mode allowing different kind of effect.
  8208. */
  8209. vignetteBlendMode: number;
  8210. private _vignetteEnabled;
  8211. /**
  8212. * Gets wether the vignette effect is enabled.
  8213. */
  8214. /**
  8215. * Sets wether the vignette effect is enabled.
  8216. */
  8217. vignetteEnabled: boolean;
  8218. private _applyByPostProcess;
  8219. /**
  8220. * Gets wether the image processing is applied through a post process or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is applied through a post process or not.
  8224. */
  8225. applyByPostProcess: boolean;
  8226. private _isEnabled;
  8227. /**
  8228. * Gets wether the image processing is enabled or not.
  8229. */
  8230. /**
  8231. * Sets wether the image processing is enabled or not.
  8232. */
  8233. isEnabled: boolean;
  8234. /**
  8235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8236. */
  8237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8238. /**
  8239. * Method called each time the image processing information changes requires to recompile the effect.
  8240. */
  8241. protected _updateParameters(): void;
  8242. /**
  8243. * Gets the current class name.
  8244. * @return "ImageProcessingConfiguration"
  8245. */
  8246. getClassName(): string;
  8247. /**
  8248. * Prepare the list of uniforms associated with the Image Processing effects.
  8249. * @param uniforms The list of uniforms used in the effect
  8250. * @param defines the list of defines currently in use
  8251. */
  8252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8253. /**
  8254. * Prepare the list of samplers associated with the Image Processing effects.
  8255. * @param samplersList The list of uniforms used in the effect
  8256. * @param defines the list of defines currently in use
  8257. */
  8258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8259. /**
  8260. * Prepare the list of defines associated to the shader.
  8261. * @param defines the list of defines to complete
  8262. * @param forPostProcess Define if we are currently in post process mode or not
  8263. */
  8264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8265. /**
  8266. * Returns true if all the image processing information are ready.
  8267. * @returns True if ready, otherwise, false
  8268. */
  8269. isReady(): boolean;
  8270. /**
  8271. * Binds the image processing to the shader.
  8272. * @param effect The effect to bind to
  8273. * @param aspectRatio Define the current aspect ratio of the effect
  8274. */
  8275. bind(effect: Effect, aspectRatio?: number): void;
  8276. /**
  8277. * Clones the current image processing instance.
  8278. * @return The cloned image processing
  8279. */
  8280. clone(): ImageProcessingConfiguration;
  8281. /**
  8282. * Serializes the current image processing instance to a json representation.
  8283. * @return a JSON representation
  8284. */
  8285. serialize(): any;
  8286. /**
  8287. * Parses the image processing from a json representation.
  8288. * @param source the JSON source to parse
  8289. * @return The parsed image processing
  8290. */
  8291. static Parse(source: any): ImageProcessingConfiguration;
  8292. private static _VIGNETTEMODE_MULTIPLY;
  8293. private static _VIGNETTEMODE_OPAQUE;
  8294. /**
  8295. * Used to apply the vignette as a mix with the pixel color.
  8296. */
  8297. static readonly VIGNETTEMODE_MULTIPLY: number;
  8298. /**
  8299. * Used to apply the vignette as a replacement of the pixel color.
  8300. */
  8301. static readonly VIGNETTEMODE_OPAQUE: number;
  8302. }
  8303. }
  8304. declare module "babylonjs/Shaders/postprocess.vertex" {
  8305. /** @hidden */
  8306. export var postprocessVertexShader: {
  8307. name: string;
  8308. shader: string;
  8309. };
  8310. }
  8311. declare module "babylonjs/Maths/math.axis" {
  8312. import { Vector3 } from "babylonjs/Maths/math.vector";
  8313. /** Defines supported spaces */
  8314. export enum Space {
  8315. /** Local (object) space */
  8316. LOCAL = 0,
  8317. /** World space */
  8318. WORLD = 1,
  8319. /** Bone space */
  8320. BONE = 2
  8321. }
  8322. /** Defines the 3 main axes */
  8323. export class Axis {
  8324. /** X axis */
  8325. static X: Vector3;
  8326. /** Y axis */
  8327. static Y: Vector3;
  8328. /** Z axis */
  8329. static Z: Vector3;
  8330. }
  8331. }
  8332. declare module "babylonjs/Cameras/targetCamera" {
  8333. import { Nullable } from "babylonjs/types";
  8334. import { Camera } from "babylonjs/Cameras/camera";
  8335. import { Scene } from "babylonjs/scene";
  8336. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * 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)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module "babylonjs/Events/keyboardEvents" {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8561. import { Nullable } from "babylonjs/types";
  8562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8564. /**
  8565. * Manage the keyboard inputs to control the movement of a free camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: FreeCamera;
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8575. */
  8576. keysUp: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8579. */
  8580. keysDown: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8583. */
  8584. keysLeft: number[];
  8585. /**
  8586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8587. */
  8588. keysRight: number[];
  8589. private _keys;
  8590. private _onCanvasBlurObserver;
  8591. private _onKeyboardObserver;
  8592. private _engine;
  8593. private _scene;
  8594. /**
  8595. * Attach the input controls to a specific dom element to get the input from.
  8596. * @param element Defines the element the controls should be listened from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current controls from the specified dom element.
  8602. * @param element Defines the element to stop listening the inputs from
  8603. */
  8604. detachControl(element: Nullable<HTMLElement>): void;
  8605. /**
  8606. * Update the current camera state depending on the inputs that have been used this frame.
  8607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8608. */
  8609. checkInputs(): void;
  8610. /**
  8611. * Gets the class name of the current intput.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /** @hidden */
  8616. _onLostFocus(): void;
  8617. /**
  8618. * Get the friendly name associated with the input class.
  8619. * @returns the input friendly name
  8620. */
  8621. getSimpleName(): string;
  8622. }
  8623. }
  8624. declare module "babylonjs/Lights/shadowLight" {
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8629. import { Light } from "babylonjs/Lights/light";
  8630. /**
  8631. * Interface describing all the common properties and methods a shadow light needs to implement.
  8632. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8633. * as well as binding the different shadow properties to the effects.
  8634. */
  8635. export interface IShadowLight extends Light {
  8636. /**
  8637. * The light id in the scene (used in scene.findLighById for instance)
  8638. */
  8639. id: string;
  8640. /**
  8641. * The position the shdow will be casted from.
  8642. */
  8643. position: Vector3;
  8644. /**
  8645. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8646. */
  8647. direction: Vector3;
  8648. /**
  8649. * The transformed position. Position of the light in world space taking parenting in account.
  8650. */
  8651. transformedPosition: Vector3;
  8652. /**
  8653. * The transformed direction. Direction of the light in world space taking parenting in account.
  8654. */
  8655. transformedDirection: Vector3;
  8656. /**
  8657. * The friendly name of the light in the scene.
  8658. */
  8659. name: string;
  8660. /**
  8661. * Defines the shadow projection clipping minimum z value.
  8662. */
  8663. shadowMinZ: number;
  8664. /**
  8665. * Defines the shadow projection clipping maximum z value.
  8666. */
  8667. shadowMaxZ: number;
  8668. /**
  8669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8671. */
  8672. computeTransformedInformation(): boolean;
  8673. /**
  8674. * Gets the scene the light belongs to.
  8675. * @returns The scene
  8676. */
  8677. getScene(): Scene;
  8678. /**
  8679. * Callback defining a custom Projection Matrix Builder.
  8680. * This can be used to override the default projection matrix computation.
  8681. */
  8682. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. /**
  8692. * Gets the current depth scale used in ESM.
  8693. * @returns The scale
  8694. */
  8695. getDepthScale(): number;
  8696. /**
  8697. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8698. * @returns true if a cube texture needs to be use
  8699. */
  8700. needCube(): boolean;
  8701. /**
  8702. * Detects if the projection matrix requires to be recomputed this frame.
  8703. * @returns true if it requires to be recomputed otherwise, false.
  8704. */
  8705. needProjectionMatrixCompute(): boolean;
  8706. /**
  8707. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8708. */
  8709. forceProjectionMatrixCompute(): void;
  8710. /**
  8711. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8714. */
  8715. getShadowDirection(faceIndex?: number): Vector3;
  8716. /**
  8717. * Gets the minZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the min for
  8719. * @returns the depth min z
  8720. */
  8721. getDepthMinZ(activeCamera: Camera): number;
  8722. /**
  8723. * Gets the maxZ used for shadow according to both the scene and the light.
  8724. * @param activeCamera The camera we are returning the max for
  8725. * @returns the depth max z
  8726. */
  8727. getDepthMaxZ(activeCamera: Camera): number;
  8728. }
  8729. /**
  8730. * Base implementation IShadowLight
  8731. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8732. */
  8733. export abstract class ShadowLight extends Light implements IShadowLight {
  8734. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8735. protected _position: Vector3;
  8736. protected _setPosition(value: Vector3): void;
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. /**
  8742. * Sets the position the shadow will be casted from. Also use as the light position for both
  8743. * point and spot lights.
  8744. */
  8745. position: Vector3;
  8746. protected _direction: Vector3;
  8747. protected _setDirection(value: Vector3): void;
  8748. /**
  8749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. /**
  8753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8754. * Also use as the light direction on spot and directional lights.
  8755. */
  8756. direction: Vector3;
  8757. private _shadowMinZ;
  8758. /**
  8759. * Gets the shadow projection clipping minimum z value.
  8760. */
  8761. /**
  8762. * Sets the shadow projection clipping minimum z value.
  8763. */
  8764. shadowMinZ: number;
  8765. private _shadowMaxZ;
  8766. /**
  8767. * Sets the shadow projection clipping maximum z value.
  8768. */
  8769. /**
  8770. * Gets the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Callback defining a custom Projection Matrix Builder.
  8775. * This can be used to override the default projection matrix computation.
  8776. */
  8777. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8778. /**
  8779. * The transformed position. Position of the light in world space taking parenting in account.
  8780. */
  8781. transformedPosition: Vector3;
  8782. /**
  8783. * The transformed direction. Direction of the light in world space taking parenting in account.
  8784. */
  8785. transformedDirection: Vector3;
  8786. private _needProjectionMatrixCompute;
  8787. /**
  8788. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8789. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8790. */
  8791. computeTransformedInformation(): boolean;
  8792. /**
  8793. * Return the depth scale used for the shadow map.
  8794. * @returns the depth scale.
  8795. */
  8796. getDepthScale(): number;
  8797. /**
  8798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8801. */
  8802. getShadowDirection(faceIndex?: number): Vector3;
  8803. /**
  8804. * Returns the ShadowLight absolute position in the World.
  8805. * @returns the position vector in world space
  8806. */
  8807. getAbsolutePosition(): Vector3;
  8808. /**
  8809. * Sets the ShadowLight direction toward the passed target.
  8810. * @param target The point to target in local space
  8811. * @returns the updated ShadowLight direction
  8812. */
  8813. setDirectionToTarget(target: Vector3): Vector3;
  8814. /**
  8815. * Returns the light rotation in euler definition.
  8816. * @returns the x y z rotation in local space.
  8817. */
  8818. getRotation(): Vector3;
  8819. /**
  8820. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8821. * @returns true if a cube texture needs to be use
  8822. */
  8823. needCube(): boolean;
  8824. /**
  8825. * Detects if the projection matrix requires to be recomputed this frame.
  8826. * @returns true if it requires to be recomputed otherwise, false.
  8827. */
  8828. needProjectionMatrixCompute(): boolean;
  8829. /**
  8830. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8831. */
  8832. forceProjectionMatrixCompute(): void;
  8833. /** @hidden */
  8834. _initCache(): void;
  8835. /** @hidden */
  8836. _isSynchronized(): boolean;
  8837. /**
  8838. * Computes the world matrix of the node
  8839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8840. * @returns the world matrix
  8841. */
  8842. computeWorldMatrix(force?: boolean): Matrix;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. }
  8864. }
  8865. declare module "babylonjs/Materials/materialHelper" {
  8866. import { Nullable } from "babylonjs/types";
  8867. import { Scene } from "babylonjs/scene";
  8868. import { Engine } from "babylonjs/Engines/engine";
  8869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8870. import { Light } from "babylonjs/Lights/light";
  8871. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8872. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8874. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8875. /**
  8876. * "Static Class" containing the most commonly used helper while dealing with material for
  8877. * rendering purpose.
  8878. *
  8879. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8880. *
  8881. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8882. */
  8883. export class MaterialHelper {
  8884. /**
  8885. * Bind the current view position to an effect.
  8886. * @param effect The effect to be bound
  8887. * @param scene The scene the eyes position is used from
  8888. */
  8889. static BindEyePosition(effect: Effect, scene: Scene): void;
  8890. /**
  8891. * Helps preparing the defines values about the UVs in used in the effect.
  8892. * UVs are shared as much as we can accross channels in the shaders.
  8893. * @param texture The texture we are preparing the UVs for
  8894. * @param defines The defines to update
  8895. * @param key The channel key "diffuse", "specular"... used in the shader
  8896. */
  8897. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8898. /**
  8899. * Binds a texture matrix value to its corrsponding uniform
  8900. * @param texture The texture to bind the matrix for
  8901. * @param uniformBuffer The uniform buffer receivin the data
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8905. /**
  8906. * Gets the current status of the fog (should it be enabled?)
  8907. * @param mesh defines the mesh to evaluate for fog support
  8908. * @param scene defines the hosting scene
  8909. * @returns true if fog must be enabled
  8910. */
  8911. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8912. /**
  8913. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8914. * @param mesh defines the current mesh
  8915. * @param scene defines the current scene
  8916. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8917. * @param pointsCloud defines if point cloud rendering has to be turned on
  8918. * @param fogEnabled defines if fog has to be turned on
  8919. * @param alphaTest defines if alpha testing has to be turned on
  8920. * @param defines defines the current list of defines
  8921. */
  8922. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8923. /**
  8924. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8925. * @param scene defines the current scene
  8926. * @param engine defines the current engine
  8927. * @param defines specifies the list of active defines
  8928. * @param useInstances defines if instances have to be turned on
  8929. * @param useClipPlane defines if clip plane have to be turned on
  8930. */
  8931. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8932. /**
  8933. * Prepares the defines for bones
  8934. * @param mesh The mesh containing the geometry data we will draw
  8935. * @param defines The defines to update
  8936. */
  8937. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8938. /**
  8939. * Prepares the defines for morph targets
  8940. * @param mesh The mesh containing the geometry data we will draw
  8941. * @param defines The defines to update
  8942. */
  8943. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8944. /**
  8945. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8946. * @param mesh The mesh containing the geometry data we will draw
  8947. * @param defines The defines to update
  8948. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8949. * @param useBones Precise whether bones should be used or not (override mesh info)
  8950. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8951. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8952. * @returns false if defines are considered not dirty and have not been checked
  8953. */
  8954. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8955. /**
  8956. * Prepares the defines related to multiview
  8957. * @param scene The scene we are intending to draw
  8958. * @param defines The defines to update
  8959. */
  8960. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8961. /**
  8962. * Prepares the defines related to the light information passed in parameter
  8963. * @param scene The scene we are intending to draw
  8964. * @param mesh The mesh the effect is compiling for
  8965. * @param light The light the effect is compiling for
  8966. * @param lightIndex The index of the light
  8967. * @param defines The defines to update
  8968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8969. * @param state Defines the current state regarding what is needed (normals, etc...)
  8970. */
  8971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8972. needNormals: boolean;
  8973. needRebuild: boolean;
  8974. shadowEnabled: boolean;
  8975. specularEnabled: boolean;
  8976. lightmapMode: boolean;
  8977. }): void;
  8978. /**
  8979. * Prepares the defines related to the light information passed in parameter
  8980. * @param scene The scene we are intending to draw
  8981. * @param mesh The mesh the effect is compiling for
  8982. * @param defines The defines to update
  8983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8986. * @returns true if normals will be required for the rest of the effect
  8987. */
  8988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8991. * @param lightIndex defines the light index
  8992. * @param uniformsList The uniform list
  8993. * @param samplersList The sampler list
  8994. * @param projectedLightTexture defines if projected texture must be used
  8995. * @param uniformBuffersList defines an optional list of uniform buffers
  8996. */
  8997. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8998. /**
  8999. * Prepares the uniforms and samplers list to be used in the effect
  9000. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9001. * @param samplersList The sampler list
  9002. * @param defines The defines helping in the list generation
  9003. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9004. */
  9005. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9006. /**
  9007. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9008. * @param defines The defines to update while falling back
  9009. * @param fallbacks The authorized effect fallbacks
  9010. * @param maxSimultaneousLights The maximum number of lights allowed
  9011. * @param rank the current rank of the Effect
  9012. * @returns The newly affected rank
  9013. */
  9014. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9015. private static _TmpMorphInfluencers;
  9016. /**
  9017. * Prepares the list of attributes required for morph targets according to the effect defines.
  9018. * @param attribs The current list of supported attribs
  9019. * @param mesh The mesh to prepare the morph targets attributes for
  9020. * @param influencers The number of influencers
  9021. */
  9022. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Check and prepare the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current MaterialDefines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9044. /**
  9045. * Add the list of attributes required for instances to the attribs array.
  9046. * @param attribs The current list of supported attribs
  9047. */
  9048. static PushAttributesForInstances(attribs: string[]): void;
  9049. /**
  9050. * Binds the light shadow information to the effect for the given mesh.
  9051. * @param light The light containing the generator
  9052. * @param scene The scene the lights belongs to
  9053. * @param mesh The mesh we are binding the information to render
  9054. * @param lightIndex The light index in the effect used to render the mesh
  9055. * @param effect The effect we are binding the data to
  9056. */
  9057. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9058. /**
  9059. * Binds the light information to the effect.
  9060. * @param light The light containing the generator
  9061. * @param effect The effect we are binding the data to
  9062. * @param lightIndex The light index in the effect used to render
  9063. */
  9064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9065. /**
  9066. * Binds the lights information from the scene to the effect for the given mesh.
  9067. * @param light Light to bind
  9068. * @param lightIndex Light index
  9069. * @param scene The scene where the light belongs to
  9070. * @param mesh The mesh we are binding the information to render
  9071. * @param effect The effect we are binding the data to
  9072. * @param useSpecular Defines if specular is supported
  9073. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9075. */
  9076. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9077. /**
  9078. * Binds the lights information from the scene to the effect for the given mesh.
  9079. * @param scene The scene the lights belongs to
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. * @param defines The generated defines for the effect
  9083. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9084. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9085. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9086. */
  9087. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9088. private static _tempFogColor;
  9089. /**
  9090. * Binds the fog information from the scene to the effect for the given mesh.
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param effect The effect we are binding the data to
  9094. * @param linearSpace Defines if the fog effect is applied in linear space
  9095. */
  9096. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9097. /**
  9098. * Binds the bones information from the mesh to the effect.
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9103. /**
  9104. * Binds the morph targets information from the mesh to the effect.
  9105. * @param abstractMesh The mesh we are binding the information to render
  9106. * @param effect The effect we are binding the data to
  9107. */
  9108. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9109. /**
  9110. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9111. * @param defines The generated defines used in the effect
  9112. * @param effect The effect we are binding the data to
  9113. * @param scene The scene we are willing to render with logarithmic scale for
  9114. */
  9115. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Binds the clip plane information from the scene to the effect.
  9118. * @param scene The scene the clip plane information are extracted from
  9119. * @param effect The effect we are binding the data to
  9120. */
  9121. static BindClipPlane(effect: Effect, scene: Scene): void;
  9122. }
  9123. }
  9124. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9125. /** @hidden */
  9126. export var packingFunctions: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9132. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9133. /** @hidden */
  9134. export var shadowMapPixelShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9140. /** @hidden */
  9141. export var bonesDeclaration: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9147. /** @hidden */
  9148. export var morphTargetsVertexGlobalDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9161. /** @hidden */
  9162. export var instancesDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9168. /** @hidden */
  9169. export var helperFunctions: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9175. /** @hidden */
  9176. export var morphTargetsVertex: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9182. /** @hidden */
  9183. export var instancesVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9189. /** @hidden */
  9190. export var bonesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9196. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9204. /** @hidden */
  9205. export var shadowMapVertexShader: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9211. /** @hidden */
  9212. export var depthBoxBlurPixelShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Matrix } from "babylonjs/Maths/math.vector";
  9221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9223. import { Mesh } from "babylonjs/Meshes/mesh";
  9224. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9226. import { Effect } from "babylonjs/Materials/effect";
  9227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9228. import "babylonjs/Shaders/shadowMap.fragment";
  9229. import "babylonjs/Shaders/shadowMap.vertex";
  9230. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9231. import { Observable } from "babylonjs/Misc/observable";
  9232. /**
  9233. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9234. */
  9235. export interface ICustomShaderOptions {
  9236. /**
  9237. * Gets or sets the custom shader name to use
  9238. */
  9239. shaderName: string;
  9240. /**
  9241. * The list of attribute names used in the shader
  9242. */
  9243. attributes?: string[];
  9244. /**
  9245. * The list of unifrom names used in the shader
  9246. */
  9247. uniforms?: string[];
  9248. /**
  9249. * The list of sampler names used in the shader
  9250. */
  9251. samplers?: string[];
  9252. /**
  9253. * The list of defines used in the shader
  9254. */
  9255. defines?: string[];
  9256. }
  9257. /**
  9258. * Interface to implement to create a shadow generator compatible with BJS.
  9259. */
  9260. export interface IShadowGenerator {
  9261. /**
  9262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9263. * @returns The render target texture if present otherwise, null
  9264. */
  9265. getShadowMap(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9268. * @returns The render target texture if the shadow map is present otherwise, null
  9269. */
  9270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9271. /**
  9272. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9273. * @param subMesh The submesh we want to render in the shadow map
  9274. * @param useInstances Defines wether will draw in the map using instances
  9275. * @returns true if ready otherwise, false
  9276. */
  9277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9278. /**
  9279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9280. * @param defines Defines of the material we want to update
  9281. * @param lightIndex Index of the light in the enabled light list of the material
  9282. */
  9283. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9284. /**
  9285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9286. * defined in the generator but impacting the effect).
  9287. * It implies the unifroms available on the materials are the standard BJS ones.
  9288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9289. * @param effect The effect we are binfing the information for
  9290. */
  9291. bindShadowLight(lightIndex: string, effect: Effect): void;
  9292. /**
  9293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9294. * (eq to shadow prjection matrix * light transform matrix)
  9295. * @returns The transform matrix used to create the shadow map
  9296. */
  9297. getTransformMatrix(): Matrix;
  9298. /**
  9299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9300. * Cube and 2D textures for instance.
  9301. */
  9302. recreateShadowMap(): void;
  9303. /**
  9304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9305. * @param onCompiled Callback triggered at the and of the effects compilation
  9306. * @param options Sets of optional options forcing the compilation with different modes
  9307. */
  9308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9309. useInstances: boolean;
  9310. }>): void;
  9311. /**
  9312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. * @returns A promise that resolves when the compilation completes
  9315. */
  9316. forceCompilationAsync(options?: Partial<{
  9317. useInstances: boolean;
  9318. }>): Promise<void>;
  9319. /**
  9320. * Serializes the shadow generator setup to a json object.
  9321. * @returns The serialized JSON object
  9322. */
  9323. serialize(): any;
  9324. /**
  9325. * Disposes the Shadow map and related Textures and effects.
  9326. */
  9327. dispose(): void;
  9328. }
  9329. /**
  9330. * Default implementation IShadowGenerator.
  9331. * This is the main object responsible of generating shadows in the framework.
  9332. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9333. */
  9334. export class ShadowGenerator implements IShadowGenerator {
  9335. /**
  9336. * Shadow generator mode None: no filtering applied.
  9337. */
  9338. static readonly FILTER_NONE: number;
  9339. /**
  9340. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9346. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9347. */
  9348. static readonly FILTER_POISSONSAMPLING: number;
  9349. /**
  9350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9352. */
  9353. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9354. /**
  9355. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9356. * edge artifacts on steep falloff.
  9357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9358. */
  9359. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9360. /**
  9361. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9362. * edge artifacts on steep falloff.
  9363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9364. */
  9365. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9366. /**
  9367. * Shadow generator mode PCF: Percentage Closer Filtering
  9368. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9369. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9370. */
  9371. static readonly FILTER_PCF: number;
  9372. /**
  9373. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9374. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9375. * Contact Hardening
  9376. */
  9377. static readonly FILTER_PCSS: number;
  9378. /**
  9379. * Reserved for PCF and PCSS
  9380. * Highest Quality.
  9381. *
  9382. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9383. *
  9384. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9385. */
  9386. static readonly QUALITY_HIGH: number;
  9387. /**
  9388. * Reserved for PCF and PCSS
  9389. * Good tradeoff for quality/perf cross devices
  9390. *
  9391. * Execute PCF on a 3*3 kernel.
  9392. *
  9393. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9394. */
  9395. static readonly QUALITY_MEDIUM: number;
  9396. /**
  9397. * Reserved for PCF and PCSS
  9398. * The lowest quality but the fastest.
  9399. *
  9400. * Execute PCF on a 1*1 kernel.
  9401. *
  9402. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9403. */
  9404. static readonly QUALITY_LOW: number;
  9405. /** Gets or sets the custom shader name to use */
  9406. customShaderOptions: ICustomShaderOptions;
  9407. /**
  9408. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9409. */
  9410. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9411. /**
  9412. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9413. */
  9414. onAfterShadowMapRenderObservable: Observable<Effect>;
  9415. /**
  9416. * Observable triggered before a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9418. */
  9419. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. /**
  9421. * Observable triggered after a mesh is rendered in the shadow map.
  9422. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9423. */
  9424. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9425. private _bias;
  9426. /**
  9427. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9428. */
  9429. /**
  9430. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9431. */
  9432. bias: number;
  9433. private _normalBias;
  9434. /**
  9435. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9436. */
  9437. /**
  9438. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9439. */
  9440. normalBias: number;
  9441. private _blurBoxOffset;
  9442. /**
  9443. * Gets the blur box offset: offset applied during the blur pass.
  9444. * Only useful if useKernelBlur = false
  9445. */
  9446. /**
  9447. * Sets the blur box offset: offset applied during the blur pass.
  9448. * Only useful if useKernelBlur = false
  9449. */
  9450. blurBoxOffset: number;
  9451. private _blurScale;
  9452. /**
  9453. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9454. * 2 means half of the size.
  9455. */
  9456. /**
  9457. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9458. * 2 means half of the size.
  9459. */
  9460. blurScale: number;
  9461. private _blurKernel;
  9462. /**
  9463. * Gets the blur kernel: kernel size of the blur pass.
  9464. * Only useful if useKernelBlur = true
  9465. */
  9466. /**
  9467. * Sets the blur kernel: kernel size of the blur pass.
  9468. * Only useful if useKernelBlur = true
  9469. */
  9470. blurKernel: number;
  9471. private _useKernelBlur;
  9472. /**
  9473. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9475. */
  9476. /**
  9477. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9478. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9479. */
  9480. useKernelBlur: boolean;
  9481. private _depthScale;
  9482. /**
  9483. * Gets the depth scale used in ESM mode.
  9484. */
  9485. /**
  9486. * Sets the depth scale used in ESM mode.
  9487. * This can override the scale stored on the light.
  9488. */
  9489. depthScale: number;
  9490. private _filter;
  9491. /**
  9492. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9494. */
  9495. /**
  9496. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9497. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9498. */
  9499. filter: number;
  9500. /**
  9501. * Gets if the current filter is set to Poisson Sampling.
  9502. */
  9503. /**
  9504. * Sets the current filter to Poisson Sampling.
  9505. */
  9506. usePoissonSampling: boolean;
  9507. /**
  9508. * Gets if the current filter is set to ESM.
  9509. */
  9510. /**
  9511. * Sets the current filter is to ESM.
  9512. */
  9513. useExponentialShadowMap: boolean;
  9514. /**
  9515. * Gets if the current filter is set to filtered ESM.
  9516. */
  9517. /**
  9518. * Gets if the current filter is set to filtered ESM.
  9519. */
  9520. useBlurExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9523. * exponential to prevent steep falloff artifacts).
  9524. */
  9525. /**
  9526. * Sets the current filter to "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. useCloseExponentialShadowMap: boolean;
  9530. /**
  9531. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9532. * exponential to prevent steep falloff artifacts).
  9533. */
  9534. /**
  9535. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9536. * exponential to prevent steep falloff artifacts).
  9537. */
  9538. useBlurCloseExponentialShadowMap: boolean;
  9539. /**
  9540. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9541. */
  9542. /**
  9543. * Sets the current filter to "PCF" (percentage closer filtering).
  9544. */
  9545. usePercentageCloserFiltering: boolean;
  9546. private _filteringQuality;
  9547. /**
  9548. * Gets the PCF or PCSS Quality.
  9549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9550. */
  9551. /**
  9552. * Sets the PCF or PCSS Quality.
  9553. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9554. */
  9555. filteringQuality: number;
  9556. /**
  9557. * Gets if the current filter is set to "PCSS" (contact hardening).
  9558. */
  9559. /**
  9560. * Sets the current filter to "PCSS" (contact hardening).
  9561. */
  9562. useContactHardeningShadow: boolean;
  9563. private _contactHardeningLightSizeUVRatio;
  9564. /**
  9565. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9566. * Using a ratio helps keeping shape stability independently of the map size.
  9567. *
  9568. * It does not account for the light projection as it was having too much
  9569. * instability during the light setup or during light position changes.
  9570. *
  9571. * Only valid if useContactHardeningShadow is true.
  9572. */
  9573. /**
  9574. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9575. * Using a ratio helps keeping shape stability independently of the map size.
  9576. *
  9577. * It does not account for the light projection as it was having too much
  9578. * instability during the light setup or during light position changes.
  9579. *
  9580. * Only valid if useContactHardeningShadow is true.
  9581. */
  9582. contactHardeningLightSizeUVRatio: number;
  9583. private _darkness;
  9584. /** Gets or sets the actual darkness of a shadow */
  9585. darkness: number;
  9586. /**
  9587. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9588. * 0 means strongest and 1 would means no shadow.
  9589. * @returns the darkness.
  9590. */
  9591. getDarkness(): number;
  9592. /**
  9593. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9594. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9595. * @returns the shadow generator allowing fluent coding.
  9596. */
  9597. setDarkness(darkness: number): ShadowGenerator;
  9598. private _transparencyShadow;
  9599. /** Gets or sets the ability to have transparent shadow */
  9600. transparencyShadow: boolean;
  9601. /**
  9602. * Sets the ability to have transparent shadow (boolean).
  9603. * @param transparent True if transparent else False
  9604. * @returns the shadow generator allowing fluent coding
  9605. */
  9606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9607. private _shadowMap;
  9608. private _shadowMap2;
  9609. /**
  9610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9611. * @returns The render target texture if present otherwise, null
  9612. */
  9613. getShadowMap(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9616. * @returns The render target texture if the shadow map is present otherwise, null
  9617. */
  9618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9619. /**
  9620. * Gets the class name of that object
  9621. * @returns "ShadowGenerator"
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9626. * @param mesh Mesh to add
  9627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9628. * @returns the Shadow Generator itself
  9629. */
  9630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9631. /**
  9632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9633. * @param mesh Mesh to remove
  9634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Controls the extent to which the shadows fade out at the edge of the frustum
  9640. * Used only by directionals and spots
  9641. */
  9642. frustumEdgeFalloff: number;
  9643. private _light;
  9644. /**
  9645. * Returns the associated light object.
  9646. * @returns the light generating the shadow
  9647. */
  9648. getLight(): IShadowLight;
  9649. /**
  9650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9652. * It might on the other hand introduce peter panning.
  9653. */
  9654. forceBackFacesOnly: boolean;
  9655. private _scene;
  9656. private _lightDirection;
  9657. private _effect;
  9658. private _viewMatrix;
  9659. private _projectionMatrix;
  9660. private _transformMatrix;
  9661. private _cachedPosition;
  9662. private _cachedDirection;
  9663. private _cachedDefines;
  9664. private _currentRenderID;
  9665. private _boxBlurPostprocess;
  9666. private _kernelBlurXPostprocess;
  9667. private _kernelBlurYPostprocess;
  9668. private _blurPostProcesses;
  9669. private _mapSize;
  9670. private _currentFaceIndex;
  9671. private _currentFaceIndexCache;
  9672. private _textureType;
  9673. private _defaultTextureMatrix;
  9674. /** @hidden */
  9675. static _SceneComponentInitialization: (scene: Scene) => void;
  9676. /**
  9677. * Creates a ShadowGenerator object.
  9678. * A ShadowGenerator is the required tool to use the shadows.
  9679. * Each light casting shadows needs to use its own ShadowGenerator.
  9680. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9681. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9682. * @param light The light object generating the shadows.
  9683. * @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.
  9684. */
  9685. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9686. private _initializeGenerator;
  9687. private _initializeShadowMap;
  9688. private _initializeBlurRTTAndPostProcesses;
  9689. private _renderForShadowMap;
  9690. private _renderSubMeshForShadowMap;
  9691. private _applyFilterValues;
  9692. /**
  9693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9694. * @param onCompiled Callback triggered at the and of the effects compilation
  9695. * @param options Sets of optional options forcing the compilation with different modes
  9696. */
  9697. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9698. useInstances: boolean;
  9699. }>): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. * @returns A promise that resolves when the compilation completes
  9704. */
  9705. forceCompilationAsync(options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): Promise<void>;
  9708. /**
  9709. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9710. * @param subMesh The submesh we want to render in the shadow map
  9711. * @param useInstances Defines wether will draw in the map using instances
  9712. * @returns true if ready otherwise, false
  9713. */
  9714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9715. /**
  9716. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9717. * @param defines Defines of the material we want to update
  9718. * @param lightIndex Index of the light in the enabled light list of the material
  9719. */
  9720. prepareDefines(defines: any, lightIndex: number): void;
  9721. /**
  9722. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9723. * defined in the generator but impacting the effect).
  9724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9725. * @param effect The effect we are binfing the information for
  9726. */
  9727. bindShadowLight(lightIndex: string, effect: Effect): void;
  9728. /**
  9729. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9730. * (eq to shadow prjection matrix * light transform matrix)
  9731. * @returns The transform matrix used to create the shadow map
  9732. */
  9733. getTransformMatrix(): Matrix;
  9734. /**
  9735. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9736. * Cube and 2D textures for instance.
  9737. */
  9738. recreateShadowMap(): void;
  9739. private _disposeBlurPostProcesses;
  9740. private _disposeRTTandPostProcesses;
  9741. /**
  9742. * Disposes the ShadowGenerator.
  9743. * Returns nothing.
  9744. */
  9745. dispose(): void;
  9746. /**
  9747. * Serializes the shadow generator setup to a json object.
  9748. * @returns The serialized JSON object
  9749. */
  9750. serialize(): any;
  9751. /**
  9752. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9753. * @param parsedShadowGenerator The JSON object to parse
  9754. * @param scene The scene to create the shadow map for
  9755. * @returns The parsed shadow generator
  9756. */
  9757. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9758. }
  9759. }
  9760. declare module "babylonjs/Lights/light" {
  9761. import { Nullable } from "babylonjs/types";
  9762. import { Scene } from "babylonjs/scene";
  9763. import { Vector3 } from "babylonjs/Maths/math.vector";
  9764. import { Color3 } from "babylonjs/Maths/math.color";
  9765. import { Node } from "babylonjs/node";
  9766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9767. import { Effect } from "babylonjs/Materials/effect";
  9768. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9769. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9770. /**
  9771. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9772. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9773. * 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.
  9774. */
  9775. export abstract class Light extends Node {
  9776. /**
  9777. * Falloff Default: light is falling off following the material specification:
  9778. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9779. */
  9780. static readonly FALLOFF_DEFAULT: number;
  9781. /**
  9782. * Falloff Physical: light is falling off following the inverse squared distance law.
  9783. */
  9784. static readonly FALLOFF_PHYSICAL: number;
  9785. /**
  9786. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9787. * to enhance interoperability with other engines.
  9788. */
  9789. static readonly FALLOFF_GLTF: number;
  9790. /**
  9791. * Falloff Standard: light is falling off like in the standard material
  9792. * to enhance interoperability with other materials.
  9793. */
  9794. static readonly FALLOFF_STANDARD: number;
  9795. /**
  9796. * If every light affecting the material is in this lightmapMode,
  9797. * material.lightmapTexture adds or multiplies
  9798. * (depends on material.useLightmapAsShadowmap)
  9799. * after every other light calculations.
  9800. */
  9801. static readonly LIGHTMAP_DEFAULT: number;
  9802. /**
  9803. * material.lightmapTexture as only diffuse lighting from this light
  9804. * adds only specular lighting from this light
  9805. * adds dynamic shadows
  9806. */
  9807. static readonly LIGHTMAP_SPECULAR: number;
  9808. /**
  9809. * material.lightmapTexture as only lighting
  9810. * no light calculation from this light
  9811. * only adds dynamic shadows from this light
  9812. */
  9813. static readonly LIGHTMAP_SHADOWSONLY: number;
  9814. /**
  9815. * Each light type uses the default quantity according to its type:
  9816. * point/spot lights use luminous intensity
  9817. * directional lights use illuminance
  9818. */
  9819. static readonly INTENSITYMODE_AUTOMATIC: number;
  9820. /**
  9821. * lumen (lm)
  9822. */
  9823. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9824. /**
  9825. * candela (lm/sr)
  9826. */
  9827. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9828. /**
  9829. * lux (lm/m^2)
  9830. */
  9831. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9832. /**
  9833. * nit (cd/m^2)
  9834. */
  9835. static readonly INTENSITYMODE_LUMINANCE: number;
  9836. /**
  9837. * Light type const id of the point light.
  9838. */
  9839. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9840. /**
  9841. * Light type const id of the directional light.
  9842. */
  9843. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9844. /**
  9845. * Light type const id of the spot light.
  9846. */
  9847. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9848. /**
  9849. * Light type const id of the hemispheric light.
  9850. */
  9851. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9852. /**
  9853. * Diffuse gives the basic color to an object.
  9854. */
  9855. diffuse: Color3;
  9856. /**
  9857. * Specular produces a highlight color on an object.
  9858. * Note: This is note affecting PBR materials.
  9859. */
  9860. specular: Color3;
  9861. /**
  9862. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9863. * falling off base on range or angle.
  9864. * This can be set to any values in Light.FALLOFF_x.
  9865. *
  9866. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9867. * other types of materials.
  9868. */
  9869. falloffType: number;
  9870. /**
  9871. * Strength of the light.
  9872. * Note: By default it is define in the framework own unit.
  9873. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9874. */
  9875. intensity: number;
  9876. private _range;
  9877. protected _inverseSquaredRange: number;
  9878. /**
  9879. * Defines how far from the source the light is impacting in scene units.
  9880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9881. */
  9882. /**
  9883. * Defines how far from the source the light is impacting in scene units.
  9884. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9885. */
  9886. range: number;
  9887. /**
  9888. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9889. * of light.
  9890. */
  9891. private _photometricScale;
  9892. private _intensityMode;
  9893. /**
  9894. * Gets the photometric scale used to interpret the intensity.
  9895. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9896. */
  9897. /**
  9898. * Sets the photometric scale used to interpret the intensity.
  9899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9900. */
  9901. intensityMode: number;
  9902. private _radius;
  9903. /**
  9904. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9905. */
  9906. /**
  9907. * sets the light radius used by PBR Materials to simulate soft area lights.
  9908. */
  9909. radius: number;
  9910. private _renderPriority;
  9911. /**
  9912. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9913. * exceeding the number allowed of the materials.
  9914. */
  9915. renderPriority: number;
  9916. private _shadowEnabled;
  9917. /**
  9918. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9919. * the current shadow generator.
  9920. */
  9921. /**
  9922. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9923. * the current shadow generator.
  9924. */
  9925. shadowEnabled: boolean;
  9926. private _includedOnlyMeshes;
  9927. /**
  9928. * Gets the only meshes impacted by this light.
  9929. */
  9930. /**
  9931. * Sets the only meshes impacted by this light.
  9932. */
  9933. includedOnlyMeshes: AbstractMesh[];
  9934. private _excludedMeshes;
  9935. /**
  9936. * Gets the meshes not impacted by this light.
  9937. */
  9938. /**
  9939. * Sets the meshes not impacted by this light.
  9940. */
  9941. excludedMeshes: AbstractMesh[];
  9942. private _excludeWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are not impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are not impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. excludeWithLayerMask: number;
  9952. private _includeOnlyWithLayerMask;
  9953. /**
  9954. * Gets the layer id use to find what meshes are impacted by the light.
  9955. * Inactive if 0
  9956. */
  9957. /**
  9958. * Sets the layer id use to find what meshes are impacted by the light.
  9959. * Inactive if 0
  9960. */
  9961. includeOnlyWithLayerMask: number;
  9962. private _lightmapMode;
  9963. /**
  9964. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9965. */
  9966. /**
  9967. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9968. */
  9969. lightmapMode: number;
  9970. /**
  9971. * Shadow generator associted to the light.
  9972. * @hidden Internal use only.
  9973. */
  9974. _shadowGenerator: Nullable<IShadowGenerator>;
  9975. /**
  9976. * @hidden Internal use only.
  9977. */
  9978. _excludedMeshesIds: string[];
  9979. /**
  9980. * @hidden Internal use only.
  9981. */
  9982. _includedOnlyMeshesIds: string[];
  9983. /**
  9984. * The current light unifom buffer.
  9985. * @hidden Internal use only.
  9986. */
  9987. _uniformBuffer: UniformBuffer;
  9988. /**
  9989. * Creates a Light object in the scene.
  9990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9991. * @param name The firendly name of the light
  9992. * @param scene The scene the light belongs too
  9993. */
  9994. constructor(name: string, scene: Scene);
  9995. protected abstract _buildUniformLayout(): void;
  9996. /**
  9997. * Sets the passed Effect "effect" with the Light information.
  9998. * @param effect The effect to update
  9999. * @param lightIndex The index of the light in the effect to update
  10000. * @returns The light
  10001. */
  10002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10007. * @returns The light
  10008. */
  10009. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10010. /**
  10011. * Returns the string "Light".
  10012. * @returns the class name
  10013. */
  10014. getClassName(): string;
  10015. /** @hidden */
  10016. readonly _isLight: boolean;
  10017. /**
  10018. * Converts the light information to a readable string for debug purpose.
  10019. * @param fullDetails Supports for multiple levels of logging within scene loading
  10020. * @returns the human readable light info
  10021. */
  10022. toString(fullDetails?: boolean): string;
  10023. /** @hidden */
  10024. protected _syncParentEnabledState(): void;
  10025. /**
  10026. * Set the enabled state of this node.
  10027. * @param value - the new enabled state
  10028. */
  10029. setEnabled(value: boolean): void;
  10030. /**
  10031. * Returns the Light associated shadow generator if any.
  10032. * @return the associated shadow generator.
  10033. */
  10034. getShadowGenerator(): Nullable<IShadowGenerator>;
  10035. /**
  10036. * Returns a Vector3, the absolute light position in the World.
  10037. * @returns the world space position of the light
  10038. */
  10039. getAbsolutePosition(): Vector3;
  10040. /**
  10041. * Specifies if the light will affect the passed mesh.
  10042. * @param mesh The mesh to test against the light
  10043. * @return true the mesh is affected otherwise, false.
  10044. */
  10045. canAffectMesh(mesh: AbstractMesh): boolean;
  10046. /**
  10047. * Sort function to order lights for rendering.
  10048. * @param a First Light object to compare to second.
  10049. * @param b Second Light object to compare first.
  10050. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10051. */
  10052. static CompareLightsPriority(a: Light, b: Light): number;
  10053. /**
  10054. * Releases resources associated with this node.
  10055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10057. */
  10058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10059. /**
  10060. * Returns the light type ID (integer).
  10061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10062. */
  10063. getTypeID(): number;
  10064. /**
  10065. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10066. * @returns the scaled intensity in intensity mode unit
  10067. */
  10068. getScaledIntensity(): number;
  10069. /**
  10070. * Returns a new Light object, named "name", from the current one.
  10071. * @param name The name of the cloned light
  10072. * @returns the new created light
  10073. */
  10074. clone(name: string): Nullable<Light>;
  10075. /**
  10076. * Serializes the current light into a Serialization object.
  10077. * @returns the serialized object.
  10078. */
  10079. serialize(): any;
  10080. /**
  10081. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10082. * This new light is named "name" and added to the passed scene.
  10083. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10084. * @param name The friendly name of the light
  10085. * @param scene The scene the new light will belong to
  10086. * @returns the constructor function
  10087. */
  10088. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10089. /**
  10090. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10091. * @param parsedLight The JSON representation of the light
  10092. * @param scene The scene to create the parsed light in
  10093. * @returns the created light after parsing
  10094. */
  10095. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10096. private _hookArrayForExcluded;
  10097. private _hookArrayForIncludedOnly;
  10098. private _resyncMeshes;
  10099. /**
  10100. * Forces the meshes to update their light related information in their rendering used effects
  10101. * @hidden Internal Use Only
  10102. */
  10103. _markMeshesAsLightDirty(): void;
  10104. /**
  10105. * Recomputes the cached photometric scale if needed.
  10106. */
  10107. private _computePhotometricScale;
  10108. /**
  10109. * Returns the Photometric Scale according to the light type and intensity mode.
  10110. */
  10111. private _getPhotometricScale;
  10112. /**
  10113. * Reorder the light in the scene according to their defined priority.
  10114. * @hidden Internal Use Only
  10115. */
  10116. _reorderLightsInScene(): void;
  10117. /**
  10118. * Prepares the list of defines specific to the light type.
  10119. * @param defines the list of defines
  10120. * @param lightIndex defines the index of the light for the effect
  10121. */
  10122. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/action" {
  10126. import { Observable } from "babylonjs/Misc/observable";
  10127. import { Condition } from "babylonjs/Actions/condition";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. import { ActionManager } from "babylonjs/Actions/actionManager";
  10130. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10131. /**
  10132. * Interface used to define Action
  10133. */
  10134. export interface IAction {
  10135. /**
  10136. * Trigger for the action
  10137. */
  10138. trigger: number;
  10139. /** Options of the trigger */
  10140. triggerOptions: any;
  10141. /**
  10142. * Gets the trigger parameters
  10143. * @returns the trigger parameters
  10144. */
  10145. getTriggerParameter(): any;
  10146. /**
  10147. * Internal only - executes current action event
  10148. * @hidden
  10149. */
  10150. _executeCurrent(evt?: ActionEvent): void;
  10151. /**
  10152. * Serialize placeholder for child classes
  10153. * @param parent of child
  10154. * @returns the serialized object
  10155. */
  10156. serialize(parent: any): any;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */
  10161. _prepare(): void;
  10162. /**
  10163. * Internal only - manager for action
  10164. * @hidden
  10165. */
  10166. _actionManager: AbstractActionManager;
  10167. /**
  10168. * Adds action to chain of actions, may be a DoNothingAction
  10169. * @param action defines the next action to execute
  10170. * @returns The action passed in
  10171. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10172. */
  10173. then(action: IAction): IAction;
  10174. }
  10175. /**
  10176. * The action to be carried out following a trigger
  10177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10178. */
  10179. export class Action implements IAction {
  10180. /** the trigger, with or without parameters, for the action */
  10181. triggerOptions: any;
  10182. /**
  10183. * Trigger for the action
  10184. */
  10185. trigger: number;
  10186. /**
  10187. * Internal only - manager for action
  10188. * @hidden
  10189. */
  10190. _actionManager: ActionManager;
  10191. private _nextActiveAction;
  10192. private _child;
  10193. private _condition?;
  10194. private _triggerParameter;
  10195. /**
  10196. * An event triggered prior to action being executed.
  10197. */
  10198. onBeforeExecuteObservable: Observable<Action>;
  10199. /**
  10200. * Creates a new Action
  10201. * @param triggerOptions the trigger, with or without parameters, for the action
  10202. * @param condition an optional determinant of action
  10203. */
  10204. constructor(
  10205. /** the trigger, with or without parameters, for the action */
  10206. triggerOptions: any, condition?: Condition);
  10207. /**
  10208. * Internal only
  10209. * @hidden
  10210. */
  10211. _prepare(): void;
  10212. /**
  10213. * Gets the trigger parameters
  10214. * @returns the trigger parameters
  10215. */
  10216. getTriggerParameter(): any;
  10217. /**
  10218. * Internal only - executes current action event
  10219. * @hidden
  10220. */
  10221. _executeCurrent(evt?: ActionEvent): void;
  10222. /**
  10223. * Execute placeholder for child classes
  10224. * @param evt optional action event
  10225. */
  10226. execute(evt?: ActionEvent): void;
  10227. /**
  10228. * Skips to next active action
  10229. */
  10230. skipToNextActiveAction(): void;
  10231. /**
  10232. * Adds action to chain of actions, may be a DoNothingAction
  10233. * @param action defines the next action to execute
  10234. * @returns The action passed in
  10235. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10236. */
  10237. then(action: Action): Action;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */
  10242. _getProperty(propertyPath: string): string;
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _getEffectiveTarget(target: any, propertyPath: string): any;
  10248. /**
  10249. * Serialize placeholder for child classes
  10250. * @param parent of child
  10251. * @returns the serialized object
  10252. */
  10253. serialize(parent: any): any;
  10254. /**
  10255. * Internal only called by serialize
  10256. * @hidden
  10257. */
  10258. protected _serialize(serializedAction: any, parent?: any): any;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. static _SerializeValueAsString: (value: any) => string;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10269. name: string;
  10270. targetType: string;
  10271. value: string;
  10272. };
  10273. }
  10274. }
  10275. declare module "babylonjs/Actions/condition" {
  10276. import { ActionManager } from "babylonjs/Actions/actionManager";
  10277. /**
  10278. * A Condition applied to an Action
  10279. */
  10280. export class Condition {
  10281. /**
  10282. * Internal only - manager for action
  10283. * @hidden
  10284. */
  10285. _actionManager: ActionManager;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. _evaluationId: number;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. _currentResult: boolean;
  10296. /**
  10297. * Creates a new Condition
  10298. * @param actionManager the manager of the action the condition is applied to
  10299. */
  10300. constructor(actionManager: ActionManager);
  10301. /**
  10302. * Check if the current condition is valid
  10303. * @returns a boolean
  10304. */
  10305. isValid(): boolean;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. _getProperty(propertyPath: string): string;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getEffectiveTarget(target: any, propertyPath: string): any;
  10316. /**
  10317. * Serialize placeholder for child classes
  10318. * @returns the serialized object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. protected _serialize(serializedCondition: any): any;
  10326. }
  10327. /**
  10328. * Defines specific conditional operators as extensions of Condition
  10329. */
  10330. export class ValueCondition extends Condition {
  10331. /** path to specify the property of the target the conditional operator uses */
  10332. propertyPath: string;
  10333. /** the value compared by the conditional operator against the current value of the property */
  10334. value: any;
  10335. /** the conditional operator, default ValueCondition.IsEqual */
  10336. operator: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. private static _IsEqual;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. private static _IsDifferent;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */
  10351. private static _IsGreater;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. private static _IsLesser;
  10357. /**
  10358. * returns the number for IsEqual
  10359. */
  10360. static readonly IsEqual: number;
  10361. /**
  10362. * Returns the number for IsDifferent
  10363. */
  10364. static readonly IsDifferent: number;
  10365. /**
  10366. * Returns the number for IsGreater
  10367. */
  10368. static readonly IsGreater: number;
  10369. /**
  10370. * Returns the number for IsLesser
  10371. */
  10372. static readonly IsLesser: number;
  10373. /**
  10374. * Internal only The action manager for the condition
  10375. * @hidden
  10376. */
  10377. _actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. private _target;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private _effectiveTarget;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private _property;
  10393. /**
  10394. * Creates a new ValueCondition
  10395. * @param actionManager manager for the action the condition applies to
  10396. * @param target for the action
  10397. * @param propertyPath path to specify the property of the target the conditional operator uses
  10398. * @param value the value compared by the conditional operator against the current value of the property
  10399. * @param operator the conditional operator, default ValueCondition.IsEqual
  10400. */
  10401. constructor(actionManager: ActionManager, target: any,
  10402. /** path to specify the property of the target the conditional operator uses */
  10403. propertyPath: string,
  10404. /** the value compared by the conditional operator against the current value of the property */
  10405. value: any,
  10406. /** the conditional operator, default ValueCondition.IsEqual */
  10407. operator?: number);
  10408. /**
  10409. * Compares the given value with the property value for the specified conditional operator
  10410. * @returns the result of the comparison
  10411. */
  10412. isValid(): boolean;
  10413. /**
  10414. * Serialize the ValueCondition into a JSON compatible object
  10415. * @returns serialization object
  10416. */
  10417. serialize(): any;
  10418. /**
  10419. * Gets the name of the conditional operator for the ValueCondition
  10420. * @param operator the conditional operator
  10421. * @returns the name
  10422. */
  10423. static GetOperatorName(operator: number): string;
  10424. }
  10425. /**
  10426. * Defines a predicate condition as an extension of Condition
  10427. */
  10428. export class PredicateCondition extends Condition {
  10429. /** defines the predicate function used to validate the condition */
  10430. predicate: () => boolean;
  10431. /**
  10432. * Internal only - manager for action
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Creates a new PredicateCondition
  10438. * @param actionManager manager for the action the condition applies to
  10439. * @param predicate defines the predicate function used to validate the condition
  10440. */
  10441. constructor(actionManager: ActionManager,
  10442. /** defines the predicate function used to validate the condition */
  10443. predicate: () => boolean);
  10444. /**
  10445. * @returns the validity of the predicate condition
  10446. */
  10447. isValid(): boolean;
  10448. }
  10449. /**
  10450. * Defines a state condition as an extension of Condition
  10451. */
  10452. export class StateCondition extends Condition {
  10453. /** Value to compare with target state */
  10454. value: string;
  10455. /**
  10456. * Internal only - manager for action
  10457. * @hidden
  10458. */
  10459. _actionManager: ActionManager;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _target;
  10465. /**
  10466. * Creates a new StateCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target of the condition
  10469. * @param value to compare with target state
  10470. */
  10471. constructor(actionManager: ActionManager, target: any,
  10472. /** Value to compare with target state */
  10473. value: string);
  10474. /**
  10475. * Gets a boolean indicating if the current condition is met
  10476. * @returns the validity of the state
  10477. */
  10478. isValid(): boolean;
  10479. /**
  10480. * Serialize the StateCondition into a JSON compatible object
  10481. * @returns serialization object
  10482. */
  10483. serialize(): any;
  10484. }
  10485. }
  10486. declare module "babylonjs/Actions/directActions" {
  10487. import { Action } from "babylonjs/Actions/action";
  10488. import { Condition } from "babylonjs/Actions/condition";
  10489. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10490. /**
  10491. * This defines an action responsible to toggle a boolean once triggered.
  10492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10493. */
  10494. export class SwitchBooleanAction extends Action {
  10495. /**
  10496. * The path to the boolean property in the target object
  10497. */
  10498. propertyPath: string;
  10499. private _target;
  10500. private _effectiveTarget;
  10501. private _property;
  10502. /**
  10503. * Instantiate the action
  10504. * @param triggerOptions defines the trigger options
  10505. * @param target defines the object containing the boolean
  10506. * @param propertyPath defines the path to the boolean property in the target object
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action toggle the boolean value.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to set a the state field of the target
  10525. * to a desired value once triggered.
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10527. */
  10528. export class SetStateAction extends Action {
  10529. /**
  10530. * The value to store in the state field.
  10531. */
  10532. value: string;
  10533. private _target;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the state property
  10538. * @param value defines the value to store in the state field
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10542. /**
  10543. * Execute the action and store the value on the target state property.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to set a property of the target
  10555. * to a desired value once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class SetValueAction extends Action {
  10559. /**
  10560. * The path of the property to set in the target.
  10561. */
  10562. propertyPath: string;
  10563. /**
  10564. * The value to set in the property
  10565. */
  10566. value: any;
  10567. private _target;
  10568. private _effectiveTarget;
  10569. private _property;
  10570. /**
  10571. * Instantiate the action
  10572. * @param triggerOptions defines the trigger options
  10573. * @param target defines the object containing the property
  10574. * @param propertyPath defines the path of the property to set in the target
  10575. * @param value defines the value to set in the property
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action and set the targetted property to the desired value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to increment the target value
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class IncrementValueAction extends Action {
  10598. /**
  10599. * The path of the property to increment in the target.
  10600. */
  10601. propertyPath: string;
  10602. /**
  10603. * The value we should increment the property by.
  10604. */
  10605. value: any;
  10606. private _target;
  10607. private _effectiveTarget;
  10608. private _property;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the object containing the property
  10613. * @param propertyPath defines the path of the property to increment in the target
  10614. * @param value defines the value value we should increment the property by
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10618. /** @hidden */
  10619. _prepare(): void;
  10620. /**
  10621. * Execute the action and increment the target of the value amount.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to start an animation once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class PlayAnimationAction extends Action {
  10636. /**
  10637. * Where the animation should start (animation frame)
  10638. */
  10639. from: number;
  10640. /**
  10641. * Where the animation should stop (animation frame)
  10642. */
  10643. to: number;
  10644. /**
  10645. * Define if the animation should loop or stop after the first play.
  10646. */
  10647. loop?: boolean;
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param from defines from where the animation should start (animation frame)
  10654. * @param end defines where the animation should stop (animation frame)
  10655. * @param loop defines if the animation should loop or stop after the first play
  10656. * @param condition defines the trigger related conditions
  10657. */
  10658. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10659. /** @hidden */
  10660. _prepare(): void;
  10661. /**
  10662. * Execute the action and play the animation.
  10663. */
  10664. execute(): void;
  10665. /**
  10666. * Serializes the actions and its related information.
  10667. * @param parent defines the object to serialize in
  10668. * @returns the serialized object
  10669. */
  10670. serialize(parent: any): any;
  10671. }
  10672. /**
  10673. * This defines an action responsible to stop an animation once triggered.
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10675. */
  10676. export class StopAnimationAction extends Action {
  10677. private _target;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the target animation or animation name
  10682. * @param condition defines the trigger related conditions
  10683. */
  10684. constructor(triggerOptions: any, target: any, condition?: Condition);
  10685. /** @hidden */
  10686. _prepare(): void;
  10687. /**
  10688. * Execute the action and stop the animation.
  10689. */
  10690. execute(): void;
  10691. /**
  10692. * Serializes the actions and its related information.
  10693. * @param parent defines the object to serialize in
  10694. * @returns the serialized object
  10695. */
  10696. serialize(parent: any): any;
  10697. }
  10698. /**
  10699. * This defines an action responsible that does nothing once triggered.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class DoNothingAction extends Action {
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions?: any, condition?: Condition);
  10709. /**
  10710. * Execute the action and do nothing.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to trigger several actions once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class CombineAction extends Action {
  10725. /**
  10726. * The list of aggregated animations to run.
  10727. */
  10728. children: Action[];
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param children defines the list of aggregated animations to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10736. /** @hidden */
  10737. _prepare(): void;
  10738. /**
  10739. * Execute the action and executes all the aggregated actions.
  10740. */
  10741. execute(evt: ActionEvent): void;
  10742. /**
  10743. * Serializes the actions and its related information.
  10744. * @param parent defines the object to serialize in
  10745. * @returns the serialized object
  10746. */
  10747. serialize(parent: any): any;
  10748. }
  10749. /**
  10750. * This defines an action responsible to run code (external event) once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class ExecuteCodeAction extends Action {
  10754. /**
  10755. * The callback function to run.
  10756. */
  10757. func: (evt: ActionEvent) => void;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param func defines the callback function to run
  10762. * @param condition defines the trigger related conditions
  10763. */
  10764. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10765. /**
  10766. * Execute the action and run the attached code.
  10767. */
  10768. execute(evt: ActionEvent): void;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set the parent property of the target once triggered.
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class SetParentAction extends Action {
  10775. private _parent;
  10776. private _target;
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param target defines the target containing the parent property
  10781. * @param parent defines from where the animation should start (animation frame)
  10782. * @param condition defines the trigger related conditions
  10783. */
  10784. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10785. /** @hidden */
  10786. _prepare(): void;
  10787. /**
  10788. * Execute the action and set the parent property.
  10789. */
  10790. execute(): void;
  10791. /**
  10792. * Serializes the actions and its related information.
  10793. * @param parent defines the object to serialize in
  10794. * @returns the serialized object
  10795. */
  10796. serialize(parent: any): any;
  10797. }
  10798. }
  10799. declare module "babylonjs/Actions/actionManager" {
  10800. import { Nullable } from "babylonjs/types";
  10801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10802. import { Scene } from "babylonjs/scene";
  10803. import { IAction } from "babylonjs/Actions/action";
  10804. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10805. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10806. /**
  10807. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10808. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ActionManager extends AbstractActionManager {
  10812. /**
  10813. * Nothing
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly NothingTrigger: number;
  10817. /**
  10818. * On pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnPickTrigger: number;
  10822. /**
  10823. * On left pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnLeftPickTrigger: number;
  10827. /**
  10828. * On right pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnRightPickTrigger: number;
  10832. /**
  10833. * On center pick
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnCenterPickTrigger: number;
  10837. /**
  10838. * On pick down
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnPickDownTrigger: number;
  10842. /**
  10843. * On double pick
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnDoublePickTrigger: number;
  10847. /**
  10848. * On pick up
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPickUpTrigger: number;
  10852. /**
  10853. * On pick out.
  10854. * This trigger will only be raised if you also declared a OnPickDown
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnPickOutTrigger: number;
  10858. /**
  10859. * On long press
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnLongPressTrigger: number;
  10863. /**
  10864. * On pointer over
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOverTrigger: number;
  10868. /**
  10869. * On pointer out
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnPointerOutTrigger: number;
  10873. /**
  10874. * On every frame
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnEveryFrameTrigger: number;
  10878. /**
  10879. * On intersection enter
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionEnterTrigger: number;
  10883. /**
  10884. * On intersection exit
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnIntersectionExitTrigger: number;
  10888. /**
  10889. * On key down
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyDownTrigger: number;
  10893. /**
  10894. * On key up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnKeyUpTrigger: number;
  10898. private _scene;
  10899. /**
  10900. * Creates a new action manager
  10901. * @param scene defines the hosting scene
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Releases all associated resources
  10906. */
  10907. dispose(): void;
  10908. /**
  10909. * Gets hosting scene
  10910. * @returns the hosting scene
  10911. */
  10912. getScene(): Scene;
  10913. /**
  10914. * Does this action manager handles actions of any of the given triggers
  10915. * @param triggers defines the triggers to be tested
  10916. * @return a boolean indicating whether one (or more) of the triggers is handled
  10917. */
  10918. hasSpecificTriggers(triggers: number[]): boolean;
  10919. /**
  10920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10921. * speed.
  10922. * @param triggerA defines the trigger to be tested
  10923. * @param triggerB defines the trigger to be tested
  10924. * @return a boolean indicating whether one (or more) of the triggers is handled
  10925. */
  10926. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10927. /**
  10928. * Does this action manager handles actions of a given trigger
  10929. * @param trigger defines the trigger to be tested
  10930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10931. * @return whether the trigger is handled
  10932. */
  10933. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10934. /**
  10935. * Does this action manager has pointer triggers
  10936. */
  10937. readonly hasPointerTriggers: boolean;
  10938. /**
  10939. * Does this action manager has pick triggers
  10940. */
  10941. readonly hasPickTriggers: boolean;
  10942. /**
  10943. * Registers an action to this action manager
  10944. * @param action defines the action to be registered
  10945. * @return the action amended (prepared) after registration
  10946. */
  10947. registerAction(action: IAction): Nullable<IAction>;
  10948. /**
  10949. * Unregisters an action to this action manager
  10950. * @param action defines the action to be unregistered
  10951. * @return a boolean indicating whether the action has been unregistered
  10952. */
  10953. unregisterAction(action: IAction): Boolean;
  10954. /**
  10955. * Process a specific trigger
  10956. * @param trigger defines the trigger to process
  10957. * @param evt defines the event details to be processed
  10958. */
  10959. processTrigger(trigger: number, evt?: IActionEvent): void;
  10960. /** @hidden */
  10961. _getEffectiveTarget(target: any, propertyPath: string): any;
  10962. /** @hidden */
  10963. _getProperty(propertyPath: string): string;
  10964. /**
  10965. * Serialize this manager to a JSON object
  10966. * @param name defines the property name to store this manager
  10967. * @returns a JSON representation of this manager
  10968. */
  10969. serialize(name: string): any;
  10970. /**
  10971. * Creates a new ActionManager from a JSON data
  10972. * @param parsedActions defines the JSON data to read from
  10973. * @param object defines the hosting mesh
  10974. * @param scene defines the hosting scene
  10975. */
  10976. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10977. /**
  10978. * Get a trigger name by index
  10979. * @param trigger defines the trigger index
  10980. * @returns a trigger name
  10981. */
  10982. static GetTriggerName(trigger: number): string;
  10983. }
  10984. }
  10985. declare module "babylonjs/Culling/ray" {
  10986. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10989. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10990. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10991. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10992. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10993. import { Plane } from "babylonjs/Maths/math.plane";
  10994. /**
  10995. * Class representing a ray with position and direction
  10996. */
  10997. export class Ray {
  10998. /** origin point */
  10999. origin: Vector3;
  11000. /** direction */
  11001. direction: Vector3;
  11002. /** length of the ray */
  11003. length: number;
  11004. private static readonly TmpVector3;
  11005. private _tmpRay;
  11006. /**
  11007. * Creates a new ray
  11008. * @param origin origin point
  11009. * @param direction direction
  11010. * @param length length of the ray
  11011. */
  11012. constructor(
  11013. /** origin point */
  11014. origin: Vector3,
  11015. /** direction */
  11016. direction: Vector3,
  11017. /** length of the ray */
  11018. length?: number);
  11019. /**
  11020. * Checks if the ray intersects a box
  11021. * @param minimum bound of the box
  11022. * @param maximum bound of the box
  11023. * @param intersectionTreshold extra extend to be added to the box in all direction
  11024. * @returns if the box was hit
  11025. */
  11026. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11027. /**
  11028. * Checks if the ray intersects a box
  11029. * @param box the bounding box to check
  11030. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * If the ray hits a sphere
  11036. * @param sphere the bounding sphere to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11038. * @returns true if it hits the sphere
  11039. */
  11040. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a triange
  11043. * @param vertex0 triangle vertex
  11044. * @param vertex1 triangle vertex
  11045. * @param vertex2 triangle vertex
  11046. * @returns intersection information if hit
  11047. */
  11048. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11049. /**
  11050. * Checks if ray intersects a plane
  11051. * @param plane the plane to check
  11052. * @returns the distance away it was hit
  11053. */
  11054. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11055. /**
  11056. * Calculate the intercept of a ray on a given axis
  11057. * @param axis to check 'x' | 'y' | 'z'
  11058. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11059. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11060. */
  11061. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11062. /**
  11063. * Checks if ray intersects a mesh
  11064. * @param mesh the mesh to check
  11065. * @param fastCheck if only the bounding box should checked
  11066. * @returns picking info of the intersecton
  11067. */
  11068. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param meshes the meshes to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @param results array to store result in
  11074. * @returns Array of picking infos
  11075. */
  11076. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11077. private _comparePickingInfo;
  11078. private static smallnum;
  11079. private static rayl;
  11080. /**
  11081. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11082. * @param sega the first point of the segment to test the intersection against
  11083. * @param segb the second point of the segment to test the intersection against
  11084. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11085. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11086. */
  11087. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11088. /**
  11089. * Update the ray from viewport position
  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 this ray updated
  11098. */
  11099. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Creates a ray with origin and direction of 0,0,0
  11102. * @returns the new ray
  11103. */
  11104. static Zero(): Ray;
  11105. /**
  11106. * Creates a new ray from screen space and viewport
  11107. * @param x position
  11108. * @param y y position
  11109. * @param viewportWidth viewport width
  11110. * @param viewportHeight viewport height
  11111. * @param world world matrix
  11112. * @param view view matrix
  11113. * @param projection projection matrix
  11114. * @returns new ray
  11115. */
  11116. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11117. /**
  11118. * 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
  11119. * transformed to the given world matrix.
  11120. * @param origin The origin point
  11121. * @param end The end point
  11122. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11123. * @returns the new ray
  11124. */
  11125. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11126. /**
  11127. * Transforms a ray by a matrix
  11128. * @param ray ray to transform
  11129. * @param matrix matrix to apply
  11130. * @returns the resulting new ray
  11131. */
  11132. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @param result ray to store result in
  11138. */
  11139. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11140. /**
  11141. * Unproject a ray from screen space to object space
  11142. * @param sourceX defines the screen space x coordinate to use
  11143. * @param sourceY defines the screen space y coordinate to use
  11144. * @param viewportWidth defines the current width of the viewport
  11145. * @param viewportHeight defines the current height of the viewport
  11146. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11147. * @param view defines the view matrix to use
  11148. * @param projection defines the projection matrix to use
  11149. */
  11150. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11151. }
  11152. /**
  11153. * Type used to define predicate used to select faces when a mesh intersection is detected
  11154. */
  11155. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11156. module "babylonjs/scene" {
  11157. interface Scene {
  11158. /** @hidden */
  11159. _tempPickingRay: Nullable<Ray>;
  11160. /** @hidden */
  11161. _cachedRayForTransform: Ray;
  11162. /** @hidden */
  11163. _pickWithRayInverseMatrix: Matrix;
  11164. /** @hidden */
  11165. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11166. /** @hidden */
  11167. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11168. }
  11169. }
  11170. }
  11171. declare module "babylonjs/sceneComponent" {
  11172. import { Scene } from "babylonjs/scene";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11175. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11176. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11177. import { Nullable } from "babylonjs/types";
  11178. import { Camera } from "babylonjs/Cameras/camera";
  11179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11180. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11181. import { AbstractScene } from "babylonjs/abstractScene";
  11182. /**
  11183. * Groups all the scene component constants in one place to ease maintenance.
  11184. * @hidden
  11185. */
  11186. export class SceneComponentConstants {
  11187. static readonly NAME_EFFECTLAYER: string;
  11188. static readonly NAME_LAYER: string;
  11189. static readonly NAME_LENSFLARESYSTEM: string;
  11190. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11191. static readonly NAME_PARTICLESYSTEM: string;
  11192. static readonly NAME_GAMEPAD: string;
  11193. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11194. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11195. static readonly NAME_DEPTHRENDERER: string;
  11196. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11197. static readonly NAME_SPRITE: string;
  11198. static readonly NAME_OUTLINERENDERER: string;
  11199. static readonly NAME_PROCEDURALTEXTURE: string;
  11200. static readonly NAME_SHADOWGENERATOR: string;
  11201. static readonly NAME_OCTREE: string;
  11202. static readonly NAME_PHYSICSENGINE: string;
  11203. static readonly NAME_AUDIO: string;
  11204. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11205. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11206. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11207. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11208. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11209. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11210. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11211. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11212. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11213. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11214. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11215. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11217. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11218. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11219. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11220. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11221. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11222. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11223. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11224. static readonly STEP_AFTERRENDER_AUDIO: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11228. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11229. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11230. static readonly STEP_POINTERMOVE_SPRITE: number;
  11231. static readonly STEP_POINTERDOWN_SPRITE: number;
  11232. static readonly STEP_POINTERUP_SPRITE: number;
  11233. }
  11234. /**
  11235. * This represents a scene component.
  11236. *
  11237. * This is used to decouple the dependency the scene is having on the different workloads like
  11238. * layers, post processes...
  11239. */
  11240. export interface ISceneComponent {
  11241. /**
  11242. * The name of the component. Each component must have a unique name.
  11243. */
  11244. name: string;
  11245. /**
  11246. * The scene the component belongs to.
  11247. */
  11248. scene: Scene;
  11249. /**
  11250. * Register the component to one instance of a scene.
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. }
  11263. /**
  11264. * This represents a SERIALIZABLE scene component.
  11265. *
  11266. * This extends Scene Component to add Serialization methods on top.
  11267. */
  11268. export interface ISceneSerializableComponent extends ISceneComponent {
  11269. /**
  11270. * Adds all the elements from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. * @param dispose if the removed element should be disposed (default: false)
  11278. */
  11279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11280. /**
  11281. * Serializes the component data to the specified json object
  11282. * @param serializationObject The object to serialize to
  11283. */
  11284. serialize(serializationObject: any): void;
  11285. }
  11286. /**
  11287. * Strong typing of a Mesh related stage step action
  11288. */
  11289. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11290. /**
  11291. * Strong typing of a Evaluate Sub Mesh related stage step action
  11292. */
  11293. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11294. /**
  11295. * Strong typing of a Active Mesh related stage step action
  11296. */
  11297. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11298. /**
  11299. * Strong typing of a Camera related stage step action
  11300. */
  11301. export type CameraStageAction = (camera: Camera) => void;
  11302. /**
  11303. * Strong typing of a Camera Frame buffer related stage step action
  11304. */
  11305. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11306. /**
  11307. * Strong typing of a Render Target related stage step action
  11308. */
  11309. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11310. /**
  11311. * Strong typing of a RenderingGroup related stage step action
  11312. */
  11313. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11314. /**
  11315. * Strong typing of a Mesh Render related stage step action
  11316. */
  11317. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11318. /**
  11319. * Strong typing of a simple stage step action
  11320. */
  11321. export type SimpleStageAction = () => void;
  11322. /**
  11323. * Strong typing of a render target action.
  11324. */
  11325. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11326. /**
  11327. * Strong typing of a pointer move action.
  11328. */
  11329. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11330. /**
  11331. * Strong typing of a pointer up/down action.
  11332. */
  11333. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11334. /**
  11335. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11336. * @hidden
  11337. */
  11338. export class Stage<T extends Function> extends Array<{
  11339. index: number;
  11340. component: ISceneComponent;
  11341. action: T;
  11342. }> {
  11343. /**
  11344. * Hide ctor from the rest of the world.
  11345. * @param items The items to add.
  11346. */
  11347. private constructor();
  11348. /**
  11349. * Creates a new Stage.
  11350. * @returns A new instance of a Stage
  11351. */
  11352. static Create<T extends Function>(): Stage<T>;
  11353. /**
  11354. * Registers a step in an ordered way in the targeted stage.
  11355. * @param index Defines the position to register the step in
  11356. * @param component Defines the component attached to the step
  11357. * @param action Defines the action to launch during the step
  11358. */
  11359. registerStep(index: number, component: ISceneComponent, action: T): void;
  11360. /**
  11361. * Clears all the steps from the stage.
  11362. */
  11363. clear(): void;
  11364. }
  11365. }
  11366. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { Sprite } from "babylonjs/Sprites/sprite";
  11371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11372. import { Ray } from "babylonjs/Culling/ray";
  11373. import { Camera } from "babylonjs/Cameras/camera";
  11374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11375. import { ISceneComponent } from "babylonjs/sceneComponent";
  11376. module "babylonjs/scene" {
  11377. interface Scene {
  11378. /** @hidden */
  11379. _pointerOverSprite: Nullable<Sprite>;
  11380. /** @hidden */
  11381. _pickedDownSprite: Nullable<Sprite>;
  11382. /** @hidden */
  11383. _tempSpritePickingRay: Nullable<Ray>;
  11384. /**
  11385. * All of the sprite managers added to this scene
  11386. * @see http://doc.babylonjs.com/babylon101/sprites
  11387. */
  11388. spriteManagers: Array<ISpriteManager>;
  11389. /**
  11390. * An event triggered when sprites rendering is about to start
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11394. /**
  11395. * An event triggered when sprites rendering is done
  11396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11397. */
  11398. onAfterSpritesRenderingObservable: Observable<Scene>;
  11399. /** @hidden */
  11400. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /** Launch a ray to try to pick a sprite in the scene
  11402. * @param x position on screen
  11403. * @param y position on screen
  11404. * @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
  11405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11406. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11407. * @returns a PickingInfo
  11408. */
  11409. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11410. /** Use the given ray to pick a sprite in the scene
  11411. * @param ray The ray (in world space) to use to pick meshes
  11412. * @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
  11413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo
  11416. */
  11417. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11418. /** @hidden */
  11419. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11420. /** Launch a ray to try to pick sprites in the scene
  11421. * @param x position on screen
  11422. * @param y position on screen
  11423. * @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
  11424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11425. * @returns a PickingInfo array
  11426. */
  11427. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11428. /** Use the given ray to pick sprites in the scene
  11429. * @param ray The ray (in world space) to use to pick meshes
  11430. * @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
  11431. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /**
  11436. * Force the sprite under the pointer
  11437. * @param sprite defines the sprite to use
  11438. */
  11439. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11440. /**
  11441. * Gets the sprite under the pointer
  11442. * @returns a Sprite or null if no sprite is under the pointer
  11443. */
  11444. getPointerOverSprite(): Nullable<Sprite>;
  11445. }
  11446. }
  11447. /**
  11448. * Defines the sprite scene component responsible to manage sprites
  11449. * in a given scene.
  11450. */
  11451. export class SpriteSceneComponent implements ISceneComponent {
  11452. /**
  11453. * The component name helpfull to identify the component in the list of scene components.
  11454. */
  11455. readonly name: string;
  11456. /**
  11457. * The scene the component belongs to.
  11458. */
  11459. scene: Scene;
  11460. /** @hidden */
  11461. private _spritePredicate;
  11462. /**
  11463. * Creates a new instance of the component for the given scene
  11464. * @param scene Defines the scene to register the component in
  11465. */
  11466. constructor(scene: Scene);
  11467. /**
  11468. * Registers the component in a given scene
  11469. */
  11470. register(): void;
  11471. /**
  11472. * Rebuilds the elements related to this component in case of
  11473. * context lost for instance.
  11474. */
  11475. rebuild(): void;
  11476. /**
  11477. * Disposes the component and the associated ressources.
  11478. */
  11479. dispose(): void;
  11480. private _pickSpriteButKeepRay;
  11481. private _pointerMove;
  11482. private _pointerDown;
  11483. private _pointerUp;
  11484. }
  11485. }
  11486. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11487. /** @hidden */
  11488. export var fogFragmentDeclaration: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11494. /** @hidden */
  11495. export var fogFragment: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/sprites.fragment" {
  11501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11502. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11503. /** @hidden */
  11504. export var spritesPixelShader: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11510. /** @hidden */
  11511. export var fogVertexDeclaration: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/sprites.vertex" {
  11517. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11518. /** @hidden */
  11519. export var spritesVertexShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module "babylonjs/Sprites/spriteManager" {
  11525. import { IDisposable, Scene } from "babylonjs/scene";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Observable } from "babylonjs/Misc/observable";
  11528. import { Sprite } from "babylonjs/Sprites/sprite";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { Camera } from "babylonjs/Cameras/camera";
  11531. import { Texture } from "babylonjs/Materials/Textures/texture";
  11532. import "babylonjs/Shaders/sprites.fragment";
  11533. import "babylonjs/Shaders/sprites.vertex";
  11534. import { Ray } from "babylonjs/Culling/ray";
  11535. /**
  11536. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11537. */
  11538. export interface ISpriteManager extends IDisposable {
  11539. /**
  11540. * Restricts the camera to viewing objects with the same layerMask.
  11541. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11542. */
  11543. layerMask: number;
  11544. /**
  11545. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11546. */
  11547. isPickable: boolean;
  11548. /**
  11549. * Specifies the rendering group id for this mesh (0 by default)
  11550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11551. */
  11552. renderingGroupId: number;
  11553. /**
  11554. * Defines the list of sprites managed by the manager.
  11555. */
  11556. sprites: Array<Sprite>;
  11557. /**
  11558. * Tests the intersection of a sprite with a specific ray.
  11559. * @param ray The ray we are sending to test the collision
  11560. * @param camera The camera space we are sending rays in
  11561. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11562. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11563. * @returns picking info or null.
  11564. */
  11565. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11566. /**
  11567. * Intersects the sprites with a ray
  11568. * @param ray defines the ray to intersect with
  11569. * @param camera defines the current active camera
  11570. * @param predicate defines a predicate used to select candidate sprites
  11571. * @returns null if no hit or a PickingInfo array
  11572. */
  11573. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11574. /**
  11575. * Renders the list of sprites on screen.
  11576. */
  11577. render(): void;
  11578. }
  11579. /**
  11580. * Class used to manage multiple sprites on the same spritesheet
  11581. * @see http://doc.babylonjs.com/babylon101/sprites
  11582. */
  11583. export class SpriteManager implements ISpriteManager {
  11584. /** defines the manager's name */
  11585. name: string;
  11586. /** Gets the list of sprites */
  11587. sprites: Sprite[];
  11588. /** Gets or sets the rendering group id (0 by default) */
  11589. renderingGroupId: number;
  11590. /** Gets or sets camera layer mask */
  11591. layerMask: number;
  11592. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11593. fogEnabled: boolean;
  11594. /** Gets or sets a boolean indicating if the sprites are pickable */
  11595. isPickable: boolean;
  11596. /** Defines the default width of a cell in the spritesheet */
  11597. cellWidth: number;
  11598. /** Defines the default height of a cell in the spritesheet */
  11599. cellHeight: number;
  11600. /** Associative array from JSON sprite data file */
  11601. private _cellData;
  11602. /** Array of sprite names from JSON sprite data file */
  11603. private _spriteMap;
  11604. /** True when packed cell data from JSON file is ready*/
  11605. private _packedAndReady;
  11606. /**
  11607. * An event triggered when the manager is disposed.
  11608. */
  11609. onDisposeObservable: Observable<SpriteManager>;
  11610. private _onDisposeObserver;
  11611. /**
  11612. * Callback called when the manager is disposed
  11613. */
  11614. onDispose: () => void;
  11615. private _capacity;
  11616. private _fromPacked;
  11617. private _spriteTexture;
  11618. private _epsilon;
  11619. private _scene;
  11620. private _vertexData;
  11621. private _buffer;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _effectBase;
  11625. private _effectFog;
  11626. /**
  11627. * Gets or sets the spritesheet texture
  11628. */
  11629. texture: Texture;
  11630. /**
  11631. * Creates a new sprite manager
  11632. * @param name defines the manager's name
  11633. * @param imgUrl defines the sprite sheet url
  11634. * @param capacity defines the maximum allowed number of sprites
  11635. * @param cellSize defines the size of a sprite cell
  11636. * @param scene defines the hosting scene
  11637. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11638. * @param samplingMode defines the smapling mode to use with spritesheet
  11639. * @param fromPacked set to false; do not alter
  11640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11641. */
  11642. constructor(
  11643. /** defines the manager's name */
  11644. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11645. private _makePacked;
  11646. private _appendSpriteVertex;
  11647. /**
  11648. * Intersects the sprites with a ray
  11649. * @param ray defines the ray to intersect with
  11650. * @param camera defines the current active camera
  11651. * @param predicate defines a predicate used to select candidate sprites
  11652. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11653. * @returns null if no hit or a PickingInfo
  11654. */
  11655. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11656. /**
  11657. * Intersects the sprites with a ray
  11658. * @param ray defines the ray to intersect with
  11659. * @param camera defines the current active camera
  11660. * @param predicate defines a predicate used to select candidate sprites
  11661. * @returns null if no hit or a PickingInfo array
  11662. */
  11663. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11664. /**
  11665. * Render all child sprites
  11666. */
  11667. render(): void;
  11668. /**
  11669. * Release associated resources
  11670. */
  11671. dispose(): void;
  11672. }
  11673. }
  11674. declare module "babylonjs/Sprites/sprite" {
  11675. import { Vector3 } from "babylonjs/Maths/math.vector";
  11676. import { Nullable } from "babylonjs/types";
  11677. import { ActionManager } from "babylonjs/Actions/actionManager";
  11678. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11679. import { Color4 } from "babylonjs/Maths/math.color";
  11680. /**
  11681. * Class used to represent a sprite
  11682. * @see http://doc.babylonjs.com/babylon101/sprites
  11683. */
  11684. export class Sprite {
  11685. /** defines the name */
  11686. name: string;
  11687. /** Gets or sets the current world position */
  11688. position: Vector3;
  11689. /** Gets or sets the main color */
  11690. color: Color4;
  11691. /** Gets or sets the width */
  11692. width: number;
  11693. /** Gets or sets the height */
  11694. height: number;
  11695. /** Gets or sets rotation angle */
  11696. angle: number;
  11697. /** Gets or sets the cell index in the sprite sheet */
  11698. cellIndex: number;
  11699. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11700. cellRef: string;
  11701. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11702. invertU: number;
  11703. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11704. invertV: number;
  11705. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11706. disposeWhenFinishedAnimating: boolean;
  11707. /** Gets the list of attached animations */
  11708. animations: Animation[];
  11709. /** Gets or sets a boolean indicating if the sprite can be picked */
  11710. isPickable: boolean;
  11711. /**
  11712. * Gets or sets the associated action manager
  11713. */
  11714. actionManager: Nullable<ActionManager>;
  11715. private _animationStarted;
  11716. private _loopAnimation;
  11717. private _fromIndex;
  11718. private _toIndex;
  11719. private _delay;
  11720. private _direction;
  11721. private _manager;
  11722. private _time;
  11723. private _onAnimationEnd;
  11724. /**
  11725. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11726. */
  11727. isVisible: boolean;
  11728. /**
  11729. * Gets or sets the sprite size
  11730. */
  11731. size: number;
  11732. /**
  11733. * Creates a new Sprite
  11734. * @param name defines the name
  11735. * @param manager defines the manager
  11736. */
  11737. constructor(
  11738. /** defines the name */
  11739. name: string, manager: ISpriteManager);
  11740. /**
  11741. * Starts an animation
  11742. * @param from defines the initial key
  11743. * @param to defines the end key
  11744. * @param loop defines if the animation must loop
  11745. * @param delay defines the start delay (in ms)
  11746. * @param onAnimationEnd defines a callback to call when animation ends
  11747. */
  11748. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11749. /** Stops current animation (if any) */
  11750. stopAnimation(): void;
  11751. /** @hidden */
  11752. _animate(deltaTime: number): void;
  11753. /** Release associated resources */
  11754. dispose(): void;
  11755. }
  11756. }
  11757. declare module "babylonjs/Collisions/pickingInfo" {
  11758. import { Nullable } from "babylonjs/types";
  11759. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11761. import { Sprite } from "babylonjs/Sprites/sprite";
  11762. import { Ray } from "babylonjs/Culling/ray";
  11763. /**
  11764. * Information about the result of picking within a scene
  11765. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11766. */
  11767. export class PickingInfo {
  11768. /** @hidden */
  11769. _pickingUnavailable: boolean;
  11770. /**
  11771. * If the pick collided with an object
  11772. */
  11773. hit: boolean;
  11774. /**
  11775. * Distance away where the pick collided
  11776. */
  11777. distance: number;
  11778. /**
  11779. * The location of pick collision
  11780. */
  11781. pickedPoint: Nullable<Vector3>;
  11782. /**
  11783. * The mesh corresponding the the pick collision
  11784. */
  11785. pickedMesh: Nullable<AbstractMesh>;
  11786. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11787. bu: number;
  11788. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11789. bv: number;
  11790. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11791. faceId: number;
  11792. /** Id of the the submesh that was picked */
  11793. subMeshId: number;
  11794. /** If a sprite was picked, this will be the sprite the pick collided with */
  11795. pickedSprite: Nullable<Sprite>;
  11796. /**
  11797. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11798. */
  11799. originMesh: Nullable<AbstractMesh>;
  11800. /**
  11801. * The ray that was used to perform the picking.
  11802. */
  11803. ray: Nullable<Ray>;
  11804. /**
  11805. * Gets the normal correspodning to the face the pick collided with
  11806. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11807. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11808. * @returns The normal correspodning to the face the pick collided with
  11809. */
  11810. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11811. /**
  11812. * Gets the texture coordinates of where the pick occured
  11813. * @returns the vector containing the coordnates of the texture
  11814. */
  11815. getTextureCoordinates(): Nullable<Vector2>;
  11816. }
  11817. }
  11818. declare module "babylonjs/Events/pointerEvents" {
  11819. import { Nullable } from "babylonjs/types";
  11820. import { Vector2 } from "babylonjs/Maths/math.vector";
  11821. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11822. import { Ray } from "babylonjs/Culling/ray";
  11823. /**
  11824. * Gather the list of pointer event types as constants.
  11825. */
  11826. export class PointerEventTypes {
  11827. /**
  11828. * 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.
  11829. */
  11830. static readonly POINTERDOWN: number;
  11831. /**
  11832. * The pointerup event is fired when a pointer is no longer active.
  11833. */
  11834. static readonly POINTERUP: number;
  11835. /**
  11836. * The pointermove event is fired when a pointer changes coordinates.
  11837. */
  11838. static readonly POINTERMOVE: number;
  11839. /**
  11840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11841. */
  11842. static readonly POINTERWHEEL: number;
  11843. /**
  11844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11845. */
  11846. static readonly POINTERPICK: number;
  11847. /**
  11848. * The pointertap event is fired when a the object has been touched and released without drag.
  11849. */
  11850. static readonly POINTERTAP: number;
  11851. /**
  11852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11853. */
  11854. static readonly POINTERDOUBLETAP: number;
  11855. }
  11856. /**
  11857. * Base class of pointer info types.
  11858. */
  11859. export class PointerInfoBase {
  11860. /**
  11861. * Defines the type of event (PointerEventTypes)
  11862. */
  11863. type: number;
  11864. /**
  11865. * Defines the related dom event
  11866. */
  11867. event: PointerEvent | MouseWheelEvent;
  11868. /**
  11869. * Instantiates the base class of pointers info.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. */
  11873. constructor(
  11874. /**
  11875. * Defines the type of event (PointerEventTypes)
  11876. */
  11877. type: number,
  11878. /**
  11879. * Defines the related dom event
  11880. */
  11881. event: PointerEvent | MouseWheelEvent);
  11882. }
  11883. /**
  11884. * This class is used to store pointer related info for the onPrePointerObservable event.
  11885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11886. */
  11887. export class PointerInfoPre extends PointerInfoBase {
  11888. /**
  11889. * Ray from a pointer if availible (eg. 6dof controller)
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Defines the local position of the pointer on the canvas.
  11894. */
  11895. localPosition: Vector2;
  11896. /**
  11897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11898. */
  11899. skipOnPointerObservable: boolean;
  11900. /**
  11901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11902. * @param type Defines the type of event (PointerEventTypes)
  11903. * @param event Defines the related dom event
  11904. * @param localX Defines the local x coordinates of the pointer when the event occured
  11905. * @param localY Defines the local y coordinates of the pointer when the event occured
  11906. */
  11907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11908. }
  11909. /**
  11910. * This type contains all the data related to a pointer event in Babylon.js.
  11911. * 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.
  11912. */
  11913. export class PointerInfo extends PointerInfoBase {
  11914. /**
  11915. * Defines the picking info associated to the info (if any)\
  11916. */
  11917. pickInfo: Nullable<PickingInfo>;
  11918. /**
  11919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11920. * @param type Defines the type of event (PointerEventTypes)
  11921. * @param event Defines the related dom event
  11922. * @param pickInfo Defines the picking info associated to the info (if any)\
  11923. */
  11924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11925. /**
  11926. * Defines the picking info associated to the info (if any)\
  11927. */
  11928. pickInfo: Nullable<PickingInfo>);
  11929. }
  11930. /**
  11931. * Data relating to a touch event on the screen.
  11932. */
  11933. export interface PointerTouch {
  11934. /**
  11935. * X coordinate of touch.
  11936. */
  11937. x: number;
  11938. /**
  11939. * Y coordinate of touch.
  11940. */
  11941. y: number;
  11942. /**
  11943. * Id of touch. Unique for each finger.
  11944. */
  11945. pointerId: number;
  11946. /**
  11947. * Event type passed from DOM.
  11948. */
  11949. type: any;
  11950. }
  11951. }
  11952. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11953. import { Observable } from "babylonjs/Misc/observable";
  11954. import { Nullable } from "babylonjs/types";
  11955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11957. /**
  11958. * Manage the mouse inputs to control the movement of a free camera.
  11959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11960. */
  11961. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11962. /**
  11963. * Define if touch is enabled in the mouse input
  11964. */
  11965. touchEnabled: boolean;
  11966. /**
  11967. * Defines the camera the input is attached to.
  11968. */
  11969. camera: FreeCamera;
  11970. /**
  11971. * Defines the buttons associated with the input to handle camera move.
  11972. */
  11973. buttons: number[];
  11974. /**
  11975. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11976. */
  11977. angularSensibility: number;
  11978. private _pointerInput;
  11979. private _onMouseMove;
  11980. private _observer;
  11981. private previousPosition;
  11982. /**
  11983. * Observable for when a pointer move event occurs containing the move offset
  11984. */
  11985. onPointerMovedObservable: Observable<{
  11986. offsetX: number;
  11987. offsetY: number;
  11988. }>;
  11989. /**
  11990. * @hidden
  11991. * If the camera should be rotated automatically based on pointer movement
  11992. */
  11993. _allowCameraRotation: boolean;
  11994. /**
  11995. * Manage the mouse inputs to control the movement of a free camera.
  11996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11997. * @param touchEnabled Defines if touch is enabled or not
  11998. */
  11999. constructor(
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled?: boolean);
  12004. /**
  12005. * Attach the input controls to a specific dom element to get the input from.
  12006. * @param element Defines the element the controls should be listened from
  12007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12008. */
  12009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12010. /**
  12011. * Called on JS contextmenu event.
  12012. * Override this method to provide functionality.
  12013. */
  12014. protected onContextMenu(evt: PointerEvent): void;
  12015. /**
  12016. * Detach the current controls from the specified dom element.
  12017. * @param element Defines the element to stop listening the inputs from
  12018. */
  12019. detachControl(element: Nullable<HTMLElement>): void;
  12020. /**
  12021. * Gets the class name of the current intput.
  12022. * @returns the class name
  12023. */
  12024. getClassName(): string;
  12025. /**
  12026. * Get the friendly name associated with the input class.
  12027. * @returns the input friendly name
  12028. */
  12029. getSimpleName(): string;
  12030. }
  12031. }
  12032. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12033. import { Nullable } from "babylonjs/types";
  12034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12035. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12036. /**
  12037. * Manage the touch inputs to control the movement of a free camera.
  12038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12039. */
  12040. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12041. /**
  12042. * Defines the camera the input is attached to.
  12043. */
  12044. camera: FreeCamera;
  12045. /**
  12046. * Defines the touch sensibility for rotation.
  12047. * The higher the faster.
  12048. */
  12049. touchAngularSensibility: number;
  12050. /**
  12051. * Defines the touch sensibility for move.
  12052. * The higher the faster.
  12053. */
  12054. touchMoveSensibility: number;
  12055. private _offsetX;
  12056. private _offsetY;
  12057. private _pointerPressed;
  12058. private _pointerInput;
  12059. private _observer;
  12060. private _onLostFocus;
  12061. /**
  12062. * Attach the input controls to a specific dom element to get the input from.
  12063. * @param element Defines the element the controls should be listened from
  12064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12065. */
  12066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12067. /**
  12068. * Detach the current controls from the specified dom element.
  12069. * @param element Defines the element to stop listening the inputs from
  12070. */
  12071. detachControl(element: Nullable<HTMLElement>): void;
  12072. /**
  12073. * Update the current camera state depending on the inputs that have been used this frame.
  12074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12075. */
  12076. checkInputs(): void;
  12077. /**
  12078. * Gets the class name of the current intput.
  12079. * @returns the class name
  12080. */
  12081. getClassName(): string;
  12082. /**
  12083. * Get the friendly name associated with the input class.
  12084. * @returns the input friendly name
  12085. */
  12086. getSimpleName(): string;
  12087. }
  12088. }
  12089. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12090. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12091. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12092. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12093. import { Nullable } from "babylonjs/types";
  12094. /**
  12095. * Default Inputs manager for the FreeCamera.
  12096. * It groups all the default supported inputs for ease of use.
  12097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12098. */
  12099. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12100. /**
  12101. * @hidden
  12102. */
  12103. _mouseInput: Nullable<FreeCameraMouseInput>;
  12104. /**
  12105. * Instantiates a new FreeCameraInputsManager.
  12106. * @param camera Defines the camera the inputs belong to
  12107. */
  12108. constructor(camera: FreeCamera);
  12109. /**
  12110. * Add keyboard input support to the input manager.
  12111. * @returns the current input manager
  12112. */
  12113. addKeyboard(): FreeCameraInputsManager;
  12114. /**
  12115. * Add mouse input support to the input manager.
  12116. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12117. * @returns the current input manager
  12118. */
  12119. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12120. /**
  12121. * Removes the mouse input support from the manager
  12122. * @returns the current input manager
  12123. */
  12124. removeMouse(): FreeCameraInputsManager;
  12125. /**
  12126. * Add touch input support to the input manager.
  12127. * @returns the current input manager
  12128. */
  12129. addTouch(): FreeCameraInputsManager;
  12130. /**
  12131. * Remove all attached input methods from a camera
  12132. */
  12133. clear(): void;
  12134. }
  12135. }
  12136. declare module "babylonjs/Cameras/freeCamera" {
  12137. import { Vector3 } from "babylonjs/Maths/math.vector";
  12138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12139. import { Scene } from "babylonjs/scene";
  12140. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12141. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12142. /**
  12143. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12144. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12146. */
  12147. export class FreeCamera extends TargetCamera {
  12148. /**
  12149. * Define the collision ellipsoid of the camera.
  12150. * This is helpful to simulate a camera body like the player body around the camera
  12151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12152. */
  12153. ellipsoid: Vector3;
  12154. /**
  12155. * Define an offset for the position of the ellipsoid around the camera.
  12156. * This can be helpful to determine the center of the body near the gravity center of the body
  12157. * instead of its head.
  12158. */
  12159. ellipsoidOffset: Vector3;
  12160. /**
  12161. * Enable or disable collisions of the camera with the rest of the scene objects.
  12162. */
  12163. checkCollisions: boolean;
  12164. /**
  12165. * Enable or disable gravity on the camera.
  12166. */
  12167. applyGravity: boolean;
  12168. /**
  12169. * Define the input manager associated to the camera.
  12170. */
  12171. inputs: FreeCameraInputsManager;
  12172. /**
  12173. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12174. * Higher values reduce sensitivity.
  12175. */
  12176. /**
  12177. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12178. * Higher values reduce sensitivity.
  12179. */
  12180. angularSensibility: number;
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12183. */
  12184. keysUp: number[];
  12185. /**
  12186. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12187. */
  12188. keysDown: number[];
  12189. /**
  12190. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12191. */
  12192. keysLeft: number[];
  12193. /**
  12194. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12195. */
  12196. keysRight: number[];
  12197. /**
  12198. * Event raised when the camera collide with a mesh in the scene.
  12199. */
  12200. onCollide: (collidedMesh: AbstractMesh) => void;
  12201. private _collider;
  12202. private _needMoveForGravity;
  12203. private _oldPosition;
  12204. private _diffPosition;
  12205. private _newPosition;
  12206. /** @hidden */
  12207. _localDirection: Vector3;
  12208. /** @hidden */
  12209. _transformedDirection: Vector3;
  12210. /**
  12211. * Instantiates a Free Camera.
  12212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12213. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12215. * @param name Define the name of the camera in the scene
  12216. * @param position Define the start position of the camera in the scene
  12217. * @param scene Define the scene the camera belongs to
  12218. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12219. */
  12220. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12221. /**
  12222. * Attached controls to the current camera.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Detach the current controls from the camera.
  12229. * The camera will stop reacting to inputs.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: HTMLElement): void;
  12233. private _collisionMask;
  12234. /**
  12235. * Define a collision mask to limit the list of object the camera can collide with
  12236. */
  12237. collisionMask: number;
  12238. /** @hidden */
  12239. _collideWithWorld(displacement: Vector3): void;
  12240. private _onCollisionPositionChange;
  12241. /** @hidden */
  12242. _checkInputs(): void;
  12243. /** @hidden */
  12244. _decideIfNeedsToMove(): boolean;
  12245. /** @hidden */
  12246. _updatePosition(): void;
  12247. /**
  12248. * Destroy the camera and release the current resources hold by it.
  12249. */
  12250. dispose(): void;
  12251. /**
  12252. * Gets the current object class name.
  12253. * @return the class name
  12254. */
  12255. getClassName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Gamepads/gamepad" {
  12259. import { Observable } from "babylonjs/Misc/observable";
  12260. /**
  12261. * Represents a gamepad control stick position
  12262. */
  12263. export class StickValues {
  12264. /**
  12265. * The x component of the control stick
  12266. */
  12267. x: number;
  12268. /**
  12269. * The y component of the control stick
  12270. */
  12271. y: number;
  12272. /**
  12273. * Initializes the gamepad x and y control stick values
  12274. * @param x The x component of the gamepad control stick value
  12275. * @param y The y component of the gamepad control stick value
  12276. */
  12277. constructor(
  12278. /**
  12279. * The x component of the control stick
  12280. */
  12281. x: number,
  12282. /**
  12283. * The y component of the control stick
  12284. */
  12285. y: number);
  12286. }
  12287. /**
  12288. * An interface which manages callbacks for gamepad button changes
  12289. */
  12290. export interface GamepadButtonChanges {
  12291. /**
  12292. * Called when a gamepad has been changed
  12293. */
  12294. changed: boolean;
  12295. /**
  12296. * Called when a gamepad press event has been triggered
  12297. */
  12298. pressChanged: boolean;
  12299. /**
  12300. * Called when a touch event has been triggered
  12301. */
  12302. touchChanged: boolean;
  12303. /**
  12304. * Called when a value has changed
  12305. */
  12306. valueChanged: boolean;
  12307. }
  12308. /**
  12309. * Represents a gamepad
  12310. */
  12311. export class Gamepad {
  12312. /**
  12313. * The id of the gamepad
  12314. */
  12315. id: string;
  12316. /**
  12317. * The index of the gamepad
  12318. */
  12319. index: number;
  12320. /**
  12321. * The browser gamepad
  12322. */
  12323. browserGamepad: any;
  12324. /**
  12325. * Specifies what type of gamepad this represents
  12326. */
  12327. type: number;
  12328. private _leftStick;
  12329. private _rightStick;
  12330. /** @hidden */
  12331. _isConnected: boolean;
  12332. private _leftStickAxisX;
  12333. private _leftStickAxisY;
  12334. private _rightStickAxisX;
  12335. private _rightStickAxisY;
  12336. /**
  12337. * Triggered when the left control stick has been changed
  12338. */
  12339. private _onleftstickchanged;
  12340. /**
  12341. * Triggered when the right control stick has been changed
  12342. */
  12343. private _onrightstickchanged;
  12344. /**
  12345. * Represents a gamepad controller
  12346. */
  12347. static GAMEPAD: number;
  12348. /**
  12349. * Represents a generic controller
  12350. */
  12351. static GENERIC: number;
  12352. /**
  12353. * Represents an XBox controller
  12354. */
  12355. static XBOX: number;
  12356. /**
  12357. * Represents a pose-enabled controller
  12358. */
  12359. static POSE_ENABLED: number;
  12360. /**
  12361. * Represents an Dual Shock controller
  12362. */
  12363. static DUALSHOCK: number;
  12364. /**
  12365. * Specifies whether the left control stick should be Y-inverted
  12366. */
  12367. protected _invertLeftStickY: boolean;
  12368. /**
  12369. * Specifies if the gamepad has been connected
  12370. */
  12371. readonly isConnected: boolean;
  12372. /**
  12373. * Initializes the gamepad
  12374. * @param id The id of the gamepad
  12375. * @param index The index of the gamepad
  12376. * @param browserGamepad The browser gamepad
  12377. * @param leftStickX The x component of the left joystick
  12378. * @param leftStickY The y component of the left joystick
  12379. * @param rightStickX The x component of the right joystick
  12380. * @param rightStickY The y component of the right joystick
  12381. */
  12382. constructor(
  12383. /**
  12384. * The id of the gamepad
  12385. */
  12386. id: string,
  12387. /**
  12388. * The index of the gamepad
  12389. */
  12390. index: number,
  12391. /**
  12392. * The browser gamepad
  12393. */
  12394. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12395. /**
  12396. * Callback triggered when the left joystick has changed
  12397. * @param callback
  12398. */
  12399. onleftstickchanged(callback: (values: StickValues) => void): void;
  12400. /**
  12401. * Callback triggered when the right joystick has changed
  12402. * @param callback
  12403. */
  12404. onrightstickchanged(callback: (values: StickValues) => void): void;
  12405. /**
  12406. * Gets the left joystick
  12407. */
  12408. /**
  12409. * Sets the left joystick values
  12410. */
  12411. leftStick: StickValues;
  12412. /**
  12413. * Gets the right joystick
  12414. */
  12415. /**
  12416. * Sets the right joystick value
  12417. */
  12418. rightStick: StickValues;
  12419. /**
  12420. * Updates the gamepad joystick positions
  12421. */
  12422. update(): void;
  12423. /**
  12424. * Disposes the gamepad
  12425. */
  12426. dispose(): void;
  12427. }
  12428. /**
  12429. * Represents a generic gamepad
  12430. */
  12431. export class GenericPad extends Gamepad {
  12432. private _buttons;
  12433. private _onbuttondown;
  12434. private _onbuttonup;
  12435. /**
  12436. * Observable triggered when a button has been pressed
  12437. */
  12438. onButtonDownObservable: Observable<number>;
  12439. /**
  12440. * Observable triggered when a button has been released
  12441. */
  12442. onButtonUpObservable: Observable<number>;
  12443. /**
  12444. * Callback triggered when a button has been pressed
  12445. * @param callback Called when a button has been pressed
  12446. */
  12447. onbuttondown(callback: (buttonPressed: number) => void): void;
  12448. /**
  12449. * Callback triggered when a button has been released
  12450. * @param callback Called when a button has been released
  12451. */
  12452. onbuttonup(callback: (buttonReleased: number) => void): void;
  12453. /**
  12454. * Initializes the generic gamepad
  12455. * @param id The id of the generic gamepad
  12456. * @param index The index of the generic gamepad
  12457. * @param browserGamepad The browser gamepad
  12458. */
  12459. constructor(id: string, index: number, browserGamepad: any);
  12460. private _setButtonValue;
  12461. /**
  12462. * Updates the generic gamepad
  12463. */
  12464. update(): void;
  12465. /**
  12466. * Disposes the generic gamepad
  12467. */
  12468. dispose(): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12472. import { Nullable } from "babylonjs/types";
  12473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12474. import { Scene } from "babylonjs/scene";
  12475. module "babylonjs/Engines/engine" {
  12476. interface Engine {
  12477. /**
  12478. * Creates a raw texture
  12479. * @param data defines the data to store in the texture
  12480. * @param width defines the width of the texture
  12481. * @param height defines the height of the texture
  12482. * @param format defines the format of the data
  12483. * @param generateMipMaps defines if the engine should generate the mip levels
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12486. * @param compression defines the compression used (null by default)
  12487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12488. * @returns the raw texture inside an InternalTexture
  12489. */
  12490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12491. /**
  12492. * Update a raw texture
  12493. * @param texture defines the texture to update
  12494. * @param data defines the data to store in the texture
  12495. * @param format defines the format of the data
  12496. * @param invertY defines if data must be stored with Y axis inverted
  12497. */
  12498. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12499. /**
  12500. * Update a raw texture
  12501. * @param texture defines the texture to update
  12502. * @param data defines the data to store in the texture
  12503. * @param format defines the format of the data
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param compression defines the compression used (null by default)
  12506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12507. */
  12508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12509. /**
  12510. * Creates a new raw cube texture
  12511. * @param data defines the array of data to use to create each face
  12512. * @param size defines the size of the textures
  12513. * @param format defines the format of the data
  12514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12515. * @param generateMipMaps defines if the engine should generate the mip levels
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param compression defines the compression used (null by default)
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12522. /**
  12523. * Update a raw cube texture
  12524. * @param texture defines the texture to udpdate
  12525. * @param data defines the data to store
  12526. * @param format defines the data format
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @param invertY defines if data must be stored with Y axis inverted
  12529. */
  12530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12531. /**
  12532. * Update a raw cube texture
  12533. * @param texture defines the texture to udpdate
  12534. * @param data defines the data to store
  12535. * @param format defines the data format
  12536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12537. * @param invertY defines if data must be stored with Y axis inverted
  12538. * @param compression defines the compression used (null by default)
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12541. /**
  12542. * Update a raw cube texture
  12543. * @param texture defines the texture to udpdate
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. * @param invertY defines if data must be stored with Y axis inverted
  12548. * @param compression defines the compression used (null by default)
  12549. * @param level defines which level of the texture to update
  12550. */
  12551. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12552. /**
  12553. * Creates a new raw cube texture from a specified url
  12554. * @param url defines the url where the data is located
  12555. * @param scene defines the current scene
  12556. * @param size defines the size of the textures
  12557. * @param format defines the format of the data
  12558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12559. * @param noMipmap defines if the engine should avoid generating the mip levels
  12560. * @param callback defines a callback used to extract texture data from loaded data
  12561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12562. * @param onLoad defines a callback called when texture is loaded
  12563. * @param onError defines a callback called if there is an error
  12564. * @returns the cube texture as an InternalTexture
  12565. */
  12566. 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;
  12567. /**
  12568. * Creates a new raw cube texture from a specified url
  12569. * @param url defines the url where the data is located
  12570. * @param scene defines the current scene
  12571. * @param size defines the size of the textures
  12572. * @param format defines the format of the data
  12573. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12574. * @param noMipmap defines if the engine should avoid generating the mip levels
  12575. * @param callback defines a callback used to extract texture data from loaded data
  12576. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12577. * @param onLoad defines a callback called when texture is loaded
  12578. * @param onError defines a callback called if there is an error
  12579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @returns the cube texture as an InternalTexture
  12582. */
  12583. 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;
  12584. /**
  12585. * Creates a new raw 3D texture
  12586. * @param data defines the data used to create the texture
  12587. * @param width defines the width of the texture
  12588. * @param height defines the height of the texture
  12589. * @param depth defines the depth of the texture
  12590. * @param format defines the format of the texture
  12591. * @param generateMipMaps defines if the engine must generate mip levels
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12594. * @param compression defines the compressed used (can be null)
  12595. * @param textureType defines the compressed used (can be null)
  12596. * @returns a new raw 3D texture (stored in an InternalTexture)
  12597. */
  12598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12599. /**
  12600. * Update a raw 3D texture
  12601. * @param texture defines the texture to update
  12602. * @param data defines the data to store
  12603. * @param format defines the data format
  12604. * @param invertY defines if data must be stored with Y axis inverted
  12605. */
  12606. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12607. /**
  12608. * Update a raw 3D texture
  12609. * @param texture defines the texture to update
  12610. * @param data defines the data to store
  12611. * @param format defines the data format
  12612. * @param invertY defines if data must be stored with Y axis inverted
  12613. * @param compression defines the used compression (can be null)
  12614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12615. */
  12616. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12617. }
  12618. }
  12619. }
  12620. declare module "babylonjs/Materials/Textures/rawTexture" {
  12621. import { Scene } from "babylonjs/scene";
  12622. import { Texture } from "babylonjs/Materials/Textures/texture";
  12623. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12624. /**
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. */
  12629. export class RawTexture extends Texture {
  12630. /**
  12631. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. */
  12633. format: number;
  12634. private _engine;
  12635. /**
  12636. * Instantiates a new RawTexture.
  12637. * Raw texture can help creating a texture directly from an array of data.
  12638. * This can be super useful if you either get the data from an uncompressed source or
  12639. * if you wish to create your texture pixel by pixel.
  12640. * @param data define the array of data to use to create the texture
  12641. * @param width define the width of the texture
  12642. * @param height define the height of the texture
  12643. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12644. * @param scene define the scene the texture belongs to
  12645. * @param generateMipMaps define whether mip maps should be generated or not
  12646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12649. */
  12650. constructor(data: ArrayBufferView, width: number, height: number,
  12651. /**
  12652. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12653. */
  12654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12655. /**
  12656. * Updates the texture underlying data.
  12657. * @param data Define the new data of the texture
  12658. */
  12659. update(data: ArrayBufferView): void;
  12660. /**
  12661. * Creates a luminance texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance texture
  12670. */
  12671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  12682. */
  12683. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates an alpha texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @returns the alpha texture
  12694. */
  12695. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12696. /**
  12697. * Creates a RGB texture from some data.
  12698. * @param data Define the texture data
  12699. * @param width Define the width of the texture
  12700. * @param height Define the height of the texture
  12701. * @param scene Define the scene the texture belongs to
  12702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12706. * @returns the RGB alpha texture
  12707. */
  12708. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12709. /**
  12710. * Creates a RGBA texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGBA texture
  12720. */
  12721. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a R texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the R texture
  12733. */
  12734. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. }
  12736. }
  12737. declare module "babylonjs/Maths/math.size" {
  12738. /**
  12739. * Interface for the size containing width and height
  12740. */
  12741. export interface ISize {
  12742. /**
  12743. * Width
  12744. */
  12745. width: number;
  12746. /**
  12747. * Heighht
  12748. */
  12749. height: number;
  12750. }
  12751. /**
  12752. * Size containing widht and height
  12753. */
  12754. export class Size implements ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Height
  12761. */
  12762. height: number;
  12763. /**
  12764. * Creates a Size object from the given width and height (floats).
  12765. * @param width width of the new size
  12766. * @param height height of the new size
  12767. */
  12768. constructor(width: number, height: number);
  12769. /**
  12770. * Returns a string with the Size width and height
  12771. * @returns a string with the Size width and height
  12772. */
  12773. toString(): string;
  12774. /**
  12775. * "Size"
  12776. * @returns the string "Size"
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Returns the Size hash code.
  12781. * @returns a hash code for a unique width and height
  12782. */
  12783. getHashCode(): number;
  12784. /**
  12785. * Updates the current size from the given one.
  12786. * @param src the given size
  12787. */
  12788. copyFrom(src: Size): void;
  12789. /**
  12790. * Updates in place the current Size from the given floats.
  12791. * @param width width of the new size
  12792. * @param height height of the new size
  12793. * @returns the updated Size.
  12794. */
  12795. copyFromFloats(width: number, height: number): Size;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width to set
  12799. * @param height height to set
  12800. * @returns the updated Size.
  12801. */
  12802. set(width: number, height: number): Size;
  12803. /**
  12804. * Multiplies the width and height by numbers
  12805. * @param w factor to multiple the width by
  12806. * @param h factor to multiple the height by
  12807. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12808. */
  12809. multiplyByFloats(w: number, h: number): Size;
  12810. /**
  12811. * Clones the size
  12812. * @returns a new Size copied from the given one.
  12813. */
  12814. clone(): Size;
  12815. /**
  12816. * True if the current Size and the given one width and height are strictly equal.
  12817. * @param other the other size to compare against
  12818. * @returns True if the current Size and the given one width and height are strictly equal.
  12819. */
  12820. equals(other: Size): boolean;
  12821. /**
  12822. * The surface of the Size : width * height (float).
  12823. */
  12824. readonly surface: number;
  12825. /**
  12826. * Create a new size of zero
  12827. * @returns a new Size set to (0.0, 0.0)
  12828. */
  12829. static Zero(): Size;
  12830. /**
  12831. * Sums the width and height of two sizes
  12832. * @param otherSize size to add to this size
  12833. * @returns a new Size set as the addition result of the current Size and the given one.
  12834. */
  12835. add(otherSize: Size): Size;
  12836. /**
  12837. * Subtracts the width and height of two
  12838. * @param otherSize size to subtract to this size
  12839. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12840. */
  12841. subtract(otherSize: Size): Size;
  12842. /**
  12843. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12844. * @param start starting size to lerp between
  12845. * @param end end size to lerp between
  12846. * @param amount amount to lerp between the start and end values
  12847. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12848. */
  12849. static Lerp(start: Size, end: Size, amount: number): Size;
  12850. }
  12851. }
  12852. declare module "babylonjs/Animations/runtimeAnimation" {
  12853. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12854. import { Animatable } from "babylonjs/Animations/animatable";
  12855. import { Scene } from "babylonjs/scene";
  12856. /**
  12857. * Defines a runtime animation
  12858. */
  12859. export class RuntimeAnimation {
  12860. private _events;
  12861. /**
  12862. * The current frame of the runtime animation
  12863. */
  12864. private _currentFrame;
  12865. /**
  12866. * The animation used by the runtime animation
  12867. */
  12868. private _animation;
  12869. /**
  12870. * The target of the runtime animation
  12871. */
  12872. private _target;
  12873. /**
  12874. * The initiating animatable
  12875. */
  12876. private _host;
  12877. /**
  12878. * The original value of the runtime animation
  12879. */
  12880. private _originalValue;
  12881. /**
  12882. * The original blend value of the runtime animation
  12883. */
  12884. private _originalBlendValue;
  12885. /**
  12886. * The offsets cache of the runtime animation
  12887. */
  12888. private _offsetsCache;
  12889. /**
  12890. * The high limits cache of the runtime animation
  12891. */
  12892. private _highLimitsCache;
  12893. /**
  12894. * Specifies if the runtime animation has been stopped
  12895. */
  12896. private _stopped;
  12897. /**
  12898. * The blending factor of the runtime animation
  12899. */
  12900. private _blendingFactor;
  12901. /**
  12902. * The BabylonJS scene
  12903. */
  12904. private _scene;
  12905. /**
  12906. * The current value of the runtime animation
  12907. */
  12908. private _currentValue;
  12909. /** @hidden */
  12910. _animationState: _IAnimationState;
  12911. /**
  12912. * The active target of the runtime animation
  12913. */
  12914. private _activeTargets;
  12915. private _currentActiveTarget;
  12916. private _directTarget;
  12917. /**
  12918. * The target path of the runtime animation
  12919. */
  12920. private _targetPath;
  12921. /**
  12922. * The weight of the runtime animation
  12923. */
  12924. private _weight;
  12925. /**
  12926. * The ratio offset of the runtime animation
  12927. */
  12928. private _ratioOffset;
  12929. /**
  12930. * The previous delay of the runtime animation
  12931. */
  12932. private _previousDelay;
  12933. /**
  12934. * The previous ratio of the runtime animation
  12935. */
  12936. private _previousRatio;
  12937. private _enableBlending;
  12938. private _keys;
  12939. private _minFrame;
  12940. private _maxFrame;
  12941. private _minValue;
  12942. private _maxValue;
  12943. private _targetIsArray;
  12944. /**
  12945. * Gets the current frame of the runtime animation
  12946. */
  12947. readonly currentFrame: number;
  12948. /**
  12949. * Gets the weight of the runtime animation
  12950. */
  12951. readonly weight: number;
  12952. /**
  12953. * Gets the current value of the runtime animation
  12954. */
  12955. readonly currentValue: any;
  12956. /**
  12957. * Gets the target path of the runtime animation
  12958. */
  12959. readonly targetPath: string;
  12960. /**
  12961. * Gets the actual target of the runtime animation
  12962. */
  12963. readonly target: any;
  12964. /** @hidden */
  12965. _onLoop: () => void;
  12966. /**
  12967. * Create a new RuntimeAnimation object
  12968. * @param target defines the target of the animation
  12969. * @param animation defines the source animation object
  12970. * @param scene defines the hosting scene
  12971. * @param host defines the initiating Animatable
  12972. */
  12973. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12974. private _preparePath;
  12975. /**
  12976. * Gets the animation from the runtime animation
  12977. */
  12978. readonly animation: Animation;
  12979. /**
  12980. * Resets the runtime animation to the beginning
  12981. * @param restoreOriginal defines whether to restore the target property to the original value
  12982. */
  12983. reset(restoreOriginal?: boolean): void;
  12984. /**
  12985. * Specifies if the runtime animation is stopped
  12986. * @returns Boolean specifying if the runtime animation is stopped
  12987. */
  12988. isStopped(): boolean;
  12989. /**
  12990. * Disposes of the runtime animation
  12991. */
  12992. dispose(): void;
  12993. /**
  12994. * Apply the interpolated value to the target
  12995. * @param currentValue defines the value computed by the animation
  12996. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12997. */
  12998. setValue(currentValue: any, weight: number): void;
  12999. private _getOriginalValues;
  13000. private _setValue;
  13001. /**
  13002. * Gets the loop pmode of the runtime animation
  13003. * @returns Loop Mode
  13004. */
  13005. private _getCorrectLoopMode;
  13006. /**
  13007. * Move the current animation to a given frame
  13008. * @param frame defines the frame to move to
  13009. */
  13010. goToFrame(frame: number): void;
  13011. /**
  13012. * @hidden Internal use only
  13013. */
  13014. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13015. /**
  13016. * Execute the current animation
  13017. * @param delay defines the delay to add to the current frame
  13018. * @param from defines the lower bound of the animation range
  13019. * @param to defines the upper bound of the animation range
  13020. * @param loop defines if the current animation must loop
  13021. * @param speedRatio defines the current speed ratio
  13022. * @param weight defines the weight of the animation (default is -1 so no weight)
  13023. * @param onLoop optional callback called when animation loops
  13024. * @returns a boolean indicating if the animation is running
  13025. */
  13026. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13027. }
  13028. }
  13029. declare module "babylonjs/Animations/animatable" {
  13030. import { Animation } from "babylonjs/Animations/animation";
  13031. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13032. import { Nullable } from "babylonjs/types";
  13033. import { Observable } from "babylonjs/Misc/observable";
  13034. import { Scene } from "babylonjs/scene";
  13035. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13036. import { Node } from "babylonjs/node";
  13037. /**
  13038. * Class used to store an actual running animation
  13039. */
  13040. export class Animatable {
  13041. /** defines the target object */
  13042. target: any;
  13043. /** defines the starting frame number (default is 0) */
  13044. fromFrame: number;
  13045. /** defines the ending frame number (default is 100) */
  13046. toFrame: number;
  13047. /** defines if the animation must loop (default is false) */
  13048. loopAnimation: boolean;
  13049. /** defines a callback to call when animation ends if it is not looping */
  13050. onAnimationEnd?: (() => void) | null | undefined;
  13051. /** defines a callback to call when animation loops */
  13052. onAnimationLoop?: (() => void) | null | undefined;
  13053. private _localDelayOffset;
  13054. private _pausedDelay;
  13055. private _runtimeAnimations;
  13056. private _paused;
  13057. private _scene;
  13058. private _speedRatio;
  13059. private _weight;
  13060. private _syncRoot;
  13061. /**
  13062. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13063. * This will only apply for non looping animation (default is true)
  13064. */
  13065. disposeOnEnd: boolean;
  13066. /**
  13067. * Gets a boolean indicating if the animation has started
  13068. */
  13069. animationStarted: boolean;
  13070. /**
  13071. * Observer raised when the animation ends
  13072. */
  13073. onAnimationEndObservable: Observable<Animatable>;
  13074. /**
  13075. * Observer raised when the animation loops
  13076. */
  13077. onAnimationLoopObservable: Observable<Animatable>;
  13078. /**
  13079. * Gets the root Animatable used to synchronize and normalize animations
  13080. */
  13081. readonly syncRoot: Nullable<Animatable>;
  13082. /**
  13083. * Gets the current frame of the first RuntimeAnimation
  13084. * Used to synchronize Animatables
  13085. */
  13086. readonly masterFrame: number;
  13087. /**
  13088. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13089. */
  13090. weight: number;
  13091. /**
  13092. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13093. */
  13094. speedRatio: number;
  13095. /**
  13096. * Creates a new Animatable
  13097. * @param scene defines the hosting scene
  13098. * @param target defines the target object
  13099. * @param fromFrame defines the starting frame number (default is 0)
  13100. * @param toFrame defines the ending frame number (default is 100)
  13101. * @param loopAnimation defines if the animation must loop (default is false)
  13102. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13103. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13104. * @param animations defines a group of animation to add to the new Animatable
  13105. * @param onAnimationLoop defines a callback to call when animation loops
  13106. */
  13107. constructor(scene: Scene,
  13108. /** defines the target object */
  13109. target: any,
  13110. /** defines the starting frame number (default is 0) */
  13111. fromFrame?: number,
  13112. /** defines the ending frame number (default is 100) */
  13113. toFrame?: number,
  13114. /** defines if the animation must loop (default is false) */
  13115. loopAnimation?: boolean, speedRatio?: number,
  13116. /** defines a callback to call when animation ends if it is not looping */
  13117. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13118. /** defines a callback to call when animation loops */
  13119. onAnimationLoop?: (() => void) | null | undefined);
  13120. /**
  13121. * Synchronize and normalize current Animatable with a source Animatable
  13122. * This is useful when using animation weights and when animations are not of the same length
  13123. * @param root defines the root Animatable to synchronize with
  13124. * @returns the current Animatable
  13125. */
  13126. syncWith(root: Animatable): Animatable;
  13127. /**
  13128. * Gets the list of runtime animations
  13129. * @returns an array of RuntimeAnimation
  13130. */
  13131. getAnimations(): RuntimeAnimation[];
  13132. /**
  13133. * Adds more animations to the current animatable
  13134. * @param target defines the target of the animations
  13135. * @param animations defines the new animations to add
  13136. */
  13137. appendAnimations(target: any, animations: Animation[]): void;
  13138. /**
  13139. * Gets the source animation for a specific property
  13140. * @param property defines the propertyu to look for
  13141. * @returns null or the source animation for the given property
  13142. */
  13143. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13144. /**
  13145. * Gets the runtime animation for a specific property
  13146. * @param property defines the propertyu to look for
  13147. * @returns null or the runtime animation for the given property
  13148. */
  13149. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13150. /**
  13151. * Resets the animatable to its original state
  13152. */
  13153. reset(): void;
  13154. /**
  13155. * Allows the animatable to blend with current running animations
  13156. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13157. * @param blendingSpeed defines the blending speed to use
  13158. */
  13159. enableBlending(blendingSpeed: number): void;
  13160. /**
  13161. * Disable animation blending
  13162. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13163. */
  13164. disableBlending(): void;
  13165. /**
  13166. * Jump directly to a given frame
  13167. * @param frame defines the frame to jump to
  13168. */
  13169. goToFrame(frame: number): void;
  13170. /**
  13171. * Pause the animation
  13172. */
  13173. pause(): void;
  13174. /**
  13175. * Restart the animation
  13176. */
  13177. restart(): void;
  13178. private _raiseOnAnimationEnd;
  13179. /**
  13180. * Stop and delete the current animation
  13181. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13182. * @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)
  13183. */
  13184. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13185. /**
  13186. * Wait asynchronously for the animation to end
  13187. * @returns a promise which will be fullfilled when the animation ends
  13188. */
  13189. waitAsync(): Promise<Animatable>;
  13190. /** @hidden */
  13191. _animate(delay: number): boolean;
  13192. }
  13193. module "babylonjs/scene" {
  13194. interface Scene {
  13195. /** @hidden */
  13196. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13197. /** @hidden */
  13198. _processLateAnimationBindingsForMatrices(holder: {
  13199. totalWeight: number;
  13200. animations: RuntimeAnimation[];
  13201. originalValue: Matrix;
  13202. }): any;
  13203. /** @hidden */
  13204. _processLateAnimationBindingsForQuaternions(holder: {
  13205. totalWeight: number;
  13206. animations: RuntimeAnimation[];
  13207. originalValue: Quaternion;
  13208. }, refQuaternion: Quaternion): Quaternion;
  13209. /** @hidden */
  13210. _processLateAnimationBindings(): void;
  13211. /**
  13212. * Will start the animation sequence of a given target
  13213. * @param target defines the target
  13214. * @param from defines from which frame should animation start
  13215. * @param to defines until which frame should animation run.
  13216. * @param weight defines the weight to apply to the animation (1.0 by default)
  13217. * @param loop defines if the animation loops
  13218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13219. * @param onAnimationEnd defines the function to be executed when the animation ends
  13220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13221. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13222. * @param onAnimationLoop defines the callback to call when an animation loops
  13223. * @returns the animatable object created for this animation
  13224. */
  13225. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13226. /**
  13227. * Will start the animation sequence of a given target
  13228. * @param target defines the target
  13229. * @param from defines from which frame should animation start
  13230. * @param to defines until which frame should animation run.
  13231. * @param loop defines if the animation loops
  13232. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13233. * @param onAnimationEnd defines the function to be executed when the animation ends
  13234. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13235. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13236. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13237. * @param onAnimationLoop defines the callback to call when an animation loops
  13238. * @returns the animatable object created for this animation
  13239. */
  13240. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13241. /**
  13242. * Will start the animation sequence of a given target and its hierarchy
  13243. * @param target defines the target
  13244. * @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.
  13245. * @param from defines from which frame should animation start
  13246. * @param to defines until which frame should animation run.
  13247. * @param loop defines if the animation loops
  13248. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13249. * @param onAnimationEnd defines the function to be executed when the animation ends
  13250. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13251. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13252. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13253. * @param onAnimationLoop defines the callback to call when an animation loops
  13254. * @returns the list of created animatables
  13255. */
  13256. 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[];
  13257. /**
  13258. * Begin a new animation on a given node
  13259. * @param target defines the target where the animation will take place
  13260. * @param animations defines the list of animations to start
  13261. * @param from defines the initial value
  13262. * @param to defines the final value
  13263. * @param loop defines if you want animation to loop (off by default)
  13264. * @param speedRatio defines the speed ratio to apply to all animations
  13265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13266. * @param onAnimationLoop defines the callback to call when an animation loops
  13267. * @returns the list of created animatables
  13268. */
  13269. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13270. /**
  13271. * Begin a new animation on a given node and its hierarchy
  13272. * @param target defines the root node where the animation will take place
  13273. * @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.
  13274. * @param animations defines the list of animations to start
  13275. * @param from defines the initial value
  13276. * @param to defines the final value
  13277. * @param loop defines if you want animation to loop (off by default)
  13278. * @param speedRatio defines the speed ratio to apply to all animations
  13279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13280. * @param onAnimationLoop defines the callback to call when an animation loops
  13281. * @returns the list of animatables created for all nodes
  13282. */
  13283. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13284. /**
  13285. * Gets the animatable associated with a specific target
  13286. * @param target defines the target of the animatable
  13287. * @returns the required animatable if found
  13288. */
  13289. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13290. /**
  13291. * Gets all animatables associated with a given target
  13292. * @param target defines the target to look animatables for
  13293. * @returns an array of Animatables
  13294. */
  13295. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13296. /**
  13297. * Stops and removes all animations that have been applied to the scene
  13298. */
  13299. stopAllAnimations(): void;
  13300. }
  13301. }
  13302. module "babylonjs/Bones/bone" {
  13303. interface Bone {
  13304. /**
  13305. * Copy an animation range from another bone
  13306. * @param source defines the source bone
  13307. * @param rangeName defines the range name to copy
  13308. * @param frameOffset defines the frame offset
  13309. * @param rescaleAsRequired defines if rescaling must be applied if required
  13310. * @param skelDimensionsRatio defines the scaling ratio
  13311. * @returns true if operation was successful
  13312. */
  13313. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13314. }
  13315. }
  13316. }
  13317. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13318. /**
  13319. * Class used to override all child animations of a given target
  13320. */
  13321. export class AnimationPropertiesOverride {
  13322. /**
  13323. * Gets or sets a value indicating if animation blending must be used
  13324. */
  13325. enableBlending: boolean;
  13326. /**
  13327. * Gets or sets the blending speed to use when enableBlending is true
  13328. */
  13329. blendingSpeed: number;
  13330. /**
  13331. * Gets or sets the default loop mode to use
  13332. */
  13333. loopMode: number;
  13334. }
  13335. }
  13336. declare module "babylonjs/Bones/skeleton" {
  13337. import { Bone } from "babylonjs/Bones/bone";
  13338. import { Observable } from "babylonjs/Misc/observable";
  13339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13340. import { Scene } from "babylonjs/scene";
  13341. import { Nullable } from "babylonjs/types";
  13342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13343. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13344. import { Animatable } from "babylonjs/Animations/animatable";
  13345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13346. import { Animation } from "babylonjs/Animations/animation";
  13347. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13348. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13350. /**
  13351. * Class used to handle skinning animations
  13352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13353. */
  13354. export class Skeleton implements IAnimatable {
  13355. /** defines the skeleton name */
  13356. name: string;
  13357. /** defines the skeleton Id */
  13358. id: string;
  13359. /**
  13360. * Defines the list of child bones
  13361. */
  13362. bones: Bone[];
  13363. /**
  13364. * Defines an estimate of the dimension of the skeleton at rest
  13365. */
  13366. dimensionsAtRest: Vector3;
  13367. /**
  13368. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13369. */
  13370. needInitialSkinMatrix: boolean;
  13371. /**
  13372. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13373. */
  13374. overrideMesh: Nullable<AbstractMesh>;
  13375. /**
  13376. * Gets the list of animations attached to this skeleton
  13377. */
  13378. animations: Array<Animation>;
  13379. private _scene;
  13380. private _isDirty;
  13381. private _transformMatrices;
  13382. private _transformMatrixTexture;
  13383. private _meshesWithPoseMatrix;
  13384. private _animatables;
  13385. private _identity;
  13386. private _synchronizedWithMesh;
  13387. private _ranges;
  13388. private _lastAbsoluteTransformsUpdateId;
  13389. private _canUseTextureForBones;
  13390. private _uniqueId;
  13391. /** @hidden */
  13392. _numBonesWithLinkedTransformNode: number;
  13393. /** @hidden */
  13394. _hasWaitingData: Nullable<boolean>;
  13395. /**
  13396. * Specifies if the skeleton should be serialized
  13397. */
  13398. doNotSerialize: boolean;
  13399. private _useTextureToStoreBoneMatrices;
  13400. /**
  13401. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13402. * Please note that this option is not available if the hardware does not support it
  13403. */
  13404. useTextureToStoreBoneMatrices: boolean;
  13405. private _animationPropertiesOverride;
  13406. /**
  13407. * Gets or sets the animation properties override
  13408. */
  13409. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13410. /**
  13411. * List of inspectable custom properties (used by the Inspector)
  13412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13413. */
  13414. inspectableCustomProperties: IInspectable[];
  13415. /**
  13416. * An observable triggered before computing the skeleton's matrices
  13417. */
  13418. onBeforeComputeObservable: Observable<Skeleton>;
  13419. /**
  13420. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13421. */
  13422. readonly isUsingTextureForMatrices: boolean;
  13423. /**
  13424. * Gets the unique ID of this skeleton
  13425. */
  13426. readonly uniqueId: number;
  13427. /**
  13428. * Creates a new skeleton
  13429. * @param name defines the skeleton name
  13430. * @param id defines the skeleton Id
  13431. * @param scene defines the hosting scene
  13432. */
  13433. constructor(
  13434. /** defines the skeleton name */
  13435. name: string,
  13436. /** defines the skeleton Id */
  13437. id: string, scene: Scene);
  13438. /**
  13439. * Gets the current object class name.
  13440. * @return the class name
  13441. */
  13442. getClassName(): string;
  13443. /**
  13444. * Returns an array containing the root bones
  13445. * @returns an array containing the root bones
  13446. */
  13447. getChildren(): Array<Bone>;
  13448. /**
  13449. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13450. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13451. * @returns a Float32Array containing matrices data
  13452. */
  13453. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13454. /**
  13455. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13456. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13457. * @returns a raw texture containing the data
  13458. */
  13459. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13460. /**
  13461. * Gets the current hosting scene
  13462. * @returns a scene object
  13463. */
  13464. getScene(): Scene;
  13465. /**
  13466. * Gets a string representing the current skeleton data
  13467. * @param fullDetails defines a boolean indicating if we want a verbose version
  13468. * @returns a string representing the current skeleton data
  13469. */
  13470. toString(fullDetails?: boolean): string;
  13471. /**
  13472. * Get bone's index searching by name
  13473. * @param name defines bone's name to search for
  13474. * @return the indice of the bone. Returns -1 if not found
  13475. */
  13476. getBoneIndexByName(name: string): number;
  13477. /**
  13478. * Creater a new animation range
  13479. * @param name defines the name of the range
  13480. * @param from defines the start key
  13481. * @param to defines the end key
  13482. */
  13483. createAnimationRange(name: string, from: number, to: number): void;
  13484. /**
  13485. * Delete a specific animation range
  13486. * @param name defines the name of the range
  13487. * @param deleteFrames defines if frames must be removed as well
  13488. */
  13489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13490. /**
  13491. * Gets a specific animation range
  13492. * @param name defines the name of the range to look for
  13493. * @returns the requested animation range or null if not found
  13494. */
  13495. getAnimationRange(name: string): Nullable<AnimationRange>;
  13496. /**
  13497. * Gets the list of all animation ranges defined on this skeleton
  13498. * @returns an array
  13499. */
  13500. getAnimationRanges(): Nullable<AnimationRange>[];
  13501. /**
  13502. * Copy animation range from a source skeleton.
  13503. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13504. * @param source defines the source skeleton
  13505. * @param name defines the name of the range to copy
  13506. * @param rescaleAsRequired defines if rescaling must be applied if required
  13507. * @returns true if operation was successful
  13508. */
  13509. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13510. /**
  13511. * Forces the skeleton to go to rest pose
  13512. */
  13513. returnToRest(): void;
  13514. private _getHighestAnimationFrame;
  13515. /**
  13516. * Begin a specific animation range
  13517. * @param name defines the name of the range to start
  13518. * @param loop defines if looping must be turned on (false by default)
  13519. * @param speedRatio defines the speed ratio to apply (1 by default)
  13520. * @param onAnimationEnd defines a callback which will be called when animation will end
  13521. * @returns a new animatable
  13522. */
  13523. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13524. /** @hidden */
  13525. _markAsDirty(): void;
  13526. /** @hidden */
  13527. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13528. /** @hidden */
  13529. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13530. private _computeTransformMatrices;
  13531. /**
  13532. * Build all resources required to render a skeleton
  13533. */
  13534. prepare(): void;
  13535. /**
  13536. * Gets the list of animatables currently running for this skeleton
  13537. * @returns an array of animatables
  13538. */
  13539. getAnimatables(): IAnimatable[];
  13540. /**
  13541. * Clone the current skeleton
  13542. * @param name defines the name of the new skeleton
  13543. * @param id defines the id of the new skeleton
  13544. * @returns the new skeleton
  13545. */
  13546. clone(name: string, id: string): Skeleton;
  13547. /**
  13548. * Enable animation blending for this skeleton
  13549. * @param blendingSpeed defines the blending speed to apply
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. enableBlending(blendingSpeed?: number): void;
  13553. /**
  13554. * Releases all resources associated with the current skeleton
  13555. */
  13556. dispose(): void;
  13557. /**
  13558. * Serialize the skeleton in a JSON object
  13559. * @returns a JSON object
  13560. */
  13561. serialize(): any;
  13562. /**
  13563. * Creates a new skeleton from serialized data
  13564. * @param parsedSkeleton defines the serialized data
  13565. * @param scene defines the hosting scene
  13566. * @returns a new skeleton
  13567. */
  13568. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13569. /**
  13570. * Compute all node absolute transforms
  13571. * @param forceUpdate defines if computation must be done even if cache is up to date
  13572. */
  13573. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13574. /**
  13575. * Gets the root pose matrix
  13576. * @returns a matrix
  13577. */
  13578. getPoseMatrix(): Nullable<Matrix>;
  13579. /**
  13580. * Sorts bones per internal index
  13581. */
  13582. sortBones(): void;
  13583. private _sortBones;
  13584. }
  13585. }
  13586. declare module "babylonjs/Bones/bone" {
  13587. import { Skeleton } from "babylonjs/Bones/skeleton";
  13588. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Nullable } from "babylonjs/types";
  13590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13592. import { Node } from "babylonjs/node";
  13593. import { Space } from "babylonjs/Maths/math.axis";
  13594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13595. /**
  13596. * Class used to store bone information
  13597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13598. */
  13599. export class Bone extends Node {
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string;
  13604. private static _tmpVecs;
  13605. private static _tmpQuat;
  13606. private static _tmpMats;
  13607. /**
  13608. * Gets the list of child bones
  13609. */
  13610. children: Bone[];
  13611. /** Gets the animations associated with this bone */
  13612. animations: import("babylonjs/Animations/animation").Animation[];
  13613. /**
  13614. * Gets or sets bone length
  13615. */
  13616. length: number;
  13617. /**
  13618. * @hidden Internal only
  13619. * Set this value to map this bone to a different index in the transform matrices
  13620. * Set this value to -1 to exclude the bone from the transform matrices
  13621. */
  13622. _index: Nullable<number>;
  13623. private _skeleton;
  13624. private _localMatrix;
  13625. private _restPose;
  13626. private _baseMatrix;
  13627. private _absoluteTransform;
  13628. private _invertedAbsoluteTransform;
  13629. private _parent;
  13630. private _scalingDeterminant;
  13631. private _worldTransform;
  13632. private _localScaling;
  13633. private _localRotation;
  13634. private _localPosition;
  13635. private _needToDecompose;
  13636. private _needToCompose;
  13637. /** @hidden */
  13638. _linkedTransformNode: Nullable<TransformNode>;
  13639. /** @hidden */
  13640. _waitingTransformNodeId: Nullable<string>;
  13641. /** @hidden */
  13642. /** @hidden */
  13643. _matrix: Matrix;
  13644. /**
  13645. * Create a new bone
  13646. * @param name defines the bone name
  13647. * @param skeleton defines the parent skeleton
  13648. * @param parentBone defines the parent (can be null if the bone is the root)
  13649. * @param localMatrix defines the local matrix
  13650. * @param restPose defines the rest pose matrix
  13651. * @param baseMatrix defines the base matrix
  13652. * @param index defines index of the bone in the hiearchy
  13653. */
  13654. constructor(
  13655. /**
  13656. * defines the bone name
  13657. */
  13658. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13659. /**
  13660. * Gets the current object class name.
  13661. * @return the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Gets the parent skeleton
  13666. * @returns a skeleton
  13667. */
  13668. getSkeleton(): Skeleton;
  13669. /**
  13670. * Gets parent bone
  13671. * @returns a bone or null if the bone is the root of the bone hierarchy
  13672. */
  13673. getParent(): Nullable<Bone>;
  13674. /**
  13675. * Returns an array containing the root bones
  13676. * @returns an array containing the root bones
  13677. */
  13678. getChildren(): Array<Bone>;
  13679. /**
  13680. * Sets the parent bone
  13681. * @param parent defines the parent (can be null if the bone is the root)
  13682. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13683. */
  13684. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13685. /**
  13686. * Gets the local matrix
  13687. * @returns a matrix
  13688. */
  13689. getLocalMatrix(): Matrix;
  13690. /**
  13691. * Gets the base matrix (initial matrix which remains unchanged)
  13692. * @returns a matrix
  13693. */
  13694. getBaseMatrix(): Matrix;
  13695. /**
  13696. * Gets the rest pose matrix
  13697. * @returns a matrix
  13698. */
  13699. getRestPose(): Matrix;
  13700. /**
  13701. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13702. */
  13703. getWorldMatrix(): Matrix;
  13704. /**
  13705. * Sets the local matrix to rest pose matrix
  13706. */
  13707. returnToRest(): void;
  13708. /**
  13709. * Gets the inverse of the absolute transform matrix.
  13710. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13711. * @returns a matrix
  13712. */
  13713. getInvertedAbsoluteTransform(): Matrix;
  13714. /**
  13715. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13716. * @returns a matrix
  13717. */
  13718. getAbsoluteTransform(): Matrix;
  13719. /**
  13720. * Links with the given transform node.
  13721. * The local matrix of this bone is copied from the transform node every frame.
  13722. * @param transformNode defines the transform node to link to
  13723. */
  13724. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13725. /**
  13726. * Gets the node used to drive the bone's transformation
  13727. * @returns a transform node or null
  13728. */
  13729. getTransformNode(): Nullable<TransformNode>;
  13730. /** Gets or sets current position (in local space) */
  13731. position: Vector3;
  13732. /** Gets or sets current rotation (in local space) */
  13733. rotation: Vector3;
  13734. /** Gets or sets current rotation quaternion (in local space) */
  13735. rotationQuaternion: Quaternion;
  13736. /** Gets or sets current scaling (in local space) */
  13737. scaling: Vector3;
  13738. /**
  13739. * Gets the animation properties override
  13740. */
  13741. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13742. private _decompose;
  13743. private _compose;
  13744. /**
  13745. * Update the base and local matrices
  13746. * @param matrix defines the new base or local matrix
  13747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13748. * @param updateLocalMatrix defines if the local matrix should be updated
  13749. */
  13750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13751. /** @hidden */
  13752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13753. /**
  13754. * Flag the bone as dirty (Forcing it to update everything)
  13755. */
  13756. markAsDirty(): void;
  13757. /** @hidden */
  13758. _markAsDirtyAndCompose(): void;
  13759. private _markAsDirtyAndDecompose;
  13760. /**
  13761. * Translate the bone in local or world space
  13762. * @param vec The amount to translate the bone
  13763. * @param space The space that the translation is in
  13764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13765. */
  13766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Set the postion of the bone in local or world space
  13769. * @param position The position to set the bone
  13770. * @param space The space that the position is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the absolute position of the bone (world space)
  13776. * @param position The position to set the bone
  13777. * @param mesh The mesh that this bone is attached to
  13778. */
  13779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Scale the bone on the x, y and z axes (in local space)
  13782. * @param x The amount to scale the bone on the x axis
  13783. * @param y The amount to scale the bone on the y axis
  13784. * @param z The amount to scale the bone on the z axis
  13785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13786. */
  13787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13788. /**
  13789. * Set the bone scaling in local space
  13790. * @param scale defines the scaling vector
  13791. */
  13792. setScale(scale: Vector3): void;
  13793. /**
  13794. * Gets the current scaling in local space
  13795. * @returns the current scaling vector
  13796. */
  13797. getScale(): Vector3;
  13798. /**
  13799. * Gets the current scaling in local space and stores it in a target vector
  13800. * @param result defines the target vector
  13801. */
  13802. getScaleToRef(result: Vector3): void;
  13803. /**
  13804. * Set the yaw, pitch, and roll of the bone in local or world space
  13805. * @param yaw The rotation of the bone on the y axis
  13806. * @param pitch The rotation of the bone on the x axis
  13807. * @param roll The rotation of the bone on the z axis
  13808. * @param space The space that the axes of rotation are in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Add a rotation to the bone on an axis in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param amount The amount to rotate the bone
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the rotation of the bone to a particular axis angle in local or world space
  13822. * @param axis The axis to rotate the bone on
  13823. * @param angle The angle that the bone should be rotated to
  13824. * @param space The space that the axis is in
  13825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13826. */
  13827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13828. /**
  13829. * Set the euler rotation of the bone in local of world space
  13830. * @param rotation The euler rotation that the bone should be set to
  13831. * @param space The space that the rotation is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the quaternion rotation of the bone in local of world space
  13837. * @param quat The quaternion rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the rotation matrix of the bone in local of world space
  13844. * @param rotMat The rotation matrix that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13849. private _rotateWithMatrix;
  13850. private _getNegativeRotationToRef;
  13851. /**
  13852. * Get the position of the bone in local or world space
  13853. * @param space The space that the returned position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. * @returns The position of the bone
  13856. */
  13857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the position of the bone to a vector3 in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @param result The vector3 to copy the position to
  13863. */
  13864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13865. /**
  13866. * Get the absolute position of the bone (world space)
  13867. * @param mesh The mesh that this bone is attached to
  13868. * @returns The absolute position of the bone
  13869. */
  13870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13871. /**
  13872. * Copy the absolute position of the bone (world space) to the result param
  13873. * @param mesh The mesh that this bone is attached to
  13874. * @param result The vector3 to copy the absolute position to
  13875. */
  13876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13877. /**
  13878. * Compute the absolute transforms of this bone and its children
  13879. */
  13880. computeAbsoluteTransforms(): void;
  13881. /**
  13882. * Get the world direction from an axis that is in the local space of the bone
  13883. * @param localAxis The local direction that is used to compute the world direction
  13884. * @param mesh The mesh that this bone is attached to
  13885. * @returns The world direction
  13886. */
  13887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13888. /**
  13889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @param result The vector3 that the world direction will be copied to
  13893. */
  13894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13895. /**
  13896. * Get the euler rotation of the bone in local or world space
  13897. * @param space The space that the rotation should be in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The euler rotation
  13900. */
  13901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 that the rotation should be copied to
  13907. */
  13908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13909. /**
  13910. * Get the quaternion rotation of the bone in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @returns The quaternion rotation
  13914. */
  13915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13916. /**
  13917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @param result The quaternion that the rotation should be copied to
  13921. */
  13922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13923. /**
  13924. * Get the rotation matrix of the bone in local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @returns The rotation matrix
  13928. */
  13929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13930. /**
  13931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @param result The quaternion that the rotation should be copied to
  13935. */
  13936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13937. /**
  13938. * Get the world position of a point that is in the local space of the bone
  13939. * @param position The local position
  13940. * @param mesh The mesh that this bone is attached to
  13941. * @returns The world position
  13942. */
  13943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @param result The vector3 that the world position should be copied to
  13949. */
  13950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the local position of a point that is in world space
  13953. * @param position The world position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @returns The local position
  13956. */
  13957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13958. /**
  13959. * Get the local position of a point that is in world space and copy it to the result param
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @param result The vector3 that the local position should be copied to
  13963. */
  13964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13965. }
  13966. }
  13967. declare module "babylonjs/Meshes/transformNode" {
  13968. import { DeepImmutable } from "babylonjs/types";
  13969. import { Observable } from "babylonjs/Misc/observable";
  13970. import { Nullable } from "babylonjs/types";
  13971. import { Camera } from "babylonjs/Cameras/camera";
  13972. import { Scene } from "babylonjs/scene";
  13973. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13974. import { Node } from "babylonjs/node";
  13975. import { Bone } from "babylonjs/Bones/bone";
  13976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13977. import { Space } from "babylonjs/Maths/math.axis";
  13978. /**
  13979. * 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.
  13980. * @see https://doc.babylonjs.com/how_to/transformnode
  13981. */
  13982. export class TransformNode extends Node {
  13983. /**
  13984. * Object will not rotate to face the camera
  13985. */
  13986. static BILLBOARDMODE_NONE: number;
  13987. /**
  13988. * Object will rotate to face the camera but only on the x axis
  13989. */
  13990. static BILLBOARDMODE_X: number;
  13991. /**
  13992. * Object will rotate to face the camera but only on the y axis
  13993. */
  13994. static BILLBOARDMODE_Y: number;
  13995. /**
  13996. * Object will rotate to face the camera but only on the z axis
  13997. */
  13998. static BILLBOARDMODE_Z: number;
  13999. /**
  14000. * Object will rotate to face the camera
  14001. */
  14002. static BILLBOARDMODE_ALL: number;
  14003. /**
  14004. * Object will rotate to face the camera's position instead of orientation
  14005. */
  14006. static BILLBOARDMODE_USE_POSITION: number;
  14007. private _forward;
  14008. private _forwardInverted;
  14009. private _up;
  14010. private _right;
  14011. private _rightInverted;
  14012. private _position;
  14013. private _rotation;
  14014. private _rotationQuaternion;
  14015. protected _scaling: Vector3;
  14016. protected _isDirty: boolean;
  14017. private _transformToBoneReferal;
  14018. private _isAbsoluteSynced;
  14019. private _billboardMode;
  14020. /**
  14021. * Gets or sets the billboard mode. Default is 0.
  14022. *
  14023. * | Value | Type | Description |
  14024. * | --- | --- | --- |
  14025. * | 0 | BILLBOARDMODE_NONE | |
  14026. * | 1 | BILLBOARDMODE_X | |
  14027. * | 2 | BILLBOARDMODE_Y | |
  14028. * | 4 | BILLBOARDMODE_Z | |
  14029. * | 7 | BILLBOARDMODE_ALL | |
  14030. *
  14031. */
  14032. billboardMode: number;
  14033. private _preserveParentRotationForBillboard;
  14034. /**
  14035. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14036. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14037. */
  14038. preserveParentRotationForBillboard: boolean;
  14039. /**
  14040. * 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
  14041. */
  14042. scalingDeterminant: number;
  14043. private _infiniteDistance;
  14044. /**
  14045. * Gets or sets the distance of the object to max, often used by skybox
  14046. */
  14047. infiniteDistance: boolean;
  14048. /**
  14049. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14050. * By default the system will update normals to compensate
  14051. */
  14052. ignoreNonUniformScaling: boolean;
  14053. /**
  14054. * 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
  14055. */
  14056. reIntegrateRotationIntoRotationQuaternion: boolean;
  14057. /** @hidden */
  14058. _poseMatrix: Nullable<Matrix>;
  14059. /** @hidden */
  14060. _localMatrix: Matrix;
  14061. private _usePivotMatrix;
  14062. private _absolutePosition;
  14063. private _absoluteScaling;
  14064. private _absoluteRotationQuaternion;
  14065. private _pivotMatrix;
  14066. private _pivotMatrixInverse;
  14067. protected _postMultiplyPivotMatrix: boolean;
  14068. protected _isWorldMatrixFrozen: boolean;
  14069. /** @hidden */
  14070. _indexInSceneTransformNodesArray: number;
  14071. /**
  14072. * An event triggered after the world matrix is updated
  14073. */
  14074. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14075. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14076. /**
  14077. * Gets a string identifying the name of the class
  14078. * @returns "TransformNode" string
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14083. */
  14084. position: Vector3;
  14085. /**
  14086. * 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)).
  14087. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14088. */
  14089. rotation: Vector3;
  14090. /**
  14091. * 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)).
  14092. */
  14093. scaling: Vector3;
  14094. /**
  14095. * 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).
  14096. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14097. */
  14098. rotationQuaternion: Nullable<Quaternion>;
  14099. /**
  14100. * The forward direction of that transform in world space.
  14101. */
  14102. readonly forward: Vector3;
  14103. /**
  14104. * The up direction of that transform in world space.
  14105. */
  14106. readonly up: Vector3;
  14107. /**
  14108. * The right direction of that transform in world space.
  14109. */
  14110. readonly right: Vector3;
  14111. /**
  14112. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14113. * @param matrix the matrix to copy the pose from
  14114. * @returns this TransformNode.
  14115. */
  14116. updatePoseMatrix(matrix: Matrix): TransformNode;
  14117. /**
  14118. * Returns the mesh Pose matrix.
  14119. * @returns the pose matrix
  14120. */
  14121. getPoseMatrix(): Matrix;
  14122. /** @hidden */
  14123. _isSynchronized(): boolean;
  14124. /** @hidden */
  14125. _initCache(): void;
  14126. /**
  14127. * Flag the transform node as dirty (Forcing it to update everything)
  14128. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14129. * @returns this transform node
  14130. */
  14131. markAsDirty(property: string): TransformNode;
  14132. /**
  14133. * Returns the current mesh absolute position.
  14134. * Returns a Vector3.
  14135. */
  14136. readonly absolutePosition: Vector3;
  14137. /**
  14138. * Returns the current mesh absolute scaling.
  14139. * Returns a Vector3.
  14140. */
  14141. readonly absoluteScaling: Vector3;
  14142. /**
  14143. * Returns the current mesh absolute rotation.
  14144. * Returns a Quaternion.
  14145. */
  14146. readonly absoluteRotationQuaternion: Quaternion;
  14147. /**
  14148. * Sets a new matrix to apply before all other transformation
  14149. * @param matrix defines the transform matrix
  14150. * @returns the current TransformNode
  14151. */
  14152. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14153. /**
  14154. * Sets a new pivot matrix to the current node
  14155. * @param matrix defines the new pivot matrix to use
  14156. * @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
  14157. * @returns the current TransformNode
  14158. */
  14159. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14160. /**
  14161. * Returns the mesh pivot matrix.
  14162. * Default : Identity.
  14163. * @returns the matrix
  14164. */
  14165. getPivotMatrix(): Matrix;
  14166. /**
  14167. * Instantiate (when possible) or clone that node with its hierarchy
  14168. * @param newParent defines the new parent to use for the instance (or clone)
  14169. * @returns an instance (or a clone) of the current node with its hiearchy
  14170. */
  14171. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14172. /**
  14173. * Prevents the World matrix to be computed any longer
  14174. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14175. * @returns the TransformNode.
  14176. */
  14177. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14178. /**
  14179. * Allows back the World matrix computation.
  14180. * @returns the TransformNode.
  14181. */
  14182. unfreezeWorldMatrix(): this;
  14183. /**
  14184. * True if the World matrix has been frozen.
  14185. */
  14186. readonly isWorldMatrixFrozen: boolean;
  14187. /**
  14188. * Retuns the mesh absolute position in the World.
  14189. * @returns a Vector3.
  14190. */
  14191. getAbsolutePosition(): Vector3;
  14192. /**
  14193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14194. * @param absolutePosition the absolute position to set
  14195. * @returns the TransformNode.
  14196. */
  14197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14198. /**
  14199. * Sets the mesh position in its local space.
  14200. * @param vector3 the position to set in localspace
  14201. * @returns the TransformNode.
  14202. */
  14203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14204. /**
  14205. * Returns the mesh position in the local space from the current World matrix values.
  14206. * @returns a new Vector3.
  14207. */
  14208. getPositionExpressedInLocalSpace(): Vector3;
  14209. /**
  14210. * Translates the mesh along the passed Vector3 in its local space.
  14211. * @param vector3 the distance to translate in localspace
  14212. * @returns the TransformNode.
  14213. */
  14214. locallyTranslate(vector3: Vector3): TransformNode;
  14215. private static _lookAtVectorCache;
  14216. /**
  14217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14218. * @param targetPoint the position (must be in same space as current mesh) to look at
  14219. * @param yawCor optional yaw (y-axis) correction in radians
  14220. * @param pitchCor optional pitch (x-axis) correction in radians
  14221. * @param rollCor optional roll (z-axis) correction in radians
  14222. * @param space the choosen space of the target
  14223. * @returns the TransformNode.
  14224. */
  14225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14226. /**
  14227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14228. * This Vector3 is expressed in the World space.
  14229. * @param localAxis axis to rotate
  14230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14231. */
  14232. getDirection(localAxis: Vector3): Vector3;
  14233. /**
  14234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14235. * localAxis is expressed in the mesh local space.
  14236. * result is computed in the Wordl space from the mesh World matrix.
  14237. * @param localAxis axis to rotate
  14238. * @param result the resulting transformnode
  14239. * @returns this TransformNode.
  14240. */
  14241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14242. /**
  14243. * Sets this transform node rotation to the given local axis.
  14244. * @param localAxis the axis in local space
  14245. * @param yawCor optional yaw (y-axis) correction in radians
  14246. * @param pitchCor optional pitch (x-axis) correction in radians
  14247. * @param rollCor optional roll (z-axis) correction in radians
  14248. * @returns this TransformNode
  14249. */
  14250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14251. /**
  14252. * Sets a new pivot point to the current node
  14253. * @param point defines the new pivot point to use
  14254. * @param space defines if the point is in world or local space (local by default)
  14255. * @returns the current TransformNode
  14256. */
  14257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14258. /**
  14259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14260. * @returns the pivot point
  14261. */
  14262. getPivotPoint(): Vector3;
  14263. /**
  14264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14265. * @param result the vector3 to store the result
  14266. * @returns this TransformNode.
  14267. */
  14268. getPivotPointToRef(result: Vector3): TransformNode;
  14269. /**
  14270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14272. */
  14273. getAbsolutePivotPoint(): Vector3;
  14274. /**
  14275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14276. * @param result vector3 to store the result
  14277. * @returns this TransformNode.
  14278. */
  14279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14280. /**
  14281. * Defines the passed node as the parent of the current node.
  14282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14283. * @see https://doc.babylonjs.com/how_to/parenting
  14284. * @param node the node ot set as the parent
  14285. * @returns this TransformNode.
  14286. */
  14287. setParent(node: Nullable<Node>): TransformNode;
  14288. private _nonUniformScaling;
  14289. /**
  14290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14291. */
  14292. readonly nonUniformScaling: boolean;
  14293. /** @hidden */
  14294. _updateNonUniformScalingState(value: boolean): boolean;
  14295. /**
  14296. * Attach the current TransformNode to another TransformNode associated with a bone
  14297. * @param bone Bone affecting the TransformNode
  14298. * @param affectedTransformNode TransformNode associated with the bone
  14299. * @returns this object
  14300. */
  14301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14302. /**
  14303. * Detach the transform node if its associated with a bone
  14304. * @returns this object
  14305. */
  14306. detachFromBone(): TransformNode;
  14307. private static _rotationAxisCache;
  14308. /**
  14309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14312. * The passed axis is also normalized.
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @param space Space to rotate in (Default: local)
  14316. * @returns the TransformNode.
  14317. */
  14318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14319. /**
  14320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14322. * The passed axis is also normalized. .
  14323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14324. * @param point the point to rotate around
  14325. * @param axis the axis to rotate around
  14326. * @param amount the amount to rotate in radians
  14327. * @returns the TransformNode
  14328. */
  14329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14330. /**
  14331. * Translates the mesh along the axis vector for the passed distance in the given space.
  14332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14333. * @param axis the axis to translate in
  14334. * @param distance the distance to translate
  14335. * @param space Space to rotate in (Default: local)
  14336. * @returns the TransformNode.
  14337. */
  14338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14339. /**
  14340. * Adds a rotation step to the mesh current rotation.
  14341. * x, y, z are Euler angles expressed in radians.
  14342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14343. * This means this rotation is made in the mesh local space only.
  14344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14346. * ```javascript
  14347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14348. * ```
  14349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14350. * 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.
  14351. * @param x Rotation to add
  14352. * @param y Rotation to add
  14353. * @param z Rotation to add
  14354. * @returns the TransformNode.
  14355. */
  14356. addRotation(x: number, y: number, z: number): TransformNode;
  14357. /**
  14358. * @hidden
  14359. */
  14360. protected _getEffectiveParent(): Nullable<Node>;
  14361. /**
  14362. * Computes the world matrix of the node
  14363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14364. * @returns the world matrix
  14365. */
  14366. computeWorldMatrix(force?: boolean): Matrix;
  14367. protected _afterComputeWorldMatrix(): void;
  14368. /**
  14369. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14370. * @param func callback function to add
  14371. *
  14372. * @returns the TransformNode.
  14373. */
  14374. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14375. /**
  14376. * Removes a registered callback function.
  14377. * @param func callback function to remove
  14378. * @returns the TransformNode.
  14379. */
  14380. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14381. /**
  14382. * Gets the position of the current mesh in camera space
  14383. * @param camera defines the camera to use
  14384. * @returns a position
  14385. */
  14386. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14387. /**
  14388. * Returns the distance from the mesh to the active camera
  14389. * @param camera defines the camera to use
  14390. * @returns the distance
  14391. */
  14392. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14393. /**
  14394. * Clone the current transform node
  14395. * @param name Name of the new clone
  14396. * @param newParent New parent for the clone
  14397. * @param doNotCloneChildren Do not clone children hierarchy
  14398. * @returns the new transform node
  14399. */
  14400. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14401. /**
  14402. * Serializes the objects information.
  14403. * @param currentSerializationObject defines the object to serialize in
  14404. * @returns the serialized object
  14405. */
  14406. serialize(currentSerializationObject?: any): any;
  14407. /**
  14408. * Returns a new TransformNode object parsed from the source provided.
  14409. * @param parsedTransformNode is the source.
  14410. * @param scene the scne the object belongs to
  14411. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14412. * @returns a new TransformNode object parsed from the source provided.
  14413. */
  14414. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14415. /**
  14416. * Get all child-transformNodes of this node
  14417. * @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
  14418. * @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
  14419. * @returns an array of TransformNode
  14420. */
  14421. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14422. /**
  14423. * Releases resources associated with this transform node.
  14424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14426. */
  14427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14428. /**
  14429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14433. * @returns the current mesh
  14434. */
  14435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14436. private _syncAbsoluteScalingAndRotation;
  14437. }
  14438. }
  14439. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14440. import { Observable } from "babylonjs/Misc/observable";
  14441. import { Nullable } from "babylonjs/types";
  14442. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14445. import { Ray } from "babylonjs/Culling/ray";
  14446. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14447. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14449. /**
  14450. * Defines the types of pose enabled controllers that are supported
  14451. */
  14452. export enum PoseEnabledControllerType {
  14453. /**
  14454. * HTC Vive
  14455. */
  14456. VIVE = 0,
  14457. /**
  14458. * Oculus Rift
  14459. */
  14460. OCULUS = 1,
  14461. /**
  14462. * Windows mixed reality
  14463. */
  14464. WINDOWS = 2,
  14465. /**
  14466. * Samsung gear VR
  14467. */
  14468. GEAR_VR = 3,
  14469. /**
  14470. * Google Daydream
  14471. */
  14472. DAYDREAM = 4,
  14473. /**
  14474. * Generic
  14475. */
  14476. GENERIC = 5
  14477. }
  14478. /**
  14479. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14480. */
  14481. export interface MutableGamepadButton {
  14482. /**
  14483. * Value of the button/trigger
  14484. */
  14485. value: number;
  14486. /**
  14487. * If the button/trigger is currently touched
  14488. */
  14489. touched: boolean;
  14490. /**
  14491. * If the button/trigger is currently pressed
  14492. */
  14493. pressed: boolean;
  14494. }
  14495. /**
  14496. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14497. * @hidden
  14498. */
  14499. export interface ExtendedGamepadButton extends GamepadButton {
  14500. /**
  14501. * If the button/trigger is currently pressed
  14502. */
  14503. readonly pressed: boolean;
  14504. /**
  14505. * If the button/trigger is currently touched
  14506. */
  14507. readonly touched: boolean;
  14508. /**
  14509. * Value of the button/trigger
  14510. */
  14511. readonly value: number;
  14512. }
  14513. /** @hidden */
  14514. export interface _GamePadFactory {
  14515. /**
  14516. * Returns wether or not the current gamepad can be created for this type of controller.
  14517. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14518. * @returns true if it can be created, otherwise false
  14519. */
  14520. canCreate(gamepadInfo: any): boolean;
  14521. /**
  14522. * Creates a new instance of the Gamepad.
  14523. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14524. * @returns the new gamepad instance
  14525. */
  14526. create(gamepadInfo: any): Gamepad;
  14527. }
  14528. /**
  14529. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14530. */
  14531. export class PoseEnabledControllerHelper {
  14532. /** @hidden */
  14533. static _ControllerFactories: _GamePadFactory[];
  14534. /** @hidden */
  14535. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14536. /**
  14537. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14538. * @param vrGamepad the gamepad to initialized
  14539. * @returns a vr controller of the type the gamepad identified as
  14540. */
  14541. static InitiateController(vrGamepad: any): Gamepad;
  14542. }
  14543. /**
  14544. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14545. */
  14546. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14547. /**
  14548. * If the controller is used in a webXR session
  14549. */
  14550. isXR: boolean;
  14551. private _deviceRoomPosition;
  14552. private _deviceRoomRotationQuaternion;
  14553. /**
  14554. * The device position in babylon space
  14555. */
  14556. devicePosition: Vector3;
  14557. /**
  14558. * The device rotation in babylon space
  14559. */
  14560. deviceRotationQuaternion: Quaternion;
  14561. /**
  14562. * The scale factor of the device in babylon space
  14563. */
  14564. deviceScaleFactor: number;
  14565. /**
  14566. * (Likely devicePosition should be used instead) The device position in its room space
  14567. */
  14568. position: Vector3;
  14569. /**
  14570. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14571. */
  14572. rotationQuaternion: Quaternion;
  14573. /**
  14574. * The type of controller (Eg. Windows mixed reality)
  14575. */
  14576. controllerType: PoseEnabledControllerType;
  14577. protected _calculatedPosition: Vector3;
  14578. private _calculatedRotation;
  14579. /**
  14580. * The raw pose from the device
  14581. */
  14582. rawPose: DevicePose;
  14583. private _trackPosition;
  14584. private _maxRotationDistFromHeadset;
  14585. private _draggedRoomRotation;
  14586. /**
  14587. * @hidden
  14588. */
  14589. _disableTrackPosition(fixedPosition: Vector3): void;
  14590. /**
  14591. * Internal, the mesh attached to the controller
  14592. * @hidden
  14593. */
  14594. _mesh: Nullable<AbstractMesh>;
  14595. private _poseControlledCamera;
  14596. private _leftHandSystemQuaternion;
  14597. /**
  14598. * Internal, matrix used to convert room space to babylon space
  14599. * @hidden
  14600. */
  14601. _deviceToWorld: Matrix;
  14602. /**
  14603. * Node to be used when casting a ray from the controller
  14604. * @hidden
  14605. */
  14606. _pointingPoseNode: Nullable<TransformNode>;
  14607. /**
  14608. * Name of the child mesh that can be used to cast a ray from the controller
  14609. */
  14610. static readonly POINTING_POSE: string;
  14611. /**
  14612. * Creates a new PoseEnabledController from a gamepad
  14613. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14614. */
  14615. constructor(browserGamepad: any);
  14616. private _workingMatrix;
  14617. /**
  14618. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14619. */
  14620. update(): void;
  14621. /**
  14622. * Updates only the pose device and mesh without doing any button event checking
  14623. */
  14624. protected _updatePoseAndMesh(): void;
  14625. /**
  14626. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14627. * @param poseData raw pose fromthe device
  14628. */
  14629. updateFromDevice(poseData: DevicePose): void;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _meshAttachedObservable: Observable<AbstractMesh>;
  14634. /**
  14635. * Attaches a mesh to the controller
  14636. * @param mesh the mesh to be attached
  14637. */
  14638. attachToMesh(mesh: AbstractMesh): void;
  14639. /**
  14640. * Attaches the controllers mesh to a camera
  14641. * @param camera the camera the mesh should be attached to
  14642. */
  14643. attachToPoseControlledCamera(camera: TargetCamera): void;
  14644. /**
  14645. * Disposes of the controller
  14646. */
  14647. dispose(): void;
  14648. /**
  14649. * The mesh that is attached to the controller
  14650. */
  14651. readonly mesh: Nullable<AbstractMesh>;
  14652. /**
  14653. * Gets the ray of the controller in the direction the controller is pointing
  14654. * @param length the length the resulting ray should be
  14655. * @returns a ray in the direction the controller is pointing
  14656. */
  14657. getForwardRay(length?: number): Ray;
  14658. }
  14659. }
  14660. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14661. import { Observable } from "babylonjs/Misc/observable";
  14662. import { Scene } from "babylonjs/scene";
  14663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14664. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14665. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14666. /**
  14667. * Defines the WebVRController object that represents controllers tracked in 3D space
  14668. */
  14669. export abstract class WebVRController extends PoseEnabledController {
  14670. /**
  14671. * Internal, the default controller model for the controller
  14672. */
  14673. protected _defaultModel: AbstractMesh;
  14674. /**
  14675. * Fired when the trigger state has changed
  14676. */
  14677. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when the main button state has changed
  14680. */
  14681. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14682. /**
  14683. * Fired when the secondary button state has changed
  14684. */
  14685. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14686. /**
  14687. * Fired when the pad state has changed
  14688. */
  14689. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14690. /**
  14691. * Fired when controllers stick values have changed
  14692. */
  14693. onPadValuesChangedObservable: Observable<StickValues>;
  14694. /**
  14695. * Array of button availible on the controller
  14696. */
  14697. protected _buttons: Array<MutableGamepadButton>;
  14698. private _onButtonStateChange;
  14699. /**
  14700. * Fired when a controller button's state has changed
  14701. * @param callback the callback containing the button that was modified
  14702. */
  14703. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14704. /**
  14705. * X and Y axis corresponding to the controllers joystick
  14706. */
  14707. pad: StickValues;
  14708. /**
  14709. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14710. */
  14711. hand: string;
  14712. /**
  14713. * The default controller model for the controller
  14714. */
  14715. readonly defaultModel: AbstractMesh;
  14716. /**
  14717. * Creates a new WebVRController from a gamepad
  14718. * @param vrGamepad the gamepad that the WebVRController should be created from
  14719. */
  14720. constructor(vrGamepad: any);
  14721. /**
  14722. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14723. */
  14724. update(): void;
  14725. /**
  14726. * Function to be called when a button is modified
  14727. */
  14728. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14729. /**
  14730. * Loads a mesh and attaches it to the controller
  14731. * @param scene the scene the mesh should be added to
  14732. * @param meshLoaded callback for when the mesh has been loaded
  14733. */
  14734. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14735. private _setButtonValue;
  14736. private _changes;
  14737. private _checkChanges;
  14738. /**
  14739. * Disposes of th webVRCOntroller
  14740. */
  14741. dispose(): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Lights/hemisphericLight" {
  14745. import { Nullable } from "babylonjs/types";
  14746. import { Scene } from "babylonjs/scene";
  14747. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14748. import { Color3 } from "babylonjs/Maths/math.color";
  14749. import { Effect } from "babylonjs/Materials/effect";
  14750. import { Light } from "babylonjs/Lights/light";
  14751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14752. /**
  14753. * The HemisphericLight simulates the ambient environment light,
  14754. * so the passed direction is the light reflection direction, not the incoming direction.
  14755. */
  14756. export class HemisphericLight extends Light {
  14757. /**
  14758. * The groundColor is the light in the opposite direction to the one specified during creation.
  14759. * 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.
  14760. */
  14761. groundColor: Color3;
  14762. /**
  14763. * The light reflection direction, not the incoming direction.
  14764. */
  14765. direction: Vector3;
  14766. /**
  14767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14769. * The HemisphericLight can't cast shadows.
  14770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14771. * @param name The friendly name of the light
  14772. * @param direction The direction of the light reflection
  14773. * @param scene The scene the light belongs to
  14774. */
  14775. constructor(name: string, direction: Vector3, scene: Scene);
  14776. protected _buildUniformLayout(): void;
  14777. /**
  14778. * Returns the string "HemisphericLight".
  14779. * @return The class name
  14780. */
  14781. getClassName(): string;
  14782. /**
  14783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14784. * Returns the updated direction.
  14785. * @param target The target the direction should point to
  14786. * @return The computed direction
  14787. */
  14788. setDirectionToTarget(target: Vector3): Vector3;
  14789. /**
  14790. * Returns the shadow generator associated to the light.
  14791. * @returns Always null for hemispheric lights because it does not support shadows.
  14792. */
  14793. getShadowGenerator(): Nullable<IShadowGenerator>;
  14794. /**
  14795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14796. * @param effect The effect to update
  14797. * @param lightIndex The index of the light in the effect to update
  14798. * @returns The hemispheric light
  14799. */
  14800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14801. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14802. /**
  14803. * Computes the world matrix of the node
  14804. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14805. * @param useWasUpdatedFlag defines a reserved property
  14806. * @returns the world matrix
  14807. */
  14808. computeWorldMatrix(): Matrix;
  14809. /**
  14810. * Returns the integer 3.
  14811. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14812. */
  14813. getTypeID(): number;
  14814. /**
  14815. * Prepares the list of defines specific to the light type.
  14816. * @param defines the list of defines
  14817. * @param lightIndex defines the index of the light for the effect
  14818. */
  14819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14820. }
  14821. }
  14822. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14823. /** @hidden */
  14824. export var vrMultiviewToSingleviewPixelShader: {
  14825. name: string;
  14826. shader: string;
  14827. };
  14828. }
  14829. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14831. import { Scene } from "babylonjs/scene";
  14832. /**
  14833. * Renders to multiple views with a single draw call
  14834. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14835. */
  14836. export class MultiviewRenderTarget extends RenderTargetTexture {
  14837. /**
  14838. * Creates a multiview render target
  14839. * @param scene scene used with the render target
  14840. * @param size the size of the render target (used for each view)
  14841. */
  14842. constructor(scene: Scene, size?: number | {
  14843. width: number;
  14844. height: number;
  14845. } | {
  14846. ratio: number;
  14847. });
  14848. /**
  14849. * @hidden
  14850. * @param faceIndex the face index, if its a cube texture
  14851. */
  14852. _bindFrameBuffer(faceIndex?: number): void;
  14853. /**
  14854. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14855. * @returns the view count
  14856. */
  14857. getViewCount(): number;
  14858. }
  14859. }
  14860. declare module "babylonjs/Maths/math.frustum" {
  14861. import { Matrix } from "babylonjs/Maths/math.vector";
  14862. import { DeepImmutable } from "babylonjs/types";
  14863. import { Plane } from "babylonjs/Maths/math.plane";
  14864. /**
  14865. * Reprasents a camera frustum
  14866. */
  14867. export class Frustum {
  14868. /**
  14869. * Gets the planes representing the frustum
  14870. * @param transform matrix to be applied to the returned planes
  14871. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14872. */
  14873. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14874. /**
  14875. * Gets the near frustum plane transformed by the transform matrix
  14876. * @param transform transformation matrix to be applied to the resulting frustum plane
  14877. * @param frustumPlane the resuling frustum plane
  14878. */
  14879. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14880. /**
  14881. * Gets the far frustum plane transformed by the transform matrix
  14882. * @param transform transformation matrix to be applied to the resulting frustum plane
  14883. * @param frustumPlane the resuling frustum plane
  14884. */
  14885. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14886. /**
  14887. * Gets the left frustum plane transformed by the transform matrix
  14888. * @param transform transformation matrix to be applied to the resulting frustum plane
  14889. * @param frustumPlane the resuling frustum plane
  14890. */
  14891. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14892. /**
  14893. * Gets the right frustum plane transformed by the transform matrix
  14894. * @param transform transformation matrix to be applied to the resulting frustum plane
  14895. * @param frustumPlane the resuling frustum plane
  14896. */
  14897. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14898. /**
  14899. * Gets the top frustum plane transformed by the transform matrix
  14900. * @param transform transformation matrix to be applied to the resulting frustum plane
  14901. * @param frustumPlane the resuling frustum plane
  14902. */
  14903. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14904. /**
  14905. * Gets the bottom frustum plane transformed by the transform matrix
  14906. * @param transform transformation matrix to be applied to the resulting frustum plane
  14907. * @param frustumPlane the resuling frustum plane
  14908. */
  14909. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14910. /**
  14911. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14912. * @param transform transformation matrix to be applied to the resulting frustum planes
  14913. * @param frustumPlanes the resuling frustum planes
  14914. */
  14915. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14919. import { Camera } from "babylonjs/Cameras/camera";
  14920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14921. import { Nullable } from "babylonjs/types";
  14922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14923. import { Matrix } from "babylonjs/Maths/math.vector";
  14924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14925. module "babylonjs/Engines/engine" {
  14926. interface Engine {
  14927. /**
  14928. * Creates a new multiview render target
  14929. * @param width defines the width of the texture
  14930. * @param height defines the height of the texture
  14931. * @returns the created multiview texture
  14932. */
  14933. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14934. /**
  14935. * Binds a multiview framebuffer to be drawn to
  14936. * @param multiviewTexture texture to bind
  14937. */
  14938. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14939. }
  14940. }
  14941. module "babylonjs/Cameras/camera" {
  14942. interface Camera {
  14943. /**
  14944. * @hidden
  14945. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14946. */
  14947. _useMultiviewToSingleView: boolean;
  14948. /**
  14949. * @hidden
  14950. * 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)
  14951. */
  14952. _multiviewTexture: Nullable<RenderTargetTexture>;
  14953. /**
  14954. * @hidden
  14955. * ensures the multiview texture of the camera exists and has the specified width/height
  14956. * @param width height to set on the multiview texture
  14957. * @param height width to set on the multiview texture
  14958. */
  14959. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14960. }
  14961. }
  14962. module "babylonjs/scene" {
  14963. interface Scene {
  14964. /** @hidden */
  14965. _transformMatrixR: Matrix;
  14966. /** @hidden */
  14967. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14968. /** @hidden */
  14969. _createMultiviewUbo(): void;
  14970. /** @hidden */
  14971. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14972. /** @hidden */
  14973. _renderMultiviewToSingleView(camera: Camera): void;
  14974. }
  14975. }
  14976. }
  14977. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14978. import { Camera } from "babylonjs/Cameras/camera";
  14979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14980. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14981. import "babylonjs/Engines/Extensions/engine.multiview";
  14982. /**
  14983. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14984. * This will not be used for webXR as it supports displaying texture arrays directly
  14985. */
  14986. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14987. /**
  14988. * Initializes a VRMultiviewToSingleview
  14989. * @param name name of the post process
  14990. * @param camera camera to be applied to
  14991. * @param scaleFactor scaling factor to the size of the output texture
  14992. */
  14993. constructor(name: string, camera: Camera, scaleFactor: number);
  14994. }
  14995. }
  14996. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14997. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14998. import { Nullable } from "babylonjs/types";
  14999. import { Size } from "babylonjs/Maths/math.size";
  15000. import { Observable } from "babylonjs/Misc/observable";
  15001. module "babylonjs/Engines/engine" {
  15002. interface Engine {
  15003. /** @hidden */
  15004. _vrDisplay: any;
  15005. /** @hidden */
  15006. _vrSupported: boolean;
  15007. /** @hidden */
  15008. _oldSize: Size;
  15009. /** @hidden */
  15010. _oldHardwareScaleFactor: number;
  15011. /** @hidden */
  15012. _vrExclusivePointerMode: boolean;
  15013. /** @hidden */
  15014. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15015. /** @hidden */
  15016. _onVRDisplayPointerRestricted: () => void;
  15017. /** @hidden */
  15018. _onVRDisplayPointerUnrestricted: () => void;
  15019. /** @hidden */
  15020. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15021. /** @hidden */
  15022. _onVrDisplayDisconnect: Nullable<() => void>;
  15023. /** @hidden */
  15024. _onVrDisplayPresentChange: Nullable<() => void>;
  15025. /**
  15026. * Observable signaled when VR display mode changes
  15027. */
  15028. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15029. /**
  15030. * Observable signaled when VR request present is complete
  15031. */
  15032. onVRRequestPresentComplete: Observable<boolean>;
  15033. /**
  15034. * Observable signaled when VR request present starts
  15035. */
  15036. onVRRequestPresentStart: Observable<Engine>;
  15037. /**
  15038. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15039. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15040. */
  15041. isInVRExclusivePointerMode: boolean;
  15042. /**
  15043. * Gets a boolean indicating if a webVR device was detected
  15044. * @returns true if a webVR device was detected
  15045. */
  15046. isVRDevicePresent(): boolean;
  15047. /**
  15048. * Gets the current webVR device
  15049. * @returns the current webVR device (or null)
  15050. */
  15051. getVRDevice(): any;
  15052. /**
  15053. * Initializes a webVR display and starts listening to display change events
  15054. * The onVRDisplayChangedObservable will be notified upon these changes
  15055. * @returns A promise containing a VRDisplay and if vr is supported
  15056. */
  15057. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15060. /**
  15061. * Call this function to switch to webVR mode
  15062. * Will do nothing if webVR is not supported or if there is no webVR device
  15063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15064. */
  15065. enableVR(): void;
  15066. /** @hidden */
  15067. _onVRFullScreenTriggered(): void;
  15068. }
  15069. }
  15070. }
  15071. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15072. import { Nullable } from "babylonjs/types";
  15073. import { Observable } from "babylonjs/Misc/observable";
  15074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15075. import { Scene } from "babylonjs/scene";
  15076. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15078. import { Node } from "babylonjs/node";
  15079. import { Ray } from "babylonjs/Culling/ray";
  15080. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15081. import "babylonjs/Engines/Extensions/engine.webVR";
  15082. /**
  15083. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15084. * IMPORTANT!! The data is right-hand data.
  15085. * @export
  15086. * @interface DevicePose
  15087. */
  15088. export interface DevicePose {
  15089. /**
  15090. * The position of the device, values in array are [x,y,z].
  15091. */
  15092. readonly position: Nullable<Float32Array>;
  15093. /**
  15094. * The linearVelocity of the device, values in array are [x,y,z].
  15095. */
  15096. readonly linearVelocity: Nullable<Float32Array>;
  15097. /**
  15098. * The linearAcceleration of the device, values in array are [x,y,z].
  15099. */
  15100. readonly linearAcceleration: Nullable<Float32Array>;
  15101. /**
  15102. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15103. */
  15104. readonly orientation: Nullable<Float32Array>;
  15105. /**
  15106. * The angularVelocity of the device, values in array are [x,y,z].
  15107. */
  15108. readonly angularVelocity: Nullable<Float32Array>;
  15109. /**
  15110. * The angularAcceleration of the device, values in array are [x,y,z].
  15111. */
  15112. readonly angularAcceleration: Nullable<Float32Array>;
  15113. }
  15114. /**
  15115. * Interface representing a pose controlled object in Babylon.
  15116. * A pose controlled object has both regular pose values as well as pose values
  15117. * from an external device such as a VR head mounted display
  15118. */
  15119. export interface PoseControlled {
  15120. /**
  15121. * The position of the object in babylon space.
  15122. */
  15123. position: Vector3;
  15124. /**
  15125. * The rotation quaternion of the object in babylon space.
  15126. */
  15127. rotationQuaternion: Quaternion;
  15128. /**
  15129. * The position of the device in babylon space.
  15130. */
  15131. devicePosition?: Vector3;
  15132. /**
  15133. * The rotation quaternion of the device in babylon space.
  15134. */
  15135. deviceRotationQuaternion: Quaternion;
  15136. /**
  15137. * The raw pose coming from the device.
  15138. */
  15139. rawPose: Nullable<DevicePose>;
  15140. /**
  15141. * The scale of the device to be used when translating from device space to babylon space.
  15142. */
  15143. deviceScaleFactor: number;
  15144. /**
  15145. * Updates the poseControlled values based on the input device pose.
  15146. * @param poseData the pose data to update the object with
  15147. */
  15148. updateFromDevice(poseData: DevicePose): void;
  15149. }
  15150. /**
  15151. * Set of options to customize the webVRCamera
  15152. */
  15153. export interface WebVROptions {
  15154. /**
  15155. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15156. */
  15157. trackPosition?: boolean;
  15158. /**
  15159. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15160. */
  15161. positionScale?: number;
  15162. /**
  15163. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15164. */
  15165. displayName?: string;
  15166. /**
  15167. * Should the native controller meshes be initialized. (default: true)
  15168. */
  15169. controllerMeshes?: boolean;
  15170. /**
  15171. * Creating a default HemiLight only on controllers. (default: true)
  15172. */
  15173. defaultLightingOnControllers?: boolean;
  15174. /**
  15175. * If you don't want to use the default VR button of the helper. (default: false)
  15176. */
  15177. useCustomVRButton?: boolean;
  15178. /**
  15179. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15180. */
  15181. customVRButton?: HTMLButtonElement;
  15182. /**
  15183. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15184. */
  15185. rayLength?: number;
  15186. /**
  15187. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15188. */
  15189. defaultHeight?: number;
  15190. /**
  15191. * If multiview should be used if availible (default: false)
  15192. */
  15193. useMultiview?: boolean;
  15194. }
  15195. /**
  15196. * This represents a WebVR camera.
  15197. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15198. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15199. */
  15200. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15201. private webVROptions;
  15202. /**
  15203. * @hidden
  15204. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15205. */
  15206. _vrDevice: any;
  15207. /**
  15208. * The rawPose of the vrDevice.
  15209. */
  15210. rawPose: Nullable<DevicePose>;
  15211. private _onVREnabled;
  15212. private _specsVersion;
  15213. private _attached;
  15214. private _frameData;
  15215. protected _descendants: Array<Node>;
  15216. private _deviceRoomPosition;
  15217. /** @hidden */
  15218. _deviceRoomRotationQuaternion: Quaternion;
  15219. private _standingMatrix;
  15220. /**
  15221. * Represents device position in babylon space.
  15222. */
  15223. devicePosition: Vector3;
  15224. /**
  15225. * Represents device rotation in babylon space.
  15226. */
  15227. deviceRotationQuaternion: Quaternion;
  15228. /**
  15229. * The scale of the device to be used when translating from device space to babylon space.
  15230. */
  15231. deviceScaleFactor: number;
  15232. private _deviceToWorld;
  15233. private _worldToDevice;
  15234. /**
  15235. * References to the webVR controllers for the vrDevice.
  15236. */
  15237. controllers: Array<WebVRController>;
  15238. /**
  15239. * Emits an event when a controller is attached.
  15240. */
  15241. onControllersAttachedObservable: Observable<WebVRController[]>;
  15242. /**
  15243. * Emits an event when a controller's mesh has been loaded;
  15244. */
  15245. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15246. /**
  15247. * Emits an event when the HMD's pose has been updated.
  15248. */
  15249. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15250. private _poseSet;
  15251. /**
  15252. * If the rig cameras be used as parent instead of this camera.
  15253. */
  15254. rigParenting: boolean;
  15255. private _lightOnControllers;
  15256. private _defaultHeight?;
  15257. /**
  15258. * Instantiates a WebVRFreeCamera.
  15259. * @param name The name of the WebVRFreeCamera
  15260. * @param position The starting anchor position for the camera
  15261. * @param scene The scene the camera belongs to
  15262. * @param webVROptions a set of customizable options for the webVRCamera
  15263. */
  15264. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15265. /**
  15266. * Gets the device distance from the ground in meters.
  15267. * @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.
  15268. */
  15269. deviceDistanceToRoomGround(): number;
  15270. /**
  15271. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15272. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15273. */
  15274. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15275. /**
  15276. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15277. * @returns A promise with a boolean set to if the standing matrix is supported.
  15278. */
  15279. useStandingMatrixAsync(): Promise<boolean>;
  15280. /**
  15281. * Disposes the camera
  15282. */
  15283. dispose(): void;
  15284. /**
  15285. * Gets a vrController by name.
  15286. * @param name The name of the controller to retreive
  15287. * @returns the controller matching the name specified or null if not found
  15288. */
  15289. getControllerByName(name: string): Nullable<WebVRController>;
  15290. private _leftController;
  15291. /**
  15292. * The controller corresponding to the users left hand.
  15293. */
  15294. readonly leftController: Nullable<WebVRController>;
  15295. private _rightController;
  15296. /**
  15297. * The controller corresponding to the users right hand.
  15298. */
  15299. readonly rightController: Nullable<WebVRController>;
  15300. /**
  15301. * Casts a ray forward from the vrCamera's gaze.
  15302. * @param length Length of the ray (default: 100)
  15303. * @returns the ray corresponding to the gaze
  15304. */
  15305. getForwardRay(length?: number): Ray;
  15306. /**
  15307. * @hidden
  15308. * Updates the camera based on device's frame data
  15309. */
  15310. _checkInputs(): void;
  15311. /**
  15312. * Updates the poseControlled values based on the input device pose.
  15313. * @param poseData Pose coming from the device
  15314. */
  15315. updateFromDevice(poseData: DevicePose): void;
  15316. private _htmlElementAttached;
  15317. private _detachIfAttached;
  15318. /**
  15319. * WebVR's attach control will start broadcasting frames to the device.
  15320. * Note that in certain browsers (chrome for example) this function must be called
  15321. * within a user-interaction callback. Example:
  15322. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15323. *
  15324. * @param element html element to attach the vrDevice to
  15325. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15326. */
  15327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15328. /**
  15329. * Detaches the camera from the html element and disables VR
  15330. *
  15331. * @param element html element to detach from
  15332. */
  15333. detachControl(element: HTMLElement): void;
  15334. /**
  15335. * @returns the name of this class
  15336. */
  15337. getClassName(): string;
  15338. /**
  15339. * Calls resetPose on the vrDisplay
  15340. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15341. */
  15342. resetToCurrentRotation(): void;
  15343. /**
  15344. * @hidden
  15345. * Updates the rig cameras (left and right eye)
  15346. */
  15347. _updateRigCameras(): void;
  15348. private _workingVector;
  15349. private _oneVector;
  15350. private _workingMatrix;
  15351. private updateCacheCalled;
  15352. private _correctPositionIfNotTrackPosition;
  15353. /**
  15354. * @hidden
  15355. * Updates the cached values of the camera
  15356. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15357. */
  15358. _updateCache(ignoreParentClass?: boolean): void;
  15359. /**
  15360. * @hidden
  15361. * Get current device position in babylon world
  15362. */
  15363. _computeDevicePosition(): void;
  15364. /**
  15365. * Updates the current device position and rotation in the babylon world
  15366. */
  15367. update(): void;
  15368. /**
  15369. * @hidden
  15370. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15371. * @returns an identity matrix
  15372. */
  15373. _getViewMatrix(): Matrix;
  15374. private _tmpMatrix;
  15375. /**
  15376. * This function is called by the two RIG cameras.
  15377. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15378. * @hidden
  15379. */
  15380. _getWebVRViewMatrix(): Matrix;
  15381. /** @hidden */
  15382. _getWebVRProjectionMatrix(): Matrix;
  15383. private _onGamepadConnectedObserver;
  15384. private _onGamepadDisconnectedObserver;
  15385. private _updateCacheWhenTrackingDisabledObserver;
  15386. /**
  15387. * Initializes the controllers and their meshes
  15388. */
  15389. initControllers(): void;
  15390. }
  15391. }
  15392. declare module "babylonjs/PostProcesses/postProcess" {
  15393. import { Nullable } from "babylonjs/types";
  15394. import { SmartArray } from "babylonjs/Misc/smartArray";
  15395. import { Observable } from "babylonjs/Misc/observable";
  15396. import { Vector2 } from "babylonjs/Maths/math.vector";
  15397. import { Camera } from "babylonjs/Cameras/camera";
  15398. import { Effect } from "babylonjs/Materials/effect";
  15399. import "babylonjs/Shaders/postprocess.vertex";
  15400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15401. import { Engine } from "babylonjs/Engines/engine";
  15402. import { Color4 } from "babylonjs/Maths/math.color";
  15403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15404. /**
  15405. * Size options for a post process
  15406. */
  15407. export type PostProcessOptions = {
  15408. width: number;
  15409. height: number;
  15410. };
  15411. /**
  15412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15414. */
  15415. export class PostProcess {
  15416. /** Name of the PostProcess. */
  15417. name: string;
  15418. /**
  15419. * Gets or sets the unique id of the post process
  15420. */
  15421. uniqueId: number;
  15422. /**
  15423. * Width of the texture to apply the post process on
  15424. */
  15425. width: number;
  15426. /**
  15427. * Height of the texture to apply the post process on
  15428. */
  15429. height: number;
  15430. /**
  15431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15432. * @hidden
  15433. */
  15434. _outputTexture: Nullable<InternalTexture>;
  15435. /**
  15436. * Sampling mode used by the shader
  15437. * See https://doc.babylonjs.com/classes/3.1/texture
  15438. */
  15439. renderTargetSamplingMode: number;
  15440. /**
  15441. * Clear color to use when screen clearing
  15442. */
  15443. clearColor: Color4;
  15444. /**
  15445. * If the buffer needs to be cleared before applying the post process. (default: true)
  15446. * Should be set to false if shader will overwrite all previous pixels.
  15447. */
  15448. autoClear: boolean;
  15449. /**
  15450. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15451. */
  15452. alphaMode: number;
  15453. /**
  15454. * Sets the setAlphaBlendConstants of the babylon engine
  15455. */
  15456. alphaConstants: Color4;
  15457. /**
  15458. * Animations to be used for the post processing
  15459. */
  15460. animations: import("babylonjs/Animations/animation").Animation[];
  15461. /**
  15462. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15463. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15464. */
  15465. enablePixelPerfectMode: boolean;
  15466. /**
  15467. * Force the postprocess to be applied without taking in account viewport
  15468. */
  15469. forceFullscreenViewport: boolean;
  15470. /**
  15471. * List of inspectable custom properties (used by the Inspector)
  15472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15473. */
  15474. inspectableCustomProperties: IInspectable[];
  15475. /**
  15476. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15477. *
  15478. * | Value | Type | Description |
  15479. * | ----- | ----------------------------------- | ----------- |
  15480. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15481. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15482. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15483. *
  15484. */
  15485. scaleMode: number;
  15486. /**
  15487. * Force textures to be a power of two (default: false)
  15488. */
  15489. alwaysForcePOT: boolean;
  15490. private _samples;
  15491. /**
  15492. * Number of sample textures (default: 1)
  15493. */
  15494. samples: number;
  15495. /**
  15496. * Modify the scale of the post process to be the same as the viewport (default: false)
  15497. */
  15498. adaptScaleToCurrentViewport: boolean;
  15499. private _camera;
  15500. private _scene;
  15501. private _engine;
  15502. private _options;
  15503. private _reusable;
  15504. private _textureType;
  15505. /**
  15506. * Smart array of input and output textures for the post process.
  15507. * @hidden
  15508. */
  15509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15510. /**
  15511. * The index in _textures that corresponds to the output texture.
  15512. * @hidden
  15513. */
  15514. _currentRenderTextureInd: number;
  15515. private _effect;
  15516. private _samplers;
  15517. private _fragmentUrl;
  15518. private _vertexUrl;
  15519. private _parameters;
  15520. private _scaleRatio;
  15521. protected _indexParameters: any;
  15522. private _shareOutputWithPostProcess;
  15523. private _texelSize;
  15524. private _forcedOutputTexture;
  15525. /**
  15526. * Returns the fragment url or shader name used in the post process.
  15527. * @returns the fragment url or name in the shader store.
  15528. */
  15529. getEffectName(): string;
  15530. /**
  15531. * An event triggered when the postprocess is activated.
  15532. */
  15533. onActivateObservable: Observable<Camera>;
  15534. private _onActivateObserver;
  15535. /**
  15536. * A function that is added to the onActivateObservable
  15537. */
  15538. onActivate: Nullable<(camera: Camera) => void>;
  15539. /**
  15540. * An event triggered when the postprocess changes its size.
  15541. */
  15542. onSizeChangedObservable: Observable<PostProcess>;
  15543. private _onSizeChangedObserver;
  15544. /**
  15545. * A function that is added to the onSizeChangedObservable
  15546. */
  15547. onSizeChanged: (postProcess: PostProcess) => void;
  15548. /**
  15549. * An event triggered when the postprocess applies its effect.
  15550. */
  15551. onApplyObservable: Observable<Effect>;
  15552. private _onApplyObserver;
  15553. /**
  15554. * A function that is added to the onApplyObservable
  15555. */
  15556. onApply: (effect: Effect) => void;
  15557. /**
  15558. * An event triggered before rendering the postprocess
  15559. */
  15560. onBeforeRenderObservable: Observable<Effect>;
  15561. private _onBeforeRenderObserver;
  15562. /**
  15563. * A function that is added to the onBeforeRenderObservable
  15564. */
  15565. onBeforeRender: (effect: Effect) => void;
  15566. /**
  15567. * An event triggered after rendering the postprocess
  15568. */
  15569. onAfterRenderObservable: Observable<Effect>;
  15570. private _onAfterRenderObserver;
  15571. /**
  15572. * A function that is added to the onAfterRenderObservable
  15573. */
  15574. onAfterRender: (efect: Effect) => void;
  15575. /**
  15576. * 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
  15577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15578. */
  15579. inputTexture: InternalTexture;
  15580. /**
  15581. * Gets the camera which post process is applied to.
  15582. * @returns The camera the post process is applied to.
  15583. */
  15584. getCamera(): Camera;
  15585. /**
  15586. * Gets the texel size of the postprocess.
  15587. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15588. */
  15589. readonly texelSize: Vector2;
  15590. /**
  15591. * Creates a new instance PostProcess
  15592. * @param name The name of the PostProcess.
  15593. * @param fragmentUrl The url of the fragment shader to be used.
  15594. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15595. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15596. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15597. * @param camera The camera to apply the render pass to.
  15598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15599. * @param engine The engine which the post process will be applied. (default: current engine)
  15600. * @param reusable If the post process can be reused on the same frame. (default: false)
  15601. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15602. * @param textureType Type of textures used when performing the post process. (default: 0)
  15603. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15604. * @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
  15605. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15606. */
  15607. constructor(
  15608. /** Name of the PostProcess. */
  15609. 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);
  15610. /**
  15611. * Gets a string idenfifying the name of the class
  15612. * @returns "PostProcess" string
  15613. */
  15614. getClassName(): string;
  15615. /**
  15616. * Gets the engine which this post process belongs to.
  15617. * @returns The engine the post process was enabled with.
  15618. */
  15619. getEngine(): Engine;
  15620. /**
  15621. * The effect that is created when initializing the post process.
  15622. * @returns The created effect corresponding the the postprocess.
  15623. */
  15624. getEffect(): Effect;
  15625. /**
  15626. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15627. * @param postProcess The post process to share the output with.
  15628. * @returns This post process.
  15629. */
  15630. shareOutputWith(postProcess: PostProcess): PostProcess;
  15631. /**
  15632. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15633. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15634. */
  15635. useOwnOutput(): void;
  15636. /**
  15637. * Updates the effect with the current post process compile time values and recompiles the shader.
  15638. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15639. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15640. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15641. * @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
  15642. * @param onCompiled Called when the shader has been compiled.
  15643. * @param onError Called if there is an error when compiling a shader.
  15644. */
  15645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15646. /**
  15647. * The post process is reusable if it can be used multiple times within one frame.
  15648. * @returns If the post process is reusable
  15649. */
  15650. isReusable(): boolean;
  15651. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15652. markTextureDirty(): void;
  15653. /**
  15654. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15655. * 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.
  15656. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15657. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15658. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15659. * @returns The target texture that was bound to be written to.
  15660. */
  15661. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15662. /**
  15663. * If the post process is supported.
  15664. */
  15665. readonly isSupported: boolean;
  15666. /**
  15667. * The aspect ratio of the output texture.
  15668. */
  15669. readonly aspectRatio: number;
  15670. /**
  15671. * Get a value indicating if the post-process is ready to be used
  15672. * @returns true if the post-process is ready (shader is compiled)
  15673. */
  15674. isReady(): boolean;
  15675. /**
  15676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15677. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15678. */
  15679. apply(): Nullable<Effect>;
  15680. private _disposeTextures;
  15681. /**
  15682. * Disposes the post process.
  15683. * @param camera The camera to dispose the post process on.
  15684. */
  15685. dispose(camera?: Camera): void;
  15686. }
  15687. }
  15688. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15689. /** @hidden */
  15690. export var kernelBlurVaryingDeclaration: {
  15691. name: string;
  15692. shader: string;
  15693. };
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15696. /** @hidden */
  15697. export var kernelBlurFragment: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment2: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15710. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15711. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15712. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15713. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15714. /** @hidden */
  15715. export var kernelBlurPixelShader: {
  15716. name: string;
  15717. shader: string;
  15718. };
  15719. }
  15720. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15721. /** @hidden */
  15722. export var kernelBlurVertex: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15728. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15729. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15730. /** @hidden */
  15731. export var kernelBlurVertexShader: {
  15732. name: string;
  15733. shader: string;
  15734. };
  15735. }
  15736. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15737. import { Vector2 } from "babylonjs/Maths/math.vector";
  15738. import { Nullable } from "babylonjs/types";
  15739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15740. import { Camera } from "babylonjs/Cameras/camera";
  15741. import { Effect } from "babylonjs/Materials/effect";
  15742. import { Engine } from "babylonjs/Engines/engine";
  15743. import "babylonjs/Shaders/kernelBlur.fragment";
  15744. import "babylonjs/Shaders/kernelBlur.vertex";
  15745. /**
  15746. * The Blur Post Process which blurs an image based on a kernel and direction.
  15747. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15748. */
  15749. export class BlurPostProcess extends PostProcess {
  15750. /** The direction in which to blur the image. */
  15751. direction: Vector2;
  15752. private blockCompilation;
  15753. protected _kernel: number;
  15754. protected _idealKernel: number;
  15755. protected _packedFloat: boolean;
  15756. private _staticDefines;
  15757. /**
  15758. * Sets the length in pixels of the blur sample region
  15759. */
  15760. /**
  15761. * Gets the length in pixels of the blur sample region
  15762. */
  15763. kernel: number;
  15764. /**
  15765. * Sets wether or not the blur needs to unpack/repack floats
  15766. */
  15767. /**
  15768. * Gets wether or not the blur is unpacking/repacking floats
  15769. */
  15770. packedFloat: boolean;
  15771. /**
  15772. * Creates a new instance BlurPostProcess
  15773. * @param name The name of the effect.
  15774. * @param direction The direction in which to blur the image.
  15775. * @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.
  15776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15777. * @param camera The camera to apply the render pass to.
  15778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15779. * @param engine The engine which the post process will be applied. (default: current engine)
  15780. * @param reusable If the post process can be reused on the same frame. (default: false)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @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)
  15783. */
  15784. constructor(name: string,
  15785. /** The direction in which to blur the image. */
  15786. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15787. /**
  15788. * Updates the effect with the current post process compile time values and recompiles the shader.
  15789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15792. * @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
  15793. * @param onCompiled Called when the shader has been compiled.
  15794. * @param onError Called if there is an error when compiling a shader.
  15795. */
  15796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15797. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15798. /**
  15799. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15800. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15801. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15802. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15803. * The gaps between physical kernels are compensated for in the weighting of the samples
  15804. * @param idealKernel Ideal blur kernel.
  15805. * @return Nearest best kernel.
  15806. */
  15807. protected _nearestBestKernel(idealKernel: number): number;
  15808. /**
  15809. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15810. * @param x The point on the Gaussian distribution to sample.
  15811. * @return the value of the Gaussian function at x.
  15812. */
  15813. protected _gaussianWeight(x: number): number;
  15814. /**
  15815. * Generates a string that can be used as a floating point number in GLSL.
  15816. * @param x Value to print.
  15817. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15818. * @return GLSL float string.
  15819. */
  15820. protected _glslFloat(x: number, decimalFigures?: number): string;
  15821. }
  15822. }
  15823. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15824. import { Scene } from "babylonjs/scene";
  15825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15826. import { Plane } from "babylonjs/Maths/math.plane";
  15827. /**
  15828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15830. * You can then easily use it as a reflectionTexture on a flat surface.
  15831. * In case the surface is not a plane, please consider relying on reflection probes.
  15832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15833. */
  15834. export class MirrorTexture extends RenderTargetTexture {
  15835. private scene;
  15836. /**
  15837. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15838. * 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.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. mirrorPlane: Plane;
  15842. /**
  15843. * Define the blur ratio used to blur the reflection if needed.
  15844. */
  15845. blurRatio: number;
  15846. /**
  15847. * Define the adaptive blur kernel used to blur the reflection if needed.
  15848. * This will autocompute the closest best match for the `blurKernel`
  15849. */
  15850. adaptiveBlurKernel: number;
  15851. /**
  15852. * Define the blur kernel used to blur the reflection if needed.
  15853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15854. */
  15855. blurKernel: number;
  15856. /**
  15857. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15859. */
  15860. blurKernelX: number;
  15861. /**
  15862. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15863. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15864. */
  15865. blurKernelY: number;
  15866. private _autoComputeBlurKernel;
  15867. protected _onRatioRescale(): void;
  15868. private _updateGammaSpace;
  15869. private _imageProcessingConfigChangeObserver;
  15870. private _transformMatrix;
  15871. private _mirrorMatrix;
  15872. private _savedViewMatrix;
  15873. private _blurX;
  15874. private _blurY;
  15875. private _adaptiveBlurKernel;
  15876. private _blurKernelX;
  15877. private _blurKernelY;
  15878. private _blurRatio;
  15879. /**
  15880. * Instantiates a Mirror Texture.
  15881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15883. * You can then easily use it as a reflectionTexture on a flat surface.
  15884. * In case the surface is not a plane, please consider relying on reflection probes.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. * @param name
  15887. * @param size
  15888. * @param scene
  15889. * @param generateMipMaps
  15890. * @param type
  15891. * @param samplingMode
  15892. * @param generateDepthBuffer
  15893. */
  15894. constructor(name: string, size: number | {
  15895. width: number;
  15896. height: number;
  15897. } | {
  15898. ratio: number;
  15899. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15900. private _preparePostProcesses;
  15901. /**
  15902. * Clone the mirror texture.
  15903. * @returns the cloned texture
  15904. */
  15905. clone(): MirrorTexture;
  15906. /**
  15907. * Serialize the texture to a JSON representation you could use in Parse later on
  15908. * @returns the serialized JSON representation
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Dispose the texture and release its associated resources.
  15913. */
  15914. dispose(): void;
  15915. }
  15916. }
  15917. declare module "babylonjs/Materials/Textures/texture" {
  15918. import { Observable } from "babylonjs/Misc/observable";
  15919. import { Nullable } from "babylonjs/types";
  15920. import { Scene } from "babylonjs/scene";
  15921. import { Matrix } from "babylonjs/Maths/math.vector";
  15922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15923. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15924. import { Engine } from "babylonjs/Engines/engine";
  15925. /**
  15926. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15927. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15928. */
  15929. export class Texture extends BaseTexture {
  15930. /** @hidden */
  15931. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15932. /** @hidden */
  15933. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15934. /** @hidden */
  15935. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15936. /** nearest is mag = nearest and min = nearest and mip = linear */
  15937. static readonly NEAREST_SAMPLINGMODE: number;
  15938. /** nearest is mag = nearest and min = nearest and mip = linear */
  15939. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15941. static readonly BILINEAR_SAMPLINGMODE: number;
  15942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15943. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15944. /** Trilinear is mag = linear and min = linear and mip = linear */
  15945. static readonly TRILINEAR_SAMPLINGMODE: number;
  15946. /** Trilinear is mag = linear and min = linear and mip = linear */
  15947. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15948. /** mag = nearest and min = nearest and mip = nearest */
  15949. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15950. /** mag = nearest and min = linear and mip = nearest */
  15951. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15952. /** mag = nearest and min = linear and mip = linear */
  15953. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15954. /** mag = nearest and min = linear and mip = none */
  15955. static readonly NEAREST_LINEAR: number;
  15956. /** mag = nearest and min = nearest and mip = none */
  15957. static readonly NEAREST_NEAREST: number;
  15958. /** mag = linear and min = nearest and mip = nearest */
  15959. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15960. /** mag = linear and min = nearest and mip = linear */
  15961. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15962. /** mag = linear and min = linear and mip = none */
  15963. static readonly LINEAR_LINEAR: number;
  15964. /** mag = linear and min = nearest and mip = none */
  15965. static readonly LINEAR_NEAREST: number;
  15966. /** Explicit coordinates mode */
  15967. static readonly EXPLICIT_MODE: number;
  15968. /** Spherical coordinates mode */
  15969. static readonly SPHERICAL_MODE: number;
  15970. /** Planar coordinates mode */
  15971. static readonly PLANAR_MODE: number;
  15972. /** Cubic coordinates mode */
  15973. static readonly CUBIC_MODE: number;
  15974. /** Projection coordinates mode */
  15975. static readonly PROJECTION_MODE: number;
  15976. /** Inverse Cubic coordinates mode */
  15977. static readonly SKYBOX_MODE: number;
  15978. /** Inverse Cubic coordinates mode */
  15979. static readonly INVCUBIC_MODE: number;
  15980. /** Equirectangular coordinates mode */
  15981. static readonly EQUIRECTANGULAR_MODE: number;
  15982. /** Equirectangular Fixed coordinates mode */
  15983. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15984. /** Equirectangular Fixed Mirrored coordinates mode */
  15985. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15986. /** Texture is not repeating outside of 0..1 UVs */
  15987. static readonly CLAMP_ADDRESSMODE: number;
  15988. /** Texture is repeating outside of 0..1 UVs */
  15989. static readonly WRAP_ADDRESSMODE: number;
  15990. /** Texture is repeating and mirrored */
  15991. static readonly MIRROR_ADDRESSMODE: number;
  15992. /**
  15993. * 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
  15994. */
  15995. static UseSerializedUrlIfAny: boolean;
  15996. /**
  15997. * Define the url of the texture.
  15998. */
  15999. url: Nullable<string>;
  16000. /**
  16001. * Define an offset on the texture to offset the u coordinates of the UVs
  16002. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16003. */
  16004. uOffset: number;
  16005. /**
  16006. * Define an offset on the texture to offset the v coordinates of the UVs
  16007. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16008. */
  16009. vOffset: number;
  16010. /**
  16011. * Define an offset on the texture to scale the u coordinates of the UVs
  16012. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16013. */
  16014. uScale: number;
  16015. /**
  16016. * Define an offset on the texture to scale the v coordinates of the UVs
  16017. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16018. */
  16019. vScale: number;
  16020. /**
  16021. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials
  16023. */
  16024. uAng: number;
  16025. /**
  16026. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials
  16028. */
  16029. vAng: number;
  16030. /**
  16031. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16032. * @see http://doc.babylonjs.com/how_to/more_materials
  16033. */
  16034. wAng: number;
  16035. /**
  16036. * Defines the center of rotation (U)
  16037. */
  16038. uRotationCenter: number;
  16039. /**
  16040. * Defines the center of rotation (V)
  16041. */
  16042. vRotationCenter: number;
  16043. /**
  16044. * Defines the center of rotation (W)
  16045. */
  16046. wRotationCenter: number;
  16047. /**
  16048. * Are mip maps generated for this texture or not.
  16049. */
  16050. readonly noMipmap: boolean;
  16051. /**
  16052. * List of inspectable custom properties (used by the Inspector)
  16053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16054. */
  16055. inspectableCustomProperties: Nullable<IInspectable[]>;
  16056. private _noMipmap;
  16057. /** @hidden */
  16058. _invertY: boolean;
  16059. private _rowGenerationMatrix;
  16060. private _cachedTextureMatrix;
  16061. private _projectionModeMatrix;
  16062. private _t0;
  16063. private _t1;
  16064. private _t2;
  16065. private _cachedUOffset;
  16066. private _cachedVOffset;
  16067. private _cachedUScale;
  16068. private _cachedVScale;
  16069. private _cachedUAng;
  16070. private _cachedVAng;
  16071. private _cachedWAng;
  16072. private _cachedProjectionMatrixId;
  16073. private _cachedCoordinatesMode;
  16074. /** @hidden */
  16075. protected _initialSamplingMode: number;
  16076. /** @hidden */
  16077. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16078. private _deleteBuffer;
  16079. protected _format: Nullable<number>;
  16080. private _delayedOnLoad;
  16081. private _delayedOnError;
  16082. /**
  16083. * Observable triggered once the texture has been loaded.
  16084. */
  16085. onLoadObservable: Observable<Texture>;
  16086. protected _isBlocking: boolean;
  16087. /**
  16088. * Is the texture preventing material to render while loading.
  16089. * If false, a default texture will be used instead of the loading one during the preparation step.
  16090. */
  16091. isBlocking: boolean;
  16092. /**
  16093. * Get the current sampling mode associated with the texture.
  16094. */
  16095. readonly samplingMode: number;
  16096. /**
  16097. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16098. */
  16099. readonly invertY: boolean;
  16100. /**
  16101. * Instantiates a new texture.
  16102. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16103. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16104. * @param url define the url of the picture to load as a texture
  16105. * @param scene define the scene or engine the texture will belong to
  16106. * @param noMipmap define if the texture will require mip maps or not
  16107. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16108. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16109. * @param onLoad define a callback triggered when the texture has been loaded
  16110. * @param onError define a callback triggered when an error occurred during the loading session
  16111. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16112. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16113. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16114. */
  16115. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16116. /**
  16117. * Update the url (and optional buffer) of this texture if url was null during construction.
  16118. * @param url the url of the texture
  16119. * @param buffer the buffer of the texture (defaults to null)
  16120. * @param onLoad callback called when the texture is loaded (defaults to null)
  16121. */
  16122. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16123. /**
  16124. * Finish the loading sequence of a texture flagged as delayed load.
  16125. * @hidden
  16126. */
  16127. delayLoad(): void;
  16128. private _prepareRowForTextureGeneration;
  16129. /**
  16130. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16131. * @returns the transform matrix of the texture.
  16132. */
  16133. getTextureMatrix(): Matrix;
  16134. /**
  16135. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16136. * @returns The reflection texture transform
  16137. */
  16138. getReflectionTextureMatrix(): Matrix;
  16139. /**
  16140. * Clones the texture.
  16141. * @returns the cloned texture
  16142. */
  16143. clone(): Texture;
  16144. /**
  16145. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16146. * @returns The JSON representation of the texture
  16147. */
  16148. serialize(): any;
  16149. /**
  16150. * Get the current class name of the texture useful for serialization or dynamic coding.
  16151. * @returns "Texture"
  16152. */
  16153. getClassName(): string;
  16154. /**
  16155. * Dispose the texture and release its associated resources.
  16156. */
  16157. dispose(): void;
  16158. /**
  16159. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16160. * @param parsedTexture Define the JSON representation of the texture
  16161. * @param scene Define the scene the parsed texture should be instantiated in
  16162. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16163. * @returns The parsed texture if successful
  16164. */
  16165. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16166. /**
  16167. * Creates a texture from its base 64 representation.
  16168. * @param data Define the base64 payload without the data: prefix
  16169. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16170. * @param scene Define the scene the texture should belong to
  16171. * @param noMipmap Forces the texture to not create mip map information if true
  16172. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16173. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16174. * @param onLoad define a callback triggered when the texture has been loaded
  16175. * @param onError define a callback triggered when an error occurred during the loading session
  16176. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16177. * @returns the created texture
  16178. */
  16179. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16180. /**
  16181. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16182. * @param data Define the base64 payload without the data: prefix
  16183. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16184. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16185. * @param scene Define the scene the texture should belong to
  16186. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16187. * @param noMipmap Forces the texture to not create mip map information if true
  16188. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16189. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16190. * @param onLoad define a callback triggered when the texture has been loaded
  16191. * @param onError define a callback triggered when an error occurred during the loading session
  16192. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16193. * @returns the created texture
  16194. */
  16195. 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;
  16196. }
  16197. }
  16198. declare module "babylonjs/PostProcesses/postProcessManager" {
  16199. import { Nullable } from "babylonjs/types";
  16200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16202. import { Scene } from "babylonjs/scene";
  16203. /**
  16204. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16205. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16206. */
  16207. export class PostProcessManager {
  16208. private _scene;
  16209. private _indexBuffer;
  16210. private _vertexBuffers;
  16211. /**
  16212. * Creates a new instance PostProcess
  16213. * @param scene The scene that the post process is associated with.
  16214. */
  16215. constructor(scene: Scene);
  16216. private _prepareBuffers;
  16217. private _buildIndexBuffer;
  16218. /**
  16219. * Rebuilds the vertex buffers of the manager.
  16220. * @hidden
  16221. */
  16222. _rebuild(): void;
  16223. /**
  16224. * Prepares a frame to be run through a post process.
  16225. * @param sourceTexture The input texture to the post procesess. (default: null)
  16226. * @param postProcesses An array of post processes to be run. (default: null)
  16227. * @returns True if the post processes were able to be run.
  16228. * @hidden
  16229. */
  16230. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16231. /**
  16232. * Manually render a set of post processes to a texture.
  16233. * @param postProcesses An array of post processes to be run.
  16234. * @param targetTexture The target texture to render to.
  16235. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16236. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16237. * @param lodLevel defines which lod of the texture to render to
  16238. */
  16239. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16240. /**
  16241. * Finalize the result of the output of the postprocesses.
  16242. * @param doNotPresent If true the result will not be displayed to the screen.
  16243. * @param targetTexture The target texture to render to.
  16244. * @param faceIndex The index of the face to bind the target texture to.
  16245. * @param postProcesses The array of post processes to render.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16247. * @hidden
  16248. */
  16249. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16250. /**
  16251. * Disposes of the post process manager.
  16252. */
  16253. dispose(): void;
  16254. }
  16255. }
  16256. declare module "babylonjs/Misc/gradients" {
  16257. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16258. /** Interface used by value gradients (color, factor, ...) */
  16259. export interface IValueGradient {
  16260. /**
  16261. * Gets or sets the gradient value (between 0 and 1)
  16262. */
  16263. gradient: number;
  16264. }
  16265. /** Class used to store color4 gradient */
  16266. export class ColorGradient implements IValueGradient {
  16267. /**
  16268. * Gets or sets the gradient value (between 0 and 1)
  16269. */
  16270. gradient: number;
  16271. /**
  16272. * Gets or sets first associated color
  16273. */
  16274. color1: Color4;
  16275. /**
  16276. * Gets or sets second associated color
  16277. */
  16278. color2?: Color4;
  16279. /**
  16280. * Will get a color picked randomly between color1 and color2.
  16281. * If color2 is undefined then color1 will be used
  16282. * @param result defines the target Color4 to store the result in
  16283. */
  16284. getColorToRef(result: Color4): void;
  16285. }
  16286. /** Class used to store color 3 gradient */
  16287. export class Color3Gradient implements IValueGradient {
  16288. /**
  16289. * Gets or sets the gradient value (between 0 and 1)
  16290. */
  16291. gradient: number;
  16292. /**
  16293. * Gets or sets the associated color
  16294. */
  16295. color: Color3;
  16296. }
  16297. /** Class used to store factor gradient */
  16298. export class FactorGradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets first associated factor
  16305. */
  16306. factor1: number;
  16307. /**
  16308. * Gets or sets second associated factor
  16309. */
  16310. factor2?: number;
  16311. /**
  16312. * Will get a number picked randomly between factor1 and factor2.
  16313. * If factor2 is undefined then factor1 will be used
  16314. * @returns the picked number
  16315. */
  16316. getFactor(): number;
  16317. }
  16318. /**
  16319. * Helper used to simplify some generic gradient tasks
  16320. */
  16321. export class GradientHelper {
  16322. /**
  16323. * Gets the current gradient from an array of IValueGradient
  16324. * @param ratio defines the current ratio to get
  16325. * @param gradients defines the array of IValueGradient
  16326. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16327. */
  16328. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16329. }
  16330. }
  16331. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16332. import { Scene } from "babylonjs/scene";
  16333. import { ISceneComponent } from "babylonjs/sceneComponent";
  16334. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16335. module "babylonjs/abstractScene" {
  16336. interface AbstractScene {
  16337. /**
  16338. * The list of procedural textures added to the scene
  16339. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16340. */
  16341. proceduralTextures: Array<ProceduralTexture>;
  16342. }
  16343. }
  16344. /**
  16345. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16346. * in a given scene.
  16347. */
  16348. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16349. /**
  16350. * The component name helpfull to identify the component in the list of scene components.
  16351. */
  16352. readonly name: string;
  16353. /**
  16354. * The scene the component belongs to.
  16355. */
  16356. scene: Scene;
  16357. /**
  16358. * Creates a new instance of the component for the given scene
  16359. * @param scene Defines the scene to register the component in
  16360. */
  16361. constructor(scene: Scene);
  16362. /**
  16363. * Registers the component in a given scene
  16364. */
  16365. register(): void;
  16366. /**
  16367. * Rebuilds the elements related to this component in case of
  16368. * context lost for instance.
  16369. */
  16370. rebuild(): void;
  16371. /**
  16372. * Disposes the component and the associated ressources.
  16373. */
  16374. dispose(): void;
  16375. private _beforeClear;
  16376. }
  16377. }
  16378. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16381. module "babylonjs/Engines/engine" {
  16382. interface Engine {
  16383. /**
  16384. * Creates a new render target cube texture
  16385. * @param size defines the size of the texture
  16386. * @param options defines the options used to create the texture
  16387. * @returns a new render target cube texture stored in an InternalTexture
  16388. */
  16389. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16390. }
  16391. }
  16392. }
  16393. declare module "babylonjs/Shaders/procedural.vertex" {
  16394. /** @hidden */
  16395. export var proceduralVertexShader: {
  16396. name: string;
  16397. shader: string;
  16398. };
  16399. }
  16400. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16401. import { Observable } from "babylonjs/Misc/observable";
  16402. import { Nullable } from "babylonjs/types";
  16403. import { Scene } from "babylonjs/scene";
  16404. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16405. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16406. import { Effect } from "babylonjs/Materials/effect";
  16407. import { Texture } from "babylonjs/Materials/Textures/texture";
  16408. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16409. import "babylonjs/Shaders/procedural.vertex";
  16410. /**
  16411. * 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.
  16412. * This is the base class of any Procedural texture and contains most of the shareable code.
  16413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16414. */
  16415. export class ProceduralTexture extends Texture {
  16416. isCube: boolean;
  16417. /**
  16418. * Define if the texture is enabled or not (disabled texture will not render)
  16419. */
  16420. isEnabled: boolean;
  16421. /**
  16422. * Define if the texture must be cleared before rendering (default is true)
  16423. */
  16424. autoClear: boolean;
  16425. /**
  16426. * Callback called when the texture is generated
  16427. */
  16428. onGenerated: () => void;
  16429. /**
  16430. * Event raised when the texture is generated
  16431. */
  16432. onGeneratedObservable: Observable<ProceduralTexture>;
  16433. /** @hidden */
  16434. _generateMipMaps: boolean;
  16435. /** @hidden **/
  16436. _effect: Effect;
  16437. /** @hidden */
  16438. _textures: {
  16439. [key: string]: Texture;
  16440. };
  16441. private _size;
  16442. private _currentRefreshId;
  16443. private _refreshRate;
  16444. private _vertexBuffers;
  16445. private _indexBuffer;
  16446. private _uniforms;
  16447. private _samplers;
  16448. private _fragment;
  16449. private _floats;
  16450. private _ints;
  16451. private _floatsArrays;
  16452. private _colors3;
  16453. private _colors4;
  16454. private _vectors2;
  16455. private _vectors3;
  16456. private _matrices;
  16457. private _fallbackTexture;
  16458. private _fallbackTextureUsed;
  16459. private _engine;
  16460. private _cachedDefines;
  16461. private _contentUpdateId;
  16462. private _contentData;
  16463. /**
  16464. * Instantiates a new procedural texture.
  16465. * 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.
  16466. * This is the base class of any Procedural texture and contains most of the shareable code.
  16467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16468. * @param name Define the name of the texture
  16469. * @param size Define the size of the texture to create
  16470. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16471. * @param scene Define the scene the texture belongs to
  16472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16473. * @param generateMipMaps Define if the texture should creates mip maps or not
  16474. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16475. */
  16476. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16477. /**
  16478. * The effect that is created when initializing the post process.
  16479. * @returns The created effect corresponding the the postprocess.
  16480. */
  16481. getEffect(): Effect;
  16482. /**
  16483. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16484. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16485. */
  16486. getContent(): Nullable<ArrayBufferView>;
  16487. private _createIndexBuffer;
  16488. /** @hidden */
  16489. _rebuild(): void;
  16490. /**
  16491. * Resets the texture in order to recreate its associated resources.
  16492. * This can be called in case of context loss
  16493. */
  16494. reset(): void;
  16495. protected _getDefines(): string;
  16496. /**
  16497. * Is the texture ready to be used ? (rendered at least once)
  16498. * @returns true if ready, otherwise, false.
  16499. */
  16500. isReady(): boolean;
  16501. /**
  16502. * Resets the refresh counter of the texture and start bak from scratch.
  16503. * Could be useful to regenerate the texture if it is setup to render only once.
  16504. */
  16505. resetRefreshCounter(): void;
  16506. /**
  16507. * Set the fragment shader to use in order to render the texture.
  16508. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16509. */
  16510. setFragment(fragment: any): void;
  16511. /**
  16512. * Define the refresh rate of the texture or the rendering frequency.
  16513. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16514. */
  16515. refreshRate: number;
  16516. /** @hidden */
  16517. _shouldRender(): boolean;
  16518. /**
  16519. * Get the size the texture is rendering at.
  16520. * @returns the size (texture is always squared)
  16521. */
  16522. getRenderSize(): number;
  16523. /**
  16524. * Resize the texture to new value.
  16525. * @param size Define the new size the texture should have
  16526. * @param generateMipMaps Define whether the new texture should create mip maps
  16527. */
  16528. resize(size: number, generateMipMaps: boolean): void;
  16529. private _checkUniform;
  16530. /**
  16531. * Set a texture in the shader program used to render.
  16532. * @param name Define the name of the uniform samplers as defined in the shader
  16533. * @param texture Define the texture to bind to this sampler
  16534. * @return the texture itself allowing "fluent" like uniform updates
  16535. */
  16536. setTexture(name: string, texture: Texture): ProceduralTexture;
  16537. /**
  16538. * Set a float in the shader.
  16539. * @param name Define the name of the uniform as defined in the shader
  16540. * @param value Define the value to give to the uniform
  16541. * @return the texture itself allowing "fluent" like uniform updates
  16542. */
  16543. setFloat(name: string, value: number): ProceduralTexture;
  16544. /**
  16545. * Set a int in the shader.
  16546. * @param name Define the name of the uniform as defined in the shader
  16547. * @param value Define the value to give to the uniform
  16548. * @return the texture itself allowing "fluent" like uniform updates
  16549. */
  16550. setInt(name: string, value: number): ProceduralTexture;
  16551. /**
  16552. * Set an array of floats in the shader.
  16553. * @param name Define the name of the uniform as defined in the shader
  16554. * @param value Define the value to give to the uniform
  16555. * @return the texture itself allowing "fluent" like uniform updates
  16556. */
  16557. setFloats(name: string, value: number[]): ProceduralTexture;
  16558. /**
  16559. * Set a vec3 in the shader from a Color3.
  16560. * @param name Define the name of the uniform as defined in the shader
  16561. * @param value Define the value to give to the uniform
  16562. * @return the texture itself allowing "fluent" like uniform updates
  16563. */
  16564. setColor3(name: string, value: Color3): ProceduralTexture;
  16565. /**
  16566. * Set a vec4 in the shader from a Color4.
  16567. * @param name Define the name of the uniform as defined in the shader
  16568. * @param value Define the value to give to the uniform
  16569. * @return the texture itself allowing "fluent" like uniform updates
  16570. */
  16571. setColor4(name: string, value: Color4): ProceduralTexture;
  16572. /**
  16573. * Set a vec2 in the shader from a Vector2.
  16574. * @param name Define the name of the uniform as defined in the shader
  16575. * @param value Define the value to give to the uniform
  16576. * @return the texture itself allowing "fluent" like uniform updates
  16577. */
  16578. setVector2(name: string, value: Vector2): ProceduralTexture;
  16579. /**
  16580. * Set a vec3 in the shader from a Vector3.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the texture itself allowing "fluent" like uniform updates
  16584. */
  16585. setVector3(name: string, value: Vector3): ProceduralTexture;
  16586. /**
  16587. * Set a mat4 in the shader from a MAtrix.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the texture itself allowing "fluent" like uniform updates
  16591. */
  16592. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16593. /**
  16594. * Render the texture to its associated render target.
  16595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16596. */
  16597. render(useCameraPostProcess?: boolean): void;
  16598. /**
  16599. * Clone the texture.
  16600. * @returns the cloned texture
  16601. */
  16602. clone(): ProceduralTexture;
  16603. /**
  16604. * Dispose the texture and release its asoociated resources.
  16605. */
  16606. dispose(): void;
  16607. }
  16608. }
  16609. declare module "babylonjs/Particles/baseParticleSystem" {
  16610. import { Nullable } from "babylonjs/types";
  16611. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16613. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16614. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16615. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16616. import { Scene } from "babylonjs/scene";
  16617. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16618. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16619. import { Texture } from "babylonjs/Materials/Textures/texture";
  16620. import { Color4 } from "babylonjs/Maths/math.color";
  16621. import { Animation } from "babylonjs/Animations/animation";
  16622. /**
  16623. * This represents the base class for particle system in Babylon.
  16624. * 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.
  16625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16626. * @example https://doc.babylonjs.com/babylon101/particles
  16627. */
  16628. export class BaseParticleSystem {
  16629. /**
  16630. * Source color is added to the destination color without alpha affecting the result
  16631. */
  16632. static BLENDMODE_ONEONE: number;
  16633. /**
  16634. * Blend current color and particle color using particle’s alpha
  16635. */
  16636. static BLENDMODE_STANDARD: number;
  16637. /**
  16638. * Add current color and particle color multiplied by particle’s alpha
  16639. */
  16640. static BLENDMODE_ADD: number;
  16641. /**
  16642. * Multiply current color with particle color
  16643. */
  16644. static BLENDMODE_MULTIPLY: number;
  16645. /**
  16646. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16647. */
  16648. static BLENDMODE_MULTIPLYADD: number;
  16649. /**
  16650. * List of animations used by the particle system.
  16651. */
  16652. animations: Animation[];
  16653. /**
  16654. * The id of the Particle system.
  16655. */
  16656. id: string;
  16657. /**
  16658. * The friendly name of the Particle system.
  16659. */
  16660. name: string;
  16661. /**
  16662. * The rendering group used by the Particle system to chose when to render.
  16663. */
  16664. renderingGroupId: number;
  16665. /**
  16666. * The emitter represents the Mesh or position we are attaching the particle system to.
  16667. */
  16668. emitter: Nullable<AbstractMesh | Vector3>;
  16669. /**
  16670. * The maximum number of particles to emit per frame
  16671. */
  16672. emitRate: number;
  16673. /**
  16674. * If you want to launch only a few particles at once, that can be done, as well.
  16675. */
  16676. manualEmitCount: number;
  16677. /**
  16678. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16679. */
  16680. updateSpeed: number;
  16681. /**
  16682. * The amount of time the particle system is running (depends of the overall update speed).
  16683. */
  16684. targetStopDuration: number;
  16685. /**
  16686. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16687. */
  16688. disposeOnStop: boolean;
  16689. /**
  16690. * Minimum power of emitting particles.
  16691. */
  16692. minEmitPower: number;
  16693. /**
  16694. * Maximum power of emitting particles.
  16695. */
  16696. maxEmitPower: number;
  16697. /**
  16698. * Minimum life time of emitting particles.
  16699. */
  16700. minLifeTime: number;
  16701. /**
  16702. * Maximum life time of emitting particles.
  16703. */
  16704. maxLifeTime: number;
  16705. /**
  16706. * Minimum Size of emitting particles.
  16707. */
  16708. minSize: number;
  16709. /**
  16710. * Maximum Size of emitting particles.
  16711. */
  16712. maxSize: number;
  16713. /**
  16714. * Minimum scale of emitting particles on X axis.
  16715. */
  16716. minScaleX: number;
  16717. /**
  16718. * Maximum scale of emitting particles on X axis.
  16719. */
  16720. maxScaleX: number;
  16721. /**
  16722. * Minimum scale of emitting particles on Y axis.
  16723. */
  16724. minScaleY: number;
  16725. /**
  16726. * Maximum scale of emitting particles on Y axis.
  16727. */
  16728. maxScaleY: number;
  16729. /**
  16730. * Gets or sets the minimal initial rotation in radians.
  16731. */
  16732. minInitialRotation: number;
  16733. /**
  16734. * Gets or sets the maximal initial rotation in radians.
  16735. */
  16736. maxInitialRotation: number;
  16737. /**
  16738. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16739. */
  16740. minAngularSpeed: number;
  16741. /**
  16742. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16743. */
  16744. maxAngularSpeed: number;
  16745. /**
  16746. * The texture used to render each particle. (this can be a spritesheet)
  16747. */
  16748. particleTexture: Nullable<Texture>;
  16749. /**
  16750. * The layer mask we are rendering the particles through.
  16751. */
  16752. layerMask: number;
  16753. /**
  16754. * This can help using your own shader to render the particle system.
  16755. * The according effect will be created
  16756. */
  16757. customShader: any;
  16758. /**
  16759. * By default particle system starts as soon as they are created. This prevents the
  16760. * automatic start to happen and let you decide when to start emitting particles.
  16761. */
  16762. preventAutoStart: boolean;
  16763. private _noiseTexture;
  16764. /**
  16765. * Gets or sets a texture used to add random noise to particle positions
  16766. */
  16767. noiseTexture: Nullable<ProceduralTexture>;
  16768. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16769. noiseStrength: Vector3;
  16770. /**
  16771. * Callback triggered when the particle animation is ending.
  16772. */
  16773. onAnimationEnd: Nullable<() => void>;
  16774. /**
  16775. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16776. */
  16777. blendMode: number;
  16778. /**
  16779. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16780. * to override the particles.
  16781. */
  16782. forceDepthWrite: boolean;
  16783. /** 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 */
  16784. preWarmCycles: number;
  16785. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16786. preWarmStepOffset: number;
  16787. /**
  16788. * 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)
  16789. */
  16790. spriteCellChangeSpeed: number;
  16791. /**
  16792. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16793. */
  16794. startSpriteCellID: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16797. */
  16798. endSpriteCellID: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16801. */
  16802. spriteCellWidth: number;
  16803. /**
  16804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16805. */
  16806. spriteCellHeight: number;
  16807. /**
  16808. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16809. */
  16810. spriteRandomStartCell: boolean;
  16811. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16812. translationPivot: Vector2;
  16813. /** @hidden */
  16814. protected _isAnimationSheetEnabled: boolean;
  16815. /**
  16816. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16817. */
  16818. beginAnimationOnStart: boolean;
  16819. /**
  16820. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16821. */
  16822. beginAnimationFrom: number;
  16823. /**
  16824. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationTo: number;
  16827. /**
  16828. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16829. */
  16830. beginAnimationLoop: boolean;
  16831. /**
  16832. * Gets or sets a world offset applied to all particles
  16833. */
  16834. worldOffset: Vector3;
  16835. /**
  16836. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16837. */
  16838. isAnimationSheetEnabled: boolean;
  16839. /**
  16840. * Get hosting scene
  16841. * @returns the scene
  16842. */
  16843. getScene(): Scene;
  16844. /**
  16845. * You can use gravity if you want to give an orientation to your particles.
  16846. */
  16847. gravity: Vector3;
  16848. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16849. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16850. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16852. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16853. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16855. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16856. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16857. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16858. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16859. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16861. /**
  16862. * Defines the delay in milliseconds before starting the system (0 by default)
  16863. */
  16864. startDelay: number;
  16865. /**
  16866. * Gets the current list of drag gradients.
  16867. * You must use addDragGradient and removeDragGradient to udpate this list
  16868. * @returns the list of drag gradients
  16869. */
  16870. getDragGradients(): Nullable<Array<FactorGradient>>;
  16871. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16872. limitVelocityDamping: number;
  16873. /**
  16874. * Gets the current list of limit velocity gradients.
  16875. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16876. * @returns the list of limit velocity gradients
  16877. */
  16878. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Gets the current list of color gradients.
  16881. * You must use addColorGradient and removeColorGradient to udpate this list
  16882. * @returns the list of color gradients
  16883. */
  16884. getColorGradients(): Nullable<Array<ColorGradient>>;
  16885. /**
  16886. * Gets the current list of size gradients.
  16887. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16888. * @returns the list of size gradients
  16889. */
  16890. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Gets the current list of color remap gradients.
  16893. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16894. * @returns the list of color remap gradients
  16895. */
  16896. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16897. /**
  16898. * Gets the current list of alpha remap gradients.
  16899. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16900. * @returns the list of alpha remap gradients
  16901. */
  16902. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16903. /**
  16904. * Gets the current list of life time gradients.
  16905. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16906. * @returns the list of life time gradients
  16907. */
  16908. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16909. /**
  16910. * Gets the current list of angular speed gradients.
  16911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16912. * @returns the list of angular speed gradients
  16913. */
  16914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Gets the current list of velocity gradients.
  16917. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16918. * @returns the list of velocity gradients
  16919. */
  16920. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16921. /**
  16922. * Gets the current list of start size gradients.
  16923. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16924. * @returns the list of start size gradients
  16925. */
  16926. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16927. /**
  16928. * Gets the current list of emit rate gradients.
  16929. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16930. * @returns the list of emit rate gradients
  16931. */
  16932. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16935. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16936. */
  16937. direction1: Vector3;
  16938. /**
  16939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16940. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16941. */
  16942. direction2: Vector3;
  16943. /**
  16944. * 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.
  16945. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16946. */
  16947. minEmitBox: Vector3;
  16948. /**
  16949. * 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.
  16950. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16951. */
  16952. maxEmitBox: Vector3;
  16953. /**
  16954. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16955. */
  16956. color1: Color4;
  16957. /**
  16958. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16959. */
  16960. color2: Color4;
  16961. /**
  16962. * Color the particle will have at the end of its lifetime
  16963. */
  16964. colorDead: Color4;
  16965. /**
  16966. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16967. */
  16968. textureMask: Color4;
  16969. /**
  16970. * The particle emitter type defines the emitter used by the particle system.
  16971. * It can be for example box, sphere, or cone...
  16972. */
  16973. particleEmitterType: IParticleEmitterType;
  16974. /** @hidden */
  16975. _isSubEmitter: boolean;
  16976. /**
  16977. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16978. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16979. */
  16980. billboardMode: number;
  16981. protected _isBillboardBased: boolean;
  16982. /**
  16983. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16984. */
  16985. isBillboardBased: boolean;
  16986. /**
  16987. * The scene the particle system belongs to.
  16988. */
  16989. protected _scene: Scene;
  16990. /**
  16991. * Local cache of defines for image processing.
  16992. */
  16993. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16994. /**
  16995. * Default configuration related to image processing available in the standard Material.
  16996. */
  16997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16998. /**
  16999. * Gets the image processing configuration used either in this material.
  17000. */
  17001. /**
  17002. * Sets the Default image processing configuration used either in the this material.
  17003. *
  17004. * If sets to null, the scene one is in use.
  17005. */
  17006. imageProcessingConfiguration: ImageProcessingConfiguration;
  17007. /**
  17008. * Attaches a new image processing configuration to the Standard Material.
  17009. * @param configuration
  17010. */
  17011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17012. /** @hidden */
  17013. protected _reset(): void;
  17014. /** @hidden */
  17015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17016. /**
  17017. * Instantiates a particle system.
  17018. * 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.
  17019. * @param name The name of the particle system
  17020. */
  17021. constructor(name: string);
  17022. /**
  17023. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @returns the emitter
  17027. */
  17028. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17029. /**
  17030. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17031. * @param radius The radius of the hemisphere to emit from
  17032. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17033. * @returns the emitter
  17034. */
  17035. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17036. /**
  17037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17038. * @param radius The radius of the sphere to emit from
  17039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17040. * @returns the emitter
  17041. */
  17042. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17043. /**
  17044. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17045. * @param radius The radius of the sphere to emit from
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @returns the emitter
  17049. */
  17050. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17051. /**
  17052. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17053. * @param radius The radius of the emission cylinder
  17054. * @param height The height of the emission cylinder
  17055. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17056. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17057. * @returns the emitter
  17058. */
  17059. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17060. /**
  17061. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17062. * @param radius The radius of the cylinder to emit from
  17063. * @param height The height of the emission cylinder
  17064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17065. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17066. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @returns the emitter
  17068. */
  17069. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17070. /**
  17071. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17072. * @param radius The radius of the cone to emit from
  17073. * @param angle The base angle of the cone
  17074. * @returns the emitter
  17075. */
  17076. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17077. /**
  17078. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17082. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @returns the emitter
  17084. */
  17085. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17086. }
  17087. }
  17088. declare module "babylonjs/Particles/subEmitter" {
  17089. import { Scene } from "babylonjs/scene";
  17090. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17091. /**
  17092. * Type of sub emitter
  17093. */
  17094. export enum SubEmitterType {
  17095. /**
  17096. * Attached to the particle over it's lifetime
  17097. */
  17098. ATTACHED = 0,
  17099. /**
  17100. * Created when the particle dies
  17101. */
  17102. END = 1
  17103. }
  17104. /**
  17105. * Sub emitter class used to emit particles from an existing particle
  17106. */
  17107. export class SubEmitter {
  17108. /**
  17109. * the particle system to be used by the sub emitter
  17110. */
  17111. particleSystem: ParticleSystem;
  17112. /**
  17113. * Type of the submitter (Default: END)
  17114. */
  17115. type: SubEmitterType;
  17116. /**
  17117. * 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)
  17118. * Note: This only is supported when using an emitter of type Mesh
  17119. */
  17120. inheritDirection: boolean;
  17121. /**
  17122. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17123. */
  17124. inheritedVelocityAmount: number;
  17125. /**
  17126. * Creates a sub emitter
  17127. * @param particleSystem the particle system to be used by the sub emitter
  17128. */
  17129. constructor(
  17130. /**
  17131. * the particle system to be used by the sub emitter
  17132. */
  17133. particleSystem: ParticleSystem);
  17134. /**
  17135. * Clones the sub emitter
  17136. * @returns the cloned sub emitter
  17137. */
  17138. clone(): SubEmitter;
  17139. /**
  17140. * Serialize current object to a JSON object
  17141. * @returns the serialized object
  17142. */
  17143. serialize(): any;
  17144. /** @hidden */
  17145. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17146. /**
  17147. * Creates a new SubEmitter from a serialized JSON version
  17148. * @param serializationObject defines the JSON object to read from
  17149. * @param scene defines the hosting scene
  17150. * @param rootUrl defines the rootUrl for data loading
  17151. * @returns a new SubEmitter
  17152. */
  17153. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17154. /** Release associated resources */
  17155. dispose(): void;
  17156. }
  17157. }
  17158. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17159. /** @hidden */
  17160. export var clipPlaneFragmentDeclaration: {
  17161. name: string;
  17162. shader: string;
  17163. };
  17164. }
  17165. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17166. /** @hidden */
  17167. export var imageProcessingDeclaration: {
  17168. name: string;
  17169. shader: string;
  17170. };
  17171. }
  17172. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17173. /** @hidden */
  17174. export var imageProcessingFunctions: {
  17175. name: string;
  17176. shader: string;
  17177. };
  17178. }
  17179. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17180. /** @hidden */
  17181. export var clipPlaneFragment: {
  17182. name: string;
  17183. shader: string;
  17184. };
  17185. }
  17186. declare module "babylonjs/Shaders/particles.fragment" {
  17187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17188. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17189. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17190. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17192. /** @hidden */
  17193. export var particlesPixelShader: {
  17194. name: string;
  17195. shader: string;
  17196. };
  17197. }
  17198. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17199. /** @hidden */
  17200. export var clipPlaneVertexDeclaration: {
  17201. name: string;
  17202. shader: string;
  17203. };
  17204. }
  17205. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17206. /** @hidden */
  17207. export var clipPlaneVertex: {
  17208. name: string;
  17209. shader: string;
  17210. };
  17211. }
  17212. declare module "babylonjs/Shaders/particles.vertex" {
  17213. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17214. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17215. /** @hidden */
  17216. export var particlesVertexShader: {
  17217. name: string;
  17218. shader: string;
  17219. };
  17220. }
  17221. declare module "babylonjs/Particles/particleSystem" {
  17222. import { Nullable } from "babylonjs/types";
  17223. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17224. import { Observable } from "babylonjs/Misc/observable";
  17225. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17226. import { Effect } from "babylonjs/Materials/effect";
  17227. import { Scene, IDisposable } from "babylonjs/scene";
  17228. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17229. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17230. import { Particle } from "babylonjs/Particles/particle";
  17231. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17232. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17233. import "babylonjs/Shaders/particles.fragment";
  17234. import "babylonjs/Shaders/particles.vertex";
  17235. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17236. /**
  17237. * This represents a particle system in Babylon.
  17238. * 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.
  17239. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17240. * @example https://doc.babylonjs.com/babylon101/particles
  17241. */
  17242. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17243. /**
  17244. * Billboard mode will only apply to Y axis
  17245. */
  17246. static readonly BILLBOARDMODE_Y: number;
  17247. /**
  17248. * Billboard mode will apply to all axes
  17249. */
  17250. static readonly BILLBOARDMODE_ALL: number;
  17251. /**
  17252. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17253. */
  17254. static readonly BILLBOARDMODE_STRETCHED: number;
  17255. /**
  17256. * This function can be defined to provide custom update for active particles.
  17257. * This function will be called instead of regular update (age, position, color, etc.).
  17258. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17259. */
  17260. updateFunction: (particles: Particle[]) => void;
  17261. private _emitterWorldMatrix;
  17262. /**
  17263. * This function can be defined to specify initial direction for every new particle.
  17264. * It by default use the emitterType defined function
  17265. */
  17266. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17267. /**
  17268. * This function can be defined to specify initial position for every new particle.
  17269. * It by default use the emitterType defined function
  17270. */
  17271. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17272. /**
  17273. * @hidden
  17274. */
  17275. _inheritedVelocityOffset: Vector3;
  17276. /**
  17277. * An event triggered when the system is disposed
  17278. */
  17279. onDisposeObservable: Observable<ParticleSystem>;
  17280. private _onDisposeObserver;
  17281. /**
  17282. * Sets a callback that will be triggered when the system is disposed
  17283. */
  17284. onDispose: () => void;
  17285. private _particles;
  17286. private _epsilon;
  17287. private _capacity;
  17288. private _stockParticles;
  17289. private _newPartsExcess;
  17290. private _vertexData;
  17291. private _vertexBuffer;
  17292. private _vertexBuffers;
  17293. private _spriteBuffer;
  17294. private _indexBuffer;
  17295. private _effect;
  17296. private _customEffect;
  17297. private _cachedDefines;
  17298. private _scaledColorStep;
  17299. private _colorDiff;
  17300. private _scaledDirection;
  17301. private _scaledGravity;
  17302. private _currentRenderId;
  17303. private _alive;
  17304. private _useInstancing;
  17305. private _started;
  17306. private _stopped;
  17307. private _actualFrame;
  17308. private _scaledUpdateSpeed;
  17309. private _vertexBufferSize;
  17310. /** @hidden */
  17311. _currentEmitRateGradient: Nullable<FactorGradient>;
  17312. /** @hidden */
  17313. _currentEmitRate1: number;
  17314. /** @hidden */
  17315. _currentEmitRate2: number;
  17316. /** @hidden */
  17317. _currentStartSizeGradient: Nullable<FactorGradient>;
  17318. /** @hidden */
  17319. _currentStartSize1: number;
  17320. /** @hidden */
  17321. _currentStartSize2: number;
  17322. private readonly _rawTextureWidth;
  17323. private _rampGradientsTexture;
  17324. private _useRampGradients;
  17325. /** Gets or sets a boolean indicating that ramp gradients must be used
  17326. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17327. */
  17328. useRampGradients: boolean;
  17329. /**
  17330. * 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.
  17331. * 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: [])
  17332. */
  17333. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17334. private _subEmitters;
  17335. /**
  17336. * @hidden
  17337. * If the particle systems emitter should be disposed when the particle system is disposed
  17338. */
  17339. _disposeEmitterOnDispose: boolean;
  17340. /**
  17341. * The current active Sub-systems, this property is used by the root particle system only.
  17342. */
  17343. activeSubSystems: Array<ParticleSystem>;
  17344. private _rootParticleSystem;
  17345. /**
  17346. * Gets the current list of active particles
  17347. */
  17348. readonly particles: Particle[];
  17349. /**
  17350. * Returns the string "ParticleSystem"
  17351. * @returns a string containing the class name
  17352. */
  17353. getClassName(): string;
  17354. /**
  17355. * Instantiates a particle system.
  17356. * 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.
  17357. * @param name The name of the particle system
  17358. * @param capacity The max number of particles alive at the same time
  17359. * @param scene The scene the particle system belongs to
  17360. * @param customEffect a custom effect used to change the way particles are rendered by default
  17361. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17362. * @param epsilon Offset used to render the particles
  17363. */
  17364. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17365. private _addFactorGradient;
  17366. private _removeFactorGradient;
  17367. /**
  17368. * Adds a new life time gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the life time factor to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific life time gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new size gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the size factor to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific size gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeSizeGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new color remap gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param min defines the color remap minimal range
  17399. * @param max defines the color remap maximal range
  17400. * @returns the current particle system
  17401. */
  17402. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific color remap gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeColorRemapGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new alpha remap gradient
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param min defines the alpha remap minimal range
  17413. * @param max defines the alpha remap maximal range
  17414. * @returns the current particle system
  17415. */
  17416. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific alpha remap gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new angular speed gradient
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the angular speed to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific angular speed gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17437. /**
  17438. * Adds a new velocity gradient
  17439. * @param gradient defines the gradient to use (between 0 and 1)
  17440. * @param factor defines the velocity to affect to the specified gradient
  17441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17442. * @returns the current particle system
  17443. */
  17444. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17445. /**
  17446. * Remove a specific velocity gradient
  17447. * @param gradient defines the gradient to remove
  17448. * @returns the current particle system
  17449. */
  17450. removeVelocityGradient(gradient: number): IParticleSystem;
  17451. /**
  17452. * Adds a new limit velocity gradient
  17453. * @param gradient defines the gradient to use (between 0 and 1)
  17454. * @param factor defines the limit velocity value to affect to the specified gradient
  17455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17456. * @returns the current particle system
  17457. */
  17458. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17459. /**
  17460. * Remove a specific limit velocity gradient
  17461. * @param gradient defines the gradient to remove
  17462. * @returns the current particle system
  17463. */
  17464. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17465. /**
  17466. * Adds a new drag gradient
  17467. * @param gradient defines the gradient to use (between 0 and 1)
  17468. * @param factor defines the drag value to affect to the specified gradient
  17469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17470. * @returns the current particle system
  17471. */
  17472. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17473. /**
  17474. * Remove a specific drag gradient
  17475. * @param gradient defines the gradient to remove
  17476. * @returns the current particle system
  17477. */
  17478. removeDragGradient(gradient: number): IParticleSystem;
  17479. /**
  17480. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17481. * @param gradient defines the gradient to use (between 0 and 1)
  17482. * @param factor defines the emit rate value to affect to the specified gradient
  17483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17484. * @returns the current particle system
  17485. */
  17486. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17487. /**
  17488. * Remove a specific emit rate gradient
  17489. * @param gradient defines the gradient to remove
  17490. * @returns the current particle system
  17491. */
  17492. removeEmitRateGradient(gradient: number): IParticleSystem;
  17493. /**
  17494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17495. * @param gradient defines the gradient to use (between 0 and 1)
  17496. * @param factor defines the start size value to affect to the specified gradient
  17497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17498. * @returns the current particle system
  17499. */
  17500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17501. /**
  17502. * Remove a specific start size gradient
  17503. * @param gradient defines the gradient to remove
  17504. * @returns the current particle system
  17505. */
  17506. removeStartSizeGradient(gradient: number): IParticleSystem;
  17507. private _createRampGradientTexture;
  17508. /**
  17509. * Gets the current list of ramp gradients.
  17510. * You must use addRampGradient and removeRampGradient to udpate this list
  17511. * @returns the list of ramp gradients
  17512. */
  17513. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17514. /**
  17515. * Adds a new ramp gradient used to remap particle colors
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param color defines the color to affect to the specified gradient
  17518. * @returns the current particle system
  17519. */
  17520. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17521. /**
  17522. * Remove a specific ramp gradient
  17523. * @param gradient defines the gradient to remove
  17524. * @returns the current particle system
  17525. */
  17526. removeRampGradient(gradient: number): ParticleSystem;
  17527. /**
  17528. * Adds a new color gradient
  17529. * @param gradient defines the gradient to use (between 0 and 1)
  17530. * @param color1 defines the color to affect to the specified gradient
  17531. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17532. * @returns this particle system
  17533. */
  17534. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17535. /**
  17536. * Remove a specific color gradient
  17537. * @param gradient defines the gradient to remove
  17538. * @returns this particle system
  17539. */
  17540. removeColorGradient(gradient: number): IParticleSystem;
  17541. private _fetchR;
  17542. protected _reset(): void;
  17543. private _resetEffect;
  17544. private _createVertexBuffers;
  17545. private _createIndexBuffer;
  17546. /**
  17547. * Gets the maximum number of particles active at the same time.
  17548. * @returns The max number of active particles.
  17549. */
  17550. getCapacity(): number;
  17551. /**
  17552. * Gets whether there are still active particles in the system.
  17553. * @returns True if it is alive, otherwise false.
  17554. */
  17555. isAlive(): boolean;
  17556. /**
  17557. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17558. * @returns True if it has been started, otherwise false.
  17559. */
  17560. isStarted(): boolean;
  17561. private _prepareSubEmitterInternalArray;
  17562. /**
  17563. * Starts the particle system and begins to emit
  17564. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17565. */
  17566. start(delay?: number): void;
  17567. /**
  17568. * Stops the particle system.
  17569. * @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.
  17570. */
  17571. stop(stopSubEmitters?: boolean): void;
  17572. /**
  17573. * Remove all active particles
  17574. */
  17575. reset(): void;
  17576. /**
  17577. * @hidden (for internal use only)
  17578. */
  17579. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17580. /**
  17581. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17582. * Its lifetime will start back at 0.
  17583. */
  17584. recycleParticle: (particle: Particle) => void;
  17585. private _stopSubEmitters;
  17586. private _createParticle;
  17587. private _removeFromRoot;
  17588. private _emitFromParticle;
  17589. private _update;
  17590. /** @hidden */
  17591. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17592. /** @hidden */
  17593. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17594. /** @hidden */
  17595. private _getEffect;
  17596. /**
  17597. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17598. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17599. */
  17600. animate(preWarmOnly?: boolean): void;
  17601. private _appendParticleVertices;
  17602. /**
  17603. * Rebuilds the particle system.
  17604. */
  17605. rebuild(): void;
  17606. /**
  17607. * Is this system ready to be used/rendered
  17608. * @return true if the system is ready
  17609. */
  17610. isReady(): boolean;
  17611. private _render;
  17612. /**
  17613. * Renders the particle system in its current state.
  17614. * @returns the current number of particles
  17615. */
  17616. render(): number;
  17617. /**
  17618. * Disposes the particle system and free the associated resources
  17619. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17620. */
  17621. dispose(disposeTexture?: boolean): void;
  17622. /**
  17623. * Clones the particle system.
  17624. * @param name The name of the cloned object
  17625. * @param newEmitter The new emitter to use
  17626. * @returns the cloned particle system
  17627. */
  17628. clone(name: string, newEmitter: any): ParticleSystem;
  17629. /**
  17630. * Serializes the particle system to a JSON object.
  17631. * @returns the JSON object
  17632. */
  17633. serialize(): any;
  17634. /** @hidden */
  17635. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17636. /** @hidden */
  17637. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17638. /**
  17639. * Parses a JSON object to create a particle system.
  17640. * @param parsedParticleSystem The JSON object to parse
  17641. * @param scene The scene to create the particle system in
  17642. * @param rootUrl The root url to use to load external dependencies like texture
  17643. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17644. * @returns the Parsed particle system
  17645. */
  17646. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17647. }
  17648. }
  17649. declare module "babylonjs/Particles/particle" {
  17650. import { Nullable } from "babylonjs/types";
  17651. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17652. import { Color4 } from "babylonjs/Maths/math.color";
  17653. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17656. /**
  17657. * A particle represents one of the element emitted by a particle system.
  17658. * This is mainly define by its coordinates, direction, velocity and age.
  17659. */
  17660. export class Particle {
  17661. /**
  17662. * The particle system the particle belongs to.
  17663. */
  17664. particleSystem: ParticleSystem;
  17665. private static _Count;
  17666. /**
  17667. * Unique ID of the particle
  17668. */
  17669. id: number;
  17670. /**
  17671. * The world position of the particle in the scene.
  17672. */
  17673. position: Vector3;
  17674. /**
  17675. * The world direction of the particle in the scene.
  17676. */
  17677. direction: Vector3;
  17678. /**
  17679. * The color of the particle.
  17680. */
  17681. color: Color4;
  17682. /**
  17683. * The color change of the particle per step.
  17684. */
  17685. colorStep: Color4;
  17686. /**
  17687. * Defines how long will the life of the particle be.
  17688. */
  17689. lifeTime: number;
  17690. /**
  17691. * The current age of the particle.
  17692. */
  17693. age: number;
  17694. /**
  17695. * The current size of the particle.
  17696. */
  17697. size: number;
  17698. /**
  17699. * The current scale of the particle.
  17700. */
  17701. scale: Vector2;
  17702. /**
  17703. * The current angle of the particle.
  17704. */
  17705. angle: number;
  17706. /**
  17707. * Defines how fast is the angle changing.
  17708. */
  17709. angularSpeed: number;
  17710. /**
  17711. * Defines the cell index used by the particle to be rendered from a sprite.
  17712. */
  17713. cellIndex: number;
  17714. /**
  17715. * The information required to support color remapping
  17716. */
  17717. remapData: Vector4;
  17718. /** @hidden */
  17719. _randomCellOffset?: number;
  17720. /** @hidden */
  17721. _initialDirection: Nullable<Vector3>;
  17722. /** @hidden */
  17723. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17724. /** @hidden */
  17725. _initialStartSpriteCellID: number;
  17726. /** @hidden */
  17727. _initialEndSpriteCellID: number;
  17728. /** @hidden */
  17729. _currentColorGradient: Nullable<ColorGradient>;
  17730. /** @hidden */
  17731. _currentColor1: Color4;
  17732. /** @hidden */
  17733. _currentColor2: Color4;
  17734. /** @hidden */
  17735. _currentSizeGradient: Nullable<FactorGradient>;
  17736. /** @hidden */
  17737. _currentSize1: number;
  17738. /** @hidden */
  17739. _currentSize2: number;
  17740. /** @hidden */
  17741. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17742. /** @hidden */
  17743. _currentAngularSpeed1: number;
  17744. /** @hidden */
  17745. _currentAngularSpeed2: number;
  17746. /** @hidden */
  17747. _currentVelocityGradient: Nullable<FactorGradient>;
  17748. /** @hidden */
  17749. _currentVelocity1: number;
  17750. /** @hidden */
  17751. _currentVelocity2: number;
  17752. /** @hidden */
  17753. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17754. /** @hidden */
  17755. _currentLimitVelocity1: number;
  17756. /** @hidden */
  17757. _currentLimitVelocity2: number;
  17758. /** @hidden */
  17759. _currentDragGradient: Nullable<FactorGradient>;
  17760. /** @hidden */
  17761. _currentDrag1: number;
  17762. /** @hidden */
  17763. _currentDrag2: number;
  17764. /** @hidden */
  17765. _randomNoiseCoordinates1: Vector3;
  17766. /** @hidden */
  17767. _randomNoiseCoordinates2: Vector3;
  17768. /**
  17769. * Creates a new instance Particle
  17770. * @param particleSystem the particle system the particle belongs to
  17771. */
  17772. constructor(
  17773. /**
  17774. * The particle system the particle belongs to.
  17775. */
  17776. particleSystem: ParticleSystem);
  17777. private updateCellInfoFromSystem;
  17778. /**
  17779. * Defines how the sprite cell index is updated for the particle
  17780. */
  17781. updateCellIndex(): void;
  17782. /** @hidden */
  17783. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17784. /** @hidden */
  17785. _inheritParticleInfoToSubEmitters(): void;
  17786. /** @hidden */
  17787. _reset(): void;
  17788. /**
  17789. * Copy the properties of particle to another one.
  17790. * @param other the particle to copy the information to.
  17791. */
  17792. copyTo(other: Particle): void;
  17793. }
  17794. }
  17795. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17797. import { Effect } from "babylonjs/Materials/effect";
  17798. import { Particle } from "babylonjs/Particles/particle";
  17799. /**
  17800. * Particle emitter represents a volume emitting particles.
  17801. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17802. */
  17803. export interface IParticleEmitterType {
  17804. /**
  17805. * Called by the particle System when the direction is computed for the created particle.
  17806. * @param worldMatrix is the world matrix of the particle system
  17807. * @param directionToUpdate is the direction vector to update with the result
  17808. * @param particle is the particle we are computed the direction for
  17809. */
  17810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17811. /**
  17812. * Called by the particle System when the position is computed for the created particle.
  17813. * @param worldMatrix is the world matrix of the particle system
  17814. * @param positionToUpdate is the position vector to update with the result
  17815. * @param particle is the particle we are computed the position for
  17816. */
  17817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17818. /**
  17819. * Clones the current emitter and returns a copy of it
  17820. * @returns the new emitter
  17821. */
  17822. clone(): IParticleEmitterType;
  17823. /**
  17824. * Called by the GPUParticleSystem to setup the update shader
  17825. * @param effect defines the update shader
  17826. */
  17827. applyToShader(effect: Effect): void;
  17828. /**
  17829. * Returns a string to use to update the GPU particles update shader
  17830. * @returns the effect defines string
  17831. */
  17832. getEffectDefines(): string;
  17833. /**
  17834. * Returns a string representing the class name
  17835. * @returns a string containing the class name
  17836. */
  17837. getClassName(): string;
  17838. /**
  17839. * Serializes the particle system to a JSON object.
  17840. * @returns the JSON object
  17841. */
  17842. serialize(): any;
  17843. /**
  17844. * Parse properties from a JSON object
  17845. * @param serializationObject defines the JSON object
  17846. */
  17847. parse(serializationObject: any): void;
  17848. }
  17849. }
  17850. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17851. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17852. import { Effect } from "babylonjs/Materials/effect";
  17853. import { Particle } from "babylonjs/Particles/particle";
  17854. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17855. /**
  17856. * Particle emitter emitting particles from the inside of a box.
  17857. * It emits the particles randomly between 2 given directions.
  17858. */
  17859. export class BoxParticleEmitter implements IParticleEmitterType {
  17860. /**
  17861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17862. */
  17863. direction1: Vector3;
  17864. /**
  17865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17866. */
  17867. direction2: Vector3;
  17868. /**
  17869. * 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.
  17870. */
  17871. minEmitBox: Vector3;
  17872. /**
  17873. * 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.
  17874. */
  17875. maxEmitBox: Vector3;
  17876. /**
  17877. * Creates a new instance BoxParticleEmitter
  17878. */
  17879. constructor();
  17880. /**
  17881. * Called by the particle System when the direction is computed for the created particle.
  17882. * @param worldMatrix is the world matrix of the particle system
  17883. * @param directionToUpdate is the direction vector to update with the result
  17884. * @param particle is the particle we are computed the direction for
  17885. */
  17886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17887. /**
  17888. * Called by the particle System when the position is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param positionToUpdate is the position vector to update with the result
  17891. * @param particle is the particle we are computed the position for
  17892. */
  17893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): BoxParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "BoxParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17927. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17928. import { Effect } from "babylonjs/Materials/effect";
  17929. import { Particle } from "babylonjs/Particles/particle";
  17930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17931. /**
  17932. * Particle emitter emitting particles from the inside of a cone.
  17933. * It emits the particles alongside the cone volume from the base to the particle.
  17934. * The emission direction might be randomized.
  17935. */
  17936. export class ConeParticleEmitter implements IParticleEmitterType {
  17937. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17938. directionRandomizer: number;
  17939. private _radius;
  17940. private _angle;
  17941. private _height;
  17942. /**
  17943. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17944. */
  17945. radiusRange: number;
  17946. /**
  17947. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17948. */
  17949. heightRange: number;
  17950. /**
  17951. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17952. */
  17953. emitFromSpawnPointOnly: boolean;
  17954. /**
  17955. * Gets or sets the radius of the emission cone
  17956. */
  17957. radius: number;
  17958. /**
  17959. * Gets or sets the angle of the emission cone
  17960. */
  17961. angle: number;
  17962. private _buildHeight;
  17963. /**
  17964. * Creates a new instance ConeParticleEmitter
  17965. * @param radius the radius of the emission cone (1 by default)
  17966. * @param angle the cone base angle (PI by default)
  17967. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17968. */
  17969. constructor(radius?: number, angle?: number,
  17970. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17971. directionRandomizer?: number);
  17972. /**
  17973. * Called by the particle System when the direction is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param directionToUpdate is the direction vector to update with the result
  17976. * @param particle is the particle we are computed the direction for
  17977. */
  17978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Called by the particle System when the position is computed for the created particle.
  17981. * @param worldMatrix is the world matrix of the particle system
  17982. * @param positionToUpdate is the position vector to update with the result
  17983. * @param particle is the particle we are computed the position for
  17984. */
  17985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17986. /**
  17987. * Clones the current emitter and returns a copy of it
  17988. * @returns the new emitter
  17989. */
  17990. clone(): ConeParticleEmitter;
  17991. /**
  17992. * Called by the GPUParticleSystem to setup the update shader
  17993. * @param effect defines the update shader
  17994. */
  17995. applyToShader(effect: Effect): void;
  17996. /**
  17997. * Returns a string to use to update the GPU particles update shader
  17998. * @returns a string containng the defines string
  17999. */
  18000. getEffectDefines(): string;
  18001. /**
  18002. * Returns the string "ConeParticleEmitter"
  18003. * @returns a string containing the class name
  18004. */
  18005. getClassName(): string;
  18006. /**
  18007. * Serializes the particle system to a JSON object.
  18008. * @returns the JSON object
  18009. */
  18010. serialize(): any;
  18011. /**
  18012. * Parse properties from a JSON object
  18013. * @param serializationObject defines the JSON object
  18014. */
  18015. parse(serializationObject: any): void;
  18016. }
  18017. }
  18018. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18019. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18020. import { Effect } from "babylonjs/Materials/effect";
  18021. import { Particle } from "babylonjs/Particles/particle";
  18022. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18023. /**
  18024. * Particle emitter emitting particles from the inside of a cylinder.
  18025. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18026. */
  18027. export class CylinderParticleEmitter implements IParticleEmitterType {
  18028. /**
  18029. * The radius of the emission cylinder.
  18030. */
  18031. radius: number;
  18032. /**
  18033. * The height of the emission cylinder.
  18034. */
  18035. height: number;
  18036. /**
  18037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18038. */
  18039. radiusRange: number;
  18040. /**
  18041. * How much to randomize the particle direction [0-1].
  18042. */
  18043. directionRandomizer: number;
  18044. /**
  18045. * Creates a new instance CylinderParticleEmitter
  18046. * @param radius the radius of the emission cylinder (1 by default)
  18047. * @param height the height of the emission cylinder (1 by default)
  18048. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18049. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18050. */
  18051. constructor(
  18052. /**
  18053. * The radius of the emission cylinder.
  18054. */
  18055. radius?: number,
  18056. /**
  18057. * The height of the emission cylinder.
  18058. */
  18059. height?: number,
  18060. /**
  18061. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18062. */
  18063. radiusRange?: number,
  18064. /**
  18065. * How much to randomize the particle direction [0-1].
  18066. */
  18067. directionRandomizer?: number);
  18068. /**
  18069. * Called by the particle System when the direction is computed for the created particle.
  18070. * @param worldMatrix is the world matrix of the particle system
  18071. * @param directionToUpdate is the direction vector to update with the result
  18072. * @param particle is the particle we are computed the direction for
  18073. */
  18074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18075. /**
  18076. * Called by the particle System when the position is computed for the created particle.
  18077. * @param worldMatrix is the world matrix of the particle system
  18078. * @param positionToUpdate is the position vector to update with the result
  18079. * @param particle is the particle we are computed the position for
  18080. */
  18081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18082. /**
  18083. * Clones the current emitter and returns a copy of it
  18084. * @returns the new emitter
  18085. */
  18086. clone(): CylinderParticleEmitter;
  18087. /**
  18088. * Called by the GPUParticleSystem to setup the update shader
  18089. * @param effect defines the update shader
  18090. */
  18091. applyToShader(effect: Effect): void;
  18092. /**
  18093. * Returns a string to use to update the GPU particles update shader
  18094. * @returns a string containng the defines string
  18095. */
  18096. getEffectDefines(): string;
  18097. /**
  18098. * Returns the string "CylinderParticleEmitter"
  18099. * @returns a string containing the class name
  18100. */
  18101. getClassName(): string;
  18102. /**
  18103. * Serializes the particle system to a JSON object.
  18104. * @returns the JSON object
  18105. */
  18106. serialize(): any;
  18107. /**
  18108. * Parse properties from a JSON object
  18109. * @param serializationObject defines the JSON object
  18110. */
  18111. parse(serializationObject: any): void;
  18112. }
  18113. /**
  18114. * Particle emitter emitting particles from the inside of a cylinder.
  18115. * It emits the particles randomly between two vectors.
  18116. */
  18117. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18118. /**
  18119. * The min limit of the emission direction.
  18120. */
  18121. direction1: Vector3;
  18122. /**
  18123. * The max limit of the emission direction.
  18124. */
  18125. direction2: Vector3;
  18126. /**
  18127. * Creates a new instance CylinderDirectedParticleEmitter
  18128. * @param radius the radius of the emission cylinder (1 by default)
  18129. * @param height the height of the emission cylinder (1 by default)
  18130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18131. * @param direction1 the min limit of the emission direction (up vector by default)
  18132. * @param direction2 the max limit of the emission direction (up vector by default)
  18133. */
  18134. constructor(radius?: number, height?: number, radiusRange?: number,
  18135. /**
  18136. * The min limit of the emission direction.
  18137. */
  18138. direction1?: Vector3,
  18139. /**
  18140. * The max limit of the emission direction.
  18141. */
  18142. direction2?: Vector3);
  18143. /**
  18144. * Called by the particle System when the direction is computed for the created particle.
  18145. * @param worldMatrix is the world matrix of the particle system
  18146. * @param directionToUpdate is the direction vector to update with the result
  18147. * @param particle is the particle we are computed the direction for
  18148. */
  18149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18150. /**
  18151. * Clones the current emitter and returns a copy of it
  18152. * @returns the new emitter
  18153. */
  18154. clone(): CylinderDirectedParticleEmitter;
  18155. /**
  18156. * Called by the GPUParticleSystem to setup the update shader
  18157. * @param effect defines the update shader
  18158. */
  18159. applyToShader(effect: Effect): void;
  18160. /**
  18161. * Returns a string to use to update the GPU particles update shader
  18162. * @returns a string containng the defines string
  18163. */
  18164. getEffectDefines(): string;
  18165. /**
  18166. * Returns the string "CylinderDirectedParticleEmitter"
  18167. * @returns a string containing the class name
  18168. */
  18169. getClassName(): string;
  18170. /**
  18171. * Serializes the particle system to a JSON object.
  18172. * @returns the JSON object
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Parse properties from a JSON object
  18177. * @param serializationObject defines the JSON object
  18178. */
  18179. parse(serializationObject: any): void;
  18180. }
  18181. }
  18182. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18184. import { Effect } from "babylonjs/Materials/effect";
  18185. import { Particle } from "babylonjs/Particles/particle";
  18186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18187. /**
  18188. * Particle emitter emitting particles from the inside of a hemisphere.
  18189. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18190. */
  18191. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18192. /**
  18193. * The radius of the emission hemisphere.
  18194. */
  18195. radius: number;
  18196. /**
  18197. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18198. */
  18199. radiusRange: number;
  18200. /**
  18201. * How much to randomize the particle direction [0-1].
  18202. */
  18203. directionRandomizer: number;
  18204. /**
  18205. * Creates a new instance HemisphericParticleEmitter
  18206. * @param radius the radius of the emission hemisphere (1 by default)
  18207. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18208. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18209. */
  18210. constructor(
  18211. /**
  18212. * The radius of the emission hemisphere.
  18213. */
  18214. radius?: number,
  18215. /**
  18216. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18217. */
  18218. radiusRange?: number,
  18219. /**
  18220. * How much to randomize the particle direction [0-1].
  18221. */
  18222. directionRandomizer?: number);
  18223. /**
  18224. * Called by the particle System when the direction is computed for the created particle.
  18225. * @param worldMatrix is the world matrix of the particle system
  18226. * @param directionToUpdate is the direction vector to update with the result
  18227. * @param particle is the particle we are computed the direction for
  18228. */
  18229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18230. /**
  18231. * Called by the particle System when the position is computed for the created particle.
  18232. * @param worldMatrix is the world matrix of the particle system
  18233. * @param positionToUpdate is the position vector to update with the result
  18234. * @param particle is the particle we are computed the position for
  18235. */
  18236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18237. /**
  18238. * Clones the current emitter and returns a copy of it
  18239. * @returns the new emitter
  18240. */
  18241. clone(): HemisphericParticleEmitter;
  18242. /**
  18243. * Called by the GPUParticleSystem to setup the update shader
  18244. * @param effect defines the update shader
  18245. */
  18246. applyToShader(effect: Effect): void;
  18247. /**
  18248. * Returns a string to use to update the GPU particles update shader
  18249. * @returns a string containng the defines string
  18250. */
  18251. getEffectDefines(): string;
  18252. /**
  18253. * Returns the string "HemisphericParticleEmitter"
  18254. * @returns a string containing the class name
  18255. */
  18256. getClassName(): string;
  18257. /**
  18258. * Serializes the particle system to a JSON object.
  18259. * @returns the JSON object
  18260. */
  18261. serialize(): any;
  18262. /**
  18263. * Parse properties from a JSON object
  18264. * @param serializationObject defines the JSON object
  18265. */
  18266. parse(serializationObject: any): void;
  18267. }
  18268. }
  18269. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18270. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18271. import { Effect } from "babylonjs/Materials/effect";
  18272. import { Particle } from "babylonjs/Particles/particle";
  18273. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18274. /**
  18275. * Particle emitter emitting particles from a point.
  18276. * It emits the particles randomly between 2 given directions.
  18277. */
  18278. export class PointParticleEmitter implements IParticleEmitterType {
  18279. /**
  18280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance PointParticleEmitter
  18289. */
  18290. constructor();
  18291. /**
  18292. * Called by the particle System when the direction is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param directionToUpdate is the direction vector to update with the result
  18295. * @param particle is the particle we are computed the direction for
  18296. */
  18297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Called by the particle System when the position is computed for the created particle.
  18300. * @param worldMatrix is the world matrix of the particle system
  18301. * @param positionToUpdate is the position vector to update with the result
  18302. * @param particle is the particle we are computed the position for
  18303. */
  18304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18305. /**
  18306. * Clones the current emitter and returns a copy of it
  18307. * @returns the new emitter
  18308. */
  18309. clone(): PointParticleEmitter;
  18310. /**
  18311. * Called by the GPUParticleSystem to setup the update shader
  18312. * @param effect defines the update shader
  18313. */
  18314. applyToShader(effect: Effect): void;
  18315. /**
  18316. * Returns a string to use to update the GPU particles update shader
  18317. * @returns a string containng the defines string
  18318. */
  18319. getEffectDefines(): string;
  18320. /**
  18321. * Returns the string "PointParticleEmitter"
  18322. * @returns a string containing the class name
  18323. */
  18324. getClassName(): string;
  18325. /**
  18326. * Serializes the particle system to a JSON object.
  18327. * @returns the JSON object
  18328. */
  18329. serialize(): any;
  18330. /**
  18331. * Parse properties from a JSON object
  18332. * @param serializationObject defines the JSON object
  18333. */
  18334. parse(serializationObject: any): void;
  18335. }
  18336. }
  18337. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18338. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import { Particle } from "babylonjs/Particles/particle";
  18341. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18342. /**
  18343. * Particle emitter emitting particles from the inside of a sphere.
  18344. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18345. */
  18346. export class SphereParticleEmitter implements IParticleEmitterType {
  18347. /**
  18348. * The radius of the emission sphere.
  18349. */
  18350. radius: number;
  18351. /**
  18352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18353. */
  18354. radiusRange: number;
  18355. /**
  18356. * How much to randomize the particle direction [0-1].
  18357. */
  18358. directionRandomizer: number;
  18359. /**
  18360. * Creates a new instance SphereParticleEmitter
  18361. * @param radius the radius of the emission sphere (1 by default)
  18362. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18363. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18364. */
  18365. constructor(
  18366. /**
  18367. * The radius of the emission sphere.
  18368. */
  18369. radius?: number,
  18370. /**
  18371. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18372. */
  18373. radiusRange?: number,
  18374. /**
  18375. * How much to randomize the particle direction [0-1].
  18376. */
  18377. directionRandomizer?: number);
  18378. /**
  18379. * Called by the particle System when the direction is computed for the created particle.
  18380. * @param worldMatrix is the world matrix of the particle system
  18381. * @param directionToUpdate is the direction vector to update with the result
  18382. * @param particle is the particle we are computed the direction for
  18383. */
  18384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18385. /**
  18386. * Called by the particle System when the position is computed for the created particle.
  18387. * @param worldMatrix is the world matrix of the particle system
  18388. * @param positionToUpdate is the position vector to update with the result
  18389. * @param particle is the particle we are computed the position for
  18390. */
  18391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18392. /**
  18393. * Clones the current emitter and returns a copy of it
  18394. * @returns the new emitter
  18395. */
  18396. clone(): SphereParticleEmitter;
  18397. /**
  18398. * Called by the GPUParticleSystem to setup the update shader
  18399. * @param effect defines the update shader
  18400. */
  18401. applyToShader(effect: Effect): void;
  18402. /**
  18403. * Returns a string to use to update the GPU particles update shader
  18404. * @returns a string containng the defines string
  18405. */
  18406. getEffectDefines(): string;
  18407. /**
  18408. * Returns the string "SphereParticleEmitter"
  18409. * @returns a string containing the class name
  18410. */
  18411. getClassName(): string;
  18412. /**
  18413. * Serializes the particle system to a JSON object.
  18414. * @returns the JSON object
  18415. */
  18416. serialize(): any;
  18417. /**
  18418. * Parse properties from a JSON object
  18419. * @param serializationObject defines the JSON object
  18420. */
  18421. parse(serializationObject: any): void;
  18422. }
  18423. /**
  18424. * Particle emitter emitting particles from the inside of a sphere.
  18425. * It emits the particles randomly between two vectors.
  18426. */
  18427. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18428. /**
  18429. * The min limit of the emission direction.
  18430. */
  18431. direction1: Vector3;
  18432. /**
  18433. * The max limit of the emission direction.
  18434. */
  18435. direction2: Vector3;
  18436. /**
  18437. * Creates a new instance SphereDirectedParticleEmitter
  18438. * @param radius the radius of the emission sphere (1 by default)
  18439. * @param direction1 the min limit of the emission direction (up vector by default)
  18440. * @param direction2 the max limit of the emission direction (up vector by default)
  18441. */
  18442. constructor(radius?: number,
  18443. /**
  18444. * The min limit of the emission direction.
  18445. */
  18446. direction1?: Vector3,
  18447. /**
  18448. * The max limit of the emission direction.
  18449. */
  18450. direction2?: Vector3);
  18451. /**
  18452. * Called by the particle System when the direction is computed for the created particle.
  18453. * @param worldMatrix is the world matrix of the particle system
  18454. * @param directionToUpdate is the direction vector to update with the result
  18455. * @param particle is the particle we are computed the direction for
  18456. */
  18457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18458. /**
  18459. * Clones the current emitter and returns a copy of it
  18460. * @returns the new emitter
  18461. */
  18462. clone(): SphereDirectedParticleEmitter;
  18463. /**
  18464. * Called by the GPUParticleSystem to setup the update shader
  18465. * @param effect defines the update shader
  18466. */
  18467. applyToShader(effect: Effect): void;
  18468. /**
  18469. * Returns a string to use to update the GPU particles update shader
  18470. * @returns a string containng the defines string
  18471. */
  18472. getEffectDefines(): string;
  18473. /**
  18474. * Returns the string "SphereDirectedParticleEmitter"
  18475. * @returns a string containing the class name
  18476. */
  18477. getClassName(): string;
  18478. /**
  18479. * Serializes the particle system to a JSON object.
  18480. * @returns the JSON object
  18481. */
  18482. serialize(): any;
  18483. /**
  18484. * Parse properties from a JSON object
  18485. * @param serializationObject defines the JSON object
  18486. */
  18487. parse(serializationObject: any): void;
  18488. }
  18489. }
  18490. declare module "babylonjs/Particles/EmitterTypes/index" {
  18491. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18492. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18493. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18494. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18495. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18496. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18497. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18498. }
  18499. declare module "babylonjs/Particles/IParticleSystem" {
  18500. import { Nullable } from "babylonjs/types";
  18501. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18502. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18505. import { Texture } from "babylonjs/Materials/Textures/texture";
  18506. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18507. import { Scene } from "babylonjs/scene";
  18508. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18509. import { Animation } from "babylonjs/Animations/animation";
  18510. /**
  18511. * Interface representing a particle system in Babylon.js.
  18512. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18513. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18514. */
  18515. export interface IParticleSystem {
  18516. /**
  18517. * List of animations used by the particle system.
  18518. */
  18519. animations: Animation[];
  18520. /**
  18521. * The id of the Particle system.
  18522. */
  18523. id: string;
  18524. /**
  18525. * The name of the Particle system.
  18526. */
  18527. name: string;
  18528. /**
  18529. * The emitter represents the Mesh or position we are attaching the particle system to.
  18530. */
  18531. emitter: Nullable<AbstractMesh | Vector3>;
  18532. /**
  18533. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18534. */
  18535. isBillboardBased: boolean;
  18536. /**
  18537. * The rendering group used by the Particle system to chose when to render.
  18538. */
  18539. renderingGroupId: number;
  18540. /**
  18541. * The layer mask we are rendering the particles through.
  18542. */
  18543. layerMask: number;
  18544. /**
  18545. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18546. */
  18547. updateSpeed: number;
  18548. /**
  18549. * The amount of time the particle system is running (depends of the overall update speed).
  18550. */
  18551. targetStopDuration: number;
  18552. /**
  18553. * The texture used to render each particle. (this can be a spritesheet)
  18554. */
  18555. particleTexture: Nullable<Texture>;
  18556. /**
  18557. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18558. */
  18559. blendMode: number;
  18560. /**
  18561. * Minimum life time of emitting particles.
  18562. */
  18563. minLifeTime: number;
  18564. /**
  18565. * Maximum life time of emitting particles.
  18566. */
  18567. maxLifeTime: number;
  18568. /**
  18569. * Minimum Size of emitting particles.
  18570. */
  18571. minSize: number;
  18572. /**
  18573. * Maximum Size of emitting particles.
  18574. */
  18575. maxSize: number;
  18576. /**
  18577. * Minimum scale of emitting particles on X axis.
  18578. */
  18579. minScaleX: number;
  18580. /**
  18581. * Maximum scale of emitting particles on X axis.
  18582. */
  18583. maxScaleX: number;
  18584. /**
  18585. * Minimum scale of emitting particles on Y axis.
  18586. */
  18587. minScaleY: number;
  18588. /**
  18589. * Maximum scale of emitting particles on Y axis.
  18590. */
  18591. maxScaleY: number;
  18592. /**
  18593. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18594. */
  18595. color1: Color4;
  18596. /**
  18597. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18598. */
  18599. color2: Color4;
  18600. /**
  18601. * Color the particle will have at the end of its lifetime.
  18602. */
  18603. colorDead: Color4;
  18604. /**
  18605. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18606. */
  18607. emitRate: number;
  18608. /**
  18609. * You can use gravity if you want to give an orientation to your particles.
  18610. */
  18611. gravity: Vector3;
  18612. /**
  18613. * Minimum power of emitting particles.
  18614. */
  18615. minEmitPower: number;
  18616. /**
  18617. * Maximum power of emitting particles.
  18618. */
  18619. maxEmitPower: number;
  18620. /**
  18621. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18622. */
  18623. minAngularSpeed: number;
  18624. /**
  18625. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18626. */
  18627. maxAngularSpeed: number;
  18628. /**
  18629. * Gets or sets the minimal initial rotation in radians.
  18630. */
  18631. minInitialRotation: number;
  18632. /**
  18633. * Gets or sets the maximal initial rotation in radians.
  18634. */
  18635. maxInitialRotation: number;
  18636. /**
  18637. * The particle emitter type defines the emitter used by the particle system.
  18638. * It can be for example box, sphere, or cone...
  18639. */
  18640. particleEmitterType: Nullable<IParticleEmitterType>;
  18641. /**
  18642. * Defines the delay in milliseconds before starting the system (0 by default)
  18643. */
  18644. startDelay: number;
  18645. /**
  18646. * 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
  18647. */
  18648. preWarmCycles: number;
  18649. /**
  18650. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18651. */
  18652. preWarmStepOffset: number;
  18653. /**
  18654. * 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)
  18655. */
  18656. spriteCellChangeSpeed: number;
  18657. /**
  18658. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18659. */
  18660. startSpriteCellID: number;
  18661. /**
  18662. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18663. */
  18664. endSpriteCellID: number;
  18665. /**
  18666. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18667. */
  18668. spriteCellWidth: number;
  18669. /**
  18670. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18671. */
  18672. spriteCellHeight: number;
  18673. /**
  18674. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18675. */
  18676. spriteRandomStartCell: boolean;
  18677. /**
  18678. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18679. */
  18680. isAnimationSheetEnabled: boolean;
  18681. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18682. translationPivot: Vector2;
  18683. /**
  18684. * Gets or sets a texture used to add random noise to particle positions
  18685. */
  18686. noiseTexture: Nullable<BaseTexture>;
  18687. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18688. noiseStrength: Vector3;
  18689. /**
  18690. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18691. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18692. */
  18693. billboardMode: number;
  18694. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18695. limitVelocityDamping: number;
  18696. /**
  18697. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18698. */
  18699. beginAnimationOnStart: boolean;
  18700. /**
  18701. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18702. */
  18703. beginAnimationFrom: number;
  18704. /**
  18705. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18706. */
  18707. beginAnimationTo: number;
  18708. /**
  18709. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18710. */
  18711. beginAnimationLoop: boolean;
  18712. /**
  18713. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18714. */
  18715. disposeOnStop: boolean;
  18716. /**
  18717. * Gets the maximum number of particles active at the same time.
  18718. * @returns The max number of active particles.
  18719. */
  18720. getCapacity(): number;
  18721. /**
  18722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18723. * @returns True if it has been started, otherwise false.
  18724. */
  18725. isStarted(): boolean;
  18726. /**
  18727. * Animates the particle system for this frame.
  18728. */
  18729. animate(): void;
  18730. /**
  18731. * Renders the particle system in its current state.
  18732. * @returns the current number of particles
  18733. */
  18734. render(): number;
  18735. /**
  18736. * Dispose the particle system and frees its associated resources.
  18737. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18738. */
  18739. dispose(disposeTexture?: boolean): void;
  18740. /**
  18741. * Clones the particle system.
  18742. * @param name The name of the cloned object
  18743. * @param newEmitter The new emitter to use
  18744. * @returns the cloned particle system
  18745. */
  18746. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18747. /**
  18748. * Serializes the particle system to a JSON object.
  18749. * @returns the JSON object
  18750. */
  18751. serialize(): any;
  18752. /**
  18753. * Rebuild the particle system
  18754. */
  18755. rebuild(): void;
  18756. /**
  18757. * Starts the particle system and begins to emit
  18758. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18759. */
  18760. start(delay?: number): void;
  18761. /**
  18762. * Stops the particle system.
  18763. */
  18764. stop(): void;
  18765. /**
  18766. * Remove all active particles
  18767. */
  18768. reset(): void;
  18769. /**
  18770. * Is this system ready to be used/rendered
  18771. * @return true if the system is ready
  18772. */
  18773. isReady(): boolean;
  18774. /**
  18775. * Adds a new color gradient
  18776. * @param gradient defines the gradient to use (between 0 and 1)
  18777. * @param color1 defines the color to affect to the specified gradient
  18778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18779. * @returns the current particle system
  18780. */
  18781. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18782. /**
  18783. * Remove a specific color gradient
  18784. * @param gradient defines the gradient to remove
  18785. * @returns the current particle system
  18786. */
  18787. removeColorGradient(gradient: number): IParticleSystem;
  18788. /**
  18789. * Adds a new size gradient
  18790. * @param gradient defines the gradient to use (between 0 and 1)
  18791. * @param factor defines the size factor to affect to the specified gradient
  18792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18793. * @returns the current particle system
  18794. */
  18795. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18796. /**
  18797. * Remove a specific size gradient
  18798. * @param gradient defines the gradient to remove
  18799. * @returns the current particle system
  18800. */
  18801. removeSizeGradient(gradient: number): IParticleSystem;
  18802. /**
  18803. * Gets the current list of color gradients.
  18804. * You must use addColorGradient and removeColorGradient to udpate this list
  18805. * @returns the list of color gradients
  18806. */
  18807. getColorGradients(): Nullable<Array<ColorGradient>>;
  18808. /**
  18809. * Gets the current list of size gradients.
  18810. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18811. * @returns the list of size gradients
  18812. */
  18813. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18814. /**
  18815. * Gets the current list of angular speed gradients.
  18816. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18817. * @returns the list of angular speed gradients
  18818. */
  18819. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new angular speed gradient
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the angular speed to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific angular speed gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of velocity gradients.
  18836. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18837. * @returns the list of velocity gradients
  18838. */
  18839. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new velocity gradient
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the velocity to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific velocity gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeVelocityGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of limit velocity gradients.
  18856. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18857. * @returns the list of limit velocity gradients
  18858. */
  18859. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new limit velocity gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the limit velocity to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific limit velocity gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Adds a new drag gradient
  18876. * @param gradient defines the gradient to use (between 0 and 1)
  18877. * @param factor defines the drag to affect to the specified gradient
  18878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18879. * @returns the current particle system
  18880. */
  18881. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18882. /**
  18883. * Remove a specific drag gradient
  18884. * @param gradient defines the gradient to remove
  18885. * @returns the current particle system
  18886. */
  18887. removeDragGradient(gradient: number): IParticleSystem;
  18888. /**
  18889. * Gets the current list of drag gradients.
  18890. * You must use addDragGradient and removeDragGradient to udpate this list
  18891. * @returns the list of drag gradients
  18892. */
  18893. getDragGradients(): Nullable<Array<FactorGradient>>;
  18894. /**
  18895. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18896. * @param gradient defines the gradient to use (between 0 and 1)
  18897. * @param factor defines the emit rate to affect to the specified gradient
  18898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18899. * @returns the current particle system
  18900. */
  18901. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18902. /**
  18903. * Remove a specific emit rate gradient
  18904. * @param gradient defines the gradient to remove
  18905. * @returns the current particle system
  18906. */
  18907. removeEmitRateGradient(gradient: number): IParticleSystem;
  18908. /**
  18909. * Gets the current list of emit rate gradients.
  18910. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18911. * @returns the list of emit rate gradients
  18912. */
  18913. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18914. /**
  18915. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18916. * @param gradient defines the gradient to use (between 0 and 1)
  18917. * @param factor defines the start size to affect to the specified gradient
  18918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18919. * @returns the current particle system
  18920. */
  18921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18922. /**
  18923. * Remove a specific start size gradient
  18924. * @param gradient defines the gradient to remove
  18925. * @returns the current particle system
  18926. */
  18927. removeStartSizeGradient(gradient: number): IParticleSystem;
  18928. /**
  18929. * Gets the current list of start size gradients.
  18930. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18931. * @returns the list of start size gradients
  18932. */
  18933. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18934. /**
  18935. * Adds a new life time gradient
  18936. * @param gradient defines the gradient to use (between 0 and 1)
  18937. * @param factor defines the life time factor to affect to the specified gradient
  18938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18939. * @returns the current particle system
  18940. */
  18941. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18942. /**
  18943. * Remove a specific life time gradient
  18944. * @param gradient defines the gradient to remove
  18945. * @returns the current particle system
  18946. */
  18947. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18948. /**
  18949. * Gets the current list of life time gradients.
  18950. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18951. * @returns the list of life time gradients
  18952. */
  18953. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Gets the current list of color gradients.
  18956. * You must use addColorGradient and removeColorGradient to udpate this list
  18957. * @returns the list of color gradients
  18958. */
  18959. getColorGradients(): Nullable<Array<ColorGradient>>;
  18960. /**
  18961. * Adds a new ramp gradient used to remap particle colors
  18962. * @param gradient defines the gradient to use (between 0 and 1)
  18963. * @param color defines the color to affect to the specified gradient
  18964. * @returns the current particle system
  18965. */
  18966. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18967. /**
  18968. * Gets the current list of ramp gradients.
  18969. * You must use addRampGradient and removeRampGradient to udpate this list
  18970. * @returns the list of ramp gradients
  18971. */
  18972. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18973. /** Gets or sets a boolean indicating that ramp gradients must be used
  18974. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18975. */
  18976. useRampGradients: boolean;
  18977. /**
  18978. * Adds a new color remap gradient
  18979. * @param gradient defines the gradient to use (between 0 and 1)
  18980. * @param min defines the color remap minimal range
  18981. * @param max defines the color remap maximal range
  18982. * @returns the current particle system
  18983. */
  18984. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18985. /**
  18986. * Gets the current list of color remap gradients.
  18987. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18988. * @returns the list of color remap gradients
  18989. */
  18990. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18991. /**
  18992. * Adds a new alpha remap gradient
  18993. * @param gradient defines the gradient to use (between 0 and 1)
  18994. * @param min defines the alpha remap minimal range
  18995. * @param max defines the alpha remap maximal range
  18996. * @returns the current particle system
  18997. */
  18998. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of alpha remap gradients.
  19001. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19002. * @returns the list of alpha remap gradients
  19003. */
  19004. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19009. * @returns the emitter
  19010. */
  19011. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19012. /**
  19013. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19014. * @param radius The radius of the hemisphere to emit from
  19015. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19016. * @returns the emitter
  19017. */
  19018. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19019. /**
  19020. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19021. * @param radius The radius of the sphere to emit from
  19022. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19023. * @returns the emitter
  19024. */
  19025. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19026. /**
  19027. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19028. * @param radius The radius of the sphere to emit from
  19029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19031. * @returns the emitter
  19032. */
  19033. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19034. /**
  19035. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19036. * @param radius The radius of the emission cylinder
  19037. * @param height The height of the emission cylinder
  19038. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19039. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19040. * @returns the emitter
  19041. */
  19042. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19043. /**
  19044. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19045. * @param radius The radius of the cylinder to emit from
  19046. * @param height The height of the emission cylinder
  19047. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19050. * @returns the emitter
  19051. */
  19052. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19055. * @param radius The radius of the cone to emit from
  19056. * @param angle The base angle of the cone
  19057. * @returns the emitter
  19058. */
  19059. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19060. /**
  19061. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19062. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19063. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19064. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19065. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19066. * @returns the emitter
  19067. */
  19068. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19069. /**
  19070. * Get hosting scene
  19071. * @returns the scene
  19072. */
  19073. getScene(): Scene;
  19074. }
  19075. }
  19076. declare module "babylonjs/Meshes/instancedMesh" {
  19077. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19078. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19079. import { Camera } from "babylonjs/Cameras/camera";
  19080. import { Node } from "babylonjs/node";
  19081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19082. import { Mesh } from "babylonjs/Meshes/mesh";
  19083. import { Material } from "babylonjs/Materials/material";
  19084. import { Skeleton } from "babylonjs/Bones/skeleton";
  19085. import { Light } from "babylonjs/Lights/light";
  19086. /**
  19087. * Creates an instance based on a source mesh.
  19088. */
  19089. export class InstancedMesh extends AbstractMesh {
  19090. private _sourceMesh;
  19091. private _currentLOD;
  19092. /** @hidden */
  19093. _indexInSourceMeshInstanceArray: number;
  19094. constructor(name: string, source: Mesh);
  19095. /**
  19096. * Returns the string "InstancedMesh".
  19097. */
  19098. getClassName(): string;
  19099. /** Gets the list of lights affecting that mesh */
  19100. readonly lightSources: Light[];
  19101. _resyncLightSources(): void;
  19102. _resyncLighSource(light: Light): void;
  19103. _removeLightSource(light: Light, dispose: boolean): void;
  19104. /**
  19105. * If the source mesh receives shadows
  19106. */
  19107. readonly receiveShadows: boolean;
  19108. /**
  19109. * The material of the source mesh
  19110. */
  19111. readonly material: Nullable<Material>;
  19112. /**
  19113. * Visibility of the source mesh
  19114. */
  19115. readonly visibility: number;
  19116. /**
  19117. * Skeleton of the source mesh
  19118. */
  19119. readonly skeleton: Nullable<Skeleton>;
  19120. /**
  19121. * Rendering ground id of the source mesh
  19122. */
  19123. renderingGroupId: number;
  19124. /**
  19125. * Returns the total number of vertices (integer).
  19126. */
  19127. getTotalVertices(): number;
  19128. /**
  19129. * Returns a positive integer : the total number of indices in this mesh geometry.
  19130. * @returns the numner of indices or zero if the mesh has no geometry.
  19131. */
  19132. getTotalIndices(): number;
  19133. /**
  19134. * The source mesh of the instance
  19135. */
  19136. readonly sourceMesh: Mesh;
  19137. /**
  19138. * Is this node ready to be used/rendered
  19139. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19140. * @return {boolean} is it ready
  19141. */
  19142. isReady(completeCheck?: boolean): boolean;
  19143. /**
  19144. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19145. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19146. * @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.
  19147. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19148. */
  19149. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19150. /**
  19151. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19152. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19153. * The `data` are either a numeric array either a Float32Array.
  19154. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19155. * 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).
  19156. * Note that a new underlying VertexBuffer object is created each call.
  19157. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19158. *
  19159. * Possible `kind` values :
  19160. * - VertexBuffer.PositionKind
  19161. * - VertexBuffer.UVKind
  19162. * - VertexBuffer.UV2Kind
  19163. * - VertexBuffer.UV3Kind
  19164. * - VertexBuffer.UV4Kind
  19165. * - VertexBuffer.UV5Kind
  19166. * - VertexBuffer.UV6Kind
  19167. * - VertexBuffer.ColorKind
  19168. * - VertexBuffer.MatricesIndicesKind
  19169. * - VertexBuffer.MatricesIndicesExtraKind
  19170. * - VertexBuffer.MatricesWeightsKind
  19171. * - VertexBuffer.MatricesWeightsExtraKind
  19172. *
  19173. * Returns the Mesh.
  19174. */
  19175. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19176. /**
  19177. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19178. * If the mesh has no geometry, it is simply returned as it is.
  19179. * The `data` are either a numeric array either a Float32Array.
  19180. * No new underlying VertexBuffer object is created.
  19181. * 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.
  19182. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19183. *
  19184. * Possible `kind` values :
  19185. * - VertexBuffer.PositionKind
  19186. * - VertexBuffer.UVKind
  19187. * - VertexBuffer.UV2Kind
  19188. * - VertexBuffer.UV3Kind
  19189. * - VertexBuffer.UV4Kind
  19190. * - VertexBuffer.UV5Kind
  19191. * - VertexBuffer.UV6Kind
  19192. * - VertexBuffer.ColorKind
  19193. * - VertexBuffer.MatricesIndicesKind
  19194. * - VertexBuffer.MatricesIndicesExtraKind
  19195. * - VertexBuffer.MatricesWeightsKind
  19196. * - VertexBuffer.MatricesWeightsExtraKind
  19197. *
  19198. * Returns the Mesh.
  19199. */
  19200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19201. /**
  19202. * Sets the mesh indices.
  19203. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19204. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19205. * This method creates a new index buffer each call.
  19206. * Returns the Mesh.
  19207. */
  19208. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19209. /**
  19210. * Boolean : True if the mesh owns the requested kind of data.
  19211. */
  19212. isVerticesDataPresent(kind: string): boolean;
  19213. /**
  19214. * Returns an array of indices (IndicesArray).
  19215. */
  19216. getIndices(): Nullable<IndicesArray>;
  19217. readonly _positions: Nullable<Vector3[]>;
  19218. /**
  19219. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19220. * This means the mesh underlying bounding box and sphere are recomputed.
  19221. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19222. * @returns the current mesh
  19223. */
  19224. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19225. /** @hidden */
  19226. _preActivate(): InstancedMesh;
  19227. /** @hidden */
  19228. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19229. /** @hidden */
  19230. _postActivate(): void;
  19231. getWorldMatrix(): Matrix;
  19232. readonly isAnInstance: boolean;
  19233. /**
  19234. * Returns the current associated LOD AbstractMesh.
  19235. */
  19236. getLOD(camera: Camera): AbstractMesh;
  19237. /** @hidden */
  19238. _syncSubMeshes(): InstancedMesh;
  19239. /** @hidden */
  19240. _generatePointsArray(): boolean;
  19241. /**
  19242. * Creates a new InstancedMesh from the current mesh.
  19243. * - name (string) : the cloned mesh name
  19244. * - newParent (optional Node) : the optional Node to parent the clone to.
  19245. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19246. *
  19247. * Returns the clone.
  19248. */
  19249. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19250. /**
  19251. * Disposes the InstancedMesh.
  19252. * Returns nothing.
  19253. */
  19254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19255. }
  19256. }
  19257. declare module "babylonjs/Materials/shaderMaterial" {
  19258. import { Scene } from "babylonjs/scene";
  19259. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19261. import { Mesh } from "babylonjs/Meshes/mesh";
  19262. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19264. import { Texture } from "babylonjs/Materials/Textures/texture";
  19265. import { Material } from "babylonjs/Materials/material";
  19266. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19267. /**
  19268. * Defines the options associated with the creation of a shader material.
  19269. */
  19270. export interface IShaderMaterialOptions {
  19271. /**
  19272. * Does the material work in alpha blend mode
  19273. */
  19274. needAlphaBlending: boolean;
  19275. /**
  19276. * Does the material work in alpha test mode
  19277. */
  19278. needAlphaTesting: boolean;
  19279. /**
  19280. * The list of attribute names used in the shader
  19281. */
  19282. attributes: string[];
  19283. /**
  19284. * The list of unifrom names used in the shader
  19285. */
  19286. uniforms: string[];
  19287. /**
  19288. * The list of UBO names used in the shader
  19289. */
  19290. uniformBuffers: string[];
  19291. /**
  19292. * The list of sampler names used in the shader
  19293. */
  19294. samplers: string[];
  19295. /**
  19296. * The list of defines used in the shader
  19297. */
  19298. defines: string[];
  19299. }
  19300. /**
  19301. * 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.
  19302. *
  19303. * This returned material effects how the mesh will look based on the code in the shaders.
  19304. *
  19305. * @see http://doc.babylonjs.com/how_to/shader_material
  19306. */
  19307. export class ShaderMaterial extends Material {
  19308. private _shaderPath;
  19309. private _options;
  19310. private _textures;
  19311. private _textureArrays;
  19312. private _floats;
  19313. private _ints;
  19314. private _floatsArrays;
  19315. private _colors3;
  19316. private _colors3Arrays;
  19317. private _colors4;
  19318. private _colors4Arrays;
  19319. private _vectors2;
  19320. private _vectors3;
  19321. private _vectors4;
  19322. private _matrices;
  19323. private _matrices3x3;
  19324. private _matrices2x2;
  19325. private _vectors2Arrays;
  19326. private _vectors3Arrays;
  19327. private _vectors4Arrays;
  19328. private _cachedWorldViewMatrix;
  19329. private _cachedWorldViewProjectionMatrix;
  19330. private _renderId;
  19331. /**
  19332. * Instantiate a new shader material.
  19333. * 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.
  19334. * This returned material effects how the mesh will look based on the code in the shaders.
  19335. * @see http://doc.babylonjs.com/how_to/shader_material
  19336. * @param name Define the name of the material in the scene
  19337. * @param scene Define the scene the material belongs to
  19338. * @param shaderPath Defines the route to the shader code in one of three ways:
  19339. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19340. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19341. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19342. * @param options Define the options used to create the shader
  19343. */
  19344. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19345. /**
  19346. * Gets the options used to compile the shader.
  19347. * They can be modified to trigger a new compilation
  19348. */
  19349. readonly options: IShaderMaterialOptions;
  19350. /**
  19351. * Gets the current class name of the material e.g. "ShaderMaterial"
  19352. * Mainly use in serialization.
  19353. * @returns the class name
  19354. */
  19355. getClassName(): string;
  19356. /**
  19357. * Specifies if the material will require alpha blending
  19358. * @returns a boolean specifying if alpha blending is needed
  19359. */
  19360. needAlphaBlending(): boolean;
  19361. /**
  19362. * Specifies if this material should be rendered in alpha test mode
  19363. * @returns a boolean specifying if an alpha test is needed.
  19364. */
  19365. needAlphaTesting(): boolean;
  19366. private _checkUniform;
  19367. /**
  19368. * Set a texture in the shader.
  19369. * @param name Define the name of the uniform samplers as defined in the shader
  19370. * @param texture Define the texture to bind to this sampler
  19371. * @return the material itself allowing "fluent" like uniform updates
  19372. */
  19373. setTexture(name: string, texture: Texture): ShaderMaterial;
  19374. /**
  19375. * Set a texture array in the shader.
  19376. * @param name Define the name of the uniform sampler array as defined in the shader
  19377. * @param textures Define the list of textures to bind to this sampler
  19378. * @return the material itself allowing "fluent" like uniform updates
  19379. */
  19380. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19381. /**
  19382. * Set a float in the shader.
  19383. * @param name Define the name of the uniform as defined in the shader
  19384. * @param value Define the value to give to the uniform
  19385. * @return the material itself allowing "fluent" like uniform updates
  19386. */
  19387. setFloat(name: string, value: number): ShaderMaterial;
  19388. /**
  19389. * Set a int in the shader.
  19390. * @param name Define the name of the uniform as defined in the shader
  19391. * @param value Define the value to give to the uniform
  19392. * @return the material itself allowing "fluent" like uniform updates
  19393. */
  19394. setInt(name: string, value: number): ShaderMaterial;
  19395. /**
  19396. * Set an array of floats in the shader.
  19397. * @param name Define the name of the uniform as defined in the shader
  19398. * @param value Define the value to give to the uniform
  19399. * @return the material itself allowing "fluent" like uniform updates
  19400. */
  19401. setFloats(name: string, value: number[]): ShaderMaterial;
  19402. /**
  19403. * Set a vec3 in the shader from a Color3.
  19404. * @param name Define the name of the uniform as defined in the shader
  19405. * @param value Define the value to give to the uniform
  19406. * @return the material itself allowing "fluent" like uniform updates
  19407. */
  19408. setColor3(name: string, value: Color3): ShaderMaterial;
  19409. /**
  19410. * Set a vec3 array in the shader from a Color3 array.
  19411. * @param name Define the name of the uniform as defined in the shader
  19412. * @param value Define the value to give to the uniform
  19413. * @return the material itself allowing "fluent" like uniform updates
  19414. */
  19415. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19416. /**
  19417. * Set a vec4 in the shader from a Color4.
  19418. * @param name Define the name of the uniform as defined in the shader
  19419. * @param value Define the value to give to the uniform
  19420. * @return the material itself allowing "fluent" like uniform updates
  19421. */
  19422. setColor4(name: string, value: Color4): ShaderMaterial;
  19423. /**
  19424. * Set a vec4 array in the shader from a Color4 array.
  19425. * @param name Define the name of the uniform as defined in the shader
  19426. * @param value Define the value to give to the uniform
  19427. * @return the material itself allowing "fluent" like uniform updates
  19428. */
  19429. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19430. /**
  19431. * Set a vec2 in the shader from a Vector2.
  19432. * @param name Define the name of the uniform as defined in the shader
  19433. * @param value Define the value to give to the uniform
  19434. * @return the material itself allowing "fluent" like uniform updates
  19435. */
  19436. setVector2(name: string, value: Vector2): ShaderMaterial;
  19437. /**
  19438. * Set a vec3 in the shader from a Vector3.
  19439. * @param name Define the name of the uniform as defined in the shader
  19440. * @param value Define the value to give to the uniform
  19441. * @return the material itself allowing "fluent" like uniform updates
  19442. */
  19443. setVector3(name: string, value: Vector3): ShaderMaterial;
  19444. /**
  19445. * Set a vec4 in the shader from a Vector4.
  19446. * @param name Define the name of the uniform as defined in the shader
  19447. * @param value Define the value to give to the uniform
  19448. * @return the material itself allowing "fluent" like uniform updates
  19449. */
  19450. setVector4(name: string, value: Vector4): ShaderMaterial;
  19451. /**
  19452. * Set a mat4 in the shader from a Matrix.
  19453. * @param name Define the name of the uniform as defined in the shader
  19454. * @param value Define the value to give to the uniform
  19455. * @return the material itself allowing "fluent" like uniform updates
  19456. */
  19457. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19458. /**
  19459. * Set a mat3 in the shader from a Float32Array.
  19460. * @param name Define the name of the uniform as defined in the shader
  19461. * @param value Define the value to give to the uniform
  19462. * @return the material itself allowing "fluent" like uniform updates
  19463. */
  19464. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19465. /**
  19466. * Set a mat2 in the shader from a Float32Array.
  19467. * @param name Define the name of the uniform as defined in the shader
  19468. * @param value Define the value to give to the uniform
  19469. * @return the material itself allowing "fluent" like uniform updates
  19470. */
  19471. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19472. /**
  19473. * Set a vec2 array in the shader from a number array.
  19474. * @param name Define the name of the uniform as defined in the shader
  19475. * @param value Define the value to give to the uniform
  19476. * @return the material itself allowing "fluent" like uniform updates
  19477. */
  19478. setArray2(name: string, value: number[]): ShaderMaterial;
  19479. /**
  19480. * Set a vec3 array in the shader from a number array.
  19481. * @param name Define the name of the uniform as defined in the shader
  19482. * @param value Define the value to give to the uniform
  19483. * @return the material itself allowing "fluent" like uniform updates
  19484. */
  19485. setArray3(name: string, value: number[]): ShaderMaterial;
  19486. /**
  19487. * Set a vec4 array in the shader from a number array.
  19488. * @param name Define the name of the uniform as defined in the shader
  19489. * @param value Define the value to give to the uniform
  19490. * @return the material itself allowing "fluent" like uniform updates
  19491. */
  19492. setArray4(name: string, value: number[]): ShaderMaterial;
  19493. private _checkCache;
  19494. /**
  19495. * Specifies that the submesh is ready to be used
  19496. * @param mesh defines the mesh to check
  19497. * @param subMesh defines which submesh to check
  19498. * @param useInstances specifies that instances should be used
  19499. * @returns a boolean indicating that the submesh is ready or not
  19500. */
  19501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19502. /**
  19503. * Checks if the material is ready to render the requested mesh
  19504. * @param mesh Define the mesh to render
  19505. * @param useInstances Define whether or not the material is used with instances
  19506. * @returns true if ready, otherwise false
  19507. */
  19508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19509. /**
  19510. * Binds the world matrix to the material
  19511. * @param world defines the world transformation matrix
  19512. */
  19513. bindOnlyWorldMatrix(world: Matrix): void;
  19514. /**
  19515. * Binds the material to the mesh
  19516. * @param world defines the world transformation matrix
  19517. * @param mesh defines the mesh to bind the material to
  19518. */
  19519. bind(world: Matrix, mesh?: Mesh): void;
  19520. /**
  19521. * Gets the active textures from the material
  19522. * @returns an array of textures
  19523. */
  19524. getActiveTextures(): BaseTexture[];
  19525. /**
  19526. * Specifies if the material uses a texture
  19527. * @param texture defines the texture to check against the material
  19528. * @returns a boolean specifying if the material uses the texture
  19529. */
  19530. hasTexture(texture: BaseTexture): boolean;
  19531. /**
  19532. * Makes a duplicate of the material, and gives it a new name
  19533. * @param name defines the new name for the duplicated material
  19534. * @returns the cloned material
  19535. */
  19536. clone(name: string): ShaderMaterial;
  19537. /**
  19538. * Disposes the material
  19539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19542. */
  19543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19544. /**
  19545. * Serializes this material in a JSON representation
  19546. * @returns the serialized material object
  19547. */
  19548. serialize(): any;
  19549. /**
  19550. * Creates a shader material from parsed shader material data
  19551. * @param source defines the JSON represnetation of the material
  19552. * @param scene defines the hosting scene
  19553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19554. * @returns a new material
  19555. */
  19556. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19557. }
  19558. }
  19559. declare module "babylonjs/Shaders/color.fragment" {
  19560. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19561. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19562. /** @hidden */
  19563. export var colorPixelShader: {
  19564. name: string;
  19565. shader: string;
  19566. };
  19567. }
  19568. declare module "babylonjs/Shaders/color.vertex" {
  19569. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19571. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19572. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19573. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19574. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19575. /** @hidden */
  19576. export var colorVertexShader: {
  19577. name: string;
  19578. shader: string;
  19579. };
  19580. }
  19581. declare module "babylonjs/Meshes/linesMesh" {
  19582. import { Nullable } from "babylonjs/types";
  19583. import { Scene } from "babylonjs/scene";
  19584. import { Color3 } from "babylonjs/Maths/math.color";
  19585. import { Node } from "babylonjs/node";
  19586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19587. import { Mesh } from "babylonjs/Meshes/mesh";
  19588. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19589. import { Effect } from "babylonjs/Materials/effect";
  19590. import { Material } from "babylonjs/Materials/material";
  19591. import "babylonjs/Shaders/color.fragment";
  19592. import "babylonjs/Shaders/color.vertex";
  19593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19594. /**
  19595. * Line mesh
  19596. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19597. */
  19598. export class LinesMesh extends Mesh {
  19599. /**
  19600. * If vertex color should be applied to the mesh
  19601. */
  19602. readonly useVertexColor?: boolean | undefined;
  19603. /**
  19604. * If vertex alpha should be applied to the mesh
  19605. */
  19606. readonly useVertexAlpha?: boolean | undefined;
  19607. /**
  19608. * Color of the line (Default: White)
  19609. */
  19610. color: Color3;
  19611. /**
  19612. * Alpha of the line (Default: 1)
  19613. */
  19614. alpha: number;
  19615. /**
  19616. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19617. * This margin is expressed in world space coordinates, so its value may vary.
  19618. * Default value is 0.1
  19619. */
  19620. intersectionThreshold: number;
  19621. private _colorShader;
  19622. private color4;
  19623. /**
  19624. * Creates a new LinesMesh
  19625. * @param name defines the name
  19626. * @param scene defines the hosting scene
  19627. * @param parent defines the parent mesh if any
  19628. * @param source defines the optional source LinesMesh used to clone data from
  19629. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19630. * When false, achieved by calling a clone(), also passing False.
  19631. * This will make creation of children, recursive.
  19632. * @param useVertexColor defines if this LinesMesh supports vertex color
  19633. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19634. */
  19635. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19636. /**
  19637. * If vertex color should be applied to the mesh
  19638. */
  19639. useVertexColor?: boolean | undefined,
  19640. /**
  19641. * If vertex alpha should be applied to the mesh
  19642. */
  19643. useVertexAlpha?: boolean | undefined);
  19644. private _addClipPlaneDefine;
  19645. private _removeClipPlaneDefine;
  19646. isReady(): boolean;
  19647. /**
  19648. * Returns the string "LineMesh"
  19649. */
  19650. getClassName(): string;
  19651. /**
  19652. * @hidden
  19653. */
  19654. /**
  19655. * @hidden
  19656. */
  19657. material: Material;
  19658. /**
  19659. * @hidden
  19660. */
  19661. readonly checkCollisions: boolean;
  19662. /** @hidden */
  19663. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19664. /** @hidden */
  19665. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19666. /**
  19667. * Disposes of the line mesh
  19668. * @param doNotRecurse If children should be disposed
  19669. */
  19670. dispose(doNotRecurse?: boolean): void;
  19671. /**
  19672. * Returns a new LineMesh object cloned from the current one.
  19673. */
  19674. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19675. /**
  19676. * Creates a new InstancedLinesMesh object from the mesh model.
  19677. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19678. * @param name defines the name of the new instance
  19679. * @returns a new InstancedLinesMesh
  19680. */
  19681. createInstance(name: string): InstancedLinesMesh;
  19682. }
  19683. /**
  19684. * Creates an instance based on a source LinesMesh
  19685. */
  19686. export class InstancedLinesMesh extends InstancedMesh {
  19687. /**
  19688. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19689. * This margin is expressed in world space coordinates, so its value may vary.
  19690. * Initilized with the intersectionThreshold value of the source LinesMesh
  19691. */
  19692. intersectionThreshold: number;
  19693. constructor(name: string, source: LinesMesh);
  19694. /**
  19695. * Returns the string "InstancedLinesMesh".
  19696. */
  19697. getClassName(): string;
  19698. }
  19699. }
  19700. declare module "babylonjs/Shaders/line.fragment" {
  19701. /** @hidden */
  19702. export var linePixelShader: {
  19703. name: string;
  19704. shader: string;
  19705. };
  19706. }
  19707. declare module "babylonjs/Shaders/line.vertex" {
  19708. /** @hidden */
  19709. export var lineVertexShader: {
  19710. name: string;
  19711. shader: string;
  19712. };
  19713. }
  19714. declare module "babylonjs/Rendering/edgesRenderer" {
  19715. import { Nullable } from "babylonjs/types";
  19716. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19718. import { Vector3 } from "babylonjs/Maths/math.vector";
  19719. import { IDisposable } from "babylonjs/scene";
  19720. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19721. import "babylonjs/Shaders/line.fragment";
  19722. import "babylonjs/Shaders/line.vertex";
  19723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19724. module "babylonjs/Meshes/abstractMesh" {
  19725. interface AbstractMesh {
  19726. /**
  19727. * Gets the edgesRenderer associated with the mesh
  19728. */
  19729. edgesRenderer: Nullable<EdgesRenderer>;
  19730. }
  19731. }
  19732. module "babylonjs/Meshes/linesMesh" {
  19733. interface LinesMesh {
  19734. /**
  19735. * Enables the edge rendering mode on the mesh.
  19736. * This mode makes the mesh edges visible
  19737. * @param epsilon defines the maximal distance between two angles to detect a face
  19738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19739. * @returns the currentAbstractMesh
  19740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19741. */
  19742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19743. }
  19744. }
  19745. module "babylonjs/Meshes/linesMesh" {
  19746. interface InstancedLinesMesh {
  19747. /**
  19748. * Enables the edge rendering mode on the mesh.
  19749. * This mode makes the mesh edges visible
  19750. * @param epsilon defines the maximal distance between two angles to detect a face
  19751. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19752. * @returns the current InstancedLinesMesh
  19753. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19754. */
  19755. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19756. }
  19757. }
  19758. /**
  19759. * Defines the minimum contract an Edges renderer should follow.
  19760. */
  19761. export interface IEdgesRenderer extends IDisposable {
  19762. /**
  19763. * Gets or sets a boolean indicating if the edgesRenderer is active
  19764. */
  19765. isEnabled: boolean;
  19766. /**
  19767. * Renders the edges of the attached mesh,
  19768. */
  19769. render(): void;
  19770. /**
  19771. * Checks wether or not the edges renderer is ready to render.
  19772. * @return true if ready, otherwise false.
  19773. */
  19774. isReady(): boolean;
  19775. }
  19776. /**
  19777. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19778. */
  19779. export class EdgesRenderer implements IEdgesRenderer {
  19780. /**
  19781. * Define the size of the edges with an orthographic camera
  19782. */
  19783. edgesWidthScalerForOrthographic: number;
  19784. /**
  19785. * Define the size of the edges with a perspective camera
  19786. */
  19787. edgesWidthScalerForPerspective: number;
  19788. protected _source: AbstractMesh;
  19789. protected _linesPositions: number[];
  19790. protected _linesNormals: number[];
  19791. protected _linesIndices: number[];
  19792. protected _epsilon: number;
  19793. protected _indicesCount: number;
  19794. protected _lineShader: ShaderMaterial;
  19795. protected _ib: DataBuffer;
  19796. protected _buffers: {
  19797. [key: string]: Nullable<VertexBuffer>;
  19798. };
  19799. protected _checkVerticesInsteadOfIndices: boolean;
  19800. private _meshRebuildObserver;
  19801. private _meshDisposeObserver;
  19802. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19803. isEnabled: boolean;
  19804. /**
  19805. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19806. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19807. * @param source Mesh used to create edges
  19808. * @param epsilon sum of angles in adjacency to check for edge
  19809. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19810. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19811. */
  19812. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19813. protected _prepareRessources(): void;
  19814. /** @hidden */
  19815. _rebuild(): void;
  19816. /**
  19817. * Releases the required resources for the edges renderer
  19818. */
  19819. dispose(): void;
  19820. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19821. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19822. /**
  19823. * Checks if the pair of p0 and p1 is en edge
  19824. * @param faceIndex
  19825. * @param edge
  19826. * @param faceNormals
  19827. * @param p0
  19828. * @param p1
  19829. * @private
  19830. */
  19831. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19832. /**
  19833. * push line into the position, normal and index buffer
  19834. * @protected
  19835. */
  19836. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19837. /**
  19838. * Generates lines edges from adjacencjes
  19839. * @private
  19840. */
  19841. _generateEdgesLines(): void;
  19842. /**
  19843. * Checks wether or not the edges renderer is ready to render.
  19844. * @return true if ready, otherwise false.
  19845. */
  19846. isReady(): boolean;
  19847. /**
  19848. * Renders the edges of the attached mesh,
  19849. */
  19850. render(): void;
  19851. }
  19852. /**
  19853. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19854. */
  19855. export class LineEdgesRenderer extends EdgesRenderer {
  19856. /**
  19857. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19858. * @param source LineMesh used to generate edges
  19859. * @param epsilon not important (specified angle for edge detection)
  19860. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19861. */
  19862. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19863. /**
  19864. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19865. */
  19866. _generateEdgesLines(): void;
  19867. }
  19868. }
  19869. declare module "babylonjs/Rendering/renderingGroup" {
  19870. import { SmartArray } from "babylonjs/Misc/smartArray";
  19871. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19873. import { Nullable } from "babylonjs/types";
  19874. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19875. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19876. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19877. import { Material } from "babylonjs/Materials/material";
  19878. import { Scene } from "babylonjs/scene";
  19879. /**
  19880. * This represents the object necessary to create a rendering group.
  19881. * This is exclusively used and created by the rendering manager.
  19882. * To modify the behavior, you use the available helpers in your scene or meshes.
  19883. * @hidden
  19884. */
  19885. export class RenderingGroup {
  19886. index: number;
  19887. private static _zeroVector;
  19888. private _scene;
  19889. private _opaqueSubMeshes;
  19890. private _transparentSubMeshes;
  19891. private _alphaTestSubMeshes;
  19892. private _depthOnlySubMeshes;
  19893. private _particleSystems;
  19894. private _spriteManagers;
  19895. private _opaqueSortCompareFn;
  19896. private _alphaTestSortCompareFn;
  19897. private _transparentSortCompareFn;
  19898. private _renderOpaque;
  19899. private _renderAlphaTest;
  19900. private _renderTransparent;
  19901. /** @hidden */
  19902. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19903. onBeforeTransparentRendering: () => void;
  19904. /**
  19905. * Set the opaque sort comparison function.
  19906. * If null the sub meshes will be render in the order they were created
  19907. */
  19908. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19909. /**
  19910. * Set the alpha test sort comparison function.
  19911. * If null the sub meshes will be render in the order they were created
  19912. */
  19913. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19914. /**
  19915. * Set the transparent sort comparison function.
  19916. * If null the sub meshes will be render in the order they were created
  19917. */
  19918. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19919. /**
  19920. * Creates a new rendering group.
  19921. * @param index The rendering group index
  19922. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19923. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19924. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19925. */
  19926. 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>);
  19927. /**
  19928. * Render all the sub meshes contained in the group.
  19929. * @param customRenderFunction Used to override the default render behaviour of the group.
  19930. * @returns true if rendered some submeshes.
  19931. */
  19932. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19933. /**
  19934. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19935. * @param subMeshes The submeshes to render
  19936. */
  19937. private renderOpaqueSorted;
  19938. /**
  19939. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19940. * @param subMeshes The submeshes to render
  19941. */
  19942. private renderAlphaTestSorted;
  19943. /**
  19944. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19945. * @param subMeshes The submeshes to render
  19946. */
  19947. private renderTransparentSorted;
  19948. /**
  19949. * Renders the submeshes in a specified order.
  19950. * @param subMeshes The submeshes to sort before render
  19951. * @param sortCompareFn The comparison function use to sort
  19952. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19953. * @param transparent Specifies to activate blending if true
  19954. */
  19955. private static renderSorted;
  19956. /**
  19957. * Renders the submeshes in the order they were dispatched (no sort applied).
  19958. * @param subMeshes The submeshes to render
  19959. */
  19960. private static renderUnsorted;
  19961. /**
  19962. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19963. * are rendered back to front if in the same alpha index.
  19964. *
  19965. * @param a The first submesh
  19966. * @param b The second submesh
  19967. * @returns The result of the comparison
  19968. */
  19969. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19970. /**
  19971. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19972. * are rendered back to front.
  19973. *
  19974. * @param a The first submesh
  19975. * @param b The second submesh
  19976. * @returns The result of the comparison
  19977. */
  19978. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19979. /**
  19980. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19981. * are rendered front to back (prevent overdraw).
  19982. *
  19983. * @param a The first submesh
  19984. * @param b The second submesh
  19985. * @returns The result of the comparison
  19986. */
  19987. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19988. /**
  19989. * Resets the different lists of submeshes to prepare a new frame.
  19990. */
  19991. prepare(): void;
  19992. dispose(): void;
  19993. /**
  19994. * Inserts the submesh in its correct queue depending on its material.
  19995. * @param subMesh The submesh to dispatch
  19996. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19997. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19998. */
  19999. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20000. dispatchSprites(spriteManager: ISpriteManager): void;
  20001. dispatchParticles(particleSystem: IParticleSystem): void;
  20002. private _renderParticles;
  20003. private _renderSprites;
  20004. }
  20005. }
  20006. declare module "babylonjs/Rendering/renderingManager" {
  20007. import { Nullable } from "babylonjs/types";
  20008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20010. import { SmartArray } from "babylonjs/Misc/smartArray";
  20011. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20013. import { Material } from "babylonjs/Materials/material";
  20014. import { Scene } from "babylonjs/scene";
  20015. import { Camera } from "babylonjs/Cameras/camera";
  20016. /**
  20017. * Interface describing the different options available in the rendering manager
  20018. * regarding Auto Clear between groups.
  20019. */
  20020. export interface IRenderingManagerAutoClearSetup {
  20021. /**
  20022. * Defines whether or not autoclear is enable.
  20023. */
  20024. autoClear: boolean;
  20025. /**
  20026. * Defines whether or not to autoclear the depth buffer.
  20027. */
  20028. depth: boolean;
  20029. /**
  20030. * Defines whether or not to autoclear the stencil buffer.
  20031. */
  20032. stencil: boolean;
  20033. }
  20034. /**
  20035. * This class is used by the onRenderingGroupObservable
  20036. */
  20037. export class RenderingGroupInfo {
  20038. /**
  20039. * The Scene that being rendered
  20040. */
  20041. scene: Scene;
  20042. /**
  20043. * The camera currently used for the rendering pass
  20044. */
  20045. camera: Nullable<Camera>;
  20046. /**
  20047. * The ID of the renderingGroup being processed
  20048. */
  20049. renderingGroupId: number;
  20050. }
  20051. /**
  20052. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20053. * It is enable to manage the different groups as well as the different necessary sort functions.
  20054. * This should not be used directly aside of the few static configurations
  20055. */
  20056. export class RenderingManager {
  20057. /**
  20058. * The max id used for rendering groups (not included)
  20059. */
  20060. static MAX_RENDERINGGROUPS: number;
  20061. /**
  20062. * The min id used for rendering groups (included)
  20063. */
  20064. static MIN_RENDERINGGROUPS: number;
  20065. /**
  20066. * Used to globally prevent autoclearing scenes.
  20067. */
  20068. static AUTOCLEAR: boolean;
  20069. /**
  20070. * @hidden
  20071. */
  20072. _useSceneAutoClearSetup: boolean;
  20073. private _scene;
  20074. private _renderingGroups;
  20075. private _depthStencilBufferAlreadyCleaned;
  20076. private _autoClearDepthStencil;
  20077. private _customOpaqueSortCompareFn;
  20078. private _customAlphaTestSortCompareFn;
  20079. private _customTransparentSortCompareFn;
  20080. private _renderingGroupInfo;
  20081. /**
  20082. * Instantiates a new rendering group for a particular scene
  20083. * @param scene Defines the scene the groups belongs to
  20084. */
  20085. constructor(scene: Scene);
  20086. private _clearDepthStencilBuffer;
  20087. /**
  20088. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20089. * @hidden
  20090. */
  20091. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20092. /**
  20093. * Resets the different information of the group to prepare a new frame
  20094. * @hidden
  20095. */
  20096. reset(): void;
  20097. /**
  20098. * Dispose and release the group and its associated resources.
  20099. * @hidden
  20100. */
  20101. dispose(): void;
  20102. /**
  20103. * Clear the info related to rendering groups preventing retention points during dispose.
  20104. */
  20105. freeRenderingGroups(): void;
  20106. private _prepareRenderingGroup;
  20107. /**
  20108. * Add a sprite manager to the rendering manager in order to render it this frame.
  20109. * @param spriteManager Define the sprite manager to render
  20110. */
  20111. dispatchSprites(spriteManager: ISpriteManager): void;
  20112. /**
  20113. * Add a particle system to the rendering manager in order to render it this frame.
  20114. * @param particleSystem Define the particle system to render
  20115. */
  20116. dispatchParticles(particleSystem: IParticleSystem): void;
  20117. /**
  20118. * Add a submesh to the manager in order to render it this frame
  20119. * @param subMesh The submesh to dispatch
  20120. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20121. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20122. */
  20123. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20124. /**
  20125. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20126. * This allowed control for front to back rendering or reversly depending of the special needs.
  20127. *
  20128. * @param renderingGroupId The rendering group id corresponding to its index
  20129. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20130. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20131. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20132. */
  20133. 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;
  20134. /**
  20135. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20136. *
  20137. * @param renderingGroupId The rendering group id corresponding to its index
  20138. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20139. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20140. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20141. */
  20142. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20143. /**
  20144. * Gets the current auto clear configuration for one rendering group of the rendering
  20145. * manager.
  20146. * @param index the rendering group index to get the information for
  20147. * @returns The auto clear setup for the requested rendering group
  20148. */
  20149. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20150. }
  20151. }
  20152. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20153. import { Observable } from "babylonjs/Misc/observable";
  20154. import { SmartArray } from "babylonjs/Misc/smartArray";
  20155. import { Nullable } from "babylonjs/types";
  20156. import { Camera } from "babylonjs/Cameras/camera";
  20157. import { Scene } from "babylonjs/scene";
  20158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20159. import { Color4 } from "babylonjs/Maths/math.color";
  20160. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20164. import { Texture } from "babylonjs/Materials/Textures/texture";
  20165. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20166. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20167. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20168. import { Engine } from "babylonjs/Engines/engine";
  20169. /**
  20170. * This Helps creating a texture that will be created from a camera in your scene.
  20171. * It is basically a dynamic texture that could be used to create special effects for instance.
  20172. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20173. */
  20174. export class RenderTargetTexture extends Texture {
  20175. isCube: boolean;
  20176. /**
  20177. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20178. */
  20179. static readonly REFRESHRATE_RENDER_ONCE: number;
  20180. /**
  20181. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20182. */
  20183. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20184. /**
  20185. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20186. * the central point of your effect and can save a lot of performances.
  20187. */
  20188. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20189. /**
  20190. * Use this predicate to dynamically define the list of mesh you want to render.
  20191. * If set, the renderList property will be overwritten.
  20192. */
  20193. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20194. private _renderList;
  20195. /**
  20196. * Use this list to define the list of mesh you want to render.
  20197. */
  20198. renderList: Nullable<Array<AbstractMesh>>;
  20199. private _hookArray;
  20200. /**
  20201. * Define if particles should be rendered in your texture.
  20202. */
  20203. renderParticles: boolean;
  20204. /**
  20205. * Define if sprites should be rendered in your texture.
  20206. */
  20207. renderSprites: boolean;
  20208. /**
  20209. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20210. */
  20211. coordinatesMode: number;
  20212. /**
  20213. * Define the camera used to render the texture.
  20214. */
  20215. activeCamera: Nullable<Camera>;
  20216. /**
  20217. * Override the render function of the texture with your own one.
  20218. */
  20219. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20220. /**
  20221. * Define if camera post processes should be use while rendering the texture.
  20222. */
  20223. useCameraPostProcesses: boolean;
  20224. /**
  20225. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20226. */
  20227. ignoreCameraViewport: boolean;
  20228. private _postProcessManager;
  20229. private _postProcesses;
  20230. private _resizeObserver;
  20231. /**
  20232. * An event triggered when the texture is unbind.
  20233. */
  20234. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20235. /**
  20236. * An event triggered when the texture is unbind.
  20237. */
  20238. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20239. private _onAfterUnbindObserver;
  20240. /**
  20241. * Set a after unbind callback in the texture.
  20242. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20243. */
  20244. onAfterUnbind: () => void;
  20245. /**
  20246. * An event triggered before rendering the texture
  20247. */
  20248. onBeforeRenderObservable: Observable<number>;
  20249. private _onBeforeRenderObserver;
  20250. /**
  20251. * Set a before render callback in the texture.
  20252. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20253. */
  20254. onBeforeRender: (faceIndex: number) => void;
  20255. /**
  20256. * An event triggered after rendering the texture
  20257. */
  20258. onAfterRenderObservable: Observable<number>;
  20259. private _onAfterRenderObserver;
  20260. /**
  20261. * Set a after render callback in the texture.
  20262. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20263. */
  20264. onAfterRender: (faceIndex: number) => void;
  20265. /**
  20266. * An event triggered after the texture clear
  20267. */
  20268. onClearObservable: Observable<Engine>;
  20269. private _onClearObserver;
  20270. /**
  20271. * Set a clear callback in the texture.
  20272. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20273. */
  20274. onClear: (Engine: Engine) => void;
  20275. /**
  20276. * An event triggered when the texture is resized.
  20277. */
  20278. onResizeObservable: Observable<RenderTargetTexture>;
  20279. /**
  20280. * Define the clear color of the Render Target if it should be different from the scene.
  20281. */
  20282. clearColor: Color4;
  20283. protected _size: number | {
  20284. width: number;
  20285. height: number;
  20286. };
  20287. protected _initialSizeParameter: number | {
  20288. width: number;
  20289. height: number;
  20290. } | {
  20291. ratio: number;
  20292. };
  20293. protected _sizeRatio: Nullable<number>;
  20294. /** @hidden */
  20295. _generateMipMaps: boolean;
  20296. protected _renderingManager: RenderingManager;
  20297. /** @hidden */
  20298. _waitingRenderList: string[];
  20299. protected _doNotChangeAspectRatio: boolean;
  20300. protected _currentRefreshId: number;
  20301. protected _refreshRate: number;
  20302. protected _textureMatrix: Matrix;
  20303. protected _samples: number;
  20304. protected _renderTargetOptions: RenderTargetCreationOptions;
  20305. /**
  20306. * Gets render target creation options that were used.
  20307. */
  20308. readonly renderTargetOptions: RenderTargetCreationOptions;
  20309. protected _engine: Engine;
  20310. protected _onRatioRescale(): void;
  20311. /**
  20312. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20313. * It must define where the camera used to render the texture is set
  20314. */
  20315. boundingBoxPosition: Vector3;
  20316. private _boundingBoxSize;
  20317. /**
  20318. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20319. * When defined, the cubemap will switch to local mode
  20320. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20321. * @example https://www.babylonjs-playground.com/#RNASML
  20322. */
  20323. boundingBoxSize: Vector3;
  20324. /**
  20325. * In case the RTT has been created with a depth texture, get the associated
  20326. * depth texture.
  20327. * Otherwise, return null.
  20328. */
  20329. depthStencilTexture: Nullable<InternalTexture>;
  20330. /**
  20331. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20332. * or used a shadow, depth texture...
  20333. * @param name The friendly name of the texture
  20334. * @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)
  20335. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20336. * @param generateMipMaps True if mip maps need to be generated after render.
  20337. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20338. * @param type The type of the buffer in the RTT (int, half float, float...)
  20339. * @param isCube True if a cube texture needs to be created
  20340. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20341. * @param generateDepthBuffer True to generate a depth buffer
  20342. * @param generateStencilBuffer True to generate a stencil buffer
  20343. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20344. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20345. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20346. */
  20347. constructor(name: string, size: number | {
  20348. width: number;
  20349. height: number;
  20350. } | {
  20351. ratio: number;
  20352. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20353. /**
  20354. * Creates a depth stencil texture.
  20355. * This is only available in WebGL 2 or with the depth texture extension available.
  20356. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20357. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20358. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20359. */
  20360. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20361. private _processSizeParameter;
  20362. /**
  20363. * Define the number of samples to use in case of MSAA.
  20364. * It defaults to one meaning no MSAA has been enabled.
  20365. */
  20366. samples: number;
  20367. /**
  20368. * Resets the refresh counter of the texture and start bak from scratch.
  20369. * Could be useful to regenerate the texture if it is setup to render only once.
  20370. */
  20371. resetRefreshCounter(): void;
  20372. /**
  20373. * Define the refresh rate of the texture or the rendering frequency.
  20374. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20375. */
  20376. refreshRate: number;
  20377. /**
  20378. * Adds a post process to the render target rendering passes.
  20379. * @param postProcess define the post process to add
  20380. */
  20381. addPostProcess(postProcess: PostProcess): void;
  20382. /**
  20383. * Clear all the post processes attached to the render target
  20384. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20385. */
  20386. clearPostProcesses(dispose?: boolean): void;
  20387. /**
  20388. * Remove one of the post process from the list of attached post processes to the texture
  20389. * @param postProcess define the post process to remove from the list
  20390. */
  20391. removePostProcess(postProcess: PostProcess): void;
  20392. /** @hidden */
  20393. _shouldRender(): boolean;
  20394. /**
  20395. * Gets the actual render size of the texture.
  20396. * @returns the width of the render size
  20397. */
  20398. getRenderSize(): number;
  20399. /**
  20400. * Gets the actual render width of the texture.
  20401. * @returns the width of the render size
  20402. */
  20403. getRenderWidth(): number;
  20404. /**
  20405. * Gets the actual render height of the texture.
  20406. * @returns the height of the render size
  20407. */
  20408. getRenderHeight(): number;
  20409. /**
  20410. * Get if the texture can be rescaled or not.
  20411. */
  20412. readonly canRescale: boolean;
  20413. /**
  20414. * Resize the texture using a ratio.
  20415. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20416. */
  20417. scale(ratio: number): void;
  20418. /**
  20419. * Get the texture reflection matrix used to rotate/transform the reflection.
  20420. * @returns the reflection matrix
  20421. */
  20422. getReflectionTextureMatrix(): Matrix;
  20423. /**
  20424. * Resize the texture to a new desired size.
  20425. * Be carrefull as it will recreate all the data in the new texture.
  20426. * @param size Define the new size. It can be:
  20427. * - a number for squared texture,
  20428. * - an object containing { width: number, height: number }
  20429. * - or an object containing a ratio { ratio: number }
  20430. */
  20431. resize(size: number | {
  20432. width: number;
  20433. height: number;
  20434. } | {
  20435. ratio: number;
  20436. }): void;
  20437. /**
  20438. * Renders all the objects from the render list into the texture.
  20439. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20440. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20441. */
  20442. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20443. private _bestReflectionRenderTargetDimension;
  20444. /**
  20445. * @hidden
  20446. * @param faceIndex face index to bind to if this is a cubetexture
  20447. */
  20448. _bindFrameBuffer(faceIndex?: number): void;
  20449. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20450. private renderToTarget;
  20451. /**
  20452. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20453. * This allowed control for front to back rendering or reversly depending of the special needs.
  20454. *
  20455. * @param renderingGroupId The rendering group id corresponding to its index
  20456. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20457. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20458. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20459. */
  20460. 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;
  20461. /**
  20462. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20463. *
  20464. * @param renderingGroupId The rendering group id corresponding to its index
  20465. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20466. */
  20467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20468. /**
  20469. * Clones the texture.
  20470. * @returns the cloned texture
  20471. */
  20472. clone(): RenderTargetTexture;
  20473. /**
  20474. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20475. * @returns The JSON representation of the texture
  20476. */
  20477. serialize(): any;
  20478. /**
  20479. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20480. */
  20481. disposeFramebufferObjects(): void;
  20482. /**
  20483. * Dispose the texture and release its associated resources.
  20484. */
  20485. dispose(): void;
  20486. /** @hidden */
  20487. _rebuild(): void;
  20488. /**
  20489. * Clear the info related to rendering groups preventing retention point in material dispose.
  20490. */
  20491. freeRenderingGroups(): void;
  20492. /**
  20493. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20494. * @returns the view count
  20495. */
  20496. getViewCount(): number;
  20497. }
  20498. }
  20499. declare module "babylonjs/Materials/material" {
  20500. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20501. import { SmartArray } from "babylonjs/Misc/smartArray";
  20502. import { Observable } from "babylonjs/Misc/observable";
  20503. import { Nullable } from "babylonjs/types";
  20504. import { Scene } from "babylonjs/scene";
  20505. import { Matrix } from "babylonjs/Maths/math.vector";
  20506. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20508. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20509. import { Effect } from "babylonjs/Materials/effect";
  20510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20511. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20512. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20513. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20514. import { Mesh } from "babylonjs/Meshes/mesh";
  20515. import { Animation } from "babylonjs/Animations/animation";
  20516. /**
  20517. * Base class for the main features of a material in Babylon.js
  20518. */
  20519. export class Material implements IAnimatable {
  20520. /**
  20521. * Returns the triangle fill mode
  20522. */
  20523. static readonly TriangleFillMode: number;
  20524. /**
  20525. * Returns the wireframe mode
  20526. */
  20527. static readonly WireFrameFillMode: number;
  20528. /**
  20529. * Returns the point fill mode
  20530. */
  20531. static readonly PointFillMode: number;
  20532. /**
  20533. * Returns the point list draw mode
  20534. */
  20535. static readonly PointListDrawMode: number;
  20536. /**
  20537. * Returns the line list draw mode
  20538. */
  20539. static readonly LineListDrawMode: number;
  20540. /**
  20541. * Returns the line loop draw mode
  20542. */
  20543. static readonly LineLoopDrawMode: number;
  20544. /**
  20545. * Returns the line strip draw mode
  20546. */
  20547. static readonly LineStripDrawMode: number;
  20548. /**
  20549. * Returns the triangle strip draw mode
  20550. */
  20551. static readonly TriangleStripDrawMode: number;
  20552. /**
  20553. * Returns the triangle fan draw mode
  20554. */
  20555. static readonly TriangleFanDrawMode: number;
  20556. /**
  20557. * Stores the clock-wise side orientation
  20558. */
  20559. static readonly ClockWiseSideOrientation: number;
  20560. /**
  20561. * Stores the counter clock-wise side orientation
  20562. */
  20563. static readonly CounterClockWiseSideOrientation: number;
  20564. /**
  20565. * The dirty texture flag value
  20566. */
  20567. static readonly TextureDirtyFlag: number;
  20568. /**
  20569. * The dirty light flag value
  20570. */
  20571. static readonly LightDirtyFlag: number;
  20572. /**
  20573. * The dirty fresnel flag value
  20574. */
  20575. static readonly FresnelDirtyFlag: number;
  20576. /**
  20577. * The dirty attribute flag value
  20578. */
  20579. static readonly AttributesDirtyFlag: number;
  20580. /**
  20581. * The dirty misc flag value
  20582. */
  20583. static readonly MiscDirtyFlag: number;
  20584. /**
  20585. * The all dirty flag value
  20586. */
  20587. static readonly AllDirtyFlag: number;
  20588. /**
  20589. * The ID of the material
  20590. */
  20591. id: string;
  20592. /**
  20593. * Gets or sets the unique id of the material
  20594. */
  20595. uniqueId: number;
  20596. /**
  20597. * The name of the material
  20598. */
  20599. name: string;
  20600. /**
  20601. * Gets or sets user defined metadata
  20602. */
  20603. metadata: any;
  20604. /**
  20605. * For internal use only. Please do not use.
  20606. */
  20607. reservedDataStore: any;
  20608. /**
  20609. * Specifies if the ready state should be checked on each call
  20610. */
  20611. checkReadyOnEveryCall: boolean;
  20612. /**
  20613. * Specifies if the ready state should be checked once
  20614. */
  20615. checkReadyOnlyOnce: boolean;
  20616. /**
  20617. * The state of the material
  20618. */
  20619. state: string;
  20620. /**
  20621. * The alpha value of the material
  20622. */
  20623. protected _alpha: number;
  20624. /**
  20625. * List of inspectable custom properties (used by the Inspector)
  20626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20627. */
  20628. inspectableCustomProperties: IInspectable[];
  20629. /**
  20630. * Sets the alpha value of the material
  20631. */
  20632. /**
  20633. * Gets the alpha value of the material
  20634. */
  20635. alpha: number;
  20636. /**
  20637. * Specifies if back face culling is enabled
  20638. */
  20639. protected _backFaceCulling: boolean;
  20640. /**
  20641. * Sets the back-face culling state
  20642. */
  20643. /**
  20644. * Gets the back-face culling state
  20645. */
  20646. backFaceCulling: boolean;
  20647. /**
  20648. * Stores the value for side orientation
  20649. */
  20650. sideOrientation: number;
  20651. /**
  20652. * Callback triggered when the material is compiled
  20653. */
  20654. onCompiled: Nullable<(effect: Effect) => void>;
  20655. /**
  20656. * Callback triggered when an error occurs
  20657. */
  20658. onError: Nullable<(effect: Effect, errors: string) => void>;
  20659. /**
  20660. * Callback triggered to get the render target textures
  20661. */
  20662. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20663. /**
  20664. * Gets a boolean indicating that current material needs to register RTT
  20665. */
  20666. readonly hasRenderTargetTextures: boolean;
  20667. /**
  20668. * Specifies if the material should be serialized
  20669. */
  20670. doNotSerialize: boolean;
  20671. /**
  20672. * @hidden
  20673. */
  20674. _storeEffectOnSubMeshes: boolean;
  20675. /**
  20676. * Stores the animations for the material
  20677. */
  20678. animations: Nullable<Array<Animation>>;
  20679. /**
  20680. * An event triggered when the material is disposed
  20681. */
  20682. onDisposeObservable: Observable<Material>;
  20683. /**
  20684. * An observer which watches for dispose events
  20685. */
  20686. private _onDisposeObserver;
  20687. private _onUnBindObservable;
  20688. /**
  20689. * Called during a dispose event
  20690. */
  20691. onDispose: () => void;
  20692. private _onBindObservable;
  20693. /**
  20694. * An event triggered when the material is bound
  20695. */
  20696. readonly onBindObservable: Observable<AbstractMesh>;
  20697. /**
  20698. * An observer which watches for bind events
  20699. */
  20700. private _onBindObserver;
  20701. /**
  20702. * Called during a bind event
  20703. */
  20704. onBind: (Mesh: AbstractMesh) => void;
  20705. /**
  20706. * An event triggered when the material is unbound
  20707. */
  20708. readonly onUnBindObservable: Observable<Material>;
  20709. /**
  20710. * Stores the value of the alpha mode
  20711. */
  20712. private _alphaMode;
  20713. /**
  20714. * Sets the value of the alpha mode.
  20715. *
  20716. * | Value | Type | Description |
  20717. * | --- | --- | --- |
  20718. * | 0 | ALPHA_DISABLE | |
  20719. * | 1 | ALPHA_ADD | |
  20720. * | 2 | ALPHA_COMBINE | |
  20721. * | 3 | ALPHA_SUBTRACT | |
  20722. * | 4 | ALPHA_MULTIPLY | |
  20723. * | 5 | ALPHA_MAXIMIZED | |
  20724. * | 6 | ALPHA_ONEONE | |
  20725. * | 7 | ALPHA_PREMULTIPLIED | |
  20726. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20727. * | 9 | ALPHA_INTERPOLATE | |
  20728. * | 10 | ALPHA_SCREENMODE | |
  20729. *
  20730. */
  20731. /**
  20732. * Gets the value of the alpha mode
  20733. */
  20734. alphaMode: number;
  20735. /**
  20736. * Stores the state of the need depth pre-pass value
  20737. */
  20738. private _needDepthPrePass;
  20739. /**
  20740. * Sets the need depth pre-pass value
  20741. */
  20742. /**
  20743. * Gets the depth pre-pass value
  20744. */
  20745. needDepthPrePass: boolean;
  20746. /**
  20747. * Specifies if depth writing should be disabled
  20748. */
  20749. disableDepthWrite: boolean;
  20750. /**
  20751. * Specifies if depth writing should be forced
  20752. */
  20753. forceDepthWrite: boolean;
  20754. /**
  20755. * Specifies if there should be a separate pass for culling
  20756. */
  20757. separateCullingPass: boolean;
  20758. /**
  20759. * Stores the state specifing if fog should be enabled
  20760. */
  20761. private _fogEnabled;
  20762. /**
  20763. * Sets the state for enabling fog
  20764. */
  20765. /**
  20766. * Gets the value of the fog enabled state
  20767. */
  20768. fogEnabled: boolean;
  20769. /**
  20770. * Stores the size of points
  20771. */
  20772. pointSize: number;
  20773. /**
  20774. * Stores the z offset value
  20775. */
  20776. zOffset: number;
  20777. /**
  20778. * Gets a value specifying if wireframe mode is enabled
  20779. */
  20780. /**
  20781. * Sets the state of wireframe mode
  20782. */
  20783. wireframe: boolean;
  20784. /**
  20785. * Gets the value specifying if point clouds are enabled
  20786. */
  20787. /**
  20788. * Sets the state of point cloud mode
  20789. */
  20790. pointsCloud: boolean;
  20791. /**
  20792. * Gets the material fill mode
  20793. */
  20794. /**
  20795. * Sets the material fill mode
  20796. */
  20797. fillMode: number;
  20798. /**
  20799. * @hidden
  20800. * Stores the effects for the material
  20801. */
  20802. _effect: Nullable<Effect>;
  20803. /**
  20804. * @hidden
  20805. * Specifies if the material was previously ready
  20806. */
  20807. _wasPreviouslyReady: boolean;
  20808. /**
  20809. * Specifies if uniform buffers should be used
  20810. */
  20811. private _useUBO;
  20812. /**
  20813. * Stores a reference to the scene
  20814. */
  20815. private _scene;
  20816. /**
  20817. * Stores the fill mode state
  20818. */
  20819. private _fillMode;
  20820. /**
  20821. * Specifies if the depth write state should be cached
  20822. */
  20823. private _cachedDepthWriteState;
  20824. /**
  20825. * Stores the uniform buffer
  20826. */
  20827. protected _uniformBuffer: UniformBuffer;
  20828. /** @hidden */
  20829. _indexInSceneMaterialArray: number;
  20830. /** @hidden */
  20831. meshMap: Nullable<{
  20832. [id: string]: AbstractMesh | undefined;
  20833. }>;
  20834. /**
  20835. * Creates a material instance
  20836. * @param name defines the name of the material
  20837. * @param scene defines the scene to reference
  20838. * @param doNotAdd specifies if the material should be added to the scene
  20839. */
  20840. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20841. /**
  20842. * Returns a string representation of the current material
  20843. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20844. * @returns a string with material information
  20845. */
  20846. toString(fullDetails?: boolean): string;
  20847. /**
  20848. * Gets the class name of the material
  20849. * @returns a string with the class name of the material
  20850. */
  20851. getClassName(): string;
  20852. /**
  20853. * Specifies if updates for the material been locked
  20854. */
  20855. readonly isFrozen: boolean;
  20856. /**
  20857. * Locks updates for the material
  20858. */
  20859. freeze(): void;
  20860. /**
  20861. * Unlocks updates for the material
  20862. */
  20863. unfreeze(): void;
  20864. /**
  20865. * Specifies if the material is ready to be used
  20866. * @param mesh defines the mesh to check
  20867. * @param useInstances specifies if instances should be used
  20868. * @returns a boolean indicating if the material is ready to be used
  20869. */
  20870. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20871. /**
  20872. * Specifies that the submesh is ready to be used
  20873. * @param mesh defines the mesh to check
  20874. * @param subMesh defines which submesh to check
  20875. * @param useInstances specifies that instances should be used
  20876. * @returns a boolean indicating that the submesh is ready or not
  20877. */
  20878. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20879. /**
  20880. * Returns the material effect
  20881. * @returns the effect associated with the material
  20882. */
  20883. getEffect(): Nullable<Effect>;
  20884. /**
  20885. * Returns the current scene
  20886. * @returns a Scene
  20887. */
  20888. getScene(): Scene;
  20889. /**
  20890. * Specifies if the material will require alpha blending
  20891. * @returns a boolean specifying if alpha blending is needed
  20892. */
  20893. needAlphaBlending(): boolean;
  20894. /**
  20895. * Specifies if the mesh will require alpha blending
  20896. * @param mesh defines the mesh to check
  20897. * @returns a boolean specifying if alpha blending is needed for the mesh
  20898. */
  20899. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20900. /**
  20901. * Specifies if this material should be rendered in alpha test mode
  20902. * @returns a boolean specifying if an alpha test is needed.
  20903. */
  20904. needAlphaTesting(): boolean;
  20905. /**
  20906. * Gets the texture used for the alpha test
  20907. * @returns the texture to use for alpha testing
  20908. */
  20909. getAlphaTestTexture(): Nullable<BaseTexture>;
  20910. /**
  20911. * Marks the material to indicate that it needs to be re-calculated
  20912. */
  20913. markDirty(): void;
  20914. /** @hidden */
  20915. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20916. /**
  20917. * Binds the material to the mesh
  20918. * @param world defines the world transformation matrix
  20919. * @param mesh defines the mesh to bind the material to
  20920. */
  20921. bind(world: Matrix, mesh?: Mesh): void;
  20922. /**
  20923. * Binds the submesh to the material
  20924. * @param world defines the world transformation matrix
  20925. * @param mesh defines the mesh containing the submesh
  20926. * @param subMesh defines the submesh to bind the material to
  20927. */
  20928. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20929. /**
  20930. * Binds the world matrix to the material
  20931. * @param world defines the world transformation matrix
  20932. */
  20933. bindOnlyWorldMatrix(world: Matrix): void;
  20934. /**
  20935. * Binds the scene's uniform buffer to the effect.
  20936. * @param effect defines the effect to bind to the scene uniform buffer
  20937. * @param sceneUbo defines the uniform buffer storing scene data
  20938. */
  20939. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20940. /**
  20941. * Binds the view matrix to the effect
  20942. * @param effect defines the effect to bind the view matrix to
  20943. */
  20944. bindView(effect: Effect): void;
  20945. /**
  20946. * Binds the view projection matrix to the effect
  20947. * @param effect defines the effect to bind the view projection matrix to
  20948. */
  20949. bindViewProjection(effect: Effect): void;
  20950. /**
  20951. * Specifies if material alpha testing should be turned on for the mesh
  20952. * @param mesh defines the mesh to check
  20953. */
  20954. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20955. /**
  20956. * Processes to execute after binding the material to a mesh
  20957. * @param mesh defines the rendered mesh
  20958. */
  20959. protected _afterBind(mesh?: Mesh): void;
  20960. /**
  20961. * Unbinds the material from the mesh
  20962. */
  20963. unbind(): void;
  20964. /**
  20965. * Gets the active textures from the material
  20966. * @returns an array of textures
  20967. */
  20968. getActiveTextures(): BaseTexture[];
  20969. /**
  20970. * Specifies if the material uses a texture
  20971. * @param texture defines the texture to check against the material
  20972. * @returns a boolean specifying if the material uses the texture
  20973. */
  20974. hasTexture(texture: BaseTexture): boolean;
  20975. /**
  20976. * Makes a duplicate of the material, and gives it a new name
  20977. * @param name defines the new name for the duplicated material
  20978. * @returns the cloned material
  20979. */
  20980. clone(name: string): Nullable<Material>;
  20981. /**
  20982. * Gets the meshes bound to the material
  20983. * @returns an array of meshes bound to the material
  20984. */
  20985. getBindedMeshes(): AbstractMesh[];
  20986. /**
  20987. * Force shader compilation
  20988. * @param mesh defines the mesh associated with this material
  20989. * @param onCompiled defines a function to execute once the material is compiled
  20990. * @param options defines the options to configure the compilation
  20991. */
  20992. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20993. clipPlane: boolean;
  20994. }>): void;
  20995. /**
  20996. * Force shader compilation
  20997. * @param mesh defines the mesh that will use this material
  20998. * @param options defines additional options for compiling the shaders
  20999. * @returns a promise that resolves when the compilation completes
  21000. */
  21001. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21002. clipPlane: boolean;
  21003. }>): Promise<void>;
  21004. private static readonly _AllDirtyCallBack;
  21005. private static readonly _ImageProcessingDirtyCallBack;
  21006. private static readonly _TextureDirtyCallBack;
  21007. private static readonly _FresnelDirtyCallBack;
  21008. private static readonly _MiscDirtyCallBack;
  21009. private static readonly _LightsDirtyCallBack;
  21010. private static readonly _AttributeDirtyCallBack;
  21011. private static _FresnelAndMiscDirtyCallBack;
  21012. private static _TextureAndMiscDirtyCallBack;
  21013. private static readonly _DirtyCallbackArray;
  21014. private static readonly _RunDirtyCallBacks;
  21015. /**
  21016. * Marks a define in the material to indicate that it needs to be re-computed
  21017. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21018. */
  21019. markAsDirty(flag: number): void;
  21020. /**
  21021. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21022. * @param func defines a function which checks material defines against the submeshes
  21023. */
  21024. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21025. /**
  21026. * Indicates that we need to re-calculated for all submeshes
  21027. */
  21028. protected _markAllSubMeshesAsAllDirty(): void;
  21029. /**
  21030. * Indicates that image processing needs to be re-calculated for all submeshes
  21031. */
  21032. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21033. /**
  21034. * Indicates that textures need to be re-calculated for all submeshes
  21035. */
  21036. protected _markAllSubMeshesAsTexturesDirty(): void;
  21037. /**
  21038. * Indicates that fresnel needs to be re-calculated for all submeshes
  21039. */
  21040. protected _markAllSubMeshesAsFresnelDirty(): void;
  21041. /**
  21042. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21043. */
  21044. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21045. /**
  21046. * Indicates that lights need to be re-calculated for all submeshes
  21047. */
  21048. protected _markAllSubMeshesAsLightsDirty(): void;
  21049. /**
  21050. * Indicates that attributes need to be re-calculated for all submeshes
  21051. */
  21052. protected _markAllSubMeshesAsAttributesDirty(): void;
  21053. /**
  21054. * Indicates that misc needs to be re-calculated for all submeshes
  21055. */
  21056. protected _markAllSubMeshesAsMiscDirty(): void;
  21057. /**
  21058. * Indicates that textures and misc need to be re-calculated for all submeshes
  21059. */
  21060. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21061. /**
  21062. * Disposes the material
  21063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21066. */
  21067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21068. /** @hidden */
  21069. private releaseVertexArrayObject;
  21070. /**
  21071. * Serializes this material
  21072. * @returns the serialized material object
  21073. */
  21074. serialize(): any;
  21075. /**
  21076. * Creates a material from parsed material data
  21077. * @param parsedMaterial defines parsed material data
  21078. * @param scene defines the hosting scene
  21079. * @param rootUrl defines the root URL to use to load textures
  21080. * @returns a new material
  21081. */
  21082. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21083. }
  21084. }
  21085. declare module "babylonjs/Materials/multiMaterial" {
  21086. import { Nullable } from "babylonjs/types";
  21087. import { Scene } from "babylonjs/scene";
  21088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21089. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21090. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21091. import { Material } from "babylonjs/Materials/material";
  21092. /**
  21093. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21094. * separate meshes. This can be use to improve performances.
  21095. * @see http://doc.babylonjs.com/how_to/multi_materials
  21096. */
  21097. export class MultiMaterial extends Material {
  21098. private _subMaterials;
  21099. /**
  21100. * Gets or Sets the list of Materials used within the multi material.
  21101. * They need to be ordered according to the submeshes order in the associated mesh
  21102. */
  21103. subMaterials: Nullable<Material>[];
  21104. /**
  21105. * Function used to align with Node.getChildren()
  21106. * @returns the list of Materials used within the multi material
  21107. */
  21108. getChildren(): Nullable<Material>[];
  21109. /**
  21110. * Instantiates a new Multi Material
  21111. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21112. * separate meshes. This can be use to improve performances.
  21113. * @see http://doc.babylonjs.com/how_to/multi_materials
  21114. * @param name Define the name in the scene
  21115. * @param scene Define the scene the material belongs to
  21116. */
  21117. constructor(name: string, scene: Scene);
  21118. private _hookArray;
  21119. /**
  21120. * Get one of the submaterial by its index in the submaterials array
  21121. * @param index The index to look the sub material at
  21122. * @returns The Material if the index has been defined
  21123. */
  21124. getSubMaterial(index: number): Nullable<Material>;
  21125. /**
  21126. * Get the list of active textures for the whole sub materials list.
  21127. * @returns All the textures that will be used during the rendering
  21128. */
  21129. getActiveTextures(): BaseTexture[];
  21130. /**
  21131. * Gets the current class name of the material e.g. "MultiMaterial"
  21132. * Mainly use in serialization.
  21133. * @returns the class name
  21134. */
  21135. getClassName(): string;
  21136. /**
  21137. * Checks if the material is ready to render the requested sub mesh
  21138. * @param mesh Define the mesh the submesh belongs to
  21139. * @param subMesh Define the sub mesh to look readyness for
  21140. * @param useInstances Define whether or not the material is used with instances
  21141. * @returns true if ready, otherwise false
  21142. */
  21143. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21144. /**
  21145. * Clones the current material and its related sub materials
  21146. * @param name Define the name of the newly cloned material
  21147. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21148. * @returns the cloned material
  21149. */
  21150. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21151. /**
  21152. * Serializes the materials into a JSON representation.
  21153. * @returns the JSON representation
  21154. */
  21155. serialize(): any;
  21156. /**
  21157. * Dispose the material and release its associated resources
  21158. * @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)
  21159. * @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)
  21160. * @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)
  21161. */
  21162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21163. /**
  21164. * Creates a MultiMaterial from parsed MultiMaterial data.
  21165. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21166. * @param scene defines the hosting scene
  21167. * @returns a new MultiMaterial
  21168. */
  21169. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21170. }
  21171. }
  21172. declare module "babylonjs/Meshes/subMesh" {
  21173. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21175. import { Engine } from "babylonjs/Engines/engine";
  21176. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21177. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21178. import { Effect } from "babylonjs/Materials/effect";
  21179. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21180. import { Plane } from "babylonjs/Maths/math.plane";
  21181. import { Collider } from "babylonjs/Collisions/collider";
  21182. import { Material } from "babylonjs/Materials/material";
  21183. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { Mesh } from "babylonjs/Meshes/mesh";
  21186. import { Ray } from "babylonjs/Culling/ray";
  21187. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21188. /**
  21189. * Base class for submeshes
  21190. */
  21191. export class BaseSubMesh {
  21192. /** @hidden */
  21193. _materialDefines: Nullable<MaterialDefines>;
  21194. /** @hidden */
  21195. _materialEffect: Nullable<Effect>;
  21196. /**
  21197. * Gets associated effect
  21198. */
  21199. readonly effect: Nullable<Effect>;
  21200. /**
  21201. * Sets associated effect (effect used to render this submesh)
  21202. * @param effect defines the effect to associate with
  21203. * @param defines defines the set of defines used to compile this effect
  21204. */
  21205. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21206. }
  21207. /**
  21208. * Defines a subdivision inside a mesh
  21209. */
  21210. export class SubMesh extends BaseSubMesh implements ICullable {
  21211. /** the material index to use */
  21212. materialIndex: number;
  21213. /** vertex index start */
  21214. verticesStart: number;
  21215. /** vertices count */
  21216. verticesCount: number;
  21217. /** index start */
  21218. indexStart: number;
  21219. /** indices count */
  21220. indexCount: number;
  21221. /** @hidden */
  21222. _linesIndexCount: number;
  21223. private _mesh;
  21224. private _renderingMesh;
  21225. private _boundingInfo;
  21226. private _linesIndexBuffer;
  21227. /** @hidden */
  21228. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21229. /** @hidden */
  21230. _trianglePlanes: Plane[];
  21231. /** @hidden */
  21232. _lastColliderTransformMatrix: Nullable<Matrix>;
  21233. /** @hidden */
  21234. _renderId: number;
  21235. /** @hidden */
  21236. _alphaIndex: number;
  21237. /** @hidden */
  21238. _distanceToCamera: number;
  21239. /** @hidden */
  21240. _id: number;
  21241. private _currentMaterial;
  21242. /**
  21243. * Add a new submesh to a mesh
  21244. * @param materialIndex defines the material index to use
  21245. * @param verticesStart defines vertex index start
  21246. * @param verticesCount defines vertices count
  21247. * @param indexStart defines index start
  21248. * @param indexCount defines indices count
  21249. * @param mesh defines the parent mesh
  21250. * @param renderingMesh defines an optional rendering mesh
  21251. * @param createBoundingBox defines if bounding box should be created for this submesh
  21252. * @returns the new submesh
  21253. */
  21254. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21255. /**
  21256. * Creates a new submesh
  21257. * @param materialIndex defines the material index to use
  21258. * @param verticesStart defines vertex index start
  21259. * @param verticesCount defines vertices count
  21260. * @param indexStart defines index start
  21261. * @param indexCount defines indices count
  21262. * @param mesh defines the parent mesh
  21263. * @param renderingMesh defines an optional rendering mesh
  21264. * @param createBoundingBox defines if bounding box should be created for this submesh
  21265. */
  21266. constructor(
  21267. /** the material index to use */
  21268. materialIndex: number,
  21269. /** vertex index start */
  21270. verticesStart: number,
  21271. /** vertices count */
  21272. verticesCount: number,
  21273. /** index start */
  21274. indexStart: number,
  21275. /** indices count */
  21276. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21277. /**
  21278. * Returns true if this submesh covers the entire parent mesh
  21279. * @ignorenaming
  21280. */
  21281. readonly IsGlobal: boolean;
  21282. /**
  21283. * Returns the submesh BoudingInfo object
  21284. * @returns current bounding info (or mesh's one if the submesh is global)
  21285. */
  21286. getBoundingInfo(): BoundingInfo;
  21287. /**
  21288. * Sets the submesh BoundingInfo
  21289. * @param boundingInfo defines the new bounding info to use
  21290. * @returns the SubMesh
  21291. */
  21292. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21293. /**
  21294. * Returns the mesh of the current submesh
  21295. * @return the parent mesh
  21296. */
  21297. getMesh(): AbstractMesh;
  21298. /**
  21299. * Returns the rendering mesh of the submesh
  21300. * @returns the rendering mesh (could be different from parent mesh)
  21301. */
  21302. getRenderingMesh(): Mesh;
  21303. /**
  21304. * Returns the submesh material
  21305. * @returns null or the current material
  21306. */
  21307. getMaterial(): Nullable<Material>;
  21308. /**
  21309. * Sets a new updated BoundingInfo object to the submesh
  21310. * @param data defines an optional position array to use to determine the bounding info
  21311. * @returns the SubMesh
  21312. */
  21313. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21314. /** @hidden */
  21315. _checkCollision(collider: Collider): boolean;
  21316. /**
  21317. * Updates the submesh BoundingInfo
  21318. * @param world defines the world matrix to use to update the bounding info
  21319. * @returns the submesh
  21320. */
  21321. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21322. /**
  21323. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21324. * @param frustumPlanes defines the frustum planes
  21325. * @returns true if the submesh is intersecting with the frustum
  21326. */
  21327. isInFrustum(frustumPlanes: Plane[]): boolean;
  21328. /**
  21329. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21330. * @param frustumPlanes defines the frustum planes
  21331. * @returns true if the submesh is inside the frustum
  21332. */
  21333. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21334. /**
  21335. * Renders the submesh
  21336. * @param enableAlphaMode defines if alpha needs to be used
  21337. * @returns the submesh
  21338. */
  21339. render(enableAlphaMode: boolean): SubMesh;
  21340. /**
  21341. * @hidden
  21342. */
  21343. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21344. /**
  21345. * Checks if the submesh intersects with a ray
  21346. * @param ray defines the ray to test
  21347. * @returns true is the passed ray intersects the submesh bounding box
  21348. */
  21349. canIntersects(ray: Ray): boolean;
  21350. /**
  21351. * Intersects current submesh with a ray
  21352. * @param ray defines the ray to test
  21353. * @param positions defines mesh's positions array
  21354. * @param indices defines mesh's indices array
  21355. * @param fastCheck defines if only bounding info should be used
  21356. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21357. * @returns intersection info or null if no intersection
  21358. */
  21359. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21360. /** @hidden */
  21361. private _intersectLines;
  21362. /** @hidden */
  21363. private _intersectUnIndexedLines;
  21364. /** @hidden */
  21365. private _intersectTriangles;
  21366. /** @hidden */
  21367. private _intersectUnIndexedTriangles;
  21368. /** @hidden */
  21369. _rebuild(): void;
  21370. /**
  21371. * Creates a new submesh from the passed mesh
  21372. * @param newMesh defines the new hosting mesh
  21373. * @param newRenderingMesh defines an optional rendering mesh
  21374. * @returns the new submesh
  21375. */
  21376. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21377. /**
  21378. * Release associated resources
  21379. */
  21380. dispose(): void;
  21381. /**
  21382. * Gets the class name
  21383. * @returns the string "SubMesh".
  21384. */
  21385. getClassName(): string;
  21386. /**
  21387. * Creates a new submesh from indices data
  21388. * @param materialIndex the index of the main mesh material
  21389. * @param startIndex the index where to start the copy in the mesh indices array
  21390. * @param indexCount the number of indices to copy then from the startIndex
  21391. * @param mesh the main mesh to create the submesh from
  21392. * @param renderingMesh the optional rendering mesh
  21393. * @returns a new submesh
  21394. */
  21395. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21396. }
  21397. }
  21398. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21399. /**
  21400. * Class used to represent data loading progression
  21401. */
  21402. export class SceneLoaderFlags {
  21403. private static _ForceFullSceneLoadingForIncremental;
  21404. private static _ShowLoadingScreen;
  21405. private static _CleanBoneMatrixWeights;
  21406. private static _loggingLevel;
  21407. /**
  21408. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21409. */
  21410. static ForceFullSceneLoadingForIncremental: boolean;
  21411. /**
  21412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21413. */
  21414. static ShowLoadingScreen: boolean;
  21415. /**
  21416. * Defines the current logging level (while loading the scene)
  21417. * @ignorenaming
  21418. */
  21419. static loggingLevel: number;
  21420. /**
  21421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21422. */
  21423. static CleanBoneMatrixWeights: boolean;
  21424. }
  21425. }
  21426. declare module "babylonjs/Meshes/geometry" {
  21427. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21428. import { Scene } from "babylonjs/scene";
  21429. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21430. import { Engine } from "babylonjs/Engines/engine";
  21431. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21432. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21433. import { Effect } from "babylonjs/Materials/effect";
  21434. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21435. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21436. import { Mesh } from "babylonjs/Meshes/mesh";
  21437. /**
  21438. * Class used to store geometry data (vertex buffers + index buffer)
  21439. */
  21440. export class Geometry implements IGetSetVerticesData {
  21441. /**
  21442. * Gets or sets the ID of the geometry
  21443. */
  21444. id: string;
  21445. /**
  21446. * Gets or sets the unique ID of the geometry
  21447. */
  21448. uniqueId: number;
  21449. /**
  21450. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21451. */
  21452. delayLoadState: number;
  21453. /**
  21454. * Gets the file containing the data to load when running in delay load state
  21455. */
  21456. delayLoadingFile: Nullable<string>;
  21457. /**
  21458. * Callback called when the geometry is updated
  21459. */
  21460. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21461. private _scene;
  21462. private _engine;
  21463. private _meshes;
  21464. private _totalVertices;
  21465. /** @hidden */
  21466. _indices: IndicesArray;
  21467. /** @hidden */
  21468. _vertexBuffers: {
  21469. [key: string]: VertexBuffer;
  21470. };
  21471. private _isDisposed;
  21472. private _extend;
  21473. private _boundingBias;
  21474. /** @hidden */
  21475. _delayInfo: Array<string>;
  21476. private _indexBuffer;
  21477. private _indexBufferIsUpdatable;
  21478. /** @hidden */
  21479. _boundingInfo: Nullable<BoundingInfo>;
  21480. /** @hidden */
  21481. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21482. /** @hidden */
  21483. _softwareSkinningFrameId: number;
  21484. private _vertexArrayObjects;
  21485. private _updatable;
  21486. /** @hidden */
  21487. _positions: Nullable<Vector3[]>;
  21488. /**
  21489. * 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
  21490. */
  21491. /**
  21492. * 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
  21493. */
  21494. boundingBias: Vector2;
  21495. /**
  21496. * Static function used to attach a new empty geometry to a mesh
  21497. * @param mesh defines the mesh to attach the geometry to
  21498. * @returns the new Geometry
  21499. */
  21500. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21501. /**
  21502. * Creates a new geometry
  21503. * @param id defines the unique ID
  21504. * @param scene defines the hosting scene
  21505. * @param vertexData defines the VertexData used to get geometry data
  21506. * @param updatable defines if geometry must be updatable (false by default)
  21507. * @param mesh defines the mesh that will be associated with the geometry
  21508. */
  21509. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21510. /**
  21511. * Gets the current extend of the geometry
  21512. */
  21513. readonly extend: {
  21514. minimum: Vector3;
  21515. maximum: Vector3;
  21516. };
  21517. /**
  21518. * Gets the hosting scene
  21519. * @returns the hosting Scene
  21520. */
  21521. getScene(): Scene;
  21522. /**
  21523. * Gets the hosting engine
  21524. * @returns the hosting Engine
  21525. */
  21526. getEngine(): Engine;
  21527. /**
  21528. * Defines if the geometry is ready to use
  21529. * @returns true if the geometry is ready to be used
  21530. */
  21531. isReady(): boolean;
  21532. /**
  21533. * Gets a value indicating that the geometry should not be serialized
  21534. */
  21535. readonly doNotSerialize: boolean;
  21536. /** @hidden */
  21537. _rebuild(): void;
  21538. /**
  21539. * Affects all geometry data in one call
  21540. * @param vertexData defines the geometry data
  21541. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21542. */
  21543. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21544. /**
  21545. * Set specific vertex data
  21546. * @param kind defines the data kind (Position, normal, etc...)
  21547. * @param data defines the vertex data to use
  21548. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21549. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21550. */
  21551. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21552. /**
  21553. * Removes a specific vertex data
  21554. * @param kind defines the data kind (Position, normal, etc...)
  21555. */
  21556. removeVerticesData(kind: string): void;
  21557. /**
  21558. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21559. * @param buffer defines the vertex buffer to use
  21560. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21561. */
  21562. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21563. /**
  21564. * Update a specific vertex buffer
  21565. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21566. * It will do nothing if the buffer is not updatable
  21567. * @param kind defines the data kind (Position, normal, etc...)
  21568. * @param data defines the data to use
  21569. * @param offset defines the offset in the target buffer where to store the data
  21570. * @param useBytes set to true if the offset is in bytes
  21571. */
  21572. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21573. /**
  21574. * Update a specific vertex buffer
  21575. * This function will create a new buffer if the current one is not updatable
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. * @param data defines the data to use
  21578. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21579. */
  21580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21581. private _updateBoundingInfo;
  21582. /** @hidden */
  21583. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21584. /**
  21585. * Gets total number of vertices
  21586. * @returns the total number of vertices
  21587. */
  21588. getTotalVertices(): number;
  21589. /**
  21590. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21591. * @param kind defines the data kind (Position, normal, etc...)
  21592. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21593. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21594. * @returns a float array containing vertex data
  21595. */
  21596. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21597. /**
  21598. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21599. * @param kind defines the data kind (Position, normal, etc...)
  21600. * @returns true if the vertex buffer with the specified kind is updatable
  21601. */
  21602. isVertexBufferUpdatable(kind: string): boolean;
  21603. /**
  21604. * Gets a specific vertex buffer
  21605. * @param kind defines the data kind (Position, normal, etc...)
  21606. * @returns a VertexBuffer
  21607. */
  21608. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21609. /**
  21610. * Returns all vertex buffers
  21611. * @return an object holding all vertex buffers indexed by kind
  21612. */
  21613. getVertexBuffers(): Nullable<{
  21614. [key: string]: VertexBuffer;
  21615. }>;
  21616. /**
  21617. * Gets a boolean indicating if specific vertex buffer is present
  21618. * @param kind defines the data kind (Position, normal, etc...)
  21619. * @returns true if data is present
  21620. */
  21621. isVerticesDataPresent(kind: string): boolean;
  21622. /**
  21623. * Gets a list of all attached data kinds (Position, normal, etc...)
  21624. * @returns a list of string containing all kinds
  21625. */
  21626. getVerticesDataKinds(): string[];
  21627. /**
  21628. * Update index buffer
  21629. * @param indices defines the indices to store in the index buffer
  21630. * @param offset defines the offset in the target buffer where to store the data
  21631. * @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)
  21632. */
  21633. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21634. /**
  21635. * Creates a new index buffer
  21636. * @param indices defines the indices to store in the index buffer
  21637. * @param totalVertices defines the total number of vertices (could be null)
  21638. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21639. */
  21640. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21641. /**
  21642. * Return the total number of indices
  21643. * @returns the total number of indices
  21644. */
  21645. getTotalIndices(): number;
  21646. /**
  21647. * Gets the index buffer array
  21648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21650. * @returns the index buffer array
  21651. */
  21652. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21653. /**
  21654. * Gets the index buffer
  21655. * @return the index buffer
  21656. */
  21657. getIndexBuffer(): Nullable<DataBuffer>;
  21658. /** @hidden */
  21659. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21660. /**
  21661. * Release the associated resources for a specific mesh
  21662. * @param mesh defines the source mesh
  21663. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21664. */
  21665. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21666. /**
  21667. * Apply current geometry to a given mesh
  21668. * @param mesh defines the mesh to apply geometry to
  21669. */
  21670. applyToMesh(mesh: Mesh): void;
  21671. private _updateExtend;
  21672. private _applyToMesh;
  21673. private notifyUpdate;
  21674. /**
  21675. * Load the geometry if it was flagged as delay loaded
  21676. * @param scene defines the hosting scene
  21677. * @param onLoaded defines a callback called when the geometry is loaded
  21678. */
  21679. load(scene: Scene, onLoaded?: () => void): void;
  21680. private _queueLoad;
  21681. /**
  21682. * Invert the geometry to move from a right handed system to a left handed one.
  21683. */
  21684. toLeftHanded(): void;
  21685. /** @hidden */
  21686. _resetPointsArrayCache(): void;
  21687. /** @hidden */
  21688. _generatePointsArray(): boolean;
  21689. /**
  21690. * Gets a value indicating if the geometry is disposed
  21691. * @returns true if the geometry was disposed
  21692. */
  21693. isDisposed(): boolean;
  21694. private _disposeVertexArrayObjects;
  21695. /**
  21696. * Free all associated resources
  21697. */
  21698. dispose(): void;
  21699. /**
  21700. * Clone the current geometry into a new geometry
  21701. * @param id defines the unique ID of the new geometry
  21702. * @returns a new geometry object
  21703. */
  21704. copy(id: string): Geometry;
  21705. /**
  21706. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21707. * @return a JSON representation of the current geometry data (without the vertices data)
  21708. */
  21709. serialize(): any;
  21710. private toNumberArray;
  21711. /**
  21712. * Serialize all vertices data into a JSON oject
  21713. * @returns a JSON representation of the current geometry data
  21714. */
  21715. serializeVerticeData(): any;
  21716. /**
  21717. * Extracts a clone of a mesh geometry
  21718. * @param mesh defines the source mesh
  21719. * @param id defines the unique ID of the new geometry object
  21720. * @returns the new geometry object
  21721. */
  21722. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21723. /**
  21724. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21725. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21726. * Be aware Math.random() could cause collisions, but:
  21727. * "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"
  21728. * @returns a string containing a new GUID
  21729. */
  21730. static RandomId(): string;
  21731. /** @hidden */
  21732. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21733. private static _CleanMatricesWeights;
  21734. /**
  21735. * Create a new geometry from persisted data (Using .babylon file format)
  21736. * @param parsedVertexData defines the persisted data
  21737. * @param scene defines the hosting scene
  21738. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21739. * @returns the new geometry object
  21740. */
  21741. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21742. }
  21743. }
  21744. declare module "babylonjs/Meshes/mesh.vertexData" {
  21745. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21746. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21747. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21748. import { Geometry } from "babylonjs/Meshes/geometry";
  21749. import { Mesh } from "babylonjs/Meshes/mesh";
  21750. /**
  21751. * Define an interface for all classes that will get and set the data on vertices
  21752. */
  21753. export interface IGetSetVerticesData {
  21754. /**
  21755. * Gets a boolean indicating if specific vertex data is present
  21756. * @param kind defines the vertex data kind to use
  21757. * @returns true is data kind is present
  21758. */
  21759. isVerticesDataPresent(kind: string): boolean;
  21760. /**
  21761. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21762. * @param kind defines the data kind (Position, normal, etc...)
  21763. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21764. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21765. * @returns a float array containing vertex data
  21766. */
  21767. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21768. /**
  21769. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21770. * @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.
  21771. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21772. * @returns the indices array or an empty array if the mesh has no geometry
  21773. */
  21774. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21775. /**
  21776. * Set specific vertex data
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. * @param data defines the vertex data to use
  21779. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21780. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21781. */
  21782. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21783. /**
  21784. * Update a specific associated vertex buffer
  21785. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21786. * - VertexBuffer.PositionKind
  21787. * - VertexBuffer.UVKind
  21788. * - VertexBuffer.UV2Kind
  21789. * - VertexBuffer.UV3Kind
  21790. * - VertexBuffer.UV4Kind
  21791. * - VertexBuffer.UV5Kind
  21792. * - VertexBuffer.UV6Kind
  21793. * - VertexBuffer.ColorKind
  21794. * - VertexBuffer.MatricesIndicesKind
  21795. * - VertexBuffer.MatricesIndicesExtraKind
  21796. * - VertexBuffer.MatricesWeightsKind
  21797. * - VertexBuffer.MatricesWeightsExtraKind
  21798. * @param data defines the data source
  21799. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21800. * @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)
  21801. */
  21802. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21803. /**
  21804. * Creates a new index buffer
  21805. * @param indices defines the indices to store in the index buffer
  21806. * @param totalVertices defines the total number of vertices (could be null)
  21807. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21808. */
  21809. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21810. }
  21811. /**
  21812. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21813. */
  21814. export class VertexData {
  21815. /**
  21816. * Mesh side orientation : usually the external or front surface
  21817. */
  21818. static readonly FRONTSIDE: number;
  21819. /**
  21820. * Mesh side orientation : usually the internal or back surface
  21821. */
  21822. static readonly BACKSIDE: number;
  21823. /**
  21824. * Mesh side orientation : both internal and external or front and back surfaces
  21825. */
  21826. static readonly DOUBLESIDE: number;
  21827. /**
  21828. * Mesh side orientation : by default, `FRONTSIDE`
  21829. */
  21830. static readonly DEFAULTSIDE: number;
  21831. /**
  21832. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21833. */
  21834. positions: Nullable<FloatArray>;
  21835. /**
  21836. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21837. */
  21838. normals: Nullable<FloatArray>;
  21839. /**
  21840. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21841. */
  21842. tangents: Nullable<FloatArray>;
  21843. /**
  21844. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21845. */
  21846. uvs: Nullable<FloatArray>;
  21847. /**
  21848. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21849. */
  21850. uvs2: Nullable<FloatArray>;
  21851. /**
  21852. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21853. */
  21854. uvs3: Nullable<FloatArray>;
  21855. /**
  21856. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21857. */
  21858. uvs4: Nullable<FloatArray>;
  21859. /**
  21860. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21861. */
  21862. uvs5: Nullable<FloatArray>;
  21863. /**
  21864. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21865. */
  21866. uvs6: Nullable<FloatArray>;
  21867. /**
  21868. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21869. */
  21870. colors: Nullable<FloatArray>;
  21871. /**
  21872. * 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).
  21873. */
  21874. matricesIndices: Nullable<FloatArray>;
  21875. /**
  21876. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21877. */
  21878. matricesWeights: Nullable<FloatArray>;
  21879. /**
  21880. * An array extending the number of possible indices
  21881. */
  21882. matricesIndicesExtra: Nullable<FloatArray>;
  21883. /**
  21884. * An array extending the number of possible weights when the number of indices is extended
  21885. */
  21886. matricesWeightsExtra: Nullable<FloatArray>;
  21887. /**
  21888. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21889. */
  21890. indices: Nullable<IndicesArray>;
  21891. /**
  21892. * Uses the passed data array to set the set the values for the specified kind of data
  21893. * @param data a linear array of floating numbers
  21894. * @param kind the type of data that is being set, eg positions, colors etc
  21895. */
  21896. set(data: FloatArray, kind: string): void;
  21897. /**
  21898. * Associates the vertexData to the passed Mesh.
  21899. * Sets it as updatable or not (default `false`)
  21900. * @param mesh the mesh the vertexData is applied to
  21901. * @param updatable when used and having the value true allows new data to update the vertexData
  21902. * @returns the VertexData
  21903. */
  21904. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21905. /**
  21906. * Associates the vertexData to the passed Geometry.
  21907. * Sets it as updatable or not (default `false`)
  21908. * @param geometry the geometry the vertexData is applied to
  21909. * @param updatable when used and having the value true allows new data to update the vertexData
  21910. * @returns VertexData
  21911. */
  21912. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21913. /**
  21914. * Updates the associated mesh
  21915. * @param mesh the mesh to be updated
  21916. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21917. * @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
  21918. * @returns VertexData
  21919. */
  21920. updateMesh(mesh: Mesh): VertexData;
  21921. /**
  21922. * Updates the associated geometry
  21923. * @param geometry the geometry to be updated
  21924. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21925. * @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
  21926. * @returns VertexData.
  21927. */
  21928. updateGeometry(geometry: Geometry): VertexData;
  21929. private _applyTo;
  21930. private _update;
  21931. /**
  21932. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21933. * @param matrix the transforming matrix
  21934. * @returns the VertexData
  21935. */
  21936. transform(matrix: Matrix): VertexData;
  21937. /**
  21938. * Merges the passed VertexData into the current one
  21939. * @param other the VertexData to be merged into the current one
  21940. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21941. * @returns the modified VertexData
  21942. */
  21943. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21944. private _mergeElement;
  21945. private _validate;
  21946. /**
  21947. * Serializes the VertexData
  21948. * @returns a serialized object
  21949. */
  21950. serialize(): any;
  21951. /**
  21952. * Extracts the vertexData from a mesh
  21953. * @param mesh the mesh from which to extract the VertexData
  21954. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21955. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21956. * @returns the object VertexData associated to the passed mesh
  21957. */
  21958. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21959. /**
  21960. * Extracts the vertexData from the geometry
  21961. * @param geometry the geometry from which to extract the VertexData
  21962. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21963. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21964. * @returns the object VertexData associated to the passed mesh
  21965. */
  21966. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21967. private static _ExtractFrom;
  21968. /**
  21969. * Creates the VertexData for a Ribbon
  21970. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21971. * * pathArray array of paths, each of which an array of successive Vector3
  21972. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21973. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21974. * * 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
  21975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21976. * * 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)
  21977. * * 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)
  21978. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21979. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21980. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21981. * @returns the VertexData of the ribbon
  21982. */
  21983. static CreateRibbon(options: {
  21984. pathArray: Vector3[][];
  21985. closeArray?: boolean;
  21986. closePath?: boolean;
  21987. offset?: number;
  21988. sideOrientation?: number;
  21989. frontUVs?: Vector4;
  21990. backUVs?: Vector4;
  21991. invertUV?: boolean;
  21992. uvs?: Vector2[];
  21993. colors?: Color4[];
  21994. }): VertexData;
  21995. /**
  21996. * Creates the VertexData for a box
  21997. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21998. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21999. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22000. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22001. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22002. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22003. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22005. * * 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)
  22006. * * 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)
  22007. * @returns the VertexData of the box
  22008. */
  22009. static CreateBox(options: {
  22010. size?: number;
  22011. width?: number;
  22012. height?: number;
  22013. depth?: number;
  22014. faceUV?: Vector4[];
  22015. faceColors?: Color4[];
  22016. sideOrientation?: number;
  22017. frontUVs?: Vector4;
  22018. backUVs?: Vector4;
  22019. }): VertexData;
  22020. /**
  22021. * Creates the VertexData for a tiled box
  22022. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22023. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22024. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22025. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22027. * @returns the VertexData of the box
  22028. */
  22029. static CreateTiledBox(options: {
  22030. pattern?: number;
  22031. width?: number;
  22032. height?: number;
  22033. depth?: number;
  22034. tileSize?: number;
  22035. tileWidth?: number;
  22036. tileHeight?: number;
  22037. alignHorizontal?: number;
  22038. alignVertical?: number;
  22039. faceUV?: Vector4[];
  22040. faceColors?: Color4[];
  22041. sideOrientation?: number;
  22042. }): VertexData;
  22043. /**
  22044. * Creates the VertexData for a tiled plane
  22045. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22046. * * pattern a limited pattern arrangement depending on the number
  22047. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22048. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22049. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22051. * * 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)
  22052. * * 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)
  22053. * @returns the VertexData of the tiled plane
  22054. */
  22055. static CreateTiledPlane(options: {
  22056. pattern?: number;
  22057. tileSize?: number;
  22058. tileWidth?: number;
  22059. tileHeight?: number;
  22060. size?: number;
  22061. width?: number;
  22062. height?: number;
  22063. alignHorizontal?: number;
  22064. alignVertical?: number;
  22065. sideOrientation?: number;
  22066. frontUVs?: Vector4;
  22067. backUVs?: Vector4;
  22068. }): VertexData;
  22069. /**
  22070. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22071. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22072. * * segments sets the number of horizontal strips optional, default 32
  22073. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22074. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22075. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22076. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22077. * * 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
  22078. * * 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
  22079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22080. * * 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)
  22081. * * 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)
  22082. * @returns the VertexData of the ellipsoid
  22083. */
  22084. static CreateSphere(options: {
  22085. segments?: number;
  22086. diameter?: number;
  22087. diameterX?: number;
  22088. diameterY?: number;
  22089. diameterZ?: number;
  22090. arc?: number;
  22091. slice?: number;
  22092. sideOrientation?: number;
  22093. frontUVs?: Vector4;
  22094. backUVs?: Vector4;
  22095. }): VertexData;
  22096. /**
  22097. * Creates the VertexData for a cylinder, cone or prism
  22098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22099. * * height sets the height (y direction) of the cylinder, optional, default 2
  22100. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22101. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22102. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22103. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22104. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22105. * * 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
  22106. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22107. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22108. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22109. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22111. * * 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)
  22112. * * 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)
  22113. * @returns the VertexData of the cylinder, cone or prism
  22114. */
  22115. static CreateCylinder(options: {
  22116. height?: number;
  22117. diameterTop?: number;
  22118. diameterBottom?: number;
  22119. diameter?: number;
  22120. tessellation?: number;
  22121. subdivisions?: number;
  22122. arc?: number;
  22123. faceColors?: Color4[];
  22124. faceUV?: Vector4[];
  22125. hasRings?: boolean;
  22126. enclose?: boolean;
  22127. sideOrientation?: number;
  22128. frontUVs?: Vector4;
  22129. backUVs?: Vector4;
  22130. }): VertexData;
  22131. /**
  22132. * Creates the VertexData for a torus
  22133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22134. * * diameter the diameter of the torus, optional default 1
  22135. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22136. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22138. * * 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)
  22139. * * 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)
  22140. * @returns the VertexData of the torus
  22141. */
  22142. static CreateTorus(options: {
  22143. diameter?: number;
  22144. thickness?: number;
  22145. tessellation?: number;
  22146. sideOrientation?: number;
  22147. frontUVs?: Vector4;
  22148. backUVs?: Vector4;
  22149. }): VertexData;
  22150. /**
  22151. * Creates the VertexData of the LineSystem
  22152. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22153. * - lines an array of lines, each line being an array of successive Vector3
  22154. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22155. * @returns the VertexData of the LineSystem
  22156. */
  22157. static CreateLineSystem(options: {
  22158. lines: Vector3[][];
  22159. colors?: Nullable<Color4[][]>;
  22160. }): VertexData;
  22161. /**
  22162. * Create the VertexData for a DashedLines
  22163. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22164. * - points an array successive Vector3
  22165. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22166. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22167. * - dashNb the intended total number of dashes, optional, default 200
  22168. * @returns the VertexData for the DashedLines
  22169. */
  22170. static CreateDashedLines(options: {
  22171. points: Vector3[];
  22172. dashSize?: number;
  22173. gapSize?: number;
  22174. dashNb?: number;
  22175. }): VertexData;
  22176. /**
  22177. * Creates the VertexData for a Ground
  22178. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22179. * - width the width (x direction) of the ground, optional, default 1
  22180. * - height the height (z direction) of the ground, optional, default 1
  22181. * - subdivisions the number of subdivisions per side, optional, default 1
  22182. * @returns the VertexData of the Ground
  22183. */
  22184. static CreateGround(options: {
  22185. width?: number;
  22186. height?: number;
  22187. subdivisions?: number;
  22188. subdivisionsX?: number;
  22189. subdivisionsY?: number;
  22190. }): VertexData;
  22191. /**
  22192. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22193. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22194. * * xmin the ground minimum X coordinate, optional, default -1
  22195. * * zmin the ground minimum Z coordinate, optional, default -1
  22196. * * xmax the ground maximum X coordinate, optional, default 1
  22197. * * zmax the ground maximum Z coordinate, optional, default 1
  22198. * * 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}
  22199. * * 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}
  22200. * @returns the VertexData of the TiledGround
  22201. */
  22202. static CreateTiledGround(options: {
  22203. xmin: number;
  22204. zmin: number;
  22205. xmax: number;
  22206. zmax: number;
  22207. subdivisions?: {
  22208. w: number;
  22209. h: number;
  22210. };
  22211. precision?: {
  22212. w: number;
  22213. h: number;
  22214. };
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData of the Ground designed from a heightmap
  22218. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22219. * * width the width (x direction) of the ground
  22220. * * height the height (z direction) of the ground
  22221. * * subdivisions the number of subdivisions per side
  22222. * * minHeight the minimum altitude on the ground, optional, default 0
  22223. * * maxHeight the maximum altitude on the ground, optional default 1
  22224. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22225. * * buffer the array holding the image color data
  22226. * * bufferWidth the width of image
  22227. * * bufferHeight the height of image
  22228. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22229. * @returns the VertexData of the Ground designed from a heightmap
  22230. */
  22231. static CreateGroundFromHeightMap(options: {
  22232. width: number;
  22233. height: number;
  22234. subdivisions: number;
  22235. minHeight: number;
  22236. maxHeight: number;
  22237. colorFilter: Color3;
  22238. buffer: Uint8Array;
  22239. bufferWidth: number;
  22240. bufferHeight: number;
  22241. alphaFilter: number;
  22242. }): VertexData;
  22243. /**
  22244. * Creates the VertexData for a Plane
  22245. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22246. * * size sets the width and height of the plane to the value of size, optional default 1
  22247. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22248. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22250. * * 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)
  22251. * * 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)
  22252. * @returns the VertexData of the box
  22253. */
  22254. static CreatePlane(options: {
  22255. size?: number;
  22256. width?: number;
  22257. height?: number;
  22258. sideOrientation?: number;
  22259. frontUVs?: Vector4;
  22260. backUVs?: Vector4;
  22261. }): VertexData;
  22262. /**
  22263. * Creates the VertexData of the Disc or regular Polygon
  22264. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22265. * * radius the radius of the disc, optional default 0.5
  22266. * * tessellation the number of polygon sides, optional, default 64
  22267. * * 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
  22268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22269. * * 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)
  22270. * * 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)
  22271. * @returns the VertexData of the box
  22272. */
  22273. static CreateDisc(options: {
  22274. radius?: number;
  22275. tessellation?: number;
  22276. arc?: number;
  22277. sideOrientation?: number;
  22278. frontUVs?: Vector4;
  22279. backUVs?: Vector4;
  22280. }): VertexData;
  22281. /**
  22282. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22283. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22284. * @param polygon a mesh built from polygonTriangulation.build()
  22285. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22286. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22287. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22288. * @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)
  22289. * @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)
  22290. * @returns the VertexData of the Polygon
  22291. */
  22292. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22293. /**
  22294. * Creates the VertexData of the IcoSphere
  22295. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22296. * * radius the radius of the IcoSphere, optional default 1
  22297. * * radiusX allows stretching in the x direction, optional, default radius
  22298. * * radiusY allows stretching in the y direction, optional, default radius
  22299. * * radiusZ allows stretching in the z direction, optional, default radius
  22300. * * flat when true creates a flat shaded mesh, optional, default true
  22301. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  22306. */
  22307. static CreateIcoSphere(options: {
  22308. radius?: number;
  22309. radiusX?: number;
  22310. radiusY?: number;
  22311. radiusZ?: number;
  22312. flat?: boolean;
  22313. subdivisions?: number;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Creates the VertexData for a Polyhedron
  22320. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22321. * * type provided types are:
  22322. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22323. * * 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)
  22324. * * size the size of the IcoSphere, optional default 1
  22325. * * sizeX allows stretching in the x direction, optional, default size
  22326. * * sizeY allows stretching in the y direction, optional, default size
  22327. * * sizeZ allows stretching in the z direction, optional, default size
  22328. * * 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
  22329. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22330. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22331. * * flat when true creates a flat shaded mesh, optional, default true
  22332. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22334. * * 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)
  22335. * * 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)
  22336. * @returns the VertexData of the Polyhedron
  22337. */
  22338. static CreatePolyhedron(options: {
  22339. type?: number;
  22340. size?: number;
  22341. sizeX?: number;
  22342. sizeY?: number;
  22343. sizeZ?: number;
  22344. custom?: any;
  22345. faceUV?: Vector4[];
  22346. faceColors?: Color4[];
  22347. flat?: boolean;
  22348. sideOrientation?: number;
  22349. frontUVs?: Vector4;
  22350. backUVs?: Vector4;
  22351. }): VertexData;
  22352. /**
  22353. * Creates the VertexData for a TorusKnot
  22354. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22355. * * radius the radius of the torus knot, optional, default 2
  22356. * * tube the thickness of the tube, optional, default 0.5
  22357. * * radialSegments the number of sides on each tube segments, optional, default 32
  22358. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22359. * * p the number of windings around the z axis, optional, default 2
  22360. * * q the number of windings around the x axis, optional, default 3
  22361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22362. * * 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)
  22363. * * 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)
  22364. * @returns the VertexData of the Torus Knot
  22365. */
  22366. static CreateTorusKnot(options: {
  22367. radius?: number;
  22368. tube?: number;
  22369. radialSegments?: number;
  22370. tubularSegments?: number;
  22371. p?: number;
  22372. q?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Compute normals for given positions and indices
  22379. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22380. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22381. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22382. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22383. * * facetNormals : optional array of facet normals (vector3)
  22384. * * facetPositions : optional array of facet positions (vector3)
  22385. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22386. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22387. * * bInfo : optional bounding info, required for facetPartitioning computation
  22388. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22389. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22390. * * useRightHandedSystem: optional boolean to for right handed system computation
  22391. * * depthSort : optional boolean to enable the facet depth sort computation
  22392. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22393. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22394. */
  22395. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22396. facetNormals?: any;
  22397. facetPositions?: any;
  22398. facetPartitioning?: any;
  22399. ratio?: number;
  22400. bInfo?: any;
  22401. bbSize?: Vector3;
  22402. subDiv?: any;
  22403. useRightHandedSystem?: boolean;
  22404. depthSort?: boolean;
  22405. distanceTo?: Vector3;
  22406. depthSortedFacets?: any;
  22407. }): void;
  22408. /** @hidden */
  22409. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22410. /**
  22411. * Applies VertexData created from the imported parameters to the geometry
  22412. * @param parsedVertexData the parsed data from an imported file
  22413. * @param geometry the geometry to apply the VertexData to
  22414. */
  22415. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22416. }
  22417. }
  22418. declare module "babylonjs/Morph/morphTarget" {
  22419. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22420. import { Observable } from "babylonjs/Misc/observable";
  22421. import { Nullable, FloatArray } from "babylonjs/types";
  22422. import { Scene } from "babylonjs/scene";
  22423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22424. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22425. /**
  22426. * Defines a target to use with MorphTargetManager
  22427. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22428. */
  22429. export class MorphTarget implements IAnimatable {
  22430. /** defines the name of the target */
  22431. name: string;
  22432. /**
  22433. * Gets or sets the list of animations
  22434. */
  22435. animations: import("babylonjs/Animations/animation").Animation[];
  22436. private _scene;
  22437. private _positions;
  22438. private _normals;
  22439. private _tangents;
  22440. private _uvs;
  22441. private _influence;
  22442. /**
  22443. * Observable raised when the influence changes
  22444. */
  22445. onInfluenceChanged: Observable<boolean>;
  22446. /** @hidden */
  22447. _onDataLayoutChanged: Observable<void>;
  22448. /**
  22449. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22450. */
  22451. influence: number;
  22452. /**
  22453. * Gets or sets the id of the morph Target
  22454. */
  22455. id: string;
  22456. private _animationPropertiesOverride;
  22457. /**
  22458. * Gets or sets the animation properties override
  22459. */
  22460. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22461. /**
  22462. * Creates a new MorphTarget
  22463. * @param name defines the name of the target
  22464. * @param influence defines the influence to use
  22465. * @param scene defines the scene the morphtarget belongs to
  22466. */
  22467. constructor(
  22468. /** defines the name of the target */
  22469. name: string, influence?: number, scene?: Nullable<Scene>);
  22470. /**
  22471. * Gets a boolean defining if the target contains position data
  22472. */
  22473. readonly hasPositions: boolean;
  22474. /**
  22475. * Gets a boolean defining if the target contains normal data
  22476. */
  22477. readonly hasNormals: boolean;
  22478. /**
  22479. * Gets a boolean defining if the target contains tangent data
  22480. */
  22481. readonly hasTangents: boolean;
  22482. /**
  22483. * Gets a boolean defining if the target contains texture coordinates data
  22484. */
  22485. readonly hasUVs: boolean;
  22486. /**
  22487. * Affects position data to this target
  22488. * @param data defines the position data to use
  22489. */
  22490. setPositions(data: Nullable<FloatArray>): void;
  22491. /**
  22492. * Gets the position data stored in this target
  22493. * @returns a FloatArray containing the position data (or null if not present)
  22494. */
  22495. getPositions(): Nullable<FloatArray>;
  22496. /**
  22497. * Affects normal data to this target
  22498. * @param data defines the normal data to use
  22499. */
  22500. setNormals(data: Nullable<FloatArray>): void;
  22501. /**
  22502. * Gets the normal data stored in this target
  22503. * @returns a FloatArray containing the normal data (or null if not present)
  22504. */
  22505. getNormals(): Nullable<FloatArray>;
  22506. /**
  22507. * Affects tangent data to this target
  22508. * @param data defines the tangent data to use
  22509. */
  22510. setTangents(data: Nullable<FloatArray>): void;
  22511. /**
  22512. * Gets the tangent data stored in this target
  22513. * @returns a FloatArray containing the tangent data (or null if not present)
  22514. */
  22515. getTangents(): Nullable<FloatArray>;
  22516. /**
  22517. * Affects texture coordinates data to this target
  22518. * @param data defines the texture coordinates data to use
  22519. */
  22520. setUVs(data: Nullable<FloatArray>): void;
  22521. /**
  22522. * Gets the texture coordinates data stored in this target
  22523. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22524. */
  22525. getUVs(): Nullable<FloatArray>;
  22526. /**
  22527. * Serializes the current target into a Serialization object
  22528. * @returns the serialized object
  22529. */
  22530. serialize(): any;
  22531. /**
  22532. * Returns the string "MorphTarget"
  22533. * @returns "MorphTarget"
  22534. */
  22535. getClassName(): string;
  22536. /**
  22537. * Creates a new target from serialized data
  22538. * @param serializationObject defines the serialized data to use
  22539. * @returns a new MorphTarget
  22540. */
  22541. static Parse(serializationObject: any): MorphTarget;
  22542. /**
  22543. * Creates a MorphTarget from mesh data
  22544. * @param mesh defines the source mesh
  22545. * @param name defines the name to use for the new target
  22546. * @param influence defines the influence to attach to the target
  22547. * @returns a new MorphTarget
  22548. */
  22549. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22550. }
  22551. }
  22552. declare module "babylonjs/Morph/morphTargetManager" {
  22553. import { Nullable } from "babylonjs/types";
  22554. import { Scene } from "babylonjs/scene";
  22555. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22556. /**
  22557. * This class is used to deform meshes using morphing between different targets
  22558. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22559. */
  22560. export class MorphTargetManager {
  22561. private _targets;
  22562. private _targetInfluenceChangedObservers;
  22563. private _targetDataLayoutChangedObservers;
  22564. private _activeTargets;
  22565. private _scene;
  22566. private _influences;
  22567. private _supportsNormals;
  22568. private _supportsTangents;
  22569. private _supportsUVs;
  22570. private _vertexCount;
  22571. private _uniqueId;
  22572. private _tempInfluences;
  22573. /**
  22574. * Gets or sets a boolean indicating if normals must be morphed
  22575. */
  22576. enableNormalMorphing: boolean;
  22577. /**
  22578. * Gets or sets a boolean indicating if tangents must be morphed
  22579. */
  22580. enableTangentMorphing: boolean;
  22581. /**
  22582. * Gets or sets a boolean indicating if UV must be morphed
  22583. */
  22584. enableUVMorphing: boolean;
  22585. /**
  22586. * Creates a new MorphTargetManager
  22587. * @param scene defines the current scene
  22588. */
  22589. constructor(scene?: Nullable<Scene>);
  22590. /**
  22591. * Gets the unique ID of this manager
  22592. */
  22593. readonly uniqueId: number;
  22594. /**
  22595. * Gets the number of vertices handled by this manager
  22596. */
  22597. readonly vertexCount: number;
  22598. /**
  22599. * Gets a boolean indicating if this manager supports morphing of normals
  22600. */
  22601. readonly supportsNormals: boolean;
  22602. /**
  22603. * Gets a boolean indicating if this manager supports morphing of tangents
  22604. */
  22605. readonly supportsTangents: boolean;
  22606. /**
  22607. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22608. */
  22609. readonly supportsUVs: boolean;
  22610. /**
  22611. * Gets the number of targets stored in this manager
  22612. */
  22613. readonly numTargets: number;
  22614. /**
  22615. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22616. */
  22617. readonly numInfluencers: number;
  22618. /**
  22619. * Gets the list of influences (one per target)
  22620. */
  22621. readonly influences: Float32Array;
  22622. /**
  22623. * Gets the active target at specified index. An active target is a target with an influence > 0
  22624. * @param index defines the index to check
  22625. * @returns the requested target
  22626. */
  22627. getActiveTarget(index: number): MorphTarget;
  22628. /**
  22629. * Gets the target at specified index
  22630. * @param index defines the index to check
  22631. * @returns the requested target
  22632. */
  22633. getTarget(index: number): MorphTarget;
  22634. /**
  22635. * Add a new target to this manager
  22636. * @param target defines the target to add
  22637. */
  22638. addTarget(target: MorphTarget): void;
  22639. /**
  22640. * Removes a target from the manager
  22641. * @param target defines the target to remove
  22642. */
  22643. removeTarget(target: MorphTarget): void;
  22644. /**
  22645. * Serializes the current manager into a Serialization object
  22646. * @returns the serialized object
  22647. */
  22648. serialize(): any;
  22649. private _syncActiveTargets;
  22650. /**
  22651. * Syncrhonize the targets with all the meshes using this morph target manager
  22652. */
  22653. synchronize(): void;
  22654. /**
  22655. * Creates a new MorphTargetManager from serialized data
  22656. * @param serializationObject defines the serialized data
  22657. * @param scene defines the hosting scene
  22658. * @returns the new MorphTargetManager
  22659. */
  22660. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22661. }
  22662. }
  22663. declare module "babylonjs/Meshes/meshLODLevel" {
  22664. import { Mesh } from "babylonjs/Meshes/mesh";
  22665. import { Nullable } from "babylonjs/types";
  22666. /**
  22667. * Class used to represent a specific level of detail of a mesh
  22668. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22669. */
  22670. export class MeshLODLevel {
  22671. /** Defines the distance where this level should star being displayed */
  22672. distance: number;
  22673. /** Defines the mesh to use to render this level */
  22674. mesh: Nullable<Mesh>;
  22675. /**
  22676. * Creates a new LOD level
  22677. * @param distance defines the distance where this level should star being displayed
  22678. * @param mesh defines the mesh to use to render this level
  22679. */
  22680. constructor(
  22681. /** Defines the distance where this level should star being displayed */
  22682. distance: number,
  22683. /** Defines the mesh to use to render this level */
  22684. mesh: Nullable<Mesh>);
  22685. }
  22686. }
  22687. declare module "babylonjs/Meshes/groundMesh" {
  22688. import { Scene } from "babylonjs/scene";
  22689. import { Vector3 } from "babylonjs/Maths/math.vector";
  22690. import { Mesh } from "babylonjs/Meshes/mesh";
  22691. /**
  22692. * Mesh representing the gorund
  22693. */
  22694. export class GroundMesh extends Mesh {
  22695. /** If octree should be generated */
  22696. generateOctree: boolean;
  22697. private _heightQuads;
  22698. /** @hidden */
  22699. _subdivisionsX: number;
  22700. /** @hidden */
  22701. _subdivisionsY: number;
  22702. /** @hidden */
  22703. _width: number;
  22704. /** @hidden */
  22705. _height: number;
  22706. /** @hidden */
  22707. _minX: number;
  22708. /** @hidden */
  22709. _maxX: number;
  22710. /** @hidden */
  22711. _minZ: number;
  22712. /** @hidden */
  22713. _maxZ: number;
  22714. constructor(name: string, scene: Scene);
  22715. /**
  22716. * "GroundMesh"
  22717. * @returns "GroundMesh"
  22718. */
  22719. getClassName(): string;
  22720. /**
  22721. * The minimum of x and y subdivisions
  22722. */
  22723. readonly subdivisions: number;
  22724. /**
  22725. * X subdivisions
  22726. */
  22727. readonly subdivisionsX: number;
  22728. /**
  22729. * Y subdivisions
  22730. */
  22731. readonly subdivisionsY: number;
  22732. /**
  22733. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22734. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22735. * @param chunksCount the number of subdivisions for x and y
  22736. * @param octreeBlocksSize (Default: 32)
  22737. */
  22738. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22739. /**
  22740. * Returns a height (y) value in the Worl system :
  22741. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22742. * @param x x coordinate
  22743. * @param z z coordinate
  22744. * @returns the ground y position if (x, z) are outside the ground surface.
  22745. */
  22746. getHeightAtCoordinates(x: number, z: number): number;
  22747. /**
  22748. * Returns a normalized vector (Vector3) orthogonal to the ground
  22749. * at the ground coordinates (x, z) expressed in the World system.
  22750. * @param x x coordinate
  22751. * @param z z coordinate
  22752. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22753. */
  22754. getNormalAtCoordinates(x: number, z: number): Vector3;
  22755. /**
  22756. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22757. * at the ground coordinates (x, z) expressed in the World system.
  22758. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22759. * @param x x coordinate
  22760. * @param z z coordinate
  22761. * @param ref vector to store the result
  22762. * @returns the GroundMesh.
  22763. */
  22764. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22765. /**
  22766. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22767. * if the ground has been updated.
  22768. * This can be used in the render loop.
  22769. * @returns the GroundMesh.
  22770. */
  22771. updateCoordinateHeights(): GroundMesh;
  22772. private _getFacetAt;
  22773. private _initHeightQuads;
  22774. private _computeHeightQuads;
  22775. /**
  22776. * Serializes this ground mesh
  22777. * @param serializationObject object to write serialization to
  22778. */
  22779. serialize(serializationObject: any): void;
  22780. /**
  22781. * Parses a serialized ground mesh
  22782. * @param parsedMesh the serialized mesh
  22783. * @param scene the scene to create the ground mesh in
  22784. * @returns the created ground mesh
  22785. */
  22786. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22787. }
  22788. }
  22789. declare module "babylonjs/Physics/physicsJoint" {
  22790. import { Vector3 } from "babylonjs/Maths/math.vector";
  22791. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22792. /**
  22793. * Interface for Physics-Joint data
  22794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22795. */
  22796. export interface PhysicsJointData {
  22797. /**
  22798. * The main pivot of the joint
  22799. */
  22800. mainPivot?: Vector3;
  22801. /**
  22802. * The connected pivot of the joint
  22803. */
  22804. connectedPivot?: Vector3;
  22805. /**
  22806. * The main axis of the joint
  22807. */
  22808. mainAxis?: Vector3;
  22809. /**
  22810. * The connected axis of the joint
  22811. */
  22812. connectedAxis?: Vector3;
  22813. /**
  22814. * The collision of the joint
  22815. */
  22816. collision?: boolean;
  22817. /**
  22818. * Native Oimo/Cannon/Energy data
  22819. */
  22820. nativeParams?: any;
  22821. }
  22822. /**
  22823. * This is a holder class for the physics joint created by the physics plugin
  22824. * It holds a set of functions to control the underlying joint
  22825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22826. */
  22827. export class PhysicsJoint {
  22828. /**
  22829. * The type of the physics joint
  22830. */
  22831. type: number;
  22832. /**
  22833. * The data for the physics joint
  22834. */
  22835. jointData: PhysicsJointData;
  22836. private _physicsJoint;
  22837. protected _physicsPlugin: IPhysicsEnginePlugin;
  22838. /**
  22839. * Initializes the physics joint
  22840. * @param type The type of the physics joint
  22841. * @param jointData The data for the physics joint
  22842. */
  22843. constructor(
  22844. /**
  22845. * The type of the physics joint
  22846. */
  22847. type: number,
  22848. /**
  22849. * The data for the physics joint
  22850. */
  22851. jointData: PhysicsJointData);
  22852. /**
  22853. * Gets the physics joint
  22854. */
  22855. /**
  22856. * Sets the physics joint
  22857. */
  22858. physicsJoint: any;
  22859. /**
  22860. * Sets the physics plugin
  22861. */
  22862. physicsPlugin: IPhysicsEnginePlugin;
  22863. /**
  22864. * Execute a function that is physics-plugin specific.
  22865. * @param {Function} func the function that will be executed.
  22866. * It accepts two parameters: the physics world and the physics joint
  22867. */
  22868. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22869. /**
  22870. * Distance-Joint type
  22871. */
  22872. static DistanceJoint: number;
  22873. /**
  22874. * Hinge-Joint type
  22875. */
  22876. static HingeJoint: number;
  22877. /**
  22878. * Ball-and-Socket joint type
  22879. */
  22880. static BallAndSocketJoint: number;
  22881. /**
  22882. * Wheel-Joint type
  22883. */
  22884. static WheelJoint: number;
  22885. /**
  22886. * Slider-Joint type
  22887. */
  22888. static SliderJoint: number;
  22889. /**
  22890. * Prismatic-Joint type
  22891. */
  22892. static PrismaticJoint: number;
  22893. /**
  22894. * Universal-Joint type
  22895. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22896. */
  22897. static UniversalJoint: number;
  22898. /**
  22899. * Hinge-Joint 2 type
  22900. */
  22901. static Hinge2Joint: number;
  22902. /**
  22903. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22904. */
  22905. static PointToPointJoint: number;
  22906. /**
  22907. * Spring-Joint type
  22908. */
  22909. static SpringJoint: number;
  22910. /**
  22911. * Lock-Joint type
  22912. */
  22913. static LockJoint: number;
  22914. }
  22915. /**
  22916. * A class representing a physics distance joint
  22917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22918. */
  22919. export class DistanceJoint extends PhysicsJoint {
  22920. /**
  22921. *
  22922. * @param jointData The data for the Distance-Joint
  22923. */
  22924. constructor(jointData: DistanceJointData);
  22925. /**
  22926. * Update the predefined distance.
  22927. * @param maxDistance The maximum preferred distance
  22928. * @param minDistance The minimum preferred distance
  22929. */
  22930. updateDistance(maxDistance: number, minDistance?: number): void;
  22931. }
  22932. /**
  22933. * Represents a Motor-Enabled Joint
  22934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22935. */
  22936. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22937. /**
  22938. * Initializes the Motor-Enabled Joint
  22939. * @param type The type of the joint
  22940. * @param jointData The physica joint data for the joint
  22941. */
  22942. constructor(type: number, jointData: PhysicsJointData);
  22943. /**
  22944. * Set the motor values.
  22945. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22946. * @param force the force to apply
  22947. * @param maxForce max force for this motor.
  22948. */
  22949. setMotor(force?: number, maxForce?: number): void;
  22950. /**
  22951. * Set the motor's limits.
  22952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22953. * @param upperLimit The upper limit of the motor
  22954. * @param lowerLimit The lower limit of the motor
  22955. */
  22956. setLimit(upperLimit: number, lowerLimit?: number): void;
  22957. }
  22958. /**
  22959. * This class represents a single physics Hinge-Joint
  22960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22961. */
  22962. export class HingeJoint extends MotorEnabledJoint {
  22963. /**
  22964. * Initializes the Hinge-Joint
  22965. * @param jointData The joint data for the Hinge-Joint
  22966. */
  22967. constructor(jointData: PhysicsJointData);
  22968. /**
  22969. * Set the motor values.
  22970. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22971. * @param {number} force the force to apply
  22972. * @param {number} maxForce max force for this motor.
  22973. */
  22974. setMotor(force?: number, maxForce?: number): void;
  22975. /**
  22976. * Set the motor's limits.
  22977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22978. * @param upperLimit The upper limit of the motor
  22979. * @param lowerLimit The lower limit of the motor
  22980. */
  22981. setLimit(upperLimit: number, lowerLimit?: number): void;
  22982. }
  22983. /**
  22984. * This class represents a dual hinge physics joint (same as wheel joint)
  22985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22986. */
  22987. export class Hinge2Joint extends MotorEnabledJoint {
  22988. /**
  22989. * Initializes the Hinge2-Joint
  22990. * @param jointData The joint data for the Hinge2-Joint
  22991. */
  22992. constructor(jointData: PhysicsJointData);
  22993. /**
  22994. * Set the motor values.
  22995. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22996. * @param {number} targetSpeed the speed the motor is to reach
  22997. * @param {number} maxForce max force for this motor.
  22998. * @param {motorIndex} the motor's index, 0 or 1.
  22999. */
  23000. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23001. /**
  23002. * Set the motor limits.
  23003. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23004. * @param {number} upperLimit the upper limit
  23005. * @param {number} lowerLimit lower limit
  23006. * @param {motorIndex} the motor's index, 0 or 1.
  23007. */
  23008. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23009. }
  23010. /**
  23011. * Interface for a motor enabled joint
  23012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23013. */
  23014. export interface IMotorEnabledJoint {
  23015. /**
  23016. * Physics joint
  23017. */
  23018. physicsJoint: any;
  23019. /**
  23020. * Sets the motor of the motor-enabled joint
  23021. * @param force The force of the motor
  23022. * @param maxForce The maximum force of the motor
  23023. * @param motorIndex The index of the motor
  23024. */
  23025. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23026. /**
  23027. * Sets the limit of the motor
  23028. * @param upperLimit The upper limit of the motor
  23029. * @param lowerLimit The lower limit of the motor
  23030. * @param motorIndex The index of the motor
  23031. */
  23032. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23033. }
  23034. /**
  23035. * Joint data for a Distance-Joint
  23036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23037. */
  23038. export interface DistanceJointData extends PhysicsJointData {
  23039. /**
  23040. * Max distance the 2 joint objects can be apart
  23041. */
  23042. maxDistance: number;
  23043. }
  23044. /**
  23045. * Joint data from a spring joint
  23046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23047. */
  23048. export interface SpringJointData extends PhysicsJointData {
  23049. /**
  23050. * Length of the spring
  23051. */
  23052. length: number;
  23053. /**
  23054. * Stiffness of the spring
  23055. */
  23056. stiffness: number;
  23057. /**
  23058. * Damping of the spring
  23059. */
  23060. damping: number;
  23061. /** this callback will be called when applying the force to the impostors. */
  23062. forceApplicationCallback: () => void;
  23063. }
  23064. }
  23065. declare module "babylonjs/Physics/physicsRaycastResult" {
  23066. import { Vector3 } from "babylonjs/Maths/math.vector";
  23067. /**
  23068. * Holds the data for the raycast result
  23069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23070. */
  23071. export class PhysicsRaycastResult {
  23072. private _hasHit;
  23073. private _hitDistance;
  23074. private _hitNormalWorld;
  23075. private _hitPointWorld;
  23076. private _rayFromWorld;
  23077. private _rayToWorld;
  23078. /**
  23079. * Gets if there was a hit
  23080. */
  23081. readonly hasHit: boolean;
  23082. /**
  23083. * Gets the distance from the hit
  23084. */
  23085. readonly hitDistance: number;
  23086. /**
  23087. * Gets the hit normal/direction in the world
  23088. */
  23089. readonly hitNormalWorld: Vector3;
  23090. /**
  23091. * Gets the hit point in the world
  23092. */
  23093. readonly hitPointWorld: Vector3;
  23094. /**
  23095. * Gets the ray "start point" of the ray in the world
  23096. */
  23097. readonly rayFromWorld: Vector3;
  23098. /**
  23099. * Gets the ray "end point" of the ray in the world
  23100. */
  23101. readonly rayToWorld: Vector3;
  23102. /**
  23103. * Sets the hit data (normal & point in world space)
  23104. * @param hitNormalWorld defines the normal in world space
  23105. * @param hitPointWorld defines the point in world space
  23106. */
  23107. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23108. /**
  23109. * Sets the distance from the start point to the hit point
  23110. * @param distance
  23111. */
  23112. setHitDistance(distance: number): void;
  23113. /**
  23114. * Calculates the distance manually
  23115. */
  23116. calculateHitDistance(): void;
  23117. /**
  23118. * Resets all the values to default
  23119. * @param from The from point on world space
  23120. * @param to The to point on world space
  23121. */
  23122. reset(from?: Vector3, to?: Vector3): void;
  23123. }
  23124. /**
  23125. * Interface for the size containing width and height
  23126. */
  23127. interface IXYZ {
  23128. /**
  23129. * X
  23130. */
  23131. x: number;
  23132. /**
  23133. * Y
  23134. */
  23135. y: number;
  23136. /**
  23137. * Z
  23138. */
  23139. z: number;
  23140. }
  23141. }
  23142. declare module "babylonjs/Physics/IPhysicsEngine" {
  23143. import { Nullable } from "babylonjs/types";
  23144. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23146. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23147. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23148. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23149. /**
  23150. * Interface used to describe a physics joint
  23151. */
  23152. export interface PhysicsImpostorJoint {
  23153. /** Defines the main impostor to which the joint is linked */
  23154. mainImpostor: PhysicsImpostor;
  23155. /** Defines the impostor that is connected to the main impostor using this joint */
  23156. connectedImpostor: PhysicsImpostor;
  23157. /** Defines the joint itself */
  23158. joint: PhysicsJoint;
  23159. }
  23160. /** @hidden */
  23161. export interface IPhysicsEnginePlugin {
  23162. world: any;
  23163. name: string;
  23164. setGravity(gravity: Vector3): void;
  23165. setTimeStep(timeStep: number): void;
  23166. getTimeStep(): number;
  23167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23171. removePhysicsBody(impostor: PhysicsImpostor): void;
  23172. generateJoint(joint: PhysicsImpostorJoint): void;
  23173. removeJoint(joint: PhysicsImpostorJoint): void;
  23174. isSupported(): boolean;
  23175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23177. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23178. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23179. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23180. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23182. getBodyMass(impostor: PhysicsImpostor): number;
  23183. getBodyFriction(impostor: PhysicsImpostor): number;
  23184. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23185. getBodyRestitution(impostor: PhysicsImpostor): number;
  23186. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23187. getBodyPressure?(impostor: PhysicsImpostor): number;
  23188. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23189. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23190. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23191. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23192. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23193. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23194. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23195. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23196. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23197. sleepBody(impostor: PhysicsImpostor): void;
  23198. wakeUpBody(impostor: PhysicsImpostor): void;
  23199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23200. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23201. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23202. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23203. getRadius(impostor: PhysicsImpostor): number;
  23204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23206. dispose(): void;
  23207. }
  23208. /**
  23209. * Interface used to define a physics engine
  23210. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface IPhysicsEngine {
  23213. /**
  23214. * Gets the gravity vector used by the simulation
  23215. */
  23216. gravity: Vector3;
  23217. /**
  23218. * Sets the gravity vector used by the simulation
  23219. * @param gravity defines the gravity vector to use
  23220. */
  23221. setGravity(gravity: Vector3): void;
  23222. /**
  23223. * Set the time step of the physics engine.
  23224. * Default is 1/60.
  23225. * To slow it down, enter 1/600 for example.
  23226. * To speed it up, 1/30
  23227. * @param newTimeStep the new timestep to apply to this world.
  23228. */
  23229. setTimeStep(newTimeStep: number): void;
  23230. /**
  23231. * Get the time step of the physics engine.
  23232. * @returns the current time step
  23233. */
  23234. getTimeStep(): number;
  23235. /**
  23236. * Release all resources
  23237. */
  23238. dispose(): void;
  23239. /**
  23240. * Gets the name of the current physics plugin
  23241. * @returns the name of the plugin
  23242. */
  23243. getPhysicsPluginName(): string;
  23244. /**
  23245. * Adding a new impostor for the impostor tracking.
  23246. * This will be done by the impostor itself.
  23247. * @param impostor the impostor to add
  23248. */
  23249. addImpostor(impostor: PhysicsImpostor): void;
  23250. /**
  23251. * Remove an impostor from the engine.
  23252. * This impostor and its mesh will not longer be updated by the physics engine.
  23253. * @param impostor the impostor to remove
  23254. */
  23255. removeImpostor(impostor: PhysicsImpostor): void;
  23256. /**
  23257. * Add a joint to the physics engine
  23258. * @param mainImpostor defines the main impostor to which the joint is added.
  23259. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23260. * @param joint defines the joint that will connect both impostors.
  23261. */
  23262. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23263. /**
  23264. * Removes a joint from the simulation
  23265. * @param mainImpostor defines the impostor used with the joint
  23266. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23267. * @param joint defines the joint to remove
  23268. */
  23269. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23270. /**
  23271. * Gets the current plugin used to run the simulation
  23272. * @returns current plugin
  23273. */
  23274. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23275. /**
  23276. * Gets the list of physic impostors
  23277. * @returns an array of PhysicsImpostor
  23278. */
  23279. getImpostors(): Array<PhysicsImpostor>;
  23280. /**
  23281. * Gets the impostor for a physics enabled object
  23282. * @param object defines the object impersonated by the impostor
  23283. * @returns the PhysicsImpostor or null if not found
  23284. */
  23285. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23286. /**
  23287. * Gets the impostor for a physics body object
  23288. * @param body defines physics body used by the impostor
  23289. * @returns the PhysicsImpostor or null if not found
  23290. */
  23291. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23292. /**
  23293. * Does a raycast in the physics world
  23294. * @param from when should the ray start?
  23295. * @param to when should the ray end?
  23296. * @returns PhysicsRaycastResult
  23297. */
  23298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23299. /**
  23300. * Called by the scene. No need to call it.
  23301. * @param delta defines the timespam between frames
  23302. */
  23303. _step(delta: number): void;
  23304. }
  23305. }
  23306. declare module "babylonjs/Physics/physicsImpostor" {
  23307. import { Nullable, IndicesArray } from "babylonjs/types";
  23308. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23309. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23311. import { Scene } from "babylonjs/scene";
  23312. import { Bone } from "babylonjs/Bones/bone";
  23313. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23314. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23315. import { Space } from "babylonjs/Maths/math.axis";
  23316. /**
  23317. * The interface for the physics imposter parameters
  23318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23319. */
  23320. export interface PhysicsImpostorParameters {
  23321. /**
  23322. * The mass of the physics imposter
  23323. */
  23324. mass: number;
  23325. /**
  23326. * The friction of the physics imposter
  23327. */
  23328. friction?: number;
  23329. /**
  23330. * The coefficient of restitution of the physics imposter
  23331. */
  23332. restitution?: number;
  23333. /**
  23334. * The native options of the physics imposter
  23335. */
  23336. nativeOptions?: any;
  23337. /**
  23338. * Specifies if the parent should be ignored
  23339. */
  23340. ignoreParent?: boolean;
  23341. /**
  23342. * Specifies if bi-directional transformations should be disabled
  23343. */
  23344. disableBidirectionalTransformation?: boolean;
  23345. /**
  23346. * The pressure inside the physics imposter, soft object only
  23347. */
  23348. pressure?: number;
  23349. /**
  23350. * The stiffness the physics imposter, soft object only
  23351. */
  23352. stiffness?: number;
  23353. /**
  23354. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23355. */
  23356. velocityIterations?: number;
  23357. /**
  23358. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23359. */
  23360. positionIterations?: number;
  23361. /**
  23362. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23363. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23364. * Add to fix multiple points
  23365. */
  23366. fixedPoints?: number;
  23367. /**
  23368. * The collision margin around a soft object
  23369. */
  23370. margin?: number;
  23371. /**
  23372. * The collision margin around a soft object
  23373. */
  23374. damping?: number;
  23375. /**
  23376. * The path for a rope based on an extrusion
  23377. */
  23378. path?: any;
  23379. /**
  23380. * The shape of an extrusion used for a rope based on an extrusion
  23381. */
  23382. shape?: any;
  23383. }
  23384. /**
  23385. * Interface for a physics-enabled object
  23386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23387. */
  23388. export interface IPhysicsEnabledObject {
  23389. /**
  23390. * The position of the physics-enabled object
  23391. */
  23392. position: Vector3;
  23393. /**
  23394. * The rotation of the physics-enabled object
  23395. */
  23396. rotationQuaternion: Nullable<Quaternion>;
  23397. /**
  23398. * The scale of the physics-enabled object
  23399. */
  23400. scaling: Vector3;
  23401. /**
  23402. * The rotation of the physics-enabled object
  23403. */
  23404. rotation?: Vector3;
  23405. /**
  23406. * The parent of the physics-enabled object
  23407. */
  23408. parent?: any;
  23409. /**
  23410. * The bounding info of the physics-enabled object
  23411. * @returns The bounding info of the physics-enabled object
  23412. */
  23413. getBoundingInfo(): BoundingInfo;
  23414. /**
  23415. * Computes the world matrix
  23416. * @param force Specifies if the world matrix should be computed by force
  23417. * @returns A world matrix
  23418. */
  23419. computeWorldMatrix(force: boolean): Matrix;
  23420. /**
  23421. * Gets the world matrix
  23422. * @returns A world matrix
  23423. */
  23424. getWorldMatrix?(): Matrix;
  23425. /**
  23426. * Gets the child meshes
  23427. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23428. * @returns An array of abstract meshes
  23429. */
  23430. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23431. /**
  23432. * Gets the vertex data
  23433. * @param kind The type of vertex data
  23434. * @returns A nullable array of numbers, or a float32 array
  23435. */
  23436. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23437. /**
  23438. * Gets the indices from the mesh
  23439. * @returns A nullable array of index arrays
  23440. */
  23441. getIndices?(): Nullable<IndicesArray>;
  23442. /**
  23443. * Gets the scene from the mesh
  23444. * @returns the indices array or null
  23445. */
  23446. getScene?(): Scene;
  23447. /**
  23448. * Gets the absolute position from the mesh
  23449. * @returns the absolute position
  23450. */
  23451. getAbsolutePosition(): Vector3;
  23452. /**
  23453. * Gets the absolute pivot point from the mesh
  23454. * @returns the absolute pivot point
  23455. */
  23456. getAbsolutePivotPoint(): Vector3;
  23457. /**
  23458. * Rotates the mesh
  23459. * @param axis The axis of rotation
  23460. * @param amount The amount of rotation
  23461. * @param space The space of the rotation
  23462. * @returns The rotation transform node
  23463. */
  23464. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23465. /**
  23466. * Translates the mesh
  23467. * @param axis The axis of translation
  23468. * @param distance The distance of translation
  23469. * @param space The space of the translation
  23470. * @returns The transform node
  23471. */
  23472. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23473. /**
  23474. * Sets the absolute position of the mesh
  23475. * @param absolutePosition The absolute position of the mesh
  23476. * @returns The transform node
  23477. */
  23478. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23479. /**
  23480. * Gets the class name of the mesh
  23481. * @returns The class name
  23482. */
  23483. getClassName(): string;
  23484. }
  23485. /**
  23486. * Represents a physics imposter
  23487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23488. */
  23489. export class PhysicsImpostor {
  23490. /**
  23491. * The physics-enabled object used as the physics imposter
  23492. */
  23493. object: IPhysicsEnabledObject;
  23494. /**
  23495. * The type of the physics imposter
  23496. */
  23497. type: number;
  23498. private _options;
  23499. private _scene?;
  23500. /**
  23501. * The default object size of the imposter
  23502. */
  23503. static DEFAULT_OBJECT_SIZE: Vector3;
  23504. /**
  23505. * The identity quaternion of the imposter
  23506. */
  23507. static IDENTITY_QUATERNION: Quaternion;
  23508. /** @hidden */
  23509. _pluginData: any;
  23510. private _physicsEngine;
  23511. private _physicsBody;
  23512. private _bodyUpdateRequired;
  23513. private _onBeforePhysicsStepCallbacks;
  23514. private _onAfterPhysicsStepCallbacks;
  23515. /** @hidden */
  23516. _onPhysicsCollideCallbacks: Array<{
  23517. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23518. otherImpostors: Array<PhysicsImpostor>;
  23519. }>;
  23520. private _deltaPosition;
  23521. private _deltaRotation;
  23522. private _deltaRotationConjugated;
  23523. /** @hidden */
  23524. _isFromLine: boolean;
  23525. private _parent;
  23526. private _isDisposed;
  23527. private static _tmpVecs;
  23528. private static _tmpQuat;
  23529. /**
  23530. * Specifies if the physics imposter is disposed
  23531. */
  23532. readonly isDisposed: boolean;
  23533. /**
  23534. * Gets the mass of the physics imposter
  23535. */
  23536. mass: number;
  23537. /**
  23538. * Gets the coefficient of friction
  23539. */
  23540. /**
  23541. * Sets the coefficient of friction
  23542. */
  23543. friction: number;
  23544. /**
  23545. * Gets the coefficient of restitution
  23546. */
  23547. /**
  23548. * Sets the coefficient of restitution
  23549. */
  23550. restitution: number;
  23551. /**
  23552. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23553. */
  23554. /**
  23555. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23556. */
  23557. pressure: number;
  23558. /**
  23559. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23560. */
  23561. /**
  23562. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23563. */
  23564. stiffness: number;
  23565. /**
  23566. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23567. */
  23568. /**
  23569. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23570. */
  23571. velocityIterations: number;
  23572. /**
  23573. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23574. */
  23575. /**
  23576. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23577. */
  23578. positionIterations: number;
  23579. /**
  23580. * The unique id of the physics imposter
  23581. * set by the physics engine when adding this impostor to the array
  23582. */
  23583. uniqueId: number;
  23584. /**
  23585. * @hidden
  23586. */
  23587. soft: boolean;
  23588. /**
  23589. * @hidden
  23590. */
  23591. segments: number;
  23592. private _joints;
  23593. /**
  23594. * Initializes the physics imposter
  23595. * @param object The physics-enabled object used as the physics imposter
  23596. * @param type The type of the physics imposter
  23597. * @param _options The options for the physics imposter
  23598. * @param _scene The Babylon scene
  23599. */
  23600. constructor(
  23601. /**
  23602. * The physics-enabled object used as the physics imposter
  23603. */
  23604. object: IPhysicsEnabledObject,
  23605. /**
  23606. * The type of the physics imposter
  23607. */
  23608. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23609. /**
  23610. * This function will completly initialize this impostor.
  23611. * It will create a new body - but only if this mesh has no parent.
  23612. * If it has, this impostor will not be used other than to define the impostor
  23613. * of the child mesh.
  23614. * @hidden
  23615. */
  23616. _init(): void;
  23617. private _getPhysicsParent;
  23618. /**
  23619. * Should a new body be generated.
  23620. * @returns boolean specifying if body initialization is required
  23621. */
  23622. isBodyInitRequired(): boolean;
  23623. /**
  23624. * Sets the updated scaling
  23625. * @param updated Specifies if the scaling is updated
  23626. */
  23627. setScalingUpdated(): void;
  23628. /**
  23629. * Force a regeneration of this or the parent's impostor's body.
  23630. * Use under cautious - This will remove all joints already implemented.
  23631. */
  23632. forceUpdate(): void;
  23633. /**
  23634. * Gets the body that holds this impostor. Either its own, or its parent.
  23635. */
  23636. /**
  23637. * Set the physics body. Used mainly by the physics engine/plugin
  23638. */
  23639. physicsBody: any;
  23640. /**
  23641. * Get the parent of the physics imposter
  23642. * @returns Physics imposter or null
  23643. */
  23644. /**
  23645. * Sets the parent of the physics imposter
  23646. */
  23647. parent: Nullable<PhysicsImpostor>;
  23648. /**
  23649. * Resets the update flags
  23650. */
  23651. resetUpdateFlags(): void;
  23652. /**
  23653. * Gets the object extend size
  23654. * @returns the object extend size
  23655. */
  23656. getObjectExtendSize(): Vector3;
  23657. /**
  23658. * Gets the object center
  23659. * @returns The object center
  23660. */
  23661. getObjectCenter(): Vector3;
  23662. /**
  23663. * Get a specific parametes from the options parameter
  23664. * @param paramName The object parameter name
  23665. * @returns The object parameter
  23666. */
  23667. getParam(paramName: string): any;
  23668. /**
  23669. * Sets a specific parameter in the options given to the physics plugin
  23670. * @param paramName The parameter name
  23671. * @param value The value of the parameter
  23672. */
  23673. setParam(paramName: string, value: number): void;
  23674. /**
  23675. * Specifically change the body's mass option. Won't recreate the physics body object
  23676. * @param mass The mass of the physics imposter
  23677. */
  23678. setMass(mass: number): void;
  23679. /**
  23680. * Gets the linear velocity
  23681. * @returns linear velocity or null
  23682. */
  23683. getLinearVelocity(): Nullable<Vector3>;
  23684. /**
  23685. * Sets the linear velocity
  23686. * @param velocity linear velocity or null
  23687. */
  23688. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23689. /**
  23690. * Gets the angular velocity
  23691. * @returns angular velocity or null
  23692. */
  23693. getAngularVelocity(): Nullable<Vector3>;
  23694. /**
  23695. * Sets the angular velocity
  23696. * @param velocity The velocity or null
  23697. */
  23698. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23699. /**
  23700. * Execute a function with the physics plugin native code
  23701. * Provide a function the will have two variables - the world object and the physics body object
  23702. * @param func The function to execute with the physics plugin native code
  23703. */
  23704. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23705. /**
  23706. * Register a function that will be executed before the physics world is stepping forward
  23707. * @param func The function to execute before the physics world is stepped forward
  23708. */
  23709. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23710. /**
  23711. * Unregister a function that will be executed before the physics world is stepping forward
  23712. * @param func The function to execute before the physics world is stepped forward
  23713. */
  23714. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23715. /**
  23716. * Register a function that will be executed after the physics step
  23717. * @param func The function to execute after physics step
  23718. */
  23719. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23720. /**
  23721. * Unregisters a function that will be executed after the physics step
  23722. * @param func The function to execute after physics step
  23723. */
  23724. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23725. /**
  23726. * register a function that will be executed when this impostor collides against a different body
  23727. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23728. * @param func Callback that is executed on collision
  23729. */
  23730. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23731. /**
  23732. * Unregisters the physics imposter on contact
  23733. * @param collideAgainst The physics object to collide against
  23734. * @param func Callback to execute on collision
  23735. */
  23736. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23737. private _tmpQuat;
  23738. private _tmpQuat2;
  23739. /**
  23740. * Get the parent rotation
  23741. * @returns The parent rotation
  23742. */
  23743. getParentsRotation(): Quaternion;
  23744. /**
  23745. * this function is executed by the physics engine.
  23746. */
  23747. beforeStep: () => void;
  23748. /**
  23749. * this function is executed by the physics engine
  23750. */
  23751. afterStep: () => void;
  23752. /**
  23753. * Legacy collision detection event support
  23754. */
  23755. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23756. /**
  23757. * event and body object due to cannon's event-based architecture.
  23758. */
  23759. onCollide: (e: {
  23760. body: any;
  23761. }) => void;
  23762. /**
  23763. * Apply a force
  23764. * @param force The force to apply
  23765. * @param contactPoint The contact point for the force
  23766. * @returns The physics imposter
  23767. */
  23768. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23769. /**
  23770. * Apply an impulse
  23771. * @param force The impulse force
  23772. * @param contactPoint The contact point for the impulse force
  23773. * @returns The physics imposter
  23774. */
  23775. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23776. /**
  23777. * A help function to create a joint
  23778. * @param otherImpostor A physics imposter used to create a joint
  23779. * @param jointType The type of joint
  23780. * @param jointData The data for the joint
  23781. * @returns The physics imposter
  23782. */
  23783. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23784. /**
  23785. * Add a joint to this impostor with a different impostor
  23786. * @param otherImpostor A physics imposter used to add a joint
  23787. * @param joint The joint to add
  23788. * @returns The physics imposter
  23789. */
  23790. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23791. /**
  23792. * Add an anchor to a cloth impostor
  23793. * @param otherImpostor rigid impostor to anchor to
  23794. * @param width ratio across width from 0 to 1
  23795. * @param height ratio up height from 0 to 1
  23796. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23797. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23798. * @returns impostor the soft imposter
  23799. */
  23800. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23801. /**
  23802. * Add a hook to a rope impostor
  23803. * @param otherImpostor rigid impostor to anchor to
  23804. * @param length ratio across rope from 0 to 1
  23805. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23806. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23807. * @returns impostor the rope imposter
  23808. */
  23809. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23810. /**
  23811. * Will keep this body still, in a sleep mode.
  23812. * @returns the physics imposter
  23813. */
  23814. sleep(): PhysicsImpostor;
  23815. /**
  23816. * Wake the body up.
  23817. * @returns The physics imposter
  23818. */
  23819. wakeUp(): PhysicsImpostor;
  23820. /**
  23821. * Clones the physics imposter
  23822. * @param newObject The physics imposter clones to this physics-enabled object
  23823. * @returns A nullable physics imposter
  23824. */
  23825. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23826. /**
  23827. * Disposes the physics imposter
  23828. */
  23829. dispose(): void;
  23830. /**
  23831. * Sets the delta position
  23832. * @param position The delta position amount
  23833. */
  23834. setDeltaPosition(position: Vector3): void;
  23835. /**
  23836. * Sets the delta rotation
  23837. * @param rotation The delta rotation amount
  23838. */
  23839. setDeltaRotation(rotation: Quaternion): void;
  23840. /**
  23841. * Gets the box size of the physics imposter and stores the result in the input parameter
  23842. * @param result Stores the box size
  23843. * @returns The physics imposter
  23844. */
  23845. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23846. /**
  23847. * Gets the radius of the physics imposter
  23848. * @returns Radius of the physics imposter
  23849. */
  23850. getRadius(): number;
  23851. /**
  23852. * Sync a bone with this impostor
  23853. * @param bone The bone to sync to the impostor.
  23854. * @param boneMesh The mesh that the bone is influencing.
  23855. * @param jointPivot The pivot of the joint / bone in local space.
  23856. * @param distToJoint Optional distance from the impostor to the joint.
  23857. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23858. */
  23859. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23860. /**
  23861. * Sync impostor to a bone
  23862. * @param bone The bone that the impostor will be synced to.
  23863. * @param boneMesh The mesh that the bone is influencing.
  23864. * @param jointPivot The pivot of the joint / bone in local space.
  23865. * @param distToJoint Optional distance from the impostor to the joint.
  23866. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23867. * @param boneAxis Optional vector3 axis the bone is aligned with
  23868. */
  23869. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23870. /**
  23871. * No-Imposter type
  23872. */
  23873. static NoImpostor: number;
  23874. /**
  23875. * Sphere-Imposter type
  23876. */
  23877. static SphereImpostor: number;
  23878. /**
  23879. * Box-Imposter type
  23880. */
  23881. static BoxImpostor: number;
  23882. /**
  23883. * Plane-Imposter type
  23884. */
  23885. static PlaneImpostor: number;
  23886. /**
  23887. * Mesh-imposter type
  23888. */
  23889. static MeshImpostor: number;
  23890. /**
  23891. * Capsule-Impostor type (Ammo.js plugin only)
  23892. */
  23893. static CapsuleImpostor: number;
  23894. /**
  23895. * Cylinder-Imposter type
  23896. */
  23897. static CylinderImpostor: number;
  23898. /**
  23899. * Particle-Imposter type
  23900. */
  23901. static ParticleImpostor: number;
  23902. /**
  23903. * Heightmap-Imposter type
  23904. */
  23905. static HeightmapImpostor: number;
  23906. /**
  23907. * ConvexHull-Impostor type (Ammo.js plugin only)
  23908. */
  23909. static ConvexHullImpostor: number;
  23910. /**
  23911. * Rope-Imposter type
  23912. */
  23913. static RopeImpostor: number;
  23914. /**
  23915. * Cloth-Imposter type
  23916. */
  23917. static ClothImpostor: number;
  23918. /**
  23919. * Softbody-Imposter type
  23920. */
  23921. static SoftbodyImpostor: number;
  23922. }
  23923. }
  23924. declare module "babylonjs/Meshes/mesh" {
  23925. import { Observable } from "babylonjs/Misc/observable";
  23926. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23927. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23928. import { Camera } from "babylonjs/Cameras/camera";
  23929. import { Scene } from "babylonjs/scene";
  23930. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23931. import { Color4 } from "babylonjs/Maths/math.color";
  23932. import { Engine } from "babylonjs/Engines/engine";
  23933. import { Node } from "babylonjs/node";
  23934. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23935. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23936. import { Buffer } from "babylonjs/Meshes/buffer";
  23937. import { Geometry } from "babylonjs/Meshes/geometry";
  23938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23940. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23941. import { Effect } from "babylonjs/Materials/effect";
  23942. import { Material } from "babylonjs/Materials/material";
  23943. import { Skeleton } from "babylonjs/Bones/skeleton";
  23944. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23945. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23946. import { Path3D } from "babylonjs/Maths/math.path";
  23947. import { Plane } from "babylonjs/Maths/math.plane";
  23948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23949. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23950. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23951. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23952. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23953. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23954. /**
  23955. * @hidden
  23956. **/
  23957. export class _CreationDataStorage {
  23958. closePath?: boolean;
  23959. closeArray?: boolean;
  23960. idx: number[];
  23961. dashSize: number;
  23962. gapSize: number;
  23963. path3D: Path3D;
  23964. pathArray: Vector3[][];
  23965. arc: number;
  23966. radius: number;
  23967. cap: number;
  23968. tessellation: number;
  23969. }
  23970. /**
  23971. * @hidden
  23972. **/
  23973. class _InstanceDataStorage {
  23974. visibleInstances: any;
  23975. batchCache: _InstancesBatch;
  23976. instancesBufferSize: number;
  23977. instancesBuffer: Nullable<Buffer>;
  23978. instancesData: Float32Array;
  23979. overridenInstanceCount: number;
  23980. isFrozen: boolean;
  23981. previousBatch: Nullable<_InstancesBatch>;
  23982. hardwareInstancedRendering: boolean;
  23983. sideOrientation: number;
  23984. }
  23985. /**
  23986. * @hidden
  23987. **/
  23988. export class _InstancesBatch {
  23989. mustReturn: boolean;
  23990. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23991. renderSelf: boolean[];
  23992. hardwareInstancedRendering: boolean[];
  23993. }
  23994. /**
  23995. * Class used to represent renderable models
  23996. */
  23997. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23998. /**
  23999. * Mesh side orientation : usually the external or front surface
  24000. */
  24001. static readonly FRONTSIDE: number;
  24002. /**
  24003. * Mesh side orientation : usually the internal or back surface
  24004. */
  24005. static readonly BACKSIDE: number;
  24006. /**
  24007. * Mesh side orientation : both internal and external or front and back surfaces
  24008. */
  24009. static readonly DOUBLESIDE: number;
  24010. /**
  24011. * Mesh side orientation : by default, `FRONTSIDE`
  24012. */
  24013. static readonly DEFAULTSIDE: number;
  24014. /**
  24015. * Mesh cap setting : no cap
  24016. */
  24017. static readonly NO_CAP: number;
  24018. /**
  24019. * Mesh cap setting : one cap at the beginning of the mesh
  24020. */
  24021. static readonly CAP_START: number;
  24022. /**
  24023. * Mesh cap setting : one cap at the end of the mesh
  24024. */
  24025. static readonly CAP_END: number;
  24026. /**
  24027. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24028. */
  24029. static readonly CAP_ALL: number;
  24030. /**
  24031. * Mesh pattern setting : no flip or rotate
  24032. */
  24033. static readonly NO_FLIP: number;
  24034. /**
  24035. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24036. */
  24037. static readonly FLIP_TILE: number;
  24038. /**
  24039. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24040. */
  24041. static readonly ROTATE_TILE: number;
  24042. /**
  24043. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24044. */
  24045. static readonly FLIP_ROW: number;
  24046. /**
  24047. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24048. */
  24049. static readonly ROTATE_ROW: number;
  24050. /**
  24051. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24052. */
  24053. static readonly FLIP_N_ROTATE_TILE: number;
  24054. /**
  24055. * Mesh pattern setting : rotate pattern and rotate
  24056. */
  24057. static readonly FLIP_N_ROTATE_ROW: number;
  24058. /**
  24059. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24060. */
  24061. static readonly CENTER: number;
  24062. /**
  24063. * Mesh tile positioning : part tiles on left
  24064. */
  24065. static readonly LEFT: number;
  24066. /**
  24067. * Mesh tile positioning : part tiles on right
  24068. */
  24069. static readonly RIGHT: number;
  24070. /**
  24071. * Mesh tile positioning : part tiles on top
  24072. */
  24073. static readonly TOP: number;
  24074. /**
  24075. * Mesh tile positioning : part tiles on bottom
  24076. */
  24077. static readonly BOTTOM: number;
  24078. /**
  24079. * Gets the default side orientation.
  24080. * @param orientation the orientation to value to attempt to get
  24081. * @returns the default orientation
  24082. * @hidden
  24083. */
  24084. static _GetDefaultSideOrientation(orientation?: number): number;
  24085. private _internalMeshDataInfo;
  24086. /**
  24087. * An event triggered before rendering the mesh
  24088. */
  24089. readonly onBeforeRenderObservable: Observable<Mesh>;
  24090. /**
  24091. * An event triggered before binding the mesh
  24092. */
  24093. readonly onBeforeBindObservable: Observable<Mesh>;
  24094. /**
  24095. * An event triggered after rendering the mesh
  24096. */
  24097. readonly onAfterRenderObservable: Observable<Mesh>;
  24098. /**
  24099. * An event triggered before drawing the mesh
  24100. */
  24101. readonly onBeforeDrawObservable: Observable<Mesh>;
  24102. private _onBeforeDrawObserver;
  24103. /**
  24104. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24105. */
  24106. onBeforeDraw: () => void;
  24107. readonly hasInstances: boolean;
  24108. /**
  24109. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24110. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24111. */
  24112. delayLoadState: number;
  24113. /**
  24114. * Gets the list of instances created from this mesh
  24115. * it is not supposed to be modified manually.
  24116. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24117. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24118. */
  24119. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24120. /**
  24121. * Gets the file containing delay loading data for this mesh
  24122. */
  24123. delayLoadingFile: string;
  24124. /** @hidden */
  24125. _binaryInfo: any;
  24126. /**
  24127. * User defined function used to change how LOD level selection is done
  24128. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24129. */
  24130. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24131. /**
  24132. * Gets or sets the morph target manager
  24133. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24134. */
  24135. morphTargetManager: Nullable<MorphTargetManager>;
  24136. /** @hidden */
  24137. _creationDataStorage: Nullable<_CreationDataStorage>;
  24138. /** @hidden */
  24139. _geometry: Nullable<Geometry>;
  24140. /** @hidden */
  24141. _delayInfo: Array<string>;
  24142. /** @hidden */
  24143. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24144. /** @hidden */
  24145. _instanceDataStorage: _InstanceDataStorage;
  24146. private _effectiveMaterial;
  24147. /** @hidden */
  24148. _shouldGenerateFlatShading: boolean;
  24149. /** @hidden */
  24150. _originalBuilderSideOrientation: number;
  24151. /**
  24152. * Use this property to change the original side orientation defined at construction time
  24153. */
  24154. overrideMaterialSideOrientation: Nullable<number>;
  24155. /**
  24156. * Gets the source mesh (the one used to clone this one from)
  24157. */
  24158. readonly source: Nullable<Mesh>;
  24159. /**
  24160. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24161. */
  24162. isUnIndexed: boolean;
  24163. /**
  24164. * @constructor
  24165. * @param name The value used by scene.getMeshByName() to do a lookup.
  24166. * @param scene The scene to add this mesh to.
  24167. * @param parent The parent of this mesh, if it has one
  24168. * @param source An optional Mesh from which geometry is shared, cloned.
  24169. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24170. * When false, achieved by calling a clone(), also passing False.
  24171. * This will make creation of children, recursive.
  24172. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24173. */
  24174. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24175. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24176. /**
  24177. * Gets the class name
  24178. * @returns the string "Mesh".
  24179. */
  24180. getClassName(): string;
  24181. /** @hidden */
  24182. readonly _isMesh: boolean;
  24183. /**
  24184. * Returns a description of this mesh
  24185. * @param fullDetails define if full details about this mesh must be used
  24186. * @returns a descriptive string representing this mesh
  24187. */
  24188. toString(fullDetails?: boolean): string;
  24189. /** @hidden */
  24190. _unBindEffect(): void;
  24191. /**
  24192. * Gets a boolean indicating if this mesh has LOD
  24193. */
  24194. readonly hasLODLevels: boolean;
  24195. /**
  24196. * Gets the list of MeshLODLevel associated with the current mesh
  24197. * @returns an array of MeshLODLevel
  24198. */
  24199. getLODLevels(): MeshLODLevel[];
  24200. private _sortLODLevels;
  24201. /**
  24202. * Add a mesh as LOD level triggered at the given distance.
  24203. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24204. * @param distance The distance from the center of the object to show this level
  24205. * @param mesh The mesh to be added as LOD level (can be null)
  24206. * @return This mesh (for chaining)
  24207. */
  24208. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24209. /**
  24210. * Returns the LOD level mesh at the passed distance or null if not found.
  24211. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24212. * @param distance The distance from the center of the object to show this level
  24213. * @returns a Mesh or `null`
  24214. */
  24215. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24216. /**
  24217. * Remove a mesh from the LOD array
  24218. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24219. * @param mesh defines the mesh to be removed
  24220. * @return This mesh (for chaining)
  24221. */
  24222. removeLODLevel(mesh: Mesh): Mesh;
  24223. /**
  24224. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24225. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24226. * @param camera defines the camera to use to compute distance
  24227. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24228. * @return This mesh (for chaining)
  24229. */
  24230. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24231. /**
  24232. * Gets the mesh internal Geometry object
  24233. */
  24234. readonly geometry: Nullable<Geometry>;
  24235. /**
  24236. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24237. * @returns the total number of vertices
  24238. */
  24239. getTotalVertices(): number;
  24240. /**
  24241. * Returns the content of an associated vertex buffer
  24242. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24243. * - VertexBuffer.PositionKind
  24244. * - VertexBuffer.UVKind
  24245. * - VertexBuffer.UV2Kind
  24246. * - VertexBuffer.UV3Kind
  24247. * - VertexBuffer.UV4Kind
  24248. * - VertexBuffer.UV5Kind
  24249. * - VertexBuffer.UV6Kind
  24250. * - VertexBuffer.ColorKind
  24251. * - VertexBuffer.MatricesIndicesKind
  24252. * - VertexBuffer.MatricesIndicesExtraKind
  24253. * - VertexBuffer.MatricesWeightsKind
  24254. * - VertexBuffer.MatricesWeightsExtraKind
  24255. * @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
  24256. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24257. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24258. */
  24259. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24260. /**
  24261. * Returns the mesh VertexBuffer object from the requested `kind`
  24262. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24263. * - VertexBuffer.PositionKind
  24264. * - VertexBuffer.NormalKind
  24265. * - VertexBuffer.UVKind
  24266. * - VertexBuffer.UV2Kind
  24267. * - VertexBuffer.UV3Kind
  24268. * - VertexBuffer.UV4Kind
  24269. * - VertexBuffer.UV5Kind
  24270. * - VertexBuffer.UV6Kind
  24271. * - VertexBuffer.ColorKind
  24272. * - VertexBuffer.MatricesIndicesKind
  24273. * - VertexBuffer.MatricesIndicesExtraKind
  24274. * - VertexBuffer.MatricesWeightsKind
  24275. * - VertexBuffer.MatricesWeightsExtraKind
  24276. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24277. */
  24278. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24279. /**
  24280. * Tests if a specific vertex buffer is associated with this mesh
  24281. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24282. * - VertexBuffer.PositionKind
  24283. * - VertexBuffer.NormalKind
  24284. * - VertexBuffer.UVKind
  24285. * - VertexBuffer.UV2Kind
  24286. * - VertexBuffer.UV3Kind
  24287. * - VertexBuffer.UV4Kind
  24288. * - VertexBuffer.UV5Kind
  24289. * - VertexBuffer.UV6Kind
  24290. * - VertexBuffer.ColorKind
  24291. * - VertexBuffer.MatricesIndicesKind
  24292. * - VertexBuffer.MatricesIndicesExtraKind
  24293. * - VertexBuffer.MatricesWeightsKind
  24294. * - VertexBuffer.MatricesWeightsExtraKind
  24295. * @returns a boolean
  24296. */
  24297. isVerticesDataPresent(kind: string): boolean;
  24298. /**
  24299. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24300. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24301. * - VertexBuffer.PositionKind
  24302. * - VertexBuffer.UVKind
  24303. * - VertexBuffer.UV2Kind
  24304. * - VertexBuffer.UV3Kind
  24305. * - VertexBuffer.UV4Kind
  24306. * - VertexBuffer.UV5Kind
  24307. * - VertexBuffer.UV6Kind
  24308. * - VertexBuffer.ColorKind
  24309. * - VertexBuffer.MatricesIndicesKind
  24310. * - VertexBuffer.MatricesIndicesExtraKind
  24311. * - VertexBuffer.MatricesWeightsKind
  24312. * - VertexBuffer.MatricesWeightsExtraKind
  24313. * @returns a boolean
  24314. */
  24315. isVertexBufferUpdatable(kind: string): boolean;
  24316. /**
  24317. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24318. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24319. * - VertexBuffer.PositionKind
  24320. * - VertexBuffer.NormalKind
  24321. * - VertexBuffer.UVKind
  24322. * - VertexBuffer.UV2Kind
  24323. * - VertexBuffer.UV3Kind
  24324. * - VertexBuffer.UV4Kind
  24325. * - VertexBuffer.UV5Kind
  24326. * - VertexBuffer.UV6Kind
  24327. * - VertexBuffer.ColorKind
  24328. * - VertexBuffer.MatricesIndicesKind
  24329. * - VertexBuffer.MatricesIndicesExtraKind
  24330. * - VertexBuffer.MatricesWeightsKind
  24331. * - VertexBuffer.MatricesWeightsExtraKind
  24332. * @returns an array of strings
  24333. */
  24334. getVerticesDataKinds(): string[];
  24335. /**
  24336. * Returns a positive integer : the total number of indices in this mesh geometry.
  24337. * @returns the numner of indices or zero if the mesh has no geometry.
  24338. */
  24339. getTotalIndices(): number;
  24340. /**
  24341. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24342. * @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.
  24343. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24344. * @returns the indices array or an empty array if the mesh has no geometry
  24345. */
  24346. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24347. readonly isBlocked: boolean;
  24348. /**
  24349. * Determine if the current mesh is ready to be rendered
  24350. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24351. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24352. * @returns true if all associated assets are ready (material, textures, shaders)
  24353. */
  24354. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24355. /**
  24356. * 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.
  24357. */
  24358. readonly areNormalsFrozen: boolean;
  24359. /**
  24360. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24361. * @returns the current mesh
  24362. */
  24363. freezeNormals(): Mesh;
  24364. /**
  24365. * 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
  24366. * @returns the current mesh
  24367. */
  24368. unfreezeNormals(): Mesh;
  24369. /**
  24370. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24371. */
  24372. overridenInstanceCount: number;
  24373. /** @hidden */
  24374. _preActivate(): Mesh;
  24375. /** @hidden */
  24376. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24377. /** @hidden */
  24378. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24379. /**
  24380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24381. * This means the mesh underlying bounding box and sphere are recomputed.
  24382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24383. * @returns the current mesh
  24384. */
  24385. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24386. /** @hidden */
  24387. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24388. /**
  24389. * This function will subdivide the mesh into multiple submeshes
  24390. * @param count defines the expected number of submeshes
  24391. */
  24392. subdivide(count: number): void;
  24393. /**
  24394. * Copy a FloatArray into a specific associated vertex buffer
  24395. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24396. * - VertexBuffer.PositionKind
  24397. * - VertexBuffer.UVKind
  24398. * - VertexBuffer.UV2Kind
  24399. * - VertexBuffer.UV3Kind
  24400. * - VertexBuffer.UV4Kind
  24401. * - VertexBuffer.UV5Kind
  24402. * - VertexBuffer.UV6Kind
  24403. * - VertexBuffer.ColorKind
  24404. * - VertexBuffer.MatricesIndicesKind
  24405. * - VertexBuffer.MatricesIndicesExtraKind
  24406. * - VertexBuffer.MatricesWeightsKind
  24407. * - VertexBuffer.MatricesWeightsExtraKind
  24408. * @param data defines the data source
  24409. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24410. * @param stride defines the data stride size (can be null)
  24411. * @returns the current mesh
  24412. */
  24413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24414. /**
  24415. * Flags an associated vertex buffer as updatable
  24416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24417. * - VertexBuffer.PositionKind
  24418. * - VertexBuffer.UVKind
  24419. * - VertexBuffer.UV2Kind
  24420. * - VertexBuffer.UV3Kind
  24421. * - VertexBuffer.UV4Kind
  24422. * - VertexBuffer.UV5Kind
  24423. * - VertexBuffer.UV6Kind
  24424. * - VertexBuffer.ColorKind
  24425. * - VertexBuffer.MatricesIndicesKind
  24426. * - VertexBuffer.MatricesIndicesExtraKind
  24427. * - VertexBuffer.MatricesWeightsKind
  24428. * - VertexBuffer.MatricesWeightsExtraKind
  24429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24430. */
  24431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24432. /**
  24433. * Sets the mesh global Vertex Buffer
  24434. * @param buffer defines the buffer to use
  24435. * @returns the current mesh
  24436. */
  24437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24438. /**
  24439. * Update a specific associated vertex buffer
  24440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24441. * - VertexBuffer.PositionKind
  24442. * - VertexBuffer.UVKind
  24443. * - VertexBuffer.UV2Kind
  24444. * - VertexBuffer.UV3Kind
  24445. * - VertexBuffer.UV4Kind
  24446. * - VertexBuffer.UV5Kind
  24447. * - VertexBuffer.UV6Kind
  24448. * - VertexBuffer.ColorKind
  24449. * - VertexBuffer.MatricesIndicesKind
  24450. * - VertexBuffer.MatricesIndicesExtraKind
  24451. * - VertexBuffer.MatricesWeightsKind
  24452. * - VertexBuffer.MatricesWeightsExtraKind
  24453. * @param data defines the data source
  24454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24455. * @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)
  24456. * @returns the current mesh
  24457. */
  24458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24459. /**
  24460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24461. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24464. * @returns the current mesh
  24465. */
  24466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24467. /**
  24468. * Creates a un-shared specific occurence of the geometry for the mesh.
  24469. * @returns the current mesh
  24470. */
  24471. makeGeometryUnique(): Mesh;
  24472. /**
  24473. * Set the index buffer of this mesh
  24474. * @param indices defines the source data
  24475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24477. * @returns the current mesh
  24478. */
  24479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24480. /**
  24481. * Update the current index buffer
  24482. * @param indices defines the source data
  24483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24484. * @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)
  24485. * @returns the current mesh
  24486. */
  24487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24488. /**
  24489. * Invert the geometry to move from a right handed system to a left handed one.
  24490. * @returns the current mesh
  24491. */
  24492. toLeftHanded(): Mesh;
  24493. /** @hidden */
  24494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24495. /** @hidden */
  24496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24497. /**
  24498. * Registers for this mesh a javascript function called just before the rendering process
  24499. * @param func defines the function to call before rendering this mesh
  24500. * @returns the current mesh
  24501. */
  24502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24503. /**
  24504. * Disposes a previously registered javascript function called before the rendering
  24505. * @param func defines the function to remove
  24506. * @returns the current mesh
  24507. */
  24508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24509. /**
  24510. * Registers for this mesh a javascript function called just after the rendering is complete
  24511. * @param func defines the function to call after rendering this mesh
  24512. * @returns the current mesh
  24513. */
  24514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24515. /**
  24516. * Disposes a previously registered javascript function called after the rendering.
  24517. * @param func defines the function to remove
  24518. * @returns the current mesh
  24519. */
  24520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24521. /** @hidden */
  24522. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24523. /** @hidden */
  24524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24525. /** @hidden */
  24526. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24527. /** @hidden */
  24528. _rebuild(): void;
  24529. /** @hidden */
  24530. _freeze(): void;
  24531. /** @hidden */
  24532. _unFreeze(): void;
  24533. /**
  24534. * 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
  24535. * @param subMesh defines the subMesh to render
  24536. * @param enableAlphaMode defines if alpha mode can be changed
  24537. * @returns the current mesh
  24538. */
  24539. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24540. private _onBeforeDraw;
  24541. /**
  24542. * Renormalize the mesh and patch it up if there are no weights
  24543. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24544. * However in the case of zero weights then we set just a single influence to 1.
  24545. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24546. */
  24547. cleanMatrixWeights(): void;
  24548. private normalizeSkinFourWeights;
  24549. private normalizeSkinWeightsAndExtra;
  24550. /**
  24551. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24552. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24553. * the user know there was an issue with importing the mesh
  24554. * @returns a validation object with skinned, valid and report string
  24555. */
  24556. validateSkinning(): {
  24557. skinned: boolean;
  24558. valid: boolean;
  24559. report: string;
  24560. };
  24561. /** @hidden */
  24562. _checkDelayState(): Mesh;
  24563. private _queueLoad;
  24564. /**
  24565. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24566. * A mesh is in the frustum if its bounding box intersects the frustum
  24567. * @param frustumPlanes defines the frustum to test
  24568. * @returns true if the mesh is in the frustum planes
  24569. */
  24570. isInFrustum(frustumPlanes: Plane[]): boolean;
  24571. /**
  24572. * Sets the mesh material by the material or multiMaterial `id` property
  24573. * @param id is a string identifying the material or the multiMaterial
  24574. * @returns the current mesh
  24575. */
  24576. setMaterialByID(id: string): Mesh;
  24577. /**
  24578. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24579. * @returns an array of IAnimatable
  24580. */
  24581. getAnimatables(): IAnimatable[];
  24582. /**
  24583. * Modifies the mesh geometry according to the passed transformation matrix.
  24584. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24585. * The mesh normals are modified using the same transformation.
  24586. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24587. * @param transform defines the transform matrix to use
  24588. * @see http://doc.babylonjs.com/resources/baking_transformations
  24589. * @returns the current mesh
  24590. */
  24591. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24592. /**
  24593. * Modifies the mesh geometry according to its own current World Matrix.
  24594. * The mesh World Matrix is then reset.
  24595. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24596. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24597. * @see http://doc.babylonjs.com/resources/baking_transformations
  24598. * @returns the current mesh
  24599. */
  24600. bakeCurrentTransformIntoVertices(): Mesh;
  24601. /** @hidden */
  24602. readonly _positions: Nullable<Vector3[]>;
  24603. /** @hidden */
  24604. _resetPointsArrayCache(): Mesh;
  24605. /** @hidden */
  24606. _generatePointsArray(): boolean;
  24607. /**
  24608. * Returns a new Mesh object generated from the current mesh properties.
  24609. * This method must not get confused with createInstance()
  24610. * @param name is a string, the name given to the new mesh
  24611. * @param newParent can be any Node object (default `null`)
  24612. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24613. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24614. * @returns a new mesh
  24615. */
  24616. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24617. /**
  24618. * Releases resources associated with this mesh.
  24619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24621. */
  24622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24623. /**
  24624. * Modifies the mesh geometry according to a displacement map.
  24625. * 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.
  24626. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24627. * @param url is a string, the URL from the image file is to be downloaded.
  24628. * @param minHeight is the lower limit of the displacement.
  24629. * @param maxHeight is the upper limit of the displacement.
  24630. * @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.
  24631. * @param uvOffset is an optional vector2 used to offset UV.
  24632. * @param uvScale is an optional vector2 used to scale UV.
  24633. * @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.
  24634. * @returns the Mesh.
  24635. */
  24636. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24637. /**
  24638. * Modifies the mesh geometry according to a displacementMap buffer.
  24639. * 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.
  24640. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24641. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24642. * @param heightMapWidth is the width of the buffer image.
  24643. * @param heightMapHeight is the height of the buffer image.
  24644. * @param minHeight is the lower limit of the displacement.
  24645. * @param maxHeight is the upper limit of the displacement.
  24646. * @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.
  24647. * @param uvOffset is an optional vector2 used to offset UV.
  24648. * @param uvScale is an optional vector2 used to scale UV.
  24649. * @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.
  24650. * @returns the Mesh.
  24651. */
  24652. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24653. /**
  24654. * Modify the mesh to get a flat shading rendering.
  24655. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24656. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24657. * @returns current mesh
  24658. */
  24659. convertToFlatShadedMesh(): Mesh;
  24660. /**
  24661. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24662. * In other words, more vertices, no more indices and a single bigger VBO.
  24663. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24664. * @returns current mesh
  24665. */
  24666. convertToUnIndexedMesh(): Mesh;
  24667. /**
  24668. * Inverses facet orientations.
  24669. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24670. * @param flipNormals will also inverts the normals
  24671. * @returns current mesh
  24672. */
  24673. flipFaces(flipNormals?: boolean): Mesh;
  24674. /**
  24675. * Increase the number of facets and hence vertices in a mesh
  24676. * Vertex normals are interpolated from existing vertex normals
  24677. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24678. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24679. */
  24680. increaseVertices(numberPerEdge: number): void;
  24681. /**
  24682. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24683. * This will undo any application of covertToFlatShadedMesh
  24684. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24685. */
  24686. forceSharedVertices(): void;
  24687. /** @hidden */
  24688. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24689. /** @hidden */
  24690. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24691. /**
  24692. * Creates a new InstancedMesh object from the mesh model.
  24693. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24694. * @param name defines the name of the new instance
  24695. * @returns a new InstancedMesh
  24696. */
  24697. createInstance(name: string): InstancedMesh;
  24698. /**
  24699. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24700. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24701. * @returns the current mesh
  24702. */
  24703. synchronizeInstances(): Mesh;
  24704. /**
  24705. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24706. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24707. * This should be used together with the simplification to avoid disappearing triangles.
  24708. * @param successCallback an optional success callback to be called after the optimization finished.
  24709. * @returns the current mesh
  24710. */
  24711. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24712. /**
  24713. * Serialize current mesh
  24714. * @param serializationObject defines the object which will receive the serialization data
  24715. */
  24716. serialize(serializationObject: any): void;
  24717. /** @hidden */
  24718. _syncGeometryWithMorphTargetManager(): void;
  24719. /** @hidden */
  24720. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24721. /**
  24722. * Returns a new Mesh object parsed from the source provided.
  24723. * @param parsedMesh is the source
  24724. * @param scene defines the hosting scene
  24725. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24726. * @returns a new Mesh
  24727. */
  24728. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24729. /**
  24730. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24731. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24732. * @param name defines the name of the mesh to create
  24733. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24734. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24735. * @param closePath creates a seam between the first and the last points of each path of the path array
  24736. * @param offset is taken in account only if the `pathArray` is containing a single path
  24737. * @param scene defines the hosting scene
  24738. * @param updatable defines if the mesh must be flagged as updatable
  24739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24740. * @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)
  24741. * @returns a new Mesh
  24742. */
  24743. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24744. /**
  24745. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24746. * @param name defines the name of the mesh to create
  24747. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24748. * @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
  24749. * @param scene defines the hosting scene
  24750. * @param updatable defines if the mesh must be flagged as updatable
  24751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24752. * @returns a new Mesh
  24753. */
  24754. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24755. /**
  24756. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24757. * @param name defines the name of the mesh to create
  24758. * @param size sets the size (float) of each box side (default 1)
  24759. * @param scene defines the hosting scene
  24760. * @param updatable defines if the mesh must be flagged as updatable
  24761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24762. * @returns a new Mesh
  24763. */
  24764. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24765. /**
  24766. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24767. * @param name defines the name of the mesh to create
  24768. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24769. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24770. * @param scene defines the hosting scene
  24771. * @param updatable defines if the mesh must be flagged as updatable
  24772. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24773. * @returns a new Mesh
  24774. */
  24775. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24776. /**
  24777. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24778. * @param name defines the name of the mesh to create
  24779. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24780. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24781. * @param scene defines the hosting scene
  24782. * @returns a new Mesh
  24783. */
  24784. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24785. /**
  24786. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24787. * @param name defines the name of the mesh to create
  24788. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24789. * @param diameterTop set the top cap diameter (floats, default 1)
  24790. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24791. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24792. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24793. * @param scene defines the hosting scene
  24794. * @param updatable defines if the mesh must be flagged as updatable
  24795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24796. * @returns a new Mesh
  24797. */
  24798. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24799. /**
  24800. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24801. * @param name defines the name of the mesh to create
  24802. * @param diameter sets the diameter size (float) of the torus (default 1)
  24803. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24804. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24805. * @param scene defines the hosting scene
  24806. * @param updatable defines if the mesh must be flagged as updatable
  24807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24808. * @returns a new Mesh
  24809. */
  24810. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24811. /**
  24812. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24813. * @param name defines the name of the mesh to create
  24814. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24815. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24816. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24817. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24818. * @param p the number of windings on X axis (positive integers, default 2)
  24819. * @param q the number of windings on Y axis (positive integers, default 3)
  24820. * @param scene defines the hosting scene
  24821. * @param updatable defines if the mesh must be flagged as updatable
  24822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24823. * @returns a new Mesh
  24824. */
  24825. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24826. /**
  24827. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24828. * @param name defines the name of the mesh to create
  24829. * @param points is an array successive Vector3
  24830. * @param scene defines the hosting scene
  24831. * @param updatable defines if the mesh must be flagged as updatable
  24832. * @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).
  24833. * @returns a new Mesh
  24834. */
  24835. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24836. /**
  24837. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24838. * @param name defines the name of the mesh to create
  24839. * @param points is an array successive Vector3
  24840. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24841. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24842. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24843. * @param scene defines the hosting scene
  24844. * @param updatable defines if the mesh must be flagged as updatable
  24845. * @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)
  24846. * @returns a new Mesh
  24847. */
  24848. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24849. /**
  24850. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24851. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24852. * 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.
  24853. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24854. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24855. * Remember you can only change the shape positions, not their number when updating a polygon.
  24856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24857. * @param name defines the name of the mesh to create
  24858. * @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
  24859. * @param scene defines the hosting scene
  24860. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24861. * @param updatable defines if the mesh must be flagged as updatable
  24862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24863. * @param earcutInjection can be used to inject your own earcut reference
  24864. * @returns a new Mesh
  24865. */
  24866. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24867. /**
  24868. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24869. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24870. * @param name defines the name of the mesh to create
  24871. * @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
  24872. * @param depth defines the height of extrusion
  24873. * @param scene defines the hosting scene
  24874. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24875. * @param updatable defines if the mesh must be flagged as updatable
  24876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24877. * @param earcutInjection can be used to inject your own earcut reference
  24878. * @returns a new Mesh
  24879. */
  24880. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24881. /**
  24882. * Creates an extruded shape mesh.
  24883. * 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
  24884. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24886. * @param name defines the name of the mesh to create
  24887. * @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
  24888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24889. * @param scale is the value to scale the shape
  24890. * @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
  24891. * @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
  24892. * @param scene defines the hosting scene
  24893. * @param updatable defines if the mesh must be flagged as updatable
  24894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24895. * @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)
  24896. * @returns a new Mesh
  24897. */
  24898. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24899. /**
  24900. * Creates an custom extruded shape mesh.
  24901. * The custom extrusion is a parametric shape.
  24902. * It has no predefined shape. Its final shape will depend on the input parameters.
  24903. * Please consider using the same method from the MeshBuilder class instead
  24904. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24905. * @param name defines the name of the mesh to create
  24906. * @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
  24907. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24908. * @param scaleFunction is a custom Javascript function called on each path point
  24909. * @param rotationFunction is a custom Javascript function called on each path point
  24910. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24911. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24912. * @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
  24913. * @param scene defines the hosting scene
  24914. * @param updatable defines if the mesh must be flagged as updatable
  24915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24916. * @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)
  24917. * @returns a new Mesh
  24918. */
  24919. 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;
  24920. /**
  24921. * Creates lathe mesh.
  24922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24923. * Please consider using the same method from the MeshBuilder class instead
  24924. * @param name defines the name of the mesh to create
  24925. * @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
  24926. * @param radius is the radius value of the lathe
  24927. * @param tessellation is the side number of the lathe.
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @returns a new Mesh
  24932. */
  24933. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24934. /**
  24935. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24936. * @param name defines the name of the mesh to create
  24937. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24938. * @param scene defines the hosting scene
  24939. * @param updatable defines if the mesh must be flagged as updatable
  24940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24941. * @returns a new Mesh
  24942. */
  24943. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24944. /**
  24945. * Creates a ground mesh.
  24946. * Please consider using the same method from the MeshBuilder class instead
  24947. * @param name defines the name of the mesh to create
  24948. * @param width set the width of the ground
  24949. * @param height set the height of the ground
  24950. * @param subdivisions sets the number of subdivisions per side
  24951. * @param scene defines the hosting scene
  24952. * @param updatable defines if the mesh must be flagged as updatable
  24953. * @returns a new Mesh
  24954. */
  24955. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24956. /**
  24957. * Creates a tiled ground mesh.
  24958. * Please consider using the same method from the MeshBuilder class instead
  24959. * @param name defines the name of the mesh to create
  24960. * @param xmin set the ground minimum X coordinate
  24961. * @param zmin set the ground minimum Y coordinate
  24962. * @param xmax set the ground maximum X coordinate
  24963. * @param zmax set the ground maximum Z coordinate
  24964. * @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
  24965. * @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
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @returns a new Mesh
  24969. */
  24970. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24971. w: number;
  24972. h: number;
  24973. }, precision: {
  24974. w: number;
  24975. h: number;
  24976. }, scene: Scene, updatable?: boolean): Mesh;
  24977. /**
  24978. * Creates a ground mesh from a height map.
  24979. * Please consider using the same method from the MeshBuilder class instead
  24980. * @see http://doc.babylonjs.com/babylon101/height_map
  24981. * @param name defines the name of the mesh to create
  24982. * @param url sets the URL of the height map image resource
  24983. * @param width set the ground width size
  24984. * @param height set the ground height size
  24985. * @param subdivisions sets the number of subdivision per side
  24986. * @param minHeight is the minimum altitude on the ground
  24987. * @param maxHeight is the maximum altitude on the ground
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24991. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24992. * @returns a new Mesh
  24993. */
  24994. 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;
  24995. /**
  24996. * Creates a tube mesh.
  24997. * The tube is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25003. * @param radius sets the tube radius size
  25004. * @param tessellation is the number of sides on the tubular surface
  25005. * @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
  25006. * @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
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25010. * @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)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25014. (i: number, distance: number): number;
  25015. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25016. /**
  25017. * Creates a polyhedron mesh.
  25018. * Please consider using the same method from the MeshBuilder class instead.
  25019. * * 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
  25020. * * The parameter `size` (positive float, default 1) sets the polygon size
  25021. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25022. * * 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`
  25023. * * 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
  25024. * * 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)`)
  25025. * * 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
  25026. * * 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
  25027. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25028. * * If you create a double-sided mesh, you can choose what parts of 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
  25029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25030. * @param name defines the name of the mesh to create
  25031. * @param options defines the options used to create the mesh
  25032. * @param scene defines the hosting scene
  25033. * @returns a new Mesh
  25034. */
  25035. static CreatePolyhedron(name: string, options: {
  25036. type?: number;
  25037. size?: number;
  25038. sizeX?: number;
  25039. sizeY?: number;
  25040. sizeZ?: number;
  25041. custom?: any;
  25042. faceUV?: Vector4[];
  25043. faceColors?: Color4[];
  25044. updatable?: boolean;
  25045. sideOrientation?: number;
  25046. }, scene: Scene): Mesh;
  25047. /**
  25048. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25049. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25050. * * 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`)
  25051. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25052. * * 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
  25053. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25054. * * If you create a double-sided mesh, you can choose what parts of 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
  25055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25056. * @param name defines the name of the mesh
  25057. * @param options defines the options used to create the mesh
  25058. * @param scene defines the hosting scene
  25059. * @returns a new Mesh
  25060. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25061. */
  25062. static CreateIcoSphere(name: string, options: {
  25063. radius?: number;
  25064. flat?: boolean;
  25065. subdivisions?: number;
  25066. sideOrientation?: number;
  25067. updatable?: boolean;
  25068. }, scene: Scene): Mesh;
  25069. /**
  25070. * Creates a decal mesh.
  25071. * Please consider using the same method from the MeshBuilder class instead.
  25072. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25073. * @param name defines the name of the mesh
  25074. * @param sourceMesh defines the mesh receiving the decal
  25075. * @param position sets the position of the decal in world coordinates
  25076. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25077. * @param size sets the decal scaling
  25078. * @param angle sets the angle to rotate the decal
  25079. * @returns a new Mesh
  25080. */
  25081. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25082. /**
  25083. * Prepare internal position array for software CPU skinning
  25084. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25085. */
  25086. setPositionsForCPUSkinning(): Float32Array;
  25087. /**
  25088. * Prepare internal normal array for software CPU skinning
  25089. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25090. */
  25091. setNormalsForCPUSkinning(): Float32Array;
  25092. /**
  25093. * Updates the vertex buffer by applying transformation from the bones
  25094. * @param skeleton defines the skeleton to apply to current mesh
  25095. * @returns the current mesh
  25096. */
  25097. applySkeleton(skeleton: Skeleton): Mesh;
  25098. /**
  25099. * 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
  25100. * @param meshes defines the list of meshes to scan
  25101. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25102. */
  25103. static MinMax(meshes: AbstractMesh[]): {
  25104. min: Vector3;
  25105. max: Vector3;
  25106. };
  25107. /**
  25108. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25109. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25110. * @returns a vector3
  25111. */
  25112. static Center(meshesOrMinMaxVector: {
  25113. min: Vector3;
  25114. max: Vector3;
  25115. } | AbstractMesh[]): Vector3;
  25116. /**
  25117. * Merge the array of meshes into a single mesh for performance reasons.
  25118. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25119. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25120. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25121. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25122. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25123. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25124. * @returns a new mesh
  25125. */
  25126. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25127. /** @hidden */
  25128. addInstance(instance: InstancedMesh): void;
  25129. /** @hidden */
  25130. removeInstance(instance: InstancedMesh): void;
  25131. }
  25132. }
  25133. declare module "babylonjs/Cameras/camera" {
  25134. import { SmartArray } from "babylonjs/Misc/smartArray";
  25135. import { Observable } from "babylonjs/Misc/observable";
  25136. import { Nullable } from "babylonjs/types";
  25137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25138. import { Scene } from "babylonjs/scene";
  25139. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25140. import { Node } from "babylonjs/node";
  25141. import { Mesh } from "babylonjs/Meshes/mesh";
  25142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25143. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25144. import { Viewport } from "babylonjs/Maths/math.viewport";
  25145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25146. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25147. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25148. import { Ray } from "babylonjs/Culling/ray";
  25149. /**
  25150. * This is the base class of all the camera used in the application.
  25151. * @see http://doc.babylonjs.com/features/cameras
  25152. */
  25153. export class Camera extends Node {
  25154. /** @hidden */
  25155. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25156. /**
  25157. * This is the default projection mode used by the cameras.
  25158. * It helps recreating a feeling of perspective and better appreciate depth.
  25159. * This is the best way to simulate real life cameras.
  25160. */
  25161. static readonly PERSPECTIVE_CAMERA: number;
  25162. /**
  25163. * This helps creating camera with an orthographic mode.
  25164. * 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.
  25165. */
  25166. static readonly ORTHOGRAPHIC_CAMERA: number;
  25167. /**
  25168. * This is the default FOV mode for perspective cameras.
  25169. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25170. */
  25171. static readonly FOVMODE_VERTICAL_FIXED: number;
  25172. /**
  25173. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25174. */
  25175. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25176. /**
  25177. * This specifies ther is no need for a camera rig.
  25178. * Basically only one eye is rendered corresponding to the camera.
  25179. */
  25180. static readonly RIG_MODE_NONE: number;
  25181. /**
  25182. * Simulates a camera Rig with one blue eye and one red eye.
  25183. * This can be use with 3d blue and red glasses.
  25184. */
  25185. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25186. /**
  25187. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25188. */
  25189. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25190. /**
  25191. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25192. */
  25193. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25194. /**
  25195. * Defines that both eyes of the camera will be rendered over under each other.
  25196. */
  25197. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25198. /**
  25199. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25200. */
  25201. static readonly RIG_MODE_VR: number;
  25202. /**
  25203. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25204. */
  25205. static readonly RIG_MODE_WEBVR: number;
  25206. /**
  25207. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25208. */
  25209. static readonly RIG_MODE_CUSTOM: number;
  25210. /**
  25211. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25212. */
  25213. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25214. /**
  25215. * Define the input manager associated with the camera.
  25216. */
  25217. inputs: CameraInputsManager<Camera>;
  25218. /** @hidden */
  25219. _position: Vector3;
  25220. /**
  25221. * Define the current local position of the camera in the scene
  25222. */
  25223. position: Vector3;
  25224. /**
  25225. * The vector the camera should consider as up.
  25226. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25227. */
  25228. upVector: Vector3;
  25229. /**
  25230. * Define the current limit on the left side for an orthographic camera
  25231. * In scene unit
  25232. */
  25233. orthoLeft: Nullable<number>;
  25234. /**
  25235. * Define the current limit on the right side for an orthographic camera
  25236. * In scene unit
  25237. */
  25238. orthoRight: Nullable<number>;
  25239. /**
  25240. * Define the current limit on the bottom side for an orthographic camera
  25241. * In scene unit
  25242. */
  25243. orthoBottom: Nullable<number>;
  25244. /**
  25245. * Define the current limit on the top side for an orthographic camera
  25246. * In scene unit
  25247. */
  25248. orthoTop: Nullable<number>;
  25249. /**
  25250. * Field Of View is set in Radians. (default is 0.8)
  25251. */
  25252. fov: number;
  25253. /**
  25254. * Define the minimum distance the camera can see from.
  25255. * This is important to note that the depth buffer are not infinite and the closer it starts
  25256. * the more your scene might encounter depth fighting issue.
  25257. */
  25258. minZ: number;
  25259. /**
  25260. * Define the maximum distance the camera can see to.
  25261. * This is important to note that the depth buffer are not infinite and the further it end
  25262. * the more your scene might encounter depth fighting issue.
  25263. */
  25264. maxZ: number;
  25265. /**
  25266. * Define the default inertia of the camera.
  25267. * This helps giving a smooth feeling to the camera movement.
  25268. */
  25269. inertia: number;
  25270. /**
  25271. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25272. */
  25273. mode: number;
  25274. /**
  25275. * Define wether the camera is intermediate.
  25276. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25277. */
  25278. isIntermediate: boolean;
  25279. /**
  25280. * Define the viewport of the camera.
  25281. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25282. */
  25283. viewport: Viewport;
  25284. /**
  25285. * Restricts the camera to viewing objects with the same layerMask.
  25286. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25287. */
  25288. layerMask: number;
  25289. /**
  25290. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25291. */
  25292. fovMode: number;
  25293. /**
  25294. * Rig mode of the camera.
  25295. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25296. * This is normally controlled byt the camera themselves as internal use.
  25297. */
  25298. cameraRigMode: number;
  25299. /**
  25300. * Defines the distance between both "eyes" in case of a RIG
  25301. */
  25302. interaxialDistance: number;
  25303. /**
  25304. * Defines if stereoscopic rendering is done side by side or over under.
  25305. */
  25306. isStereoscopicSideBySide: boolean;
  25307. /**
  25308. * 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
  25309. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25310. * else in the scene. (Eg. security camera)
  25311. *
  25312. * 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)
  25313. */
  25314. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25315. /**
  25316. * When set, the camera will render to this render target instead of the default canvas
  25317. *
  25318. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25319. */
  25320. outputRenderTarget: Nullable<RenderTargetTexture>;
  25321. /**
  25322. * Observable triggered when the camera view matrix has changed.
  25323. */
  25324. onViewMatrixChangedObservable: Observable<Camera>;
  25325. /**
  25326. * Observable triggered when the camera Projection matrix has changed.
  25327. */
  25328. onProjectionMatrixChangedObservable: Observable<Camera>;
  25329. /**
  25330. * Observable triggered when the inputs have been processed.
  25331. */
  25332. onAfterCheckInputsObservable: Observable<Camera>;
  25333. /**
  25334. * Observable triggered when reset has been called and applied to the camera.
  25335. */
  25336. onRestoreStateObservable: Observable<Camera>;
  25337. /** @hidden */
  25338. _cameraRigParams: any;
  25339. /** @hidden */
  25340. _rigCameras: Camera[];
  25341. /** @hidden */
  25342. _rigPostProcess: Nullable<PostProcess>;
  25343. protected _webvrViewMatrix: Matrix;
  25344. /** @hidden */
  25345. _skipRendering: boolean;
  25346. /** @hidden */
  25347. _projectionMatrix: Matrix;
  25348. /** @hidden */
  25349. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25350. /** @hidden */
  25351. _activeMeshes: SmartArray<AbstractMesh>;
  25352. protected _globalPosition: Vector3;
  25353. /** @hidden */
  25354. _computedViewMatrix: Matrix;
  25355. private _doNotComputeProjectionMatrix;
  25356. private _transformMatrix;
  25357. private _frustumPlanes;
  25358. private _refreshFrustumPlanes;
  25359. private _storedFov;
  25360. private _stateStored;
  25361. /**
  25362. * Instantiates a new camera object.
  25363. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25364. * @see http://doc.babylonjs.com/features/cameras
  25365. * @param name Defines the name of the camera in the scene
  25366. * @param position Defines the position of the camera
  25367. * @param scene Defines the scene the camera belongs too
  25368. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25369. */
  25370. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25371. /**
  25372. * Store current camera state (fov, position, etc..)
  25373. * @returns the camera
  25374. */
  25375. storeState(): Camera;
  25376. /**
  25377. * Restores the camera state values if it has been stored. You must call storeState() first
  25378. */
  25379. protected _restoreStateValues(): boolean;
  25380. /**
  25381. * Restored camera state. You must call storeState() first.
  25382. * @returns true if restored and false otherwise
  25383. */
  25384. restoreState(): boolean;
  25385. /**
  25386. * Gets the class name of the camera.
  25387. * @returns the class name
  25388. */
  25389. getClassName(): string;
  25390. /** @hidden */
  25391. readonly _isCamera: boolean;
  25392. /**
  25393. * Gets a string representation of the camera useful for debug purpose.
  25394. * @param fullDetails Defines that a more verboe level of logging is required
  25395. * @returns the string representation
  25396. */
  25397. toString(fullDetails?: boolean): string;
  25398. /**
  25399. * Gets the current world space position of the camera.
  25400. */
  25401. readonly globalPosition: Vector3;
  25402. /**
  25403. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25404. * @returns the active meshe list
  25405. */
  25406. getActiveMeshes(): SmartArray<AbstractMesh>;
  25407. /**
  25408. * Check wether a mesh is part of the current active mesh list of the camera
  25409. * @param mesh Defines the mesh to check
  25410. * @returns true if active, false otherwise
  25411. */
  25412. isActiveMesh(mesh: Mesh): boolean;
  25413. /**
  25414. * Is this camera ready to be used/rendered
  25415. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25416. * @return true if the camera is ready
  25417. */
  25418. isReady(completeCheck?: boolean): boolean;
  25419. /** @hidden */
  25420. _initCache(): void;
  25421. /** @hidden */
  25422. _updateCache(ignoreParentClass?: boolean): void;
  25423. /** @hidden */
  25424. _isSynchronized(): boolean;
  25425. /** @hidden */
  25426. _isSynchronizedViewMatrix(): boolean;
  25427. /** @hidden */
  25428. _isSynchronizedProjectionMatrix(): boolean;
  25429. /**
  25430. * Attach the input controls to a specific dom element to get the input from.
  25431. * @param element Defines the element the controls should be listened from
  25432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25433. */
  25434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25435. /**
  25436. * Detach the current controls from the specified dom element.
  25437. * @param element Defines the element to stop listening the inputs from
  25438. */
  25439. detachControl(element: HTMLElement): void;
  25440. /**
  25441. * Update the camera state according to the different inputs gathered during the frame.
  25442. */
  25443. update(): void;
  25444. /** @hidden */
  25445. _checkInputs(): void;
  25446. /** @hidden */
  25447. readonly rigCameras: Camera[];
  25448. /**
  25449. * Gets the post process used by the rig cameras
  25450. */
  25451. readonly rigPostProcess: Nullable<PostProcess>;
  25452. /**
  25453. * Internal, gets the first post proces.
  25454. * @returns the first post process to be run on this camera.
  25455. */
  25456. _getFirstPostProcess(): Nullable<PostProcess>;
  25457. private _cascadePostProcessesToRigCams;
  25458. /**
  25459. * Attach a post process to the camera.
  25460. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25461. * @param postProcess The post process to attach to the camera
  25462. * @param insertAt The position of the post process in case several of them are in use in the scene
  25463. * @returns the position the post process has been inserted at
  25464. */
  25465. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25466. /**
  25467. * Detach a post process to the camera.
  25468. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25469. * @param postProcess The post process to detach from the camera
  25470. */
  25471. detachPostProcess(postProcess: PostProcess): void;
  25472. /**
  25473. * Gets the current world matrix of the camera
  25474. */
  25475. getWorldMatrix(): Matrix;
  25476. /** @hidden */
  25477. _getViewMatrix(): Matrix;
  25478. /**
  25479. * Gets the current view matrix of the camera.
  25480. * @param force forces the camera to recompute the matrix without looking at the cached state
  25481. * @returns the view matrix
  25482. */
  25483. getViewMatrix(force?: boolean): Matrix;
  25484. /**
  25485. * Freeze the projection matrix.
  25486. * It will prevent the cache check of the camera projection compute and can speed up perf
  25487. * if no parameter of the camera are meant to change
  25488. * @param projection Defines manually a projection if necessary
  25489. */
  25490. freezeProjectionMatrix(projection?: Matrix): void;
  25491. /**
  25492. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25493. */
  25494. unfreezeProjectionMatrix(): void;
  25495. /**
  25496. * Gets the current projection matrix of the camera.
  25497. * @param force forces the camera to recompute the matrix without looking at the cached state
  25498. * @returns the projection matrix
  25499. */
  25500. getProjectionMatrix(force?: boolean): Matrix;
  25501. /**
  25502. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25503. * @returns a Matrix
  25504. */
  25505. getTransformationMatrix(): Matrix;
  25506. private _updateFrustumPlanes;
  25507. /**
  25508. * Checks if a cullable object (mesh...) is in the camera frustum
  25509. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25510. * @param target The object to check
  25511. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25512. * @returns true if the object is in frustum otherwise false
  25513. */
  25514. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25515. /**
  25516. * Checks if a cullable object (mesh...) is in the camera frustum
  25517. * Unlike isInFrustum this cheks the full bounding box
  25518. * @param target The object to check
  25519. * @returns true if the object is in frustum otherwise false
  25520. */
  25521. isCompletelyInFrustum(target: ICullable): boolean;
  25522. /**
  25523. * Gets a ray in the forward direction from the camera.
  25524. * @param length Defines the length of the ray to create
  25525. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25526. * @param origin Defines the start point of the ray which defaults to the camera position
  25527. * @returns the forward ray
  25528. */
  25529. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25530. /**
  25531. * Releases resources associated with this node.
  25532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25534. */
  25535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25536. /** @hidden */
  25537. _isLeftCamera: boolean;
  25538. /**
  25539. * Gets the left camera of a rig setup in case of Rigged Camera
  25540. */
  25541. readonly isLeftCamera: boolean;
  25542. /** @hidden */
  25543. _isRightCamera: boolean;
  25544. /**
  25545. * Gets the right camera of a rig setup in case of Rigged Camera
  25546. */
  25547. readonly isRightCamera: boolean;
  25548. /**
  25549. * Gets the left camera of a rig setup in case of Rigged Camera
  25550. */
  25551. readonly leftCamera: Nullable<FreeCamera>;
  25552. /**
  25553. * Gets the right camera of a rig setup in case of Rigged Camera
  25554. */
  25555. readonly rightCamera: Nullable<FreeCamera>;
  25556. /**
  25557. * Gets the left camera target of a rig setup in case of Rigged Camera
  25558. * @returns the target position
  25559. */
  25560. getLeftTarget(): Nullable<Vector3>;
  25561. /**
  25562. * Gets the right camera target of a rig setup in case of Rigged Camera
  25563. * @returns the target position
  25564. */
  25565. getRightTarget(): Nullable<Vector3>;
  25566. /**
  25567. * @hidden
  25568. */
  25569. setCameraRigMode(mode: number, rigParams: any): void;
  25570. /** @hidden */
  25571. static _setStereoscopicRigMode(camera: Camera): void;
  25572. /** @hidden */
  25573. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25574. /** @hidden */
  25575. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25576. /** @hidden */
  25577. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25578. /** @hidden */
  25579. _getVRProjectionMatrix(): Matrix;
  25580. protected _updateCameraRotationMatrix(): void;
  25581. protected _updateWebVRCameraRotationMatrix(): void;
  25582. /**
  25583. * This function MUST be overwritten by the different WebVR cameras available.
  25584. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25585. * @hidden
  25586. */
  25587. _getWebVRProjectionMatrix(): Matrix;
  25588. /**
  25589. * This function MUST be overwritten by the different WebVR cameras available.
  25590. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25591. * @hidden
  25592. */
  25593. _getWebVRViewMatrix(): Matrix;
  25594. /** @hidden */
  25595. setCameraRigParameter(name: string, value: any): void;
  25596. /**
  25597. * needs to be overridden by children so sub has required properties to be copied
  25598. * @hidden
  25599. */
  25600. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25601. /**
  25602. * May need to be overridden by children
  25603. * @hidden
  25604. */
  25605. _updateRigCameras(): void;
  25606. /** @hidden */
  25607. _setupInputs(): void;
  25608. /**
  25609. * Serialiaze the camera setup to a json represention
  25610. * @returns the JSON representation
  25611. */
  25612. serialize(): any;
  25613. /**
  25614. * Clones the current camera.
  25615. * @param name The cloned camera name
  25616. * @returns the cloned camera
  25617. */
  25618. clone(name: string): Camera;
  25619. /**
  25620. * Gets the direction of the camera relative to a given local axis.
  25621. * @param localAxis Defines the reference axis to provide a relative direction.
  25622. * @return the direction
  25623. */
  25624. getDirection(localAxis: Vector3): Vector3;
  25625. /**
  25626. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25627. * @param localAxis Defines the reference axis to provide a relative direction.
  25628. * @param result Defines the vector to store the result in
  25629. */
  25630. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25631. /**
  25632. * Gets a camera constructor for a given camera type
  25633. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25634. * @param name The name of the camera the result will be able to instantiate
  25635. * @param scene The scene the result will construct the camera in
  25636. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25637. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25638. * @returns a factory method to construc the camera
  25639. */
  25640. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25641. /**
  25642. * Compute the world matrix of the camera.
  25643. * @returns the camera workd matrix
  25644. */
  25645. computeWorldMatrix(): Matrix;
  25646. /**
  25647. * Parse a JSON and creates the camera from the parsed information
  25648. * @param parsedCamera The JSON to parse
  25649. * @param scene The scene to instantiate the camera in
  25650. * @returns the newly constructed camera
  25651. */
  25652. static Parse(parsedCamera: any, scene: Scene): Camera;
  25653. }
  25654. }
  25655. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25656. import { Nullable } from "babylonjs/types";
  25657. import { Scene } from "babylonjs/scene";
  25658. import { Vector4 } from "babylonjs/Maths/math.vector";
  25659. import { Mesh } from "babylonjs/Meshes/mesh";
  25660. /**
  25661. * Class containing static functions to help procedurally build meshes
  25662. */
  25663. export class DiscBuilder {
  25664. /**
  25665. * Creates a plane polygonal mesh. By default, this is a disc
  25666. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25667. * * 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
  25668. * * 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
  25669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25672. * @param name defines the name of the mesh
  25673. * @param options defines the options used to create the mesh
  25674. * @param scene defines the hosting scene
  25675. * @returns the plane polygonal mesh
  25676. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25677. */
  25678. static CreateDisc(name: string, options: {
  25679. radius?: number;
  25680. tessellation?: number;
  25681. arc?: number;
  25682. updatable?: boolean;
  25683. sideOrientation?: number;
  25684. frontUVs?: Vector4;
  25685. backUVs?: Vector4;
  25686. }, scene?: Nullable<Scene>): Mesh;
  25687. }
  25688. }
  25689. declare module "babylonjs/Particles/solidParticleSystem" {
  25690. import { Vector3 } from "babylonjs/Maths/math.vector";
  25691. import { Mesh } from "babylonjs/Meshes/mesh";
  25692. import { Scene, IDisposable } from "babylonjs/scene";
  25693. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25694. /**
  25695. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25696. *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.
  25697. * The SPS is also a particle system. It provides some methods to manage the particles.
  25698. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25699. *
  25700. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25701. */
  25702. export class SolidParticleSystem implements IDisposable {
  25703. /**
  25704. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25705. * Example : var p = SPS.particles[i];
  25706. */
  25707. particles: SolidParticle[];
  25708. /**
  25709. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25710. */
  25711. nbParticles: number;
  25712. /**
  25713. * If the particles must ever face the camera (default false). Useful for planar particles.
  25714. */
  25715. billboard: boolean;
  25716. /**
  25717. * Recompute normals when adding a shape
  25718. */
  25719. recomputeNormals: boolean;
  25720. /**
  25721. * This a counter ofr your own usage. It's not set by any SPS functions.
  25722. */
  25723. counter: number;
  25724. /**
  25725. * The SPS name. This name is also given to the underlying mesh.
  25726. */
  25727. name: string;
  25728. /**
  25729. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25730. */
  25731. mesh: Mesh;
  25732. /**
  25733. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25734. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25735. */
  25736. vars: any;
  25737. /**
  25738. * This array is populated when the SPS is set as 'pickable'.
  25739. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25740. * Each element of this array is an object `{idx: int, faceId: int}`.
  25741. * `idx` is the picked particle index in the `SPS.particles` array
  25742. * `faceId` is the picked face index counted within this particle.
  25743. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25744. */
  25745. pickedParticles: {
  25746. idx: number;
  25747. faceId: number;
  25748. }[];
  25749. /**
  25750. * This array is populated when `enableDepthSort` is set to true.
  25751. * Each element of this array is an instance of the class DepthSortedParticle.
  25752. */
  25753. depthSortedParticles: DepthSortedParticle[];
  25754. /**
  25755. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25756. * @hidden
  25757. */
  25758. _bSphereOnly: boolean;
  25759. /**
  25760. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25761. * @hidden
  25762. */
  25763. _bSphereRadiusFactor: number;
  25764. private _scene;
  25765. private _positions;
  25766. private _indices;
  25767. private _normals;
  25768. private _colors;
  25769. private _uvs;
  25770. private _indices32;
  25771. private _positions32;
  25772. private _normals32;
  25773. private _fixedNormal32;
  25774. private _colors32;
  25775. private _uvs32;
  25776. private _index;
  25777. private _updatable;
  25778. private _pickable;
  25779. private _isVisibilityBoxLocked;
  25780. private _alwaysVisible;
  25781. private _depthSort;
  25782. private _shapeCounter;
  25783. private _copy;
  25784. private _color;
  25785. private _computeParticleColor;
  25786. private _computeParticleTexture;
  25787. private _computeParticleRotation;
  25788. private _computeParticleVertex;
  25789. private _computeBoundingBox;
  25790. private _depthSortParticles;
  25791. private _camera;
  25792. private _mustUnrotateFixedNormals;
  25793. private _particlesIntersect;
  25794. private _needs32Bits;
  25795. /**
  25796. * Creates a SPS (Solid Particle System) object.
  25797. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25798. * @param scene (Scene) is the scene in which the SPS is added.
  25799. * @param options defines the options of the sps e.g.
  25800. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25801. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25802. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25803. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25804. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25805. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25806. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25807. */
  25808. constructor(name: string, scene: Scene, options?: {
  25809. updatable?: boolean;
  25810. isPickable?: boolean;
  25811. enableDepthSort?: boolean;
  25812. particleIntersection?: boolean;
  25813. boundingSphereOnly?: boolean;
  25814. bSphereRadiusFactor?: number;
  25815. });
  25816. /**
  25817. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25818. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25819. * @returns the created mesh
  25820. */
  25821. buildMesh(): Mesh;
  25822. /**
  25823. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25824. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25825. * Thus the particles generated from `digest()` have their property `position` set yet.
  25826. * @param mesh ( Mesh ) is the mesh to be digested
  25827. * @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
  25828. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25829. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25830. * @returns the current SPS
  25831. */
  25832. digest(mesh: Mesh, options?: {
  25833. facetNb?: number;
  25834. number?: number;
  25835. delta?: number;
  25836. }): SolidParticleSystem;
  25837. private _unrotateFixedNormals;
  25838. private _resetCopy;
  25839. private _meshBuilder;
  25840. private _posToShape;
  25841. private _uvsToShapeUV;
  25842. private _addParticle;
  25843. /**
  25844. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25845. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25846. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25847. * @param nb (positive integer) the number of particles to be created from this model
  25848. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25849. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25850. * @returns the number of shapes in the system
  25851. */
  25852. addShape(mesh: Mesh, nb: number, options?: {
  25853. positionFunction?: any;
  25854. vertexFunction?: any;
  25855. }): number;
  25856. private _rebuildParticle;
  25857. /**
  25858. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25859. * @returns the SPS.
  25860. */
  25861. rebuildMesh(): SolidParticleSystem;
  25862. /**
  25863. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25864. * This method calls `updateParticle()` for each particle of the SPS.
  25865. * For an animated SPS, it is usually called within the render loop.
  25866. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25867. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25868. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25869. * @returns the SPS.
  25870. */
  25871. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25872. /**
  25873. * Disposes the SPS.
  25874. */
  25875. dispose(): void;
  25876. /**
  25877. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25879. * @returns the SPS.
  25880. */
  25881. refreshVisibleSize(): SolidParticleSystem;
  25882. /**
  25883. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25884. * @param size the size (float) of the visibility box
  25885. * note : this doesn't lock the SPS mesh bounding box.
  25886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25887. */
  25888. setVisibilityBox(size: number): void;
  25889. /**
  25890. * Gets whether the SPS as always visible or not
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25892. */
  25893. /**
  25894. * Sets the SPS as always visible or not
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25896. */
  25897. isAlwaysVisible: boolean;
  25898. /**
  25899. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25901. */
  25902. /**
  25903. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25905. */
  25906. isVisibilityBoxLocked: boolean;
  25907. /**
  25908. * Tells to `setParticles()` to compute the particle rotations or not.
  25909. * Default value : true. The SPS is faster when it's set to false.
  25910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25911. */
  25912. /**
  25913. * Gets if `setParticles()` computes the particle rotations or not.
  25914. * Default value : true. The SPS is faster when it's set to false.
  25915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25916. */
  25917. computeParticleRotation: boolean;
  25918. /**
  25919. * Tells to `setParticles()` to compute the particle colors or not.
  25920. * Default value : true. The SPS is faster when it's set to false.
  25921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25922. */
  25923. /**
  25924. * Gets if `setParticles()` computes the particle colors or not.
  25925. * Default value : true. The SPS is faster when it's set to false.
  25926. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25927. */
  25928. computeParticleColor: boolean;
  25929. /**
  25930. * Gets if `setParticles()` computes the particle textures or not.
  25931. * Default value : true. The SPS is faster when it's set to false.
  25932. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25933. */
  25934. computeParticleTexture: boolean;
  25935. /**
  25936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25937. * Default value : false. The SPS is faster when it's set to false.
  25938. * Note : the particle custom vertex positions aren't stored values.
  25939. */
  25940. /**
  25941. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25942. * Default value : false. The SPS is faster when it's set to false.
  25943. * Note : the particle custom vertex positions aren't stored values.
  25944. */
  25945. computeParticleVertex: boolean;
  25946. /**
  25947. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25948. */
  25949. /**
  25950. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25951. */
  25952. computeBoundingBox: boolean;
  25953. /**
  25954. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25956. * Default : `true`
  25957. */
  25958. /**
  25959. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25960. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25961. * Default : `true`
  25962. */
  25963. depthSortParticles: boolean;
  25964. /**
  25965. * This function does nothing. It may be overwritten to set all the particle first values.
  25966. * The SPS doesn't call this function, you may have to call it by your own.
  25967. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25968. */
  25969. initParticles(): void;
  25970. /**
  25971. * This function does nothing. It may be overwritten to recycle a particle.
  25972. * The SPS doesn't call this function, you may have to call it by your own.
  25973. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25974. * @param particle The particle to recycle
  25975. * @returns the recycled particle
  25976. */
  25977. recycleParticle(particle: SolidParticle): SolidParticle;
  25978. /**
  25979. * Updates a particle : this function should be overwritten by the user.
  25980. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25981. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25982. * @example : just set a particle position or velocity and recycle conditions
  25983. * @param particle The particle to update
  25984. * @returns the updated particle
  25985. */
  25986. updateParticle(particle: SolidParticle): SolidParticle;
  25987. /**
  25988. * Updates a vertex of a particle : it can be overwritten by the user.
  25989. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25990. * @param particle the current particle
  25991. * @param vertex the current index of the current particle
  25992. * @param pt the index of the current vertex in the particle shape
  25993. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25994. * @example : just set a vertex particle position
  25995. * @returns the updated vertex
  25996. */
  25997. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25998. /**
  25999. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26000. * This does nothing and may be overwritten by the user.
  26001. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26002. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26003. * @param update the boolean update value actually passed to setParticles()
  26004. */
  26005. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26006. /**
  26007. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26008. * This will be passed three parameters.
  26009. * This does nothing and may be overwritten by the user.
  26010. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26012. * @param update the boolean update value actually passed to setParticles()
  26013. */
  26014. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26015. }
  26016. }
  26017. declare module "babylonjs/Particles/solidParticle" {
  26018. import { Nullable } from "babylonjs/types";
  26019. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26020. import { Color4 } from "babylonjs/Maths/math.color";
  26021. import { Mesh } from "babylonjs/Meshes/mesh";
  26022. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26023. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26024. import { Plane } from "babylonjs/Maths/math.plane";
  26025. /**
  26026. * Represents one particle of a solid particle system.
  26027. */
  26028. export class SolidParticle {
  26029. /**
  26030. * particle global index
  26031. */
  26032. idx: number;
  26033. /**
  26034. * The color of the particle
  26035. */
  26036. color: Nullable<Color4>;
  26037. /**
  26038. * The world space position of the particle.
  26039. */
  26040. position: Vector3;
  26041. /**
  26042. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26043. */
  26044. rotation: Vector3;
  26045. /**
  26046. * The world space rotation quaternion of the particle.
  26047. */
  26048. rotationQuaternion: Nullable<Quaternion>;
  26049. /**
  26050. * The scaling of the particle.
  26051. */
  26052. scaling: Vector3;
  26053. /**
  26054. * The uvs of the particle.
  26055. */
  26056. uvs: Vector4;
  26057. /**
  26058. * The current speed of the particle.
  26059. */
  26060. velocity: Vector3;
  26061. /**
  26062. * The pivot point in the particle local space.
  26063. */
  26064. pivot: Vector3;
  26065. /**
  26066. * Must the particle be translated from its pivot point in its local space ?
  26067. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26068. * Default : false
  26069. */
  26070. translateFromPivot: boolean;
  26071. /**
  26072. * Is the particle active or not ?
  26073. */
  26074. alive: boolean;
  26075. /**
  26076. * Is the particle visible or not ?
  26077. */
  26078. isVisible: boolean;
  26079. /**
  26080. * Index of this particle in the global "positions" array (Internal use)
  26081. * @hidden
  26082. */
  26083. _pos: number;
  26084. /**
  26085. * @hidden Index of this particle in the global "indices" array (Internal use)
  26086. */
  26087. _ind: number;
  26088. /**
  26089. * @hidden ModelShape of this particle (Internal use)
  26090. */
  26091. _model: ModelShape;
  26092. /**
  26093. * ModelShape id of this particle
  26094. */
  26095. shapeId: number;
  26096. /**
  26097. * Index of the particle in its shape id
  26098. */
  26099. idxInShape: number;
  26100. /**
  26101. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26102. */
  26103. _modelBoundingInfo: BoundingInfo;
  26104. /**
  26105. * @hidden Particle BoundingInfo object (Internal use)
  26106. */
  26107. _boundingInfo: BoundingInfo;
  26108. /**
  26109. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26110. */
  26111. _sps: SolidParticleSystem;
  26112. /**
  26113. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26114. */
  26115. _stillInvisible: boolean;
  26116. /**
  26117. * @hidden Last computed particle rotation matrix
  26118. */
  26119. _rotationMatrix: number[];
  26120. /**
  26121. * Parent particle Id, if any.
  26122. * Default null.
  26123. */
  26124. parentId: Nullable<number>;
  26125. /**
  26126. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26127. * The possible values are :
  26128. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26129. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26130. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26132. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26133. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26134. * */
  26135. cullingStrategy: number;
  26136. /**
  26137. * @hidden Internal global position in the SPS.
  26138. */
  26139. _globalPosition: Vector3;
  26140. /**
  26141. * Creates a Solid Particle object.
  26142. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26143. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26144. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26145. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26146. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26147. * @param shapeId (integer) is the model shape identifier in the SPS.
  26148. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26149. * @param sps defines the sps it is associated to
  26150. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26151. */
  26152. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26153. /**
  26154. * Legacy support, changed scale to scaling
  26155. */
  26156. /**
  26157. * Legacy support, changed scale to scaling
  26158. */
  26159. scale: Vector3;
  26160. /**
  26161. * Legacy support, changed quaternion to rotationQuaternion
  26162. */
  26163. /**
  26164. * Legacy support, changed quaternion to rotationQuaternion
  26165. */
  26166. quaternion: Nullable<Quaternion>;
  26167. /**
  26168. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26169. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26170. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26171. * @returns true if it intersects
  26172. */
  26173. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26174. /**
  26175. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26176. * A particle is in the frustum if its bounding box intersects the frustum
  26177. * @param frustumPlanes defines the frustum to test
  26178. * @returns true if the particle is in the frustum planes
  26179. */
  26180. isInFrustum(frustumPlanes: Plane[]): boolean;
  26181. /**
  26182. * get the rotation matrix of the particle
  26183. * @hidden
  26184. */
  26185. getRotationMatrix(m: Matrix): void;
  26186. }
  26187. /**
  26188. * Represents the shape of the model used by one particle of a solid particle system.
  26189. * SPS internal tool, don't use it manually.
  26190. */
  26191. export class ModelShape {
  26192. /**
  26193. * The shape id
  26194. * @hidden
  26195. */
  26196. shapeID: number;
  26197. /**
  26198. * flat array of model positions (internal use)
  26199. * @hidden
  26200. */
  26201. _shape: Vector3[];
  26202. /**
  26203. * flat array of model UVs (internal use)
  26204. * @hidden
  26205. */
  26206. _shapeUV: number[];
  26207. /**
  26208. * length of the shape in the model indices array (internal use)
  26209. * @hidden
  26210. */
  26211. _indicesLength: number;
  26212. /**
  26213. * Custom position function (internal use)
  26214. * @hidden
  26215. */
  26216. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26217. /**
  26218. * Custom vertex function (internal use)
  26219. * @hidden
  26220. */
  26221. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26222. /**
  26223. * 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.
  26224. * SPS internal tool, don't use it manually.
  26225. * @hidden
  26226. */
  26227. 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>);
  26228. }
  26229. /**
  26230. * Represents a Depth Sorted Particle in the solid particle system.
  26231. */
  26232. export class DepthSortedParticle {
  26233. /**
  26234. * Index of the particle in the "indices" array
  26235. */
  26236. ind: number;
  26237. /**
  26238. * Length of the particle shape in the "indices" array
  26239. */
  26240. indicesLength: number;
  26241. /**
  26242. * Squared distance from the particle to the camera
  26243. */
  26244. sqDistance: number;
  26245. }
  26246. }
  26247. declare module "babylonjs/Collisions/meshCollisionData" {
  26248. import { Collider } from "babylonjs/Collisions/collider";
  26249. import { Vector3 } from "babylonjs/Maths/math.vector";
  26250. import { Nullable } from "babylonjs/types";
  26251. import { Observer } from "babylonjs/Misc/observable";
  26252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26253. /**
  26254. * @hidden
  26255. */
  26256. export class _MeshCollisionData {
  26257. _checkCollisions: boolean;
  26258. _collisionMask: number;
  26259. _collisionGroup: number;
  26260. _collider: Nullable<Collider>;
  26261. _oldPositionForCollisions: Vector3;
  26262. _diffPositionForCollisions: Vector3;
  26263. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26264. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26265. }
  26266. }
  26267. declare module "babylonjs/Meshes/abstractMesh" {
  26268. import { Observable } from "babylonjs/Misc/observable";
  26269. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26270. import { Camera } from "babylonjs/Cameras/camera";
  26271. import { Scene, IDisposable } from "babylonjs/scene";
  26272. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26273. import { Node } from "babylonjs/node";
  26274. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26277. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26278. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26279. import { Material } from "babylonjs/Materials/material";
  26280. import { Light } from "babylonjs/Lights/light";
  26281. import { Skeleton } from "babylonjs/Bones/skeleton";
  26282. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26283. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26284. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26285. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26286. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26287. import { Plane } from "babylonjs/Maths/math.plane";
  26288. import { Ray } from "babylonjs/Culling/ray";
  26289. import { Collider } from "babylonjs/Collisions/collider";
  26290. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26291. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26292. /** @hidden */
  26293. class _FacetDataStorage {
  26294. facetPositions: Vector3[];
  26295. facetNormals: Vector3[];
  26296. facetPartitioning: number[][];
  26297. facetNb: number;
  26298. partitioningSubdivisions: number;
  26299. partitioningBBoxRatio: number;
  26300. facetDataEnabled: boolean;
  26301. facetParameters: any;
  26302. bbSize: Vector3;
  26303. subDiv: {
  26304. max: number;
  26305. X: number;
  26306. Y: number;
  26307. Z: number;
  26308. };
  26309. facetDepthSort: boolean;
  26310. facetDepthSortEnabled: boolean;
  26311. depthSortedIndices: IndicesArray;
  26312. depthSortedFacets: {
  26313. ind: number;
  26314. sqDistance: number;
  26315. }[];
  26316. facetDepthSortFunction: (f1: {
  26317. ind: number;
  26318. sqDistance: number;
  26319. }, f2: {
  26320. ind: number;
  26321. sqDistance: number;
  26322. }) => number;
  26323. facetDepthSortFrom: Vector3;
  26324. facetDepthSortOrigin: Vector3;
  26325. invertedMatrix: Matrix;
  26326. }
  26327. /**
  26328. * @hidden
  26329. **/
  26330. class _InternalAbstractMeshDataInfo {
  26331. _hasVertexAlpha: boolean;
  26332. _useVertexColors: boolean;
  26333. _numBoneInfluencers: number;
  26334. _applyFog: boolean;
  26335. _receiveShadows: boolean;
  26336. _facetData: _FacetDataStorage;
  26337. _visibility: number;
  26338. _skeleton: Nullable<Skeleton>;
  26339. _layerMask: number;
  26340. _computeBonesUsingShaders: boolean;
  26341. _isActive: boolean;
  26342. _onlyForInstances: boolean;
  26343. _isActiveIntermediate: boolean;
  26344. _onlyForInstancesIntermediate: boolean;
  26345. }
  26346. /**
  26347. * Class used to store all common mesh properties
  26348. */
  26349. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26350. /** No occlusion */
  26351. static OCCLUSION_TYPE_NONE: number;
  26352. /** Occlusion set to optimisitic */
  26353. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26354. /** Occlusion set to strict */
  26355. static OCCLUSION_TYPE_STRICT: number;
  26356. /** Use an accurante occlusion algorithm */
  26357. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26358. /** Use a conservative occlusion algorithm */
  26359. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26360. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26361. * Test order :
  26362. * Is the bounding sphere outside the frustum ?
  26363. * If not, are the bounding box vertices outside the frustum ?
  26364. * It not, then the cullable object is in the frustum.
  26365. */
  26366. static readonly CULLINGSTRATEGY_STANDARD: number;
  26367. /** Culling strategy : Bounding Sphere Only.
  26368. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26369. * It's also less accurate than the standard because some not visible objects can still be selected.
  26370. * Test : is the bounding sphere outside the frustum ?
  26371. * If not, then the cullable object is in the frustum.
  26372. */
  26373. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26374. /** Culling strategy : Optimistic Inclusion.
  26375. * This in an inclusion test first, then the standard exclusion test.
  26376. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26377. * 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.
  26378. * Anyway, it's as accurate as the standard strategy.
  26379. * Test :
  26380. * Is the cullable object bounding sphere center in the frustum ?
  26381. * If not, apply the default culling strategy.
  26382. */
  26383. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26384. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26385. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26386. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26387. * 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.
  26388. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26389. * Test :
  26390. * Is the cullable object bounding sphere center in the frustum ?
  26391. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26392. */
  26393. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26394. /**
  26395. * No billboard
  26396. */
  26397. static readonly BILLBOARDMODE_NONE: number;
  26398. /** Billboard on X axis */
  26399. static readonly BILLBOARDMODE_X: number;
  26400. /** Billboard on Y axis */
  26401. static readonly BILLBOARDMODE_Y: number;
  26402. /** Billboard on Z axis */
  26403. static readonly BILLBOARDMODE_Z: number;
  26404. /** Billboard on all axes */
  26405. static readonly BILLBOARDMODE_ALL: number;
  26406. /** Billboard on using position instead of orientation */
  26407. static readonly BILLBOARDMODE_USE_POSITION: number;
  26408. /** @hidden */
  26409. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26410. /**
  26411. * The culling strategy to use to check whether the mesh must be rendered or not.
  26412. * This value can be changed at any time and will be used on the next render mesh selection.
  26413. * The possible values are :
  26414. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26415. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26416. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26417. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26418. * Please read each static variable documentation to get details about the culling process.
  26419. * */
  26420. cullingStrategy: number;
  26421. /**
  26422. * Gets the number of facets in the mesh
  26423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26424. */
  26425. readonly facetNb: number;
  26426. /**
  26427. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26429. */
  26430. partitioningSubdivisions: number;
  26431. /**
  26432. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26433. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26435. */
  26436. partitioningBBoxRatio: number;
  26437. /**
  26438. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26439. * Works only for updatable meshes.
  26440. * Doesn't work with multi-materials
  26441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26442. */
  26443. mustDepthSortFacets: boolean;
  26444. /**
  26445. * The location (Vector3) where the facet depth sort must be computed from.
  26446. * By default, the active camera position.
  26447. * Used only when facet depth sort is enabled
  26448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26449. */
  26450. facetDepthSortFrom: Vector3;
  26451. /**
  26452. * gets a boolean indicating if facetData is enabled
  26453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26454. */
  26455. readonly isFacetDataEnabled: boolean;
  26456. /** @hidden */
  26457. _updateNonUniformScalingState(value: boolean): boolean;
  26458. /**
  26459. * An event triggered when this mesh collides with another one
  26460. */
  26461. onCollideObservable: Observable<AbstractMesh>;
  26462. /** Set a function to call when this mesh collides with another one */
  26463. onCollide: () => void;
  26464. /**
  26465. * An event triggered when the collision's position changes
  26466. */
  26467. onCollisionPositionChangeObservable: Observable<Vector3>;
  26468. /** Set a function to call when the collision's position changes */
  26469. onCollisionPositionChange: () => void;
  26470. /**
  26471. * An event triggered when material is changed
  26472. */
  26473. onMaterialChangedObservable: Observable<AbstractMesh>;
  26474. /**
  26475. * Gets or sets the orientation for POV movement & rotation
  26476. */
  26477. definedFacingForward: boolean;
  26478. /** @hidden */
  26479. _occlusionQuery: Nullable<WebGLQuery>;
  26480. /** @hidden */
  26481. _renderingGroup: Nullable<RenderingGroup>;
  26482. /**
  26483. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26484. */
  26485. /**
  26486. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26487. */
  26488. visibility: number;
  26489. /** Gets or sets the alpha index used to sort transparent meshes
  26490. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26491. */
  26492. alphaIndex: number;
  26493. /**
  26494. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26495. */
  26496. isVisible: boolean;
  26497. /**
  26498. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26499. */
  26500. isPickable: boolean;
  26501. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26502. showSubMeshesBoundingBox: boolean;
  26503. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26504. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26505. */
  26506. isBlocker: boolean;
  26507. /**
  26508. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26509. */
  26510. enablePointerMoveEvents: boolean;
  26511. /**
  26512. * Specifies the rendering group id for this mesh (0 by default)
  26513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26514. */
  26515. renderingGroupId: number;
  26516. private _material;
  26517. /** Gets or sets current material */
  26518. material: Nullable<Material>;
  26519. /**
  26520. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26521. * @see http://doc.babylonjs.com/babylon101/shadows
  26522. */
  26523. receiveShadows: boolean;
  26524. /** Defines color to use when rendering outline */
  26525. outlineColor: Color3;
  26526. /** Define width to use when rendering outline */
  26527. outlineWidth: number;
  26528. /** Defines color to use when rendering overlay */
  26529. overlayColor: Color3;
  26530. /** Defines alpha to use when rendering overlay */
  26531. overlayAlpha: number;
  26532. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26533. hasVertexAlpha: boolean;
  26534. /** 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) */
  26535. useVertexColors: boolean;
  26536. /**
  26537. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26538. */
  26539. computeBonesUsingShaders: boolean;
  26540. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26541. numBoneInfluencers: number;
  26542. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26543. applyFog: boolean;
  26544. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26545. useOctreeForRenderingSelection: boolean;
  26546. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26547. useOctreeForPicking: boolean;
  26548. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26549. useOctreeForCollisions: boolean;
  26550. /**
  26551. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26552. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26553. */
  26554. layerMask: number;
  26555. /**
  26556. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26557. */
  26558. alwaysSelectAsActiveMesh: boolean;
  26559. /**
  26560. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26561. */
  26562. doNotSyncBoundingInfo: boolean;
  26563. /**
  26564. * Gets or sets the current action manager
  26565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26566. */
  26567. actionManager: Nullable<AbstractActionManager>;
  26568. private _meshCollisionData;
  26569. /**
  26570. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26572. */
  26573. ellipsoid: Vector3;
  26574. /**
  26575. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26577. */
  26578. ellipsoidOffset: Vector3;
  26579. /**
  26580. * Gets or sets a collision mask used to mask collisions (default is -1).
  26581. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26582. */
  26583. collisionMask: number;
  26584. /**
  26585. * Gets or sets the current collision group mask (-1 by default).
  26586. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26587. */
  26588. collisionGroup: number;
  26589. /**
  26590. * Defines edge width used when edgesRenderer is enabled
  26591. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26592. */
  26593. edgesWidth: number;
  26594. /**
  26595. * Defines edge color used when edgesRenderer is enabled
  26596. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26597. */
  26598. edgesColor: Color4;
  26599. /** @hidden */
  26600. _edgesRenderer: Nullable<IEdgesRenderer>;
  26601. /** @hidden */
  26602. _masterMesh: Nullable<AbstractMesh>;
  26603. /** @hidden */
  26604. _boundingInfo: Nullable<BoundingInfo>;
  26605. /** @hidden */
  26606. _renderId: number;
  26607. /**
  26608. * Gets or sets the list of subMeshes
  26609. * @see http://doc.babylonjs.com/how_to/multi_materials
  26610. */
  26611. subMeshes: SubMesh[];
  26612. /** @hidden */
  26613. _intersectionsInProgress: AbstractMesh[];
  26614. /** @hidden */
  26615. _unIndexed: boolean;
  26616. /** @hidden */
  26617. _lightSources: Light[];
  26618. /** Gets the list of lights affecting that mesh */
  26619. readonly lightSources: Light[];
  26620. /** @hidden */
  26621. readonly _positions: Nullable<Vector3[]>;
  26622. /** @hidden */
  26623. _waitingData: {
  26624. lods: Nullable<any>;
  26625. actions: Nullable<any>;
  26626. freezeWorldMatrix: Nullable<boolean>;
  26627. };
  26628. /** @hidden */
  26629. _bonesTransformMatrices: Nullable<Float32Array>;
  26630. /** @hidden */
  26631. _transformMatrixTexture: Nullable<RawTexture>;
  26632. /**
  26633. * Gets or sets a skeleton to apply skining transformations
  26634. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26635. */
  26636. skeleton: Nullable<Skeleton>;
  26637. /**
  26638. * An event triggered when the mesh is rebuilt.
  26639. */
  26640. onRebuildObservable: Observable<AbstractMesh>;
  26641. /**
  26642. * Creates a new AbstractMesh
  26643. * @param name defines the name of the mesh
  26644. * @param scene defines the hosting scene
  26645. */
  26646. constructor(name: string, scene?: Nullable<Scene>);
  26647. /**
  26648. * Returns the string "AbstractMesh"
  26649. * @returns "AbstractMesh"
  26650. */
  26651. getClassName(): string;
  26652. /**
  26653. * Gets a string representation of the current mesh
  26654. * @param fullDetails defines a boolean indicating if full details must be included
  26655. * @returns a string representation of the current mesh
  26656. */
  26657. toString(fullDetails?: boolean): string;
  26658. /**
  26659. * @hidden
  26660. */
  26661. protected _getEffectiveParent(): Nullable<Node>;
  26662. /** @hidden */
  26663. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26664. /** @hidden */
  26665. _rebuild(): void;
  26666. /** @hidden */
  26667. _resyncLightSources(): void;
  26668. /** @hidden */
  26669. _resyncLighSource(light: Light): void;
  26670. /** @hidden */
  26671. _unBindEffect(): void;
  26672. /** @hidden */
  26673. _removeLightSource(light: Light, dispose: boolean): void;
  26674. private _markSubMeshesAsDirty;
  26675. /** @hidden */
  26676. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26677. /** @hidden */
  26678. _markSubMeshesAsAttributesDirty(): void;
  26679. /** @hidden */
  26680. _markSubMeshesAsMiscDirty(): void;
  26681. /**
  26682. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26683. */
  26684. scaling: Vector3;
  26685. /**
  26686. * Returns true if the mesh is blocked. Implemented by child classes
  26687. */
  26688. readonly isBlocked: boolean;
  26689. /**
  26690. * Returns the mesh itself by default. Implemented by child classes
  26691. * @param camera defines the camera to use to pick the right LOD level
  26692. * @returns the currentAbstractMesh
  26693. */
  26694. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26695. /**
  26696. * Returns 0 by default. Implemented by child classes
  26697. * @returns an integer
  26698. */
  26699. getTotalVertices(): number;
  26700. /**
  26701. * Returns a positive integer : the total number of indices in this mesh geometry.
  26702. * @returns the numner of indices or zero if the mesh has no geometry.
  26703. */
  26704. getTotalIndices(): number;
  26705. /**
  26706. * Returns null by default. Implemented by child classes
  26707. * @returns null
  26708. */
  26709. getIndices(): Nullable<IndicesArray>;
  26710. /**
  26711. * Returns the array of the requested vertex data kind. Implemented by child classes
  26712. * @param kind defines the vertex data kind to use
  26713. * @returns null
  26714. */
  26715. getVerticesData(kind: string): Nullable<FloatArray>;
  26716. /**
  26717. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26718. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26719. * Note that a new underlying VertexBuffer object is created each call.
  26720. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26721. * @param kind defines vertex data kind:
  26722. * * VertexBuffer.PositionKind
  26723. * * VertexBuffer.UVKind
  26724. * * VertexBuffer.UV2Kind
  26725. * * VertexBuffer.UV3Kind
  26726. * * VertexBuffer.UV4Kind
  26727. * * VertexBuffer.UV5Kind
  26728. * * VertexBuffer.UV6Kind
  26729. * * VertexBuffer.ColorKind
  26730. * * VertexBuffer.MatricesIndicesKind
  26731. * * VertexBuffer.MatricesIndicesExtraKind
  26732. * * VertexBuffer.MatricesWeightsKind
  26733. * * VertexBuffer.MatricesWeightsExtraKind
  26734. * @param data defines the data source
  26735. * @param updatable defines if the data must be flagged as updatable (or static)
  26736. * @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
  26737. * @returns the current mesh
  26738. */
  26739. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26740. /**
  26741. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26742. * If the mesh has no geometry, it is simply returned as it is.
  26743. * @param kind defines vertex data kind:
  26744. * * VertexBuffer.PositionKind
  26745. * * VertexBuffer.UVKind
  26746. * * VertexBuffer.UV2Kind
  26747. * * VertexBuffer.UV3Kind
  26748. * * VertexBuffer.UV4Kind
  26749. * * VertexBuffer.UV5Kind
  26750. * * VertexBuffer.UV6Kind
  26751. * * VertexBuffer.ColorKind
  26752. * * VertexBuffer.MatricesIndicesKind
  26753. * * VertexBuffer.MatricesIndicesExtraKind
  26754. * * VertexBuffer.MatricesWeightsKind
  26755. * * VertexBuffer.MatricesWeightsExtraKind
  26756. * @param data defines the data source
  26757. * @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
  26758. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26759. * @returns the current mesh
  26760. */
  26761. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26762. /**
  26763. * Sets the mesh indices,
  26764. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26765. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26766. * @param totalVertices Defines the total number of vertices
  26767. * @returns the current mesh
  26768. */
  26769. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26770. /**
  26771. * Gets a boolean indicating if specific vertex data is present
  26772. * @param kind defines the vertex data kind to use
  26773. * @returns true is data kind is present
  26774. */
  26775. isVerticesDataPresent(kind: string): boolean;
  26776. /**
  26777. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26778. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26779. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26780. * @returns a BoundingInfo
  26781. */
  26782. getBoundingInfo(): BoundingInfo;
  26783. /**
  26784. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26785. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26786. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26787. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26788. * @returns the current mesh
  26789. */
  26790. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26791. /**
  26792. * Overwrite the current bounding info
  26793. * @param boundingInfo defines the new bounding info
  26794. * @returns the current mesh
  26795. */
  26796. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26797. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26798. readonly useBones: boolean;
  26799. /** @hidden */
  26800. _preActivate(): void;
  26801. /** @hidden */
  26802. _preActivateForIntermediateRendering(renderId: number): void;
  26803. /** @hidden */
  26804. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26805. /** @hidden */
  26806. _postActivate(): void;
  26807. /** @hidden */
  26808. _freeze(): void;
  26809. /** @hidden */
  26810. _unFreeze(): void;
  26811. /**
  26812. * Gets the current world matrix
  26813. * @returns a Matrix
  26814. */
  26815. getWorldMatrix(): Matrix;
  26816. /** @hidden */
  26817. _getWorldMatrixDeterminant(): number;
  26818. /**
  26819. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26820. */
  26821. readonly isAnInstance: boolean;
  26822. /**
  26823. * Gets a boolean indicating if this mesh has instances
  26824. */
  26825. readonly hasInstances: boolean;
  26826. /**
  26827. * Perform relative position change from the point of view of behind the front of the mesh.
  26828. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26829. * Supports definition of mesh facing forward or backward
  26830. * @param amountRight defines the distance on the right axis
  26831. * @param amountUp defines the distance on the up axis
  26832. * @param amountForward defines the distance on the forward axis
  26833. * @returns the current mesh
  26834. */
  26835. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26836. /**
  26837. * Calculate relative position change from the point of view of behind the front of the mesh.
  26838. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26839. * Supports definition of mesh facing forward or backward
  26840. * @param amountRight defines the distance on the right axis
  26841. * @param amountUp defines the distance on the up axis
  26842. * @param amountForward defines the distance on the forward axis
  26843. * @returns the new displacement vector
  26844. */
  26845. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26846. /**
  26847. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26848. * Supports definition of mesh facing forward or backward
  26849. * @param flipBack defines the flip
  26850. * @param twirlClockwise defines the twirl
  26851. * @param tiltRight defines the tilt
  26852. * @returns the current mesh
  26853. */
  26854. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26855. /**
  26856. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26857. * Supports definition of mesh facing forward or backward.
  26858. * @param flipBack defines the flip
  26859. * @param twirlClockwise defines the twirl
  26860. * @param tiltRight defines the tilt
  26861. * @returns the new rotation vector
  26862. */
  26863. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26864. /**
  26865. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26866. * This means the mesh underlying bounding box and sphere are recomputed.
  26867. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26868. * @returns the current mesh
  26869. */
  26870. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26871. /** @hidden */
  26872. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26873. /** @hidden */
  26874. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26875. /** @hidden */
  26876. _updateBoundingInfo(): AbstractMesh;
  26877. /** @hidden */
  26878. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26879. /** @hidden */
  26880. protected _afterComputeWorldMatrix(): void;
  26881. /** @hidden */
  26882. readonly _effectiveMesh: AbstractMesh;
  26883. /**
  26884. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26885. * A mesh is in the frustum if its bounding box intersects the frustum
  26886. * @param frustumPlanes defines the frustum to test
  26887. * @returns true if the mesh is in the frustum planes
  26888. */
  26889. isInFrustum(frustumPlanes: Plane[]): boolean;
  26890. /**
  26891. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26892. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26893. * @param frustumPlanes defines the frustum to test
  26894. * @returns true if the mesh is completely in the frustum planes
  26895. */
  26896. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26897. /**
  26898. * True if the mesh intersects another mesh or a SolidParticle object
  26899. * @param mesh defines a target mesh or SolidParticle to test
  26900. * @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)
  26901. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26902. * @returns true if there is an intersection
  26903. */
  26904. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26905. /**
  26906. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26907. * @param point defines the point to test
  26908. * @returns true if there is an intersection
  26909. */
  26910. intersectsPoint(point: Vector3): boolean;
  26911. /**
  26912. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26914. */
  26915. checkCollisions: boolean;
  26916. /**
  26917. * Gets Collider object used to compute collisions (not physics)
  26918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26919. */
  26920. readonly collider: Nullable<Collider>;
  26921. /**
  26922. * Move the mesh using collision engine
  26923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26924. * @param displacement defines the requested displacement vector
  26925. * @returns the current mesh
  26926. */
  26927. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26928. private _onCollisionPositionChange;
  26929. /** @hidden */
  26930. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26931. /** @hidden */
  26932. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26933. /** @hidden */
  26934. _checkCollision(collider: Collider): AbstractMesh;
  26935. /** @hidden */
  26936. _generatePointsArray(): boolean;
  26937. /**
  26938. * Checks if the passed Ray intersects with the mesh
  26939. * @param ray defines the ray to use
  26940. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26942. * @returns the picking info
  26943. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26944. */
  26945. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26946. /**
  26947. * Clones the current mesh
  26948. * @param name defines the mesh name
  26949. * @param newParent defines the new mesh parent
  26950. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26951. * @returns the new mesh
  26952. */
  26953. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26954. /**
  26955. * Disposes all the submeshes of the current meshnp
  26956. * @returns the current mesh
  26957. */
  26958. releaseSubMeshes(): AbstractMesh;
  26959. /**
  26960. * Releases resources associated with this abstract mesh.
  26961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26963. */
  26964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26965. /**
  26966. * Adds the passed mesh as a child to the current mesh
  26967. * @param mesh defines the child mesh
  26968. * @returns the current mesh
  26969. */
  26970. addChild(mesh: AbstractMesh): AbstractMesh;
  26971. /**
  26972. * Removes the passed mesh from the current mesh children list
  26973. * @param mesh defines the child mesh
  26974. * @returns the current mesh
  26975. */
  26976. removeChild(mesh: AbstractMesh): AbstractMesh;
  26977. /** @hidden */
  26978. private _initFacetData;
  26979. /**
  26980. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26981. * This method can be called within the render loop.
  26982. * 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
  26983. * @returns the current mesh
  26984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26985. */
  26986. updateFacetData(): AbstractMesh;
  26987. /**
  26988. * Returns the facetLocalNormals array.
  26989. * The normals are expressed in the mesh local spac
  26990. * @returns an array of Vector3
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getFacetLocalNormals(): Vector3[];
  26994. /**
  26995. * Returns the facetLocalPositions array.
  26996. * The facet positions are expressed in the mesh local space
  26997. * @returns an array of Vector3
  26998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26999. */
  27000. getFacetLocalPositions(): Vector3[];
  27001. /**
  27002. * Returns the facetLocalPartioning array
  27003. * @returns an array of array of numbers
  27004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27005. */
  27006. getFacetLocalPartitioning(): number[][];
  27007. /**
  27008. * Returns the i-th facet position in the world system.
  27009. * This method allocates a new Vector3 per call
  27010. * @param i defines the facet index
  27011. * @returns a new Vector3
  27012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27013. */
  27014. getFacetPosition(i: number): Vector3;
  27015. /**
  27016. * Sets the reference Vector3 with the i-th facet position in the world system
  27017. * @param i defines the facet index
  27018. * @param ref defines the target vector
  27019. * @returns the current mesh
  27020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27021. */
  27022. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27023. /**
  27024. * Returns the i-th facet normal in the world system.
  27025. * This method allocates a new Vector3 per call
  27026. * @param i defines the facet index
  27027. * @returns a new Vector3
  27028. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27029. */
  27030. getFacetNormal(i: number): Vector3;
  27031. /**
  27032. * Sets the reference Vector3 with the i-th facet normal in the world system
  27033. * @param i defines the facet index
  27034. * @param ref defines the target vector
  27035. * @returns the current mesh
  27036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27037. */
  27038. getFacetNormalToRef(i: number, ref: Vector3): this;
  27039. /**
  27040. * 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)
  27041. * @param x defines x coordinate
  27042. * @param y defines y coordinate
  27043. * @param z defines z coordinate
  27044. * @returns the array of facet indexes
  27045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27046. */
  27047. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27048. /**
  27049. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27050. * @param projected sets as the (x,y,z) world projection on the facet
  27051. * @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
  27052. * @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
  27053. * @param x defines x coordinate
  27054. * @param y defines y coordinate
  27055. * @param z defines z coordinate
  27056. * @returns the face index if found (or null instead)
  27057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27058. */
  27059. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27060. /**
  27061. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27062. * @param projected sets as the (x,y,z) local projection on the facet
  27063. * @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
  27064. * @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
  27065. * @param x defines x coordinate
  27066. * @param y defines y coordinate
  27067. * @param z defines z coordinate
  27068. * @returns the face index if found (or null instead)
  27069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27070. */
  27071. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27072. /**
  27073. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27074. * @returns the parameters
  27075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27076. */
  27077. getFacetDataParameters(): any;
  27078. /**
  27079. * Disables the feature FacetData and frees the related memory
  27080. * @returns the current mesh
  27081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27082. */
  27083. disableFacetData(): AbstractMesh;
  27084. /**
  27085. * Updates the AbstractMesh indices array
  27086. * @param indices defines the data source
  27087. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27088. * @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)
  27089. * @returns the current mesh
  27090. */
  27091. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27092. /**
  27093. * Creates new normals data for the mesh
  27094. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27095. * @returns the current mesh
  27096. */
  27097. createNormals(updatable: boolean): AbstractMesh;
  27098. /**
  27099. * Align the mesh with a normal
  27100. * @param normal defines the normal to use
  27101. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27102. * @returns the current mesh
  27103. */
  27104. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27105. /** @hidden */
  27106. _checkOcclusionQuery(): boolean;
  27107. /**
  27108. * Disables the mesh edge rendering mode
  27109. * @returns the currentAbstractMesh
  27110. */
  27111. disableEdgesRendering(): AbstractMesh;
  27112. /**
  27113. * Enables the edge rendering mode on the mesh.
  27114. * This mode makes the mesh edges visible
  27115. * @param epsilon defines the maximal distance between two angles to detect a face
  27116. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27117. * @returns the currentAbstractMesh
  27118. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27119. */
  27120. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27121. }
  27122. }
  27123. declare module "babylonjs/Actions/actionEvent" {
  27124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27125. import { Nullable } from "babylonjs/types";
  27126. import { Sprite } from "babylonjs/Sprites/sprite";
  27127. import { Scene } from "babylonjs/scene";
  27128. import { Vector2 } from "babylonjs/Maths/math.vector";
  27129. /**
  27130. * Interface used to define ActionEvent
  27131. */
  27132. export interface IActionEvent {
  27133. /** The mesh or sprite that triggered the action */
  27134. source: any;
  27135. /** The X mouse cursor position at the time of the event */
  27136. pointerX: number;
  27137. /** The Y mouse cursor position at the time of the event */
  27138. pointerY: number;
  27139. /** The mesh that is currently pointed at (can be null) */
  27140. meshUnderPointer: Nullable<AbstractMesh>;
  27141. /** the original (browser) event that triggered the ActionEvent */
  27142. sourceEvent?: any;
  27143. /** additional data for the event */
  27144. additionalData?: any;
  27145. }
  27146. /**
  27147. * ActionEvent is the event being sent when an action is triggered.
  27148. */
  27149. export class ActionEvent implements IActionEvent {
  27150. /** The mesh or sprite that triggered the action */
  27151. source: any;
  27152. /** The X mouse cursor position at the time of the event */
  27153. pointerX: number;
  27154. /** The Y mouse cursor position at the time of the event */
  27155. pointerY: number;
  27156. /** The mesh that is currently pointed at (can be null) */
  27157. meshUnderPointer: Nullable<AbstractMesh>;
  27158. /** the original (browser) event that triggered the ActionEvent */
  27159. sourceEvent?: any;
  27160. /** additional data for the event */
  27161. additionalData?: any;
  27162. /**
  27163. * Creates a new ActionEvent
  27164. * @param source The mesh or sprite that triggered the action
  27165. * @param pointerX The X mouse cursor position at the time of the event
  27166. * @param pointerY The Y mouse cursor position at the time of the event
  27167. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27168. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27169. * @param additionalData additional data for the event
  27170. */
  27171. constructor(
  27172. /** The mesh or sprite that triggered the action */
  27173. source: any,
  27174. /** The X mouse cursor position at the time of the event */
  27175. pointerX: number,
  27176. /** The Y mouse cursor position at the time of the event */
  27177. pointerY: number,
  27178. /** The mesh that is currently pointed at (can be null) */
  27179. meshUnderPointer: Nullable<AbstractMesh>,
  27180. /** the original (browser) event that triggered the ActionEvent */
  27181. sourceEvent?: any,
  27182. /** additional data for the event */
  27183. additionalData?: any);
  27184. /**
  27185. * Helper function to auto-create an ActionEvent from a source mesh.
  27186. * @param source The source mesh that triggered the event
  27187. * @param evt The original (browser) event
  27188. * @param additionalData additional data for the event
  27189. * @returns the new ActionEvent
  27190. */
  27191. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27192. /**
  27193. * Helper function to auto-create an ActionEvent from a source sprite
  27194. * @param source The source sprite that triggered the event
  27195. * @param scene Scene associated with the sprite
  27196. * @param evt The original (browser) event
  27197. * @param additionalData additional data for the event
  27198. * @returns the new ActionEvent
  27199. */
  27200. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27201. /**
  27202. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27203. * @param scene the scene where the event occurred
  27204. * @param evt The original (browser) event
  27205. * @returns the new ActionEvent
  27206. */
  27207. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27208. /**
  27209. * Helper function to auto-create an ActionEvent from a primitive
  27210. * @param prim defines the target primitive
  27211. * @param pointerPos defines the pointer position
  27212. * @param evt The original (browser) event
  27213. * @param additionalData additional data for the event
  27214. * @returns the new ActionEvent
  27215. */
  27216. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27217. }
  27218. }
  27219. declare module "babylonjs/Actions/abstractActionManager" {
  27220. import { IDisposable } from "babylonjs/scene";
  27221. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27222. import { IAction } from "babylonjs/Actions/action";
  27223. import { Nullable } from "babylonjs/types";
  27224. /**
  27225. * Abstract class used to decouple action Manager from scene and meshes.
  27226. * Do not instantiate.
  27227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27228. */
  27229. export abstract class AbstractActionManager implements IDisposable {
  27230. /** Gets the list of active triggers */
  27231. static Triggers: {
  27232. [key: string]: number;
  27233. };
  27234. /** Gets the cursor to use when hovering items */
  27235. hoverCursor: string;
  27236. /** Gets the list of actions */
  27237. actions: IAction[];
  27238. /**
  27239. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27240. */
  27241. isRecursive: boolean;
  27242. /**
  27243. * Releases all associated resources
  27244. */
  27245. abstract dispose(): void;
  27246. /**
  27247. * Does this action manager has pointer triggers
  27248. */
  27249. abstract readonly hasPointerTriggers: boolean;
  27250. /**
  27251. * Does this action manager has pick triggers
  27252. */
  27253. abstract readonly hasPickTriggers: boolean;
  27254. /**
  27255. * Process a specific trigger
  27256. * @param trigger defines the trigger to process
  27257. * @param evt defines the event details to be processed
  27258. */
  27259. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27260. /**
  27261. * Does this action manager handles actions of any of the given triggers
  27262. * @param triggers defines the triggers to be tested
  27263. * @return a boolean indicating whether one (or more) of the triggers is handled
  27264. */
  27265. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27266. /**
  27267. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27268. * speed.
  27269. * @param triggerA defines the trigger to be tested
  27270. * @param triggerB defines the trigger to be tested
  27271. * @return a boolean indicating whether one (or more) of the triggers is handled
  27272. */
  27273. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27274. /**
  27275. * Does this action manager handles actions of a given trigger
  27276. * @param trigger defines the trigger to be tested
  27277. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27278. * @return whether the trigger is handled
  27279. */
  27280. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27281. /**
  27282. * Serialize this manager to a JSON object
  27283. * @param name defines the property name to store this manager
  27284. * @returns a JSON representation of this manager
  27285. */
  27286. abstract serialize(name: string): any;
  27287. /**
  27288. * Registers an action to this action manager
  27289. * @param action defines the action to be registered
  27290. * @return the action amended (prepared) after registration
  27291. */
  27292. abstract registerAction(action: IAction): Nullable<IAction>;
  27293. /**
  27294. * Unregisters an action to this action manager
  27295. * @param action defines the action to be unregistered
  27296. * @return a boolean indicating whether the action has been unregistered
  27297. */
  27298. abstract unregisterAction(action: IAction): Boolean;
  27299. /**
  27300. * Does exist one action manager with at least one trigger
  27301. **/
  27302. static readonly HasTriggers: boolean;
  27303. /**
  27304. * Does exist one action manager with at least one pick trigger
  27305. **/
  27306. static readonly HasPickTriggers: boolean;
  27307. /**
  27308. * Does exist one action manager that handles actions of a given trigger
  27309. * @param trigger defines the trigger to be tested
  27310. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27311. **/
  27312. static HasSpecificTrigger(trigger: number): boolean;
  27313. }
  27314. }
  27315. declare module "babylonjs/node" {
  27316. import { Scene } from "babylonjs/scene";
  27317. import { Nullable } from "babylonjs/types";
  27318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27319. import { Engine } from "babylonjs/Engines/engine";
  27320. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27321. import { Observable } from "babylonjs/Misc/observable";
  27322. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27323. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27324. import { Animatable } from "babylonjs/Animations/animatable";
  27325. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27326. import { Animation } from "babylonjs/Animations/animation";
  27327. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27329. /**
  27330. * Defines how a node can be built from a string name.
  27331. */
  27332. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27333. /**
  27334. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27335. */
  27336. export class Node implements IBehaviorAware<Node> {
  27337. /** @hidden */
  27338. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27339. private static _NodeConstructors;
  27340. /**
  27341. * Add a new node constructor
  27342. * @param type defines the type name of the node to construct
  27343. * @param constructorFunc defines the constructor function
  27344. */
  27345. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27346. /**
  27347. * Returns a node constructor based on type name
  27348. * @param type defines the type name
  27349. * @param name defines the new node name
  27350. * @param scene defines the hosting scene
  27351. * @param options defines optional options to transmit to constructors
  27352. * @returns the new constructor or null
  27353. */
  27354. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27355. /**
  27356. * Gets or sets the name of the node
  27357. */
  27358. name: string;
  27359. /**
  27360. * Gets or sets the id of the node
  27361. */
  27362. id: string;
  27363. /**
  27364. * Gets or sets the unique id of the node
  27365. */
  27366. uniqueId: number;
  27367. /**
  27368. * Gets or sets a string used to store user defined state for the node
  27369. */
  27370. state: string;
  27371. /**
  27372. * Gets or sets an object used to store user defined information for the node
  27373. */
  27374. metadata: any;
  27375. /**
  27376. * For internal use only. Please do not use.
  27377. */
  27378. reservedDataStore: any;
  27379. /**
  27380. * List of inspectable custom properties (used by the Inspector)
  27381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27382. */
  27383. inspectableCustomProperties: IInspectable[];
  27384. /**
  27385. * Gets or sets a boolean used to define if the node must be serialized
  27386. */
  27387. doNotSerialize: boolean;
  27388. /** @hidden */
  27389. _isDisposed: boolean;
  27390. /**
  27391. * Gets a list of Animations associated with the node
  27392. */
  27393. animations: import("babylonjs/Animations/animation").Animation[];
  27394. protected _ranges: {
  27395. [name: string]: Nullable<AnimationRange>;
  27396. };
  27397. /**
  27398. * Callback raised when the node is ready to be used
  27399. */
  27400. onReady: Nullable<(node: Node) => void>;
  27401. private _isEnabled;
  27402. private _isParentEnabled;
  27403. private _isReady;
  27404. /** @hidden */
  27405. _currentRenderId: number;
  27406. private _parentUpdateId;
  27407. /** @hidden */
  27408. _childUpdateId: number;
  27409. /** @hidden */
  27410. _waitingParentId: Nullable<string>;
  27411. /** @hidden */
  27412. _scene: Scene;
  27413. /** @hidden */
  27414. _cache: any;
  27415. private _parentNode;
  27416. private _children;
  27417. /** @hidden */
  27418. _worldMatrix: Matrix;
  27419. /** @hidden */
  27420. _worldMatrixDeterminant: number;
  27421. /** @hidden */
  27422. _worldMatrixDeterminantIsDirty: boolean;
  27423. /** @hidden */
  27424. private _sceneRootNodesIndex;
  27425. /**
  27426. * Gets a boolean indicating if the node has been disposed
  27427. * @returns true if the node was disposed
  27428. */
  27429. isDisposed(): boolean;
  27430. /**
  27431. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27432. * @see https://doc.babylonjs.com/how_to/parenting
  27433. */
  27434. parent: Nullable<Node>;
  27435. private addToSceneRootNodes;
  27436. private removeFromSceneRootNodes;
  27437. private _animationPropertiesOverride;
  27438. /**
  27439. * Gets or sets the animation properties override
  27440. */
  27441. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27442. /**
  27443. * Gets a string idenfifying the name of the class
  27444. * @returns "Node" string
  27445. */
  27446. getClassName(): string;
  27447. /** @hidden */
  27448. readonly _isNode: boolean;
  27449. /**
  27450. * An event triggered when the mesh is disposed
  27451. */
  27452. onDisposeObservable: Observable<Node>;
  27453. private _onDisposeObserver;
  27454. /**
  27455. * Sets a callback that will be raised when the node will be disposed
  27456. */
  27457. onDispose: () => void;
  27458. /**
  27459. * Creates a new Node
  27460. * @param name the name and id to be given to this node
  27461. * @param scene the scene this node will be added to
  27462. * @param addToRootNodes the node will be added to scene.rootNodes
  27463. */
  27464. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27465. /**
  27466. * Gets the scene of the node
  27467. * @returns a scene
  27468. */
  27469. getScene(): Scene;
  27470. /**
  27471. * Gets the engine of the node
  27472. * @returns a Engine
  27473. */
  27474. getEngine(): Engine;
  27475. private _behaviors;
  27476. /**
  27477. * Attach a behavior to the node
  27478. * @see http://doc.babylonjs.com/features/behaviour
  27479. * @param behavior defines the behavior to attach
  27480. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27481. * @returns the current Node
  27482. */
  27483. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27484. /**
  27485. * Remove an attached behavior
  27486. * @see http://doc.babylonjs.com/features/behaviour
  27487. * @param behavior defines the behavior to attach
  27488. * @returns the current Node
  27489. */
  27490. removeBehavior(behavior: Behavior<Node>): Node;
  27491. /**
  27492. * Gets the list of attached behaviors
  27493. * @see http://doc.babylonjs.com/features/behaviour
  27494. */
  27495. readonly behaviors: Behavior<Node>[];
  27496. /**
  27497. * Gets an attached behavior by name
  27498. * @param name defines the name of the behavior to look for
  27499. * @see http://doc.babylonjs.com/features/behaviour
  27500. * @returns null if behavior was not found else the requested behavior
  27501. */
  27502. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27503. /**
  27504. * Returns the latest update of the World matrix
  27505. * @returns a Matrix
  27506. */
  27507. getWorldMatrix(): Matrix;
  27508. /** @hidden */
  27509. _getWorldMatrixDeterminant(): number;
  27510. /**
  27511. * Returns directly the latest state of the mesh World matrix.
  27512. * A Matrix is returned.
  27513. */
  27514. readonly worldMatrixFromCache: Matrix;
  27515. /** @hidden */
  27516. _initCache(): void;
  27517. /** @hidden */
  27518. updateCache(force?: boolean): void;
  27519. /** @hidden */
  27520. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27521. /** @hidden */
  27522. _updateCache(ignoreParentClass?: boolean): void;
  27523. /** @hidden */
  27524. _isSynchronized(): boolean;
  27525. /** @hidden */
  27526. _markSyncedWithParent(): void;
  27527. /** @hidden */
  27528. isSynchronizedWithParent(): boolean;
  27529. /** @hidden */
  27530. isSynchronized(): boolean;
  27531. /**
  27532. * Is this node ready to be used/rendered
  27533. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27534. * @return true if the node is ready
  27535. */
  27536. isReady(completeCheck?: boolean): boolean;
  27537. /**
  27538. * Is this node enabled?
  27539. * 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
  27540. * @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
  27541. * @return whether this node (and its parent) is enabled
  27542. */
  27543. isEnabled(checkAncestors?: boolean): boolean;
  27544. /** @hidden */
  27545. protected _syncParentEnabledState(): void;
  27546. /**
  27547. * Set the enabled state of this node
  27548. * @param value defines the new enabled state
  27549. */
  27550. setEnabled(value: boolean): void;
  27551. /**
  27552. * Is this node a descendant of the given node?
  27553. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27554. * @param ancestor defines the parent node to inspect
  27555. * @returns a boolean indicating if this node is a descendant of the given node
  27556. */
  27557. isDescendantOf(ancestor: Node): boolean;
  27558. /** @hidden */
  27559. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27560. /**
  27561. * Will return all nodes that have this node as ascendant
  27562. * @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
  27563. * @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
  27564. * @return all children nodes of all types
  27565. */
  27566. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27567. /**
  27568. * Get all child-meshes of this node
  27569. * @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)
  27570. * @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
  27571. * @returns an array of AbstractMesh
  27572. */
  27573. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27574. /**
  27575. * Get all direct children of this node
  27576. * @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
  27577. * @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)
  27578. * @returns an array of Node
  27579. */
  27580. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27581. /** @hidden */
  27582. _setReady(state: boolean): void;
  27583. /**
  27584. * Get an animation by name
  27585. * @param name defines the name of the animation to look for
  27586. * @returns null if not found else the requested animation
  27587. */
  27588. getAnimationByName(name: string): Nullable<Animation>;
  27589. /**
  27590. * Creates an animation range for this node
  27591. * @param name defines the name of the range
  27592. * @param from defines the starting key
  27593. * @param to defines the end key
  27594. */
  27595. createAnimationRange(name: string, from: number, to: number): void;
  27596. /**
  27597. * Delete a specific animation range
  27598. * @param name defines the name of the range to delete
  27599. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27600. */
  27601. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27602. /**
  27603. * Get an animation range by name
  27604. * @param name defines the name of the animation range to look for
  27605. * @returns null if not found else the requested animation range
  27606. */
  27607. getAnimationRange(name: string): Nullable<AnimationRange>;
  27608. /**
  27609. * Gets the list of all animation ranges defined on this node
  27610. * @returns an array
  27611. */
  27612. getAnimationRanges(): Nullable<AnimationRange>[];
  27613. /**
  27614. * Will start the animation sequence
  27615. * @param name defines the range frames for animation sequence
  27616. * @param loop defines if the animation should loop (false by default)
  27617. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27618. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27619. * @returns the object created for this animation. If range does not exist, it will return null
  27620. */
  27621. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27622. /**
  27623. * Serialize animation ranges into a JSON compatible object
  27624. * @returns serialization object
  27625. */
  27626. serializeAnimationRanges(): any;
  27627. /**
  27628. * Computes the world matrix of the node
  27629. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27630. * @returns the world matrix
  27631. */
  27632. computeWorldMatrix(force?: boolean): Matrix;
  27633. /**
  27634. * Releases resources associated with this node.
  27635. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27636. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27637. */
  27638. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27639. /**
  27640. * Parse animation range data from a serialization object and store them into a given node
  27641. * @param node defines where to store the animation ranges
  27642. * @param parsedNode defines the serialization object to read data from
  27643. * @param scene defines the hosting scene
  27644. */
  27645. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27646. /**
  27647. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27648. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27649. * @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
  27650. * @returns the new bounding vectors
  27651. */
  27652. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27653. min: Vector3;
  27654. max: Vector3;
  27655. };
  27656. }
  27657. }
  27658. declare module "babylonjs/Animations/animation" {
  27659. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27660. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27661. import { Color3 } from "babylonjs/Maths/math.color";
  27662. import { Nullable } from "babylonjs/types";
  27663. import { Scene } from "babylonjs/scene";
  27664. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27665. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27666. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27667. import { Node } from "babylonjs/node";
  27668. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27669. import { Size } from "babylonjs/Maths/math.size";
  27670. import { Animatable } from "babylonjs/Animations/animatable";
  27671. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27672. /**
  27673. * @hidden
  27674. */
  27675. export class _IAnimationState {
  27676. key: number;
  27677. repeatCount: number;
  27678. workValue?: any;
  27679. loopMode?: number;
  27680. offsetValue?: any;
  27681. highLimitValue?: any;
  27682. }
  27683. /**
  27684. * Class used to store any kind of animation
  27685. */
  27686. export class Animation {
  27687. /**Name of the animation */
  27688. name: string;
  27689. /**Property to animate */
  27690. targetProperty: string;
  27691. /**The frames per second of the animation */
  27692. framePerSecond: number;
  27693. /**The data type of the animation */
  27694. dataType: number;
  27695. /**The loop mode of the animation */
  27696. loopMode?: number | undefined;
  27697. /**Specifies if blending should be enabled */
  27698. enableBlending?: boolean | undefined;
  27699. /**
  27700. * Use matrix interpolation instead of using direct key value when animating matrices
  27701. */
  27702. static AllowMatricesInterpolation: boolean;
  27703. /**
  27704. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27705. */
  27706. static AllowMatrixDecomposeForInterpolation: boolean;
  27707. /**
  27708. * Stores the key frames of the animation
  27709. */
  27710. private _keys;
  27711. /**
  27712. * Stores the easing function of the animation
  27713. */
  27714. private _easingFunction;
  27715. /**
  27716. * @hidden Internal use only
  27717. */
  27718. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27719. /**
  27720. * The set of event that will be linked to this animation
  27721. */
  27722. private _events;
  27723. /**
  27724. * Stores an array of target property paths
  27725. */
  27726. targetPropertyPath: string[];
  27727. /**
  27728. * Stores the blending speed of the animation
  27729. */
  27730. blendingSpeed: number;
  27731. /**
  27732. * Stores the animation ranges for the animation
  27733. */
  27734. private _ranges;
  27735. /**
  27736. * @hidden Internal use
  27737. */
  27738. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27739. /**
  27740. * Sets up an animation
  27741. * @param property The property to animate
  27742. * @param animationType The animation type to apply
  27743. * @param framePerSecond The frames per second of the animation
  27744. * @param easingFunction The easing function used in the animation
  27745. * @returns The created animation
  27746. */
  27747. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27748. /**
  27749. * Create and start an animation on a node
  27750. * @param name defines the name of the global animation that will be run on all nodes
  27751. * @param node defines the root node where the animation will take place
  27752. * @param targetProperty defines property to animate
  27753. * @param framePerSecond defines the number of frame per second yo use
  27754. * @param totalFrame defines the number of frames in total
  27755. * @param from defines the initial value
  27756. * @param to defines the final value
  27757. * @param loopMode defines which loop mode you want to use (off by default)
  27758. * @param easingFunction defines the easing function to use (linear by default)
  27759. * @param onAnimationEnd defines the callback to call when animation end
  27760. * @returns the animatable created for this animation
  27761. */
  27762. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27763. /**
  27764. * Create and start an animation on a node and its descendants
  27765. * @param name defines the name of the global animation that will be run on all nodes
  27766. * @param node defines the root node where the animation will take place
  27767. * @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
  27768. * @param targetProperty defines property to animate
  27769. * @param framePerSecond defines the number of frame per second to use
  27770. * @param totalFrame defines the number of frames in total
  27771. * @param from defines the initial value
  27772. * @param to defines the final value
  27773. * @param loopMode defines which loop mode you want to use (off by default)
  27774. * @param easingFunction defines the easing function to use (linear by default)
  27775. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27776. * @returns the list of animatables created for all nodes
  27777. * @example https://www.babylonjs-playground.com/#MH0VLI
  27778. */
  27779. 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[]>;
  27780. /**
  27781. * Creates a new animation, merges it with the existing animations and starts it
  27782. * @param name Name of the animation
  27783. * @param node Node which contains the scene that begins the animations
  27784. * @param targetProperty Specifies which property to animate
  27785. * @param framePerSecond The frames per second of the animation
  27786. * @param totalFrame The total number of frames
  27787. * @param from The frame at the beginning of the animation
  27788. * @param to The frame at the end of the animation
  27789. * @param loopMode Specifies the loop mode of the animation
  27790. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27791. * @param onAnimationEnd Callback to run once the animation is complete
  27792. * @returns Nullable animation
  27793. */
  27794. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27795. /**
  27796. * Transition property of an host to the target Value
  27797. * @param property The property to transition
  27798. * @param targetValue The target Value of the property
  27799. * @param host The object where the property to animate belongs
  27800. * @param scene Scene used to run the animation
  27801. * @param frameRate Framerate (in frame/s) to use
  27802. * @param transition The transition type we want to use
  27803. * @param duration The duration of the animation, in milliseconds
  27804. * @param onAnimationEnd Callback trigger at the end of the animation
  27805. * @returns Nullable animation
  27806. */
  27807. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27808. /**
  27809. * Return the array of runtime animations currently using this animation
  27810. */
  27811. readonly runtimeAnimations: RuntimeAnimation[];
  27812. /**
  27813. * Specifies if any of the runtime animations are currently running
  27814. */
  27815. readonly hasRunningRuntimeAnimations: boolean;
  27816. /**
  27817. * Initializes the animation
  27818. * @param name Name of the animation
  27819. * @param targetProperty Property to animate
  27820. * @param framePerSecond The frames per second of the animation
  27821. * @param dataType The data type of the animation
  27822. * @param loopMode The loop mode of the animation
  27823. * @param enableBlending Specifies if blending should be enabled
  27824. */
  27825. constructor(
  27826. /**Name of the animation */
  27827. name: string,
  27828. /**Property to animate */
  27829. targetProperty: string,
  27830. /**The frames per second of the animation */
  27831. framePerSecond: number,
  27832. /**The data type of the animation */
  27833. dataType: number,
  27834. /**The loop mode of the animation */
  27835. loopMode?: number | undefined,
  27836. /**Specifies if blending should be enabled */
  27837. enableBlending?: boolean | undefined);
  27838. /**
  27839. * Converts the animation to a string
  27840. * @param fullDetails support for multiple levels of logging within scene loading
  27841. * @returns String form of the animation
  27842. */
  27843. toString(fullDetails?: boolean): string;
  27844. /**
  27845. * Add an event to this animation
  27846. * @param event Event to add
  27847. */
  27848. addEvent(event: AnimationEvent): void;
  27849. /**
  27850. * Remove all events found at the given frame
  27851. * @param frame The frame to remove events from
  27852. */
  27853. removeEvents(frame: number): void;
  27854. /**
  27855. * Retrieves all the events from the animation
  27856. * @returns Events from the animation
  27857. */
  27858. getEvents(): AnimationEvent[];
  27859. /**
  27860. * Creates an animation range
  27861. * @param name Name of the animation range
  27862. * @param from Starting frame of the animation range
  27863. * @param to Ending frame of the animation
  27864. */
  27865. createRange(name: string, from: number, to: number): void;
  27866. /**
  27867. * Deletes an animation range by name
  27868. * @param name Name of the animation range to delete
  27869. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27870. */
  27871. deleteRange(name: string, deleteFrames?: boolean): void;
  27872. /**
  27873. * Gets the animation range by name, or null if not defined
  27874. * @param name Name of the animation range
  27875. * @returns Nullable animation range
  27876. */
  27877. getRange(name: string): Nullable<AnimationRange>;
  27878. /**
  27879. * Gets the key frames from the animation
  27880. * @returns The key frames of the animation
  27881. */
  27882. getKeys(): Array<IAnimationKey>;
  27883. /**
  27884. * Gets the highest frame rate of the animation
  27885. * @returns Highest frame rate of the animation
  27886. */
  27887. getHighestFrame(): number;
  27888. /**
  27889. * Gets the easing function of the animation
  27890. * @returns Easing function of the animation
  27891. */
  27892. getEasingFunction(): IEasingFunction;
  27893. /**
  27894. * Sets the easing function of the animation
  27895. * @param easingFunction A custom mathematical formula for animation
  27896. */
  27897. setEasingFunction(easingFunction: EasingFunction): void;
  27898. /**
  27899. * Interpolates a scalar linearly
  27900. * @param startValue Start value of the animation curve
  27901. * @param endValue End value of the animation curve
  27902. * @param gradient Scalar amount to interpolate
  27903. * @returns Interpolated scalar value
  27904. */
  27905. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27906. /**
  27907. * Interpolates a scalar cubically
  27908. * @param startValue Start value of the animation curve
  27909. * @param outTangent End tangent of the animation
  27910. * @param endValue End value of the animation curve
  27911. * @param inTangent Start tangent of the animation curve
  27912. * @param gradient Scalar amount to interpolate
  27913. * @returns Interpolated scalar value
  27914. */
  27915. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27916. /**
  27917. * Interpolates a quaternion using a spherical linear interpolation
  27918. * @param startValue Start value of the animation curve
  27919. * @param endValue End value of the animation curve
  27920. * @param gradient Scalar amount to interpolate
  27921. * @returns Interpolated quaternion value
  27922. */
  27923. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27924. /**
  27925. * Interpolates a quaternion cubically
  27926. * @param startValue Start value of the animation curve
  27927. * @param outTangent End tangent of the animation curve
  27928. * @param endValue End value of the animation curve
  27929. * @param inTangent Start tangent of the animation curve
  27930. * @param gradient Scalar amount to interpolate
  27931. * @returns Interpolated quaternion value
  27932. */
  27933. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27934. /**
  27935. * Interpolates a Vector3 linearl
  27936. * @param startValue Start value of the animation curve
  27937. * @param endValue End value of the animation curve
  27938. * @param gradient Scalar amount to interpolate
  27939. * @returns Interpolated scalar value
  27940. */
  27941. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27942. /**
  27943. * Interpolates a Vector3 cubically
  27944. * @param startValue Start value of the animation curve
  27945. * @param outTangent End tangent of the animation
  27946. * @param endValue End value of the animation curve
  27947. * @param inTangent Start tangent of the animation curve
  27948. * @param gradient Scalar amount to interpolate
  27949. * @returns InterpolatedVector3 value
  27950. */
  27951. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27952. /**
  27953. * Interpolates a Vector2 linearly
  27954. * @param startValue Start value of the animation curve
  27955. * @param endValue End value of the animation curve
  27956. * @param gradient Scalar amount to interpolate
  27957. * @returns Interpolated Vector2 value
  27958. */
  27959. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27960. /**
  27961. * Interpolates a Vector2 cubically
  27962. * @param startValue Start value of the animation curve
  27963. * @param outTangent End tangent of the animation
  27964. * @param endValue End value of the animation curve
  27965. * @param inTangent Start tangent of the animation curve
  27966. * @param gradient Scalar amount to interpolate
  27967. * @returns Interpolated Vector2 value
  27968. */
  27969. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27970. /**
  27971. * Interpolates a size linearly
  27972. * @param startValue Start value of the animation curve
  27973. * @param endValue End value of the animation curve
  27974. * @param gradient Scalar amount to interpolate
  27975. * @returns Interpolated Size value
  27976. */
  27977. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27978. /**
  27979. * Interpolates a Color3 linearly
  27980. * @param startValue Start value of the animation curve
  27981. * @param endValue End value of the animation curve
  27982. * @param gradient Scalar amount to interpolate
  27983. * @returns Interpolated Color3 value
  27984. */
  27985. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27986. /**
  27987. * @hidden Internal use only
  27988. */
  27989. _getKeyValue(value: any): any;
  27990. /**
  27991. * @hidden Internal use only
  27992. */
  27993. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27994. /**
  27995. * Defines the function to use to interpolate matrices
  27996. * @param startValue defines the start matrix
  27997. * @param endValue defines the end matrix
  27998. * @param gradient defines the gradient between both matrices
  27999. * @param result defines an optional target matrix where to store the interpolation
  28000. * @returns the interpolated matrix
  28001. */
  28002. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28003. /**
  28004. * Makes a copy of the animation
  28005. * @returns Cloned animation
  28006. */
  28007. clone(): Animation;
  28008. /**
  28009. * Sets the key frames of the animation
  28010. * @param values The animation key frames to set
  28011. */
  28012. setKeys(values: Array<IAnimationKey>): void;
  28013. /**
  28014. * Serializes the animation to an object
  28015. * @returns Serialized object
  28016. */
  28017. serialize(): any;
  28018. /**
  28019. * Float animation type
  28020. */
  28021. private static _ANIMATIONTYPE_FLOAT;
  28022. /**
  28023. * Vector3 animation type
  28024. */
  28025. private static _ANIMATIONTYPE_VECTOR3;
  28026. /**
  28027. * Quaternion animation type
  28028. */
  28029. private static _ANIMATIONTYPE_QUATERNION;
  28030. /**
  28031. * Matrix animation type
  28032. */
  28033. private static _ANIMATIONTYPE_MATRIX;
  28034. /**
  28035. * Color3 animation type
  28036. */
  28037. private static _ANIMATIONTYPE_COLOR3;
  28038. /**
  28039. * Vector2 animation type
  28040. */
  28041. private static _ANIMATIONTYPE_VECTOR2;
  28042. /**
  28043. * Size animation type
  28044. */
  28045. private static _ANIMATIONTYPE_SIZE;
  28046. /**
  28047. * Relative Loop Mode
  28048. */
  28049. private static _ANIMATIONLOOPMODE_RELATIVE;
  28050. /**
  28051. * Cycle Loop Mode
  28052. */
  28053. private static _ANIMATIONLOOPMODE_CYCLE;
  28054. /**
  28055. * Constant Loop Mode
  28056. */
  28057. private static _ANIMATIONLOOPMODE_CONSTANT;
  28058. /**
  28059. * Get the float animation type
  28060. */
  28061. static readonly ANIMATIONTYPE_FLOAT: number;
  28062. /**
  28063. * Get the Vector3 animation type
  28064. */
  28065. static readonly ANIMATIONTYPE_VECTOR3: number;
  28066. /**
  28067. * Get the Vector2 animation type
  28068. */
  28069. static readonly ANIMATIONTYPE_VECTOR2: number;
  28070. /**
  28071. * Get the Size animation type
  28072. */
  28073. static readonly ANIMATIONTYPE_SIZE: number;
  28074. /**
  28075. * Get the Quaternion animation type
  28076. */
  28077. static readonly ANIMATIONTYPE_QUATERNION: number;
  28078. /**
  28079. * Get the Matrix animation type
  28080. */
  28081. static readonly ANIMATIONTYPE_MATRIX: number;
  28082. /**
  28083. * Get the Color3 animation type
  28084. */
  28085. static readonly ANIMATIONTYPE_COLOR3: number;
  28086. /**
  28087. * Get the Relative Loop Mode
  28088. */
  28089. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28090. /**
  28091. * Get the Cycle Loop Mode
  28092. */
  28093. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28094. /**
  28095. * Get the Constant Loop Mode
  28096. */
  28097. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28098. /** @hidden */
  28099. static _UniversalLerp(left: any, right: any, amount: number): any;
  28100. /**
  28101. * Parses an animation object and creates an animation
  28102. * @param parsedAnimation Parsed animation object
  28103. * @returns Animation object
  28104. */
  28105. static Parse(parsedAnimation: any): Animation;
  28106. /**
  28107. * Appends the serialized animations from the source animations
  28108. * @param source Source containing the animations
  28109. * @param destination Target to store the animations
  28110. */
  28111. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28112. }
  28113. }
  28114. declare module "babylonjs/Animations/animatable.interface" {
  28115. import { Nullable } from "babylonjs/types";
  28116. import { Animation } from "babylonjs/Animations/animation";
  28117. /**
  28118. * Interface containing an array of animations
  28119. */
  28120. export interface IAnimatable {
  28121. /**
  28122. * Array of animations
  28123. */
  28124. animations: Nullable<Array<Animation>>;
  28125. }
  28126. }
  28127. declare module "babylonjs/Materials/fresnelParameters" {
  28128. import { Color3 } from "babylonjs/Maths/math.color";
  28129. /**
  28130. * This represents all the required information to add a fresnel effect on a material:
  28131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28132. */
  28133. export class FresnelParameters {
  28134. private _isEnabled;
  28135. /**
  28136. * Define if the fresnel effect is enable or not.
  28137. */
  28138. isEnabled: boolean;
  28139. /**
  28140. * Define the color used on edges (grazing angle)
  28141. */
  28142. leftColor: Color3;
  28143. /**
  28144. * Define the color used on center
  28145. */
  28146. rightColor: Color3;
  28147. /**
  28148. * Define bias applied to computed fresnel term
  28149. */
  28150. bias: number;
  28151. /**
  28152. * Defined the power exponent applied to fresnel term
  28153. */
  28154. power: number;
  28155. /**
  28156. * Clones the current fresnel and its valuues
  28157. * @returns a clone fresnel configuration
  28158. */
  28159. clone(): FresnelParameters;
  28160. /**
  28161. * Serializes the current fresnel parameters to a JSON representation.
  28162. * @return the JSON serialization
  28163. */
  28164. serialize(): any;
  28165. /**
  28166. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28167. * @param parsedFresnelParameters Define the JSON representation
  28168. * @returns the parsed parameters
  28169. */
  28170. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28171. }
  28172. }
  28173. declare module "babylonjs/Misc/decorators" {
  28174. import { Nullable } from "babylonjs/types";
  28175. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28176. import { Scene } from "babylonjs/scene";
  28177. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28178. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28179. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28180. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28181. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28182. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28183. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28184. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28185. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28186. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28187. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28188. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28189. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28190. /**
  28191. * Decorator used to define property that can be serialized as reference to a camera
  28192. * @param sourceName defines the name of the property to decorate
  28193. */
  28194. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28195. /**
  28196. * Class used to help serialization objects
  28197. */
  28198. export class SerializationHelper {
  28199. /** @hidden */
  28200. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28201. /** @hidden */
  28202. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28203. /** @hidden */
  28204. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28205. /** @hidden */
  28206. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28207. /**
  28208. * Appends the serialized animations from the source animations
  28209. * @param source Source containing the animations
  28210. * @param destination Target to store the animations
  28211. */
  28212. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28213. /**
  28214. * Static function used to serialized a specific entity
  28215. * @param entity defines the entity to serialize
  28216. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28217. * @returns a JSON compatible object representing the serialization of the entity
  28218. */
  28219. static Serialize<T>(entity: T, serializationObject?: any): any;
  28220. /**
  28221. * Creates a new entity from a serialization data object
  28222. * @param creationFunction defines a function used to instanciated the new entity
  28223. * @param source defines the source serialization data
  28224. * @param scene defines the hosting scene
  28225. * @param rootUrl defines the root url for resources
  28226. * @returns a new entity
  28227. */
  28228. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28229. /**
  28230. * Clones an object
  28231. * @param creationFunction defines the function used to instanciate the new object
  28232. * @param source defines the source object
  28233. * @returns the cloned object
  28234. */
  28235. static Clone<T>(creationFunction: () => T, source: T): T;
  28236. /**
  28237. * Instanciates a new object based on a source one (some data will be shared between both object)
  28238. * @param creationFunction defines the function used to instanciate the new object
  28239. * @param source defines the source object
  28240. * @returns the new object
  28241. */
  28242. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28243. }
  28244. }
  28245. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28246. import { Nullable } from "babylonjs/types";
  28247. /**
  28248. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28249. */
  28250. export interface CubeMapInfo {
  28251. /**
  28252. * The pixel array for the front face.
  28253. * This is stored in format, left to right, up to down format.
  28254. */
  28255. front: Nullable<ArrayBufferView>;
  28256. /**
  28257. * The pixel array for the back face.
  28258. * This is stored in format, left to right, up to down format.
  28259. */
  28260. back: Nullable<ArrayBufferView>;
  28261. /**
  28262. * The pixel array for the left face.
  28263. * This is stored in format, left to right, up to down format.
  28264. */
  28265. left: Nullable<ArrayBufferView>;
  28266. /**
  28267. * The pixel array for the right face.
  28268. * This is stored in format, left to right, up to down format.
  28269. */
  28270. right: Nullable<ArrayBufferView>;
  28271. /**
  28272. * The pixel array for the up face.
  28273. * This is stored in format, left to right, up to down format.
  28274. */
  28275. up: Nullable<ArrayBufferView>;
  28276. /**
  28277. * The pixel array for the down face.
  28278. * This is stored in format, left to right, up to down format.
  28279. */
  28280. down: Nullable<ArrayBufferView>;
  28281. /**
  28282. * The size of the cubemap stored.
  28283. *
  28284. * Each faces will be size * size pixels.
  28285. */
  28286. size: number;
  28287. /**
  28288. * The format of the texture.
  28289. *
  28290. * RGBA, RGB.
  28291. */
  28292. format: number;
  28293. /**
  28294. * The type of the texture data.
  28295. *
  28296. * UNSIGNED_INT, FLOAT.
  28297. */
  28298. type: number;
  28299. /**
  28300. * Specifies whether the texture is in gamma space.
  28301. */
  28302. gammaSpace: boolean;
  28303. }
  28304. /**
  28305. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28306. */
  28307. export class PanoramaToCubeMapTools {
  28308. private static FACE_FRONT;
  28309. private static FACE_BACK;
  28310. private static FACE_RIGHT;
  28311. private static FACE_LEFT;
  28312. private static FACE_DOWN;
  28313. private static FACE_UP;
  28314. /**
  28315. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28316. *
  28317. * @param float32Array The source data.
  28318. * @param inputWidth The width of the input panorama.
  28319. * @param inputHeight The height of the input panorama.
  28320. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28321. * @return The cubemap data
  28322. */
  28323. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28324. private static CreateCubemapTexture;
  28325. private static CalcProjectionSpherical;
  28326. }
  28327. }
  28328. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28329. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28331. import { Nullable } from "babylonjs/types";
  28332. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28333. /**
  28334. * Helper class dealing with the extraction of spherical polynomial dataArray
  28335. * from a cube map.
  28336. */
  28337. export class CubeMapToSphericalPolynomialTools {
  28338. private static FileFaces;
  28339. /**
  28340. * Converts a texture to the according Spherical Polynomial data.
  28341. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28342. *
  28343. * @param texture The texture to extract the information from.
  28344. * @return The Spherical Polynomial data.
  28345. */
  28346. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28347. /**
  28348. * Converts a cubemap to the according Spherical Polynomial data.
  28349. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28350. *
  28351. * @param cubeInfo The Cube map to extract the information from.
  28352. * @return The Spherical Polynomial data.
  28353. */
  28354. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28355. }
  28356. }
  28357. declare module "babylonjs/Misc/guid" {
  28358. /**
  28359. * Class used to manipulate GUIDs
  28360. */
  28361. export class GUID {
  28362. /**
  28363. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28364. * Be aware Math.random() could cause collisions, but:
  28365. * "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"
  28366. * @returns a pseudo random id
  28367. */
  28368. static RandomId(): string;
  28369. }
  28370. }
  28371. declare module "babylonjs/Materials/Textures/baseTexture" {
  28372. import { Observable } from "babylonjs/Misc/observable";
  28373. import { Nullable } from "babylonjs/types";
  28374. import { Scene } from "babylonjs/scene";
  28375. import { Matrix } from "babylonjs/Maths/math.vector";
  28376. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28378. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28379. import { ISize } from "babylonjs/Maths/math.size";
  28380. /**
  28381. * Base class of all the textures in babylon.
  28382. * It groups all the common properties the materials, post process, lights... might need
  28383. * in order to make a correct use of the texture.
  28384. */
  28385. export class BaseTexture implements IAnimatable {
  28386. /**
  28387. * Default anisotropic filtering level for the application.
  28388. * It is set to 4 as a good tradeoff between perf and quality.
  28389. */
  28390. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28391. /**
  28392. * Gets or sets the unique id of the texture
  28393. */
  28394. uniqueId: number;
  28395. /**
  28396. * Define the name of the texture.
  28397. */
  28398. name: string;
  28399. /**
  28400. * Gets or sets an object used to store user defined information.
  28401. */
  28402. metadata: any;
  28403. /**
  28404. * For internal use only. Please do not use.
  28405. */
  28406. reservedDataStore: any;
  28407. private _hasAlpha;
  28408. /**
  28409. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28410. */
  28411. hasAlpha: boolean;
  28412. /**
  28413. * Defines if the alpha value should be determined via the rgb values.
  28414. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28415. */
  28416. getAlphaFromRGB: boolean;
  28417. /**
  28418. * Intensity or strength of the texture.
  28419. * It is commonly used by materials to fine tune the intensity of the texture
  28420. */
  28421. level: number;
  28422. /**
  28423. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28424. * This is part of the texture as textures usually maps to one uv set.
  28425. */
  28426. coordinatesIndex: number;
  28427. private _coordinatesMode;
  28428. /**
  28429. * How a texture is mapped.
  28430. *
  28431. * | Value | Type | Description |
  28432. * | ----- | ----------------------------------- | ----------- |
  28433. * | 0 | EXPLICIT_MODE | |
  28434. * | 1 | SPHERICAL_MODE | |
  28435. * | 2 | PLANAR_MODE | |
  28436. * | 3 | CUBIC_MODE | |
  28437. * | 4 | PROJECTION_MODE | |
  28438. * | 5 | SKYBOX_MODE | |
  28439. * | 6 | INVCUBIC_MODE | |
  28440. * | 7 | EQUIRECTANGULAR_MODE | |
  28441. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28442. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28443. */
  28444. coordinatesMode: number;
  28445. /**
  28446. * | Value | Type | Description |
  28447. * | ----- | ------------------ | ----------- |
  28448. * | 0 | CLAMP_ADDRESSMODE | |
  28449. * | 1 | WRAP_ADDRESSMODE | |
  28450. * | 2 | MIRROR_ADDRESSMODE | |
  28451. */
  28452. wrapU: number;
  28453. /**
  28454. * | Value | Type | Description |
  28455. * | ----- | ------------------ | ----------- |
  28456. * | 0 | CLAMP_ADDRESSMODE | |
  28457. * | 1 | WRAP_ADDRESSMODE | |
  28458. * | 2 | MIRROR_ADDRESSMODE | |
  28459. */
  28460. wrapV: number;
  28461. /**
  28462. * | Value | Type | Description |
  28463. * | ----- | ------------------ | ----------- |
  28464. * | 0 | CLAMP_ADDRESSMODE | |
  28465. * | 1 | WRAP_ADDRESSMODE | |
  28466. * | 2 | MIRROR_ADDRESSMODE | |
  28467. */
  28468. wrapR: number;
  28469. /**
  28470. * With compliant hardware and browser (supporting anisotropic filtering)
  28471. * this defines the level of anisotropic filtering in the texture.
  28472. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28473. */
  28474. anisotropicFilteringLevel: number;
  28475. /**
  28476. * Define if the texture is a cube texture or if false a 2d texture.
  28477. */
  28478. isCube: boolean;
  28479. /**
  28480. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28481. */
  28482. is3D: boolean;
  28483. /**
  28484. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28485. * HDR texture are usually stored in linear space.
  28486. * This only impacts the PBR and Background materials
  28487. */
  28488. gammaSpace: boolean;
  28489. /**
  28490. * Gets whether or not the texture contains RGBD data.
  28491. */
  28492. readonly isRGBD: boolean;
  28493. /**
  28494. * Is Z inverted in the texture (useful in a cube texture).
  28495. */
  28496. invertZ: boolean;
  28497. /**
  28498. * Are mip maps generated for this texture or not.
  28499. */
  28500. readonly noMipmap: boolean;
  28501. /**
  28502. * @hidden
  28503. */
  28504. lodLevelInAlpha: boolean;
  28505. /**
  28506. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28507. */
  28508. lodGenerationOffset: number;
  28509. /**
  28510. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28511. */
  28512. lodGenerationScale: number;
  28513. /**
  28514. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28515. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28516. * average roughness values.
  28517. */
  28518. linearSpecularLOD: boolean;
  28519. /**
  28520. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28521. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28522. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28523. */
  28524. irradianceTexture: Nullable<BaseTexture>;
  28525. /**
  28526. * Define if the texture is a render target.
  28527. */
  28528. isRenderTarget: boolean;
  28529. /**
  28530. * Define the unique id of the texture in the scene.
  28531. */
  28532. readonly uid: string;
  28533. /**
  28534. * Return a string representation of the texture.
  28535. * @returns the texture as a string
  28536. */
  28537. toString(): string;
  28538. /**
  28539. * Get the class name of the texture.
  28540. * @returns "BaseTexture"
  28541. */
  28542. getClassName(): string;
  28543. /**
  28544. * Define the list of animation attached to the texture.
  28545. */
  28546. animations: import("babylonjs/Animations/animation").Animation[];
  28547. /**
  28548. * An event triggered when the texture is disposed.
  28549. */
  28550. onDisposeObservable: Observable<BaseTexture>;
  28551. private _onDisposeObserver;
  28552. /**
  28553. * Callback triggered when the texture has been disposed.
  28554. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28555. */
  28556. onDispose: () => void;
  28557. /**
  28558. * Define the current state of the loading sequence when in delayed load mode.
  28559. */
  28560. delayLoadState: number;
  28561. private _scene;
  28562. /** @hidden */
  28563. _texture: Nullable<InternalTexture>;
  28564. private _uid;
  28565. /**
  28566. * Define if the texture is preventinga material to render or not.
  28567. * If not and the texture is not ready, the engine will use a default black texture instead.
  28568. */
  28569. readonly isBlocking: boolean;
  28570. /**
  28571. * Instantiates a new BaseTexture.
  28572. * Base class of all the textures in babylon.
  28573. * It groups all the common properties the materials, post process, lights... might need
  28574. * in order to make a correct use of the texture.
  28575. * @param scene Define the scene the texture blongs to
  28576. */
  28577. constructor(scene: Nullable<Scene>);
  28578. /**
  28579. * Get the scene the texture belongs to.
  28580. * @returns the scene or null if undefined
  28581. */
  28582. getScene(): Nullable<Scene>;
  28583. /**
  28584. * Get the texture transform matrix used to offset tile the texture for istance.
  28585. * @returns the transformation matrix
  28586. */
  28587. getTextureMatrix(): Matrix;
  28588. /**
  28589. * Get the texture reflection matrix used to rotate/transform the reflection.
  28590. * @returns the reflection matrix
  28591. */
  28592. getReflectionTextureMatrix(): Matrix;
  28593. /**
  28594. * Get the underlying lower level texture from Babylon.
  28595. * @returns the insternal texture
  28596. */
  28597. getInternalTexture(): Nullable<InternalTexture>;
  28598. /**
  28599. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28600. * @returns true if ready or not blocking
  28601. */
  28602. isReadyOrNotBlocking(): boolean;
  28603. /**
  28604. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28605. * @returns true if fully ready
  28606. */
  28607. isReady(): boolean;
  28608. private _cachedSize;
  28609. /**
  28610. * Get the size of the texture.
  28611. * @returns the texture size.
  28612. */
  28613. getSize(): ISize;
  28614. /**
  28615. * Get the base size of the texture.
  28616. * It can be different from the size if the texture has been resized for POT for instance
  28617. * @returns the base size
  28618. */
  28619. getBaseSize(): ISize;
  28620. /**
  28621. * Update the sampling mode of the texture.
  28622. * Default is Trilinear mode.
  28623. *
  28624. * | Value | Type | Description |
  28625. * | ----- | ------------------ | ----------- |
  28626. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28627. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28628. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28629. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28630. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28631. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28632. * | 7 | NEAREST_LINEAR | |
  28633. * | 8 | NEAREST_NEAREST | |
  28634. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28635. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28636. * | 11 | LINEAR_LINEAR | |
  28637. * | 12 | LINEAR_NEAREST | |
  28638. *
  28639. * > _mag_: magnification filter (close to the viewer)
  28640. * > _min_: minification filter (far from the viewer)
  28641. * > _mip_: filter used between mip map levels
  28642. *@param samplingMode Define the new sampling mode of the texture
  28643. */
  28644. updateSamplingMode(samplingMode: number): void;
  28645. /**
  28646. * Scales the texture if is `canRescale()`
  28647. * @param ratio the resize factor we want to use to rescale
  28648. */
  28649. scale(ratio: number): void;
  28650. /**
  28651. * Get if the texture can rescale.
  28652. */
  28653. readonly canRescale: boolean;
  28654. /** @hidden */
  28655. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28656. /** @hidden */
  28657. _rebuild(): void;
  28658. /**
  28659. * Triggers the load sequence in delayed load mode.
  28660. */
  28661. delayLoad(): void;
  28662. /**
  28663. * Clones the texture.
  28664. * @returns the cloned texture
  28665. */
  28666. clone(): Nullable<BaseTexture>;
  28667. /**
  28668. * Get the texture underlying type (INT, FLOAT...)
  28669. */
  28670. readonly textureType: number;
  28671. /**
  28672. * Get the texture underlying format (RGB, RGBA...)
  28673. */
  28674. readonly textureFormat: number;
  28675. /**
  28676. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28677. * This will returns an RGBA array buffer containing either in values (0-255) or
  28678. * float values (0-1) depending of the underlying buffer type.
  28679. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28680. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28681. * @param buffer defines a user defined buffer to fill with data (can be null)
  28682. * @returns The Array buffer containing the pixels data.
  28683. */
  28684. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28685. /**
  28686. * Release and destroy the underlying lower level texture aka internalTexture.
  28687. */
  28688. releaseInternalTexture(): void;
  28689. /**
  28690. * Get the polynomial representation of the texture data.
  28691. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28692. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28693. */
  28694. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28695. /** @hidden */
  28696. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28697. /** @hidden */
  28698. readonly _lodTextureMid: Nullable<BaseTexture>;
  28699. /** @hidden */
  28700. readonly _lodTextureLow: Nullable<BaseTexture>;
  28701. /**
  28702. * Dispose the texture and release its associated resources.
  28703. */
  28704. dispose(): void;
  28705. /**
  28706. * Serialize the texture into a JSON representation that can be parsed later on.
  28707. * @returns the JSON representation of the texture
  28708. */
  28709. serialize(): any;
  28710. /**
  28711. * Helper function to be called back once a list of texture contains only ready textures.
  28712. * @param textures Define the list of textures to wait for
  28713. * @param callback Define the callback triggered once the entire list will be ready
  28714. */
  28715. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28716. }
  28717. }
  28718. declare module "babylonjs/Materials/Textures/internalTexture" {
  28719. import { Observable } from "babylonjs/Misc/observable";
  28720. import { Nullable, int } from "babylonjs/types";
  28721. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28722. import { Engine } from "babylonjs/Engines/engine";
  28723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28724. /**
  28725. * Class used to store data associated with WebGL texture data for the engine
  28726. * This class should not be used directly
  28727. */
  28728. export class InternalTexture {
  28729. /** @hidden */
  28730. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28731. /**
  28732. * The source of the texture data is unknown
  28733. */
  28734. static DATASOURCE_UNKNOWN: number;
  28735. /**
  28736. * Texture data comes from an URL
  28737. */
  28738. static DATASOURCE_URL: number;
  28739. /**
  28740. * Texture data is only used for temporary storage
  28741. */
  28742. static DATASOURCE_TEMP: number;
  28743. /**
  28744. * Texture data comes from raw data (ArrayBuffer)
  28745. */
  28746. static DATASOURCE_RAW: number;
  28747. /**
  28748. * Texture content is dynamic (video or dynamic texture)
  28749. */
  28750. static DATASOURCE_DYNAMIC: number;
  28751. /**
  28752. * Texture content is generated by rendering to it
  28753. */
  28754. static DATASOURCE_RENDERTARGET: number;
  28755. /**
  28756. * Texture content is part of a multi render target process
  28757. */
  28758. static DATASOURCE_MULTIRENDERTARGET: number;
  28759. /**
  28760. * Texture data comes from a cube data file
  28761. */
  28762. static DATASOURCE_CUBE: number;
  28763. /**
  28764. * Texture data comes from a raw cube data
  28765. */
  28766. static DATASOURCE_CUBERAW: number;
  28767. /**
  28768. * Texture data come from a prefiltered cube data file
  28769. */
  28770. static DATASOURCE_CUBEPREFILTERED: number;
  28771. /**
  28772. * Texture content is raw 3D data
  28773. */
  28774. static DATASOURCE_RAW3D: number;
  28775. /**
  28776. * Texture content is a depth texture
  28777. */
  28778. static DATASOURCE_DEPTHTEXTURE: number;
  28779. /**
  28780. * Texture data comes from a raw cube data encoded with RGBD
  28781. */
  28782. static DATASOURCE_CUBERAW_RGBD: number;
  28783. /**
  28784. * Defines if the texture is ready
  28785. */
  28786. isReady: boolean;
  28787. /**
  28788. * Defines if the texture is a cube texture
  28789. */
  28790. isCube: boolean;
  28791. /**
  28792. * Defines if the texture contains 3D data
  28793. */
  28794. is3D: boolean;
  28795. /**
  28796. * Defines if the texture contains multiview data
  28797. */
  28798. isMultiview: boolean;
  28799. /**
  28800. * Gets the URL used to load this texture
  28801. */
  28802. url: string;
  28803. /**
  28804. * Gets the sampling mode of the texture
  28805. */
  28806. samplingMode: number;
  28807. /**
  28808. * Gets a boolean indicating if the texture needs mipmaps generation
  28809. */
  28810. generateMipMaps: boolean;
  28811. /**
  28812. * Gets the number of samples used by the texture (WebGL2+ only)
  28813. */
  28814. samples: number;
  28815. /**
  28816. * Gets the type of the texture (int, float...)
  28817. */
  28818. type: number;
  28819. /**
  28820. * Gets the format of the texture (RGB, RGBA...)
  28821. */
  28822. format: number;
  28823. /**
  28824. * Observable called when the texture is loaded
  28825. */
  28826. onLoadedObservable: Observable<InternalTexture>;
  28827. /**
  28828. * Gets the width of the texture
  28829. */
  28830. width: number;
  28831. /**
  28832. * Gets the height of the texture
  28833. */
  28834. height: number;
  28835. /**
  28836. * Gets the depth of the texture
  28837. */
  28838. depth: number;
  28839. /**
  28840. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28841. */
  28842. baseWidth: number;
  28843. /**
  28844. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28845. */
  28846. baseHeight: number;
  28847. /**
  28848. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28849. */
  28850. baseDepth: number;
  28851. /**
  28852. * Gets a boolean indicating if the texture is inverted on Y axis
  28853. */
  28854. invertY: boolean;
  28855. /** @hidden */
  28856. _invertVScale: boolean;
  28857. /** @hidden */
  28858. _associatedChannel: number;
  28859. /** @hidden */
  28860. _dataSource: number;
  28861. /** @hidden */
  28862. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28863. /** @hidden */
  28864. _bufferView: Nullable<ArrayBufferView>;
  28865. /** @hidden */
  28866. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28867. /** @hidden */
  28868. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28869. /** @hidden */
  28870. _size: number;
  28871. /** @hidden */
  28872. _extension: string;
  28873. /** @hidden */
  28874. _files: Nullable<string[]>;
  28875. /** @hidden */
  28876. _workingCanvas: Nullable<HTMLCanvasElement>;
  28877. /** @hidden */
  28878. _workingContext: Nullable<CanvasRenderingContext2D>;
  28879. /** @hidden */
  28880. _framebuffer: Nullable<WebGLFramebuffer>;
  28881. /** @hidden */
  28882. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28883. /** @hidden */
  28884. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28885. /** @hidden */
  28886. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28887. /** @hidden */
  28888. _attachments: Nullable<number[]>;
  28889. /** @hidden */
  28890. _cachedCoordinatesMode: Nullable<number>;
  28891. /** @hidden */
  28892. _cachedWrapU: Nullable<number>;
  28893. /** @hidden */
  28894. _cachedWrapV: Nullable<number>;
  28895. /** @hidden */
  28896. _cachedWrapR: Nullable<number>;
  28897. /** @hidden */
  28898. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28899. /** @hidden */
  28900. _isDisabled: boolean;
  28901. /** @hidden */
  28902. _compression: Nullable<string>;
  28903. /** @hidden */
  28904. _generateStencilBuffer: boolean;
  28905. /** @hidden */
  28906. _generateDepthBuffer: boolean;
  28907. /** @hidden */
  28908. _comparisonFunction: number;
  28909. /** @hidden */
  28910. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28911. /** @hidden */
  28912. _lodGenerationScale: number;
  28913. /** @hidden */
  28914. _lodGenerationOffset: number;
  28915. /** @hidden */
  28916. _colorTextureArray: Nullable<WebGLTexture>;
  28917. /** @hidden */
  28918. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28919. /** @hidden */
  28920. _lodTextureHigh: Nullable<BaseTexture>;
  28921. /** @hidden */
  28922. _lodTextureMid: Nullable<BaseTexture>;
  28923. /** @hidden */
  28924. _lodTextureLow: Nullable<BaseTexture>;
  28925. /** @hidden */
  28926. _isRGBD: boolean;
  28927. /** @hidden */
  28928. _linearSpecularLOD: boolean;
  28929. /** @hidden */
  28930. _irradianceTexture: Nullable<BaseTexture>;
  28931. /** @hidden */
  28932. _webGLTexture: Nullable<WebGLTexture>;
  28933. /** @hidden */
  28934. _references: number;
  28935. private _engine;
  28936. /**
  28937. * Gets the Engine the texture belongs to.
  28938. * @returns The babylon engine
  28939. */
  28940. getEngine(): Engine;
  28941. /**
  28942. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28943. */
  28944. readonly dataSource: number;
  28945. /**
  28946. * Creates a new InternalTexture
  28947. * @param engine defines the engine to use
  28948. * @param dataSource defines the type of data that will be used
  28949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28950. */
  28951. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28952. /**
  28953. * Increments the number of references (ie. the number of Texture that point to it)
  28954. */
  28955. incrementReferences(): void;
  28956. /**
  28957. * Change the size of the texture (not the size of the content)
  28958. * @param width defines the new width
  28959. * @param height defines the new height
  28960. * @param depth defines the new depth (1 by default)
  28961. */
  28962. updateSize(width: int, height: int, depth?: int): void;
  28963. /** @hidden */
  28964. _rebuild(): void;
  28965. /** @hidden */
  28966. _swapAndDie(target: InternalTexture): void;
  28967. /**
  28968. * Dispose the current allocated resources
  28969. */
  28970. dispose(): void;
  28971. }
  28972. }
  28973. declare module "babylonjs/Materials/effect" {
  28974. import { Observable } from "babylonjs/Misc/observable";
  28975. import { Nullable } from "babylonjs/types";
  28976. import { IDisposable } from "babylonjs/scene";
  28977. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28978. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28979. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28980. import { Engine } from "babylonjs/Engines/engine";
  28981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28984. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28986. /**
  28987. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28988. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28989. */
  28990. export class EffectFallbacks {
  28991. private _defines;
  28992. private _currentRank;
  28993. private _maxRank;
  28994. private _mesh;
  28995. /**
  28996. * Removes the fallback from the bound mesh.
  28997. */
  28998. unBindMesh(): void;
  28999. /**
  29000. * Adds a fallback on the specified property.
  29001. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29002. * @param define The name of the define in the shader
  29003. */
  29004. addFallback(rank: number, define: string): void;
  29005. /**
  29006. * Sets the mesh to use CPU skinning when needing to fallback.
  29007. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29008. * @param mesh The mesh to use the fallbacks.
  29009. */
  29010. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29011. /**
  29012. * Checks to see if more fallbacks are still availible.
  29013. */
  29014. readonly hasMoreFallbacks: boolean;
  29015. /**
  29016. * Removes the defines that should be removed when falling back.
  29017. * @param currentDefines defines the current define statements for the shader.
  29018. * @param effect defines the current effect we try to compile
  29019. * @returns The resulting defines with defines of the current rank removed.
  29020. */
  29021. reduce(currentDefines: string, effect: Effect): string;
  29022. }
  29023. /**
  29024. * Options to be used when creating an effect.
  29025. */
  29026. export class EffectCreationOptions {
  29027. /**
  29028. * Atrributes that will be used in the shader.
  29029. */
  29030. attributes: string[];
  29031. /**
  29032. * Uniform varible names that will be set in the shader.
  29033. */
  29034. uniformsNames: string[];
  29035. /**
  29036. * Uniform buffer varible names that will be set in the shader.
  29037. */
  29038. uniformBuffersNames: string[];
  29039. /**
  29040. * Sampler texture variable names that will be set in the shader.
  29041. */
  29042. samplers: string[];
  29043. /**
  29044. * Define statements that will be set in the shader.
  29045. */
  29046. defines: any;
  29047. /**
  29048. * Possible fallbacks for this effect to improve performance when needed.
  29049. */
  29050. fallbacks: Nullable<EffectFallbacks>;
  29051. /**
  29052. * Callback that will be called when the shader is compiled.
  29053. */
  29054. onCompiled: Nullable<(effect: Effect) => void>;
  29055. /**
  29056. * Callback that will be called if an error occurs during shader compilation.
  29057. */
  29058. onError: Nullable<(effect: Effect, errors: string) => void>;
  29059. /**
  29060. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29061. */
  29062. indexParameters: any;
  29063. /**
  29064. * Max number of lights that can be used in the shader.
  29065. */
  29066. maxSimultaneousLights: number;
  29067. /**
  29068. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29069. */
  29070. transformFeedbackVaryings: Nullable<string[]>;
  29071. }
  29072. /**
  29073. * Effect containing vertex and fragment shader that can be executed on an object.
  29074. */
  29075. export class Effect implements IDisposable {
  29076. /**
  29077. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29078. */
  29079. static ShadersRepository: string;
  29080. /**
  29081. * Name of the effect.
  29082. */
  29083. name: any;
  29084. /**
  29085. * String container all the define statements that should be set on the shader.
  29086. */
  29087. defines: string;
  29088. /**
  29089. * Callback that will be called when the shader is compiled.
  29090. */
  29091. onCompiled: Nullable<(effect: Effect) => void>;
  29092. /**
  29093. * Callback that will be called if an error occurs during shader compilation.
  29094. */
  29095. onError: Nullable<(effect: Effect, errors: string) => void>;
  29096. /**
  29097. * Callback that will be called when effect is bound.
  29098. */
  29099. onBind: Nullable<(effect: Effect) => void>;
  29100. /**
  29101. * Unique ID of the effect.
  29102. */
  29103. uniqueId: number;
  29104. /**
  29105. * Observable that will be called when the shader is compiled.
  29106. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29107. */
  29108. onCompileObservable: Observable<Effect>;
  29109. /**
  29110. * Observable that will be called if an error occurs during shader compilation.
  29111. */
  29112. onErrorObservable: Observable<Effect>;
  29113. /** @hidden */
  29114. _onBindObservable: Nullable<Observable<Effect>>;
  29115. /**
  29116. * Observable that will be called when effect is bound.
  29117. */
  29118. readonly onBindObservable: Observable<Effect>;
  29119. /** @hidden */
  29120. _bonesComputationForcedToCPU: boolean;
  29121. private static _uniqueIdSeed;
  29122. private _engine;
  29123. private _uniformBuffersNames;
  29124. private _uniformsNames;
  29125. private _samplerList;
  29126. private _samplers;
  29127. private _isReady;
  29128. private _compilationError;
  29129. private _attributesNames;
  29130. private _attributes;
  29131. private _uniforms;
  29132. /**
  29133. * Key for the effect.
  29134. * @hidden
  29135. */
  29136. _key: string;
  29137. private _indexParameters;
  29138. private _fallbacks;
  29139. private _vertexSourceCode;
  29140. private _fragmentSourceCode;
  29141. private _vertexSourceCodeOverride;
  29142. private _fragmentSourceCodeOverride;
  29143. private _transformFeedbackVaryings;
  29144. /**
  29145. * Compiled shader to webGL program.
  29146. * @hidden
  29147. */
  29148. _pipelineContext: Nullable<IPipelineContext>;
  29149. private _valueCache;
  29150. private static _baseCache;
  29151. /**
  29152. * Instantiates an effect.
  29153. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29154. * @param baseName Name of the effect.
  29155. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29156. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29157. * @param samplers List of sampler variables that will be passed to the shader.
  29158. * @param engine Engine to be used to render the effect
  29159. * @param defines Define statements to be added to the shader.
  29160. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29161. * @param onCompiled Callback that will be called when the shader is compiled.
  29162. * @param onError Callback that will be called if an error occurs during shader compilation.
  29163. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29164. */
  29165. 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);
  29166. private _useFinalCode;
  29167. /**
  29168. * Unique key for this effect
  29169. */
  29170. readonly key: string;
  29171. /**
  29172. * If the effect has been compiled and prepared.
  29173. * @returns if the effect is compiled and prepared.
  29174. */
  29175. isReady(): boolean;
  29176. private _isReadyInternal;
  29177. /**
  29178. * The engine the effect was initialized with.
  29179. * @returns the engine.
  29180. */
  29181. getEngine(): Engine;
  29182. /**
  29183. * The pipeline context for this effect
  29184. * @returns the associated pipeline context
  29185. */
  29186. getPipelineContext(): Nullable<IPipelineContext>;
  29187. /**
  29188. * The set of names of attribute variables for the shader.
  29189. * @returns An array of attribute names.
  29190. */
  29191. getAttributesNames(): string[];
  29192. /**
  29193. * Returns the attribute at the given index.
  29194. * @param index The index of the attribute.
  29195. * @returns The location of the attribute.
  29196. */
  29197. getAttributeLocation(index: number): number;
  29198. /**
  29199. * Returns the attribute based on the name of the variable.
  29200. * @param name of the attribute to look up.
  29201. * @returns the attribute location.
  29202. */
  29203. getAttributeLocationByName(name: string): number;
  29204. /**
  29205. * The number of attributes.
  29206. * @returns the numnber of attributes.
  29207. */
  29208. getAttributesCount(): number;
  29209. /**
  29210. * Gets the index of a uniform variable.
  29211. * @param uniformName of the uniform to look up.
  29212. * @returns the index.
  29213. */
  29214. getUniformIndex(uniformName: string): number;
  29215. /**
  29216. * Returns the attribute based on the name of the variable.
  29217. * @param uniformName of the uniform to look up.
  29218. * @returns the location of the uniform.
  29219. */
  29220. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29221. /**
  29222. * Returns an array of sampler variable names
  29223. * @returns The array of sampler variable neames.
  29224. */
  29225. getSamplers(): string[];
  29226. /**
  29227. * The error from the last compilation.
  29228. * @returns the error string.
  29229. */
  29230. getCompilationError(): string;
  29231. /**
  29232. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29233. * @param func The callback to be used.
  29234. */
  29235. executeWhenCompiled(func: (effect: Effect) => void): void;
  29236. private _checkIsReady;
  29237. /** @hidden */
  29238. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29239. /** @hidden */
  29240. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29241. /** @hidden */
  29242. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29243. /**
  29244. * Recompiles the webGL program
  29245. * @param vertexSourceCode The source code for the vertex shader.
  29246. * @param fragmentSourceCode The source code for the fragment shader.
  29247. * @param onCompiled Callback called when completed.
  29248. * @param onError Callback called on error.
  29249. * @hidden
  29250. */
  29251. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29252. /**
  29253. * Prepares the effect
  29254. * @hidden
  29255. */
  29256. _prepareEffect(): void;
  29257. private _processCompilationErrors;
  29258. /**
  29259. * Checks if the effect is supported. (Must be called after compilation)
  29260. */
  29261. readonly isSupported: boolean;
  29262. /**
  29263. * Binds a texture to the engine to be used as output of the shader.
  29264. * @param channel Name of the output variable.
  29265. * @param texture Texture to bind.
  29266. * @hidden
  29267. */
  29268. _bindTexture(channel: string, texture: InternalTexture): void;
  29269. /**
  29270. * Sets a texture on the engine to be used in the shader.
  29271. * @param channel Name of the sampler variable.
  29272. * @param texture Texture to set.
  29273. */
  29274. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29275. /**
  29276. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29277. * @param channel Name of the sampler variable.
  29278. * @param texture Texture to set.
  29279. */
  29280. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29281. /**
  29282. * Sets an array of textures on the engine to be used in the shader.
  29283. * @param channel Name of the variable.
  29284. * @param textures Textures to set.
  29285. */
  29286. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29287. /**
  29288. * 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)
  29289. * @param channel Name of the sampler variable.
  29290. * @param postProcess Post process to get the input texture from.
  29291. */
  29292. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29293. /**
  29294. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29295. * 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)
  29296. * @param channel Name of the sampler variable.
  29297. * @param postProcess Post process to get the output texture from.
  29298. */
  29299. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29300. /** @hidden */
  29301. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29302. /** @hidden */
  29303. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29304. /** @hidden */
  29305. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29306. /** @hidden */
  29307. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29308. /**
  29309. * Binds a buffer to a uniform.
  29310. * @param buffer Buffer to bind.
  29311. * @param name Name of the uniform variable to bind to.
  29312. */
  29313. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29314. /**
  29315. * Binds block to a uniform.
  29316. * @param blockName Name of the block to bind.
  29317. * @param index Index to bind.
  29318. */
  29319. bindUniformBlock(blockName: string, index: number): void;
  29320. /**
  29321. * Sets an interger value on a uniform variable.
  29322. * @param uniformName Name of the variable.
  29323. * @param value Value to be set.
  29324. * @returns this effect.
  29325. */
  29326. setInt(uniformName: string, value: number): Effect;
  29327. /**
  29328. * Sets an int array on a uniform variable.
  29329. * @param uniformName Name of the variable.
  29330. * @param array array to be set.
  29331. * @returns this effect.
  29332. */
  29333. setIntArray(uniformName: string, array: Int32Array): Effect;
  29334. /**
  29335. * 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)
  29336. * @param uniformName Name of the variable.
  29337. * @param array array to be set.
  29338. * @returns this effect.
  29339. */
  29340. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29341. /**
  29342. * 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)
  29343. * @param uniformName Name of the variable.
  29344. * @param array array to be set.
  29345. * @returns this effect.
  29346. */
  29347. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29348. /**
  29349. * 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)
  29350. * @param uniformName Name of the variable.
  29351. * @param array array to be set.
  29352. * @returns this effect.
  29353. */
  29354. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29355. /**
  29356. * Sets an float array on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param array array to be set.
  29359. * @returns this effect.
  29360. */
  29361. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29362. /**
  29363. * 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)
  29364. * @param uniformName Name of the variable.
  29365. * @param array array to be set.
  29366. * @returns this effect.
  29367. */
  29368. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29369. /**
  29370. * 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)
  29371. * @param uniformName Name of the variable.
  29372. * @param array array to be set.
  29373. * @returns this effect.
  29374. */
  29375. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29376. /**
  29377. * 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)
  29378. * @param uniformName Name of the variable.
  29379. * @param array array to be set.
  29380. * @returns this effect.
  29381. */
  29382. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29383. /**
  29384. * Sets an array on a uniform variable.
  29385. * @param uniformName Name of the variable.
  29386. * @param array array to be set.
  29387. * @returns this effect.
  29388. */
  29389. setArray(uniformName: string, array: number[]): Effect;
  29390. /**
  29391. * 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)
  29392. * @param uniformName Name of the variable.
  29393. * @param array array to be set.
  29394. * @returns this effect.
  29395. */
  29396. setArray2(uniformName: string, array: number[]): Effect;
  29397. /**
  29398. * 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)
  29399. * @param uniformName Name of the variable.
  29400. * @param array array to be set.
  29401. * @returns this effect.
  29402. */
  29403. setArray3(uniformName: string, array: number[]): Effect;
  29404. /**
  29405. * 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)
  29406. * @param uniformName Name of the variable.
  29407. * @param array array to be set.
  29408. * @returns this effect.
  29409. */
  29410. setArray4(uniformName: string, array: number[]): Effect;
  29411. /**
  29412. * Sets matrices on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param matrices matrices to be set.
  29415. * @returns this effect.
  29416. */
  29417. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29418. /**
  29419. * Sets matrix on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param matrix matrix to be set.
  29422. * @returns this effect.
  29423. */
  29424. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29425. /**
  29426. * 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)
  29427. * @param uniformName Name of the variable.
  29428. * @param matrix matrix to be set.
  29429. * @returns this effect.
  29430. */
  29431. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29432. /**
  29433. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29434. * @param uniformName Name of the variable.
  29435. * @param matrix matrix to be set.
  29436. * @returns this effect.
  29437. */
  29438. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29439. /**
  29440. * Sets a float on a uniform variable.
  29441. * @param uniformName Name of the variable.
  29442. * @param value value to be set.
  29443. * @returns this effect.
  29444. */
  29445. setFloat(uniformName: string, value: number): Effect;
  29446. /**
  29447. * Sets a boolean on a uniform variable.
  29448. * @param uniformName Name of the variable.
  29449. * @param bool value to be set.
  29450. * @returns this effect.
  29451. */
  29452. setBool(uniformName: string, bool: boolean): Effect;
  29453. /**
  29454. * Sets a Vector2 on a uniform variable.
  29455. * @param uniformName Name of the variable.
  29456. * @param vector2 vector2 to be set.
  29457. * @returns this effect.
  29458. */
  29459. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29460. /**
  29461. * Sets a float2 on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param x First float in float2.
  29464. * @param y Second float in float2.
  29465. * @returns this effect.
  29466. */
  29467. setFloat2(uniformName: string, x: number, y: number): Effect;
  29468. /**
  29469. * Sets a Vector3 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param vector3 Value to be set.
  29472. * @returns this effect.
  29473. */
  29474. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29475. /**
  29476. * Sets a float3 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param x First float in float3.
  29479. * @param y Second float in float3.
  29480. * @param z Third float in float3.
  29481. * @returns this effect.
  29482. */
  29483. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29484. /**
  29485. * Sets a Vector4 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param vector4 Value to be set.
  29488. * @returns this effect.
  29489. */
  29490. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29491. /**
  29492. * Sets a float4 on a uniform variable.
  29493. * @param uniformName Name of the variable.
  29494. * @param x First float in float4.
  29495. * @param y Second float in float4.
  29496. * @param z Third float in float4.
  29497. * @param w Fourth float in float4.
  29498. * @returns this effect.
  29499. */
  29500. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29501. /**
  29502. * Sets a Color3 on a uniform variable.
  29503. * @param uniformName Name of the variable.
  29504. * @param color3 Value to be set.
  29505. * @returns this effect.
  29506. */
  29507. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29508. /**
  29509. * Sets a Color4 on a uniform variable.
  29510. * @param uniformName Name of the variable.
  29511. * @param color3 Value to be set.
  29512. * @param alpha Alpha value to be set.
  29513. * @returns this effect.
  29514. */
  29515. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29516. /**
  29517. * Sets a Color4 on a uniform variable
  29518. * @param uniformName defines the name of the variable
  29519. * @param color4 defines the value to be set
  29520. * @returns this effect.
  29521. */
  29522. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29523. /** Release all associated resources */
  29524. dispose(): void;
  29525. /**
  29526. * This function will add a new shader to the shader store
  29527. * @param name the name of the shader
  29528. * @param pixelShader optional pixel shader content
  29529. * @param vertexShader optional vertex shader content
  29530. */
  29531. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29532. /**
  29533. * Store of each shader (The can be looked up using effect.key)
  29534. */
  29535. static ShadersStore: {
  29536. [key: string]: string;
  29537. };
  29538. /**
  29539. * Store of each included file for a shader (The can be looked up using effect.key)
  29540. */
  29541. static IncludesShadersStore: {
  29542. [key: string]: string;
  29543. };
  29544. /**
  29545. * Resets the cache of effects.
  29546. */
  29547. static ResetCache(): void;
  29548. }
  29549. }
  29550. declare module "babylonjs/Materials/uniformBuffer" {
  29551. import { Nullable, FloatArray } from "babylonjs/types";
  29552. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29553. import { Engine } from "babylonjs/Engines/engine";
  29554. import { Effect } from "babylonjs/Materials/effect";
  29555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29556. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29557. import { Color3 } from "babylonjs/Maths/math.color";
  29558. /**
  29559. * Uniform buffer objects.
  29560. *
  29561. * Handles blocks of uniform on the GPU.
  29562. *
  29563. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29564. *
  29565. * For more information, please refer to :
  29566. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29567. */
  29568. export class UniformBuffer {
  29569. private _engine;
  29570. private _buffer;
  29571. private _data;
  29572. private _bufferData;
  29573. private _dynamic?;
  29574. private _uniformLocations;
  29575. private _uniformSizes;
  29576. private _uniformLocationPointer;
  29577. private _needSync;
  29578. private _noUBO;
  29579. private _currentEffect;
  29580. private static _MAX_UNIFORM_SIZE;
  29581. private static _tempBuffer;
  29582. /**
  29583. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29584. * This is dynamic to allow compat with webgl 1 and 2.
  29585. * You will need to pass the name of the uniform as well as the value.
  29586. */
  29587. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29588. /**
  29589. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29590. * This is dynamic to allow compat with webgl 1 and 2.
  29591. * You will need to pass the name of the uniform as well as the value.
  29592. */
  29593. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29594. /**
  29595. * Lambda to Update a single float in a uniform buffer.
  29596. * This is dynamic to allow compat with webgl 1 and 2.
  29597. * You will need to pass the name of the uniform as well as the value.
  29598. */
  29599. updateFloat: (name: string, x: number) => void;
  29600. /**
  29601. * Lambda to Update a vec2 of float in a uniform buffer.
  29602. * This is dynamic to allow compat with webgl 1 and 2.
  29603. * You will need to pass the name of the uniform as well as the value.
  29604. */
  29605. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29606. /**
  29607. * Lambda to Update a vec3 of float in a uniform buffer.
  29608. * This is dynamic to allow compat with webgl 1 and 2.
  29609. * You will need to pass the name of the uniform as well as the value.
  29610. */
  29611. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29612. /**
  29613. * Lambda to Update a vec4 of float in a uniform buffer.
  29614. * This is dynamic to allow compat with webgl 1 and 2.
  29615. * You will need to pass the name of the uniform as well as the value.
  29616. */
  29617. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29618. /**
  29619. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29620. * This is dynamic to allow compat with webgl 1 and 2.
  29621. * You will need to pass the name of the uniform as well as the value.
  29622. */
  29623. updateMatrix: (name: string, mat: Matrix) => void;
  29624. /**
  29625. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29626. * This is dynamic to allow compat with webgl 1 and 2.
  29627. * You will need to pass the name of the uniform as well as the value.
  29628. */
  29629. updateVector3: (name: string, vector: Vector3) => void;
  29630. /**
  29631. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29632. * This is dynamic to allow compat with webgl 1 and 2.
  29633. * You will need to pass the name of the uniform as well as the value.
  29634. */
  29635. updateVector4: (name: string, vector: Vector4) => void;
  29636. /**
  29637. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29638. * This is dynamic to allow compat with webgl 1 and 2.
  29639. * You will need to pass the name of the uniform as well as the value.
  29640. */
  29641. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29642. /**
  29643. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29644. * This is dynamic to allow compat with webgl 1 and 2.
  29645. * You will need to pass the name of the uniform as well as the value.
  29646. */
  29647. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29648. /**
  29649. * Instantiates a new Uniform buffer objects.
  29650. *
  29651. * Handles blocks of uniform on the GPU.
  29652. *
  29653. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29654. *
  29655. * For more information, please refer to :
  29656. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29657. * @param engine Define the engine the buffer is associated with
  29658. * @param data Define the data contained in the buffer
  29659. * @param dynamic Define if the buffer is updatable
  29660. */
  29661. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29662. /**
  29663. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29664. * or just falling back on setUniformXXX calls.
  29665. */
  29666. readonly useUbo: boolean;
  29667. /**
  29668. * Indicates if the WebGL underlying uniform buffer is in sync
  29669. * with the javascript cache data.
  29670. */
  29671. readonly isSync: boolean;
  29672. /**
  29673. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29674. * Also, a dynamic UniformBuffer will disable cache verification and always
  29675. * update the underlying WebGL uniform buffer to the GPU.
  29676. * @returns if Dynamic, otherwise false
  29677. */
  29678. isDynamic(): boolean;
  29679. /**
  29680. * The data cache on JS side.
  29681. * @returns the underlying data as a float array
  29682. */
  29683. getData(): Float32Array;
  29684. /**
  29685. * The underlying WebGL Uniform buffer.
  29686. * @returns the webgl buffer
  29687. */
  29688. getBuffer(): Nullable<DataBuffer>;
  29689. /**
  29690. * std140 layout specifies how to align data within an UBO structure.
  29691. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29692. * for specs.
  29693. */
  29694. private _fillAlignment;
  29695. /**
  29696. * Adds an uniform in the buffer.
  29697. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29698. * for the layout to be correct !
  29699. * @param name Name of the uniform, as used in the uniform block in the shader.
  29700. * @param size Data size, or data directly.
  29701. */
  29702. addUniform(name: string, size: number | number[]): void;
  29703. /**
  29704. * Adds a Matrix 4x4 to the uniform buffer.
  29705. * @param name Name of the uniform, as used in the uniform block in the shader.
  29706. * @param mat A 4x4 matrix.
  29707. */
  29708. addMatrix(name: string, mat: Matrix): void;
  29709. /**
  29710. * Adds a vec2 to the uniform buffer.
  29711. * @param name Name of the uniform, as used in the uniform block in the shader.
  29712. * @param x Define the x component value of the vec2
  29713. * @param y Define the y component value of the vec2
  29714. */
  29715. addFloat2(name: string, x: number, y: number): void;
  29716. /**
  29717. * Adds a vec3 to the uniform buffer.
  29718. * @param name Name of the uniform, as used in the uniform block in the shader.
  29719. * @param x Define the x component value of the vec3
  29720. * @param y Define the y component value of the vec3
  29721. * @param z Define the z component value of the vec3
  29722. */
  29723. addFloat3(name: string, x: number, y: number, z: number): void;
  29724. /**
  29725. * Adds a vec3 to the uniform buffer.
  29726. * @param name Name of the uniform, as used in the uniform block in the shader.
  29727. * @param color Define the vec3 from a Color
  29728. */
  29729. addColor3(name: string, color: Color3): void;
  29730. /**
  29731. * Adds a vec4 to the uniform buffer.
  29732. * @param name Name of the uniform, as used in the uniform block in the shader.
  29733. * @param color Define the rgb components from a Color
  29734. * @param alpha Define the a component of the vec4
  29735. */
  29736. addColor4(name: string, color: Color3, alpha: number): void;
  29737. /**
  29738. * Adds a vec3 to the uniform buffer.
  29739. * @param name Name of the uniform, as used in the uniform block in the shader.
  29740. * @param vector Define the vec3 components from a Vector
  29741. */
  29742. addVector3(name: string, vector: Vector3): void;
  29743. /**
  29744. * Adds a Matrix 3x3 to the uniform buffer.
  29745. * @param name Name of the uniform, as used in the uniform block in the shader.
  29746. */
  29747. addMatrix3x3(name: string): void;
  29748. /**
  29749. * Adds a Matrix 2x2 to the uniform buffer.
  29750. * @param name Name of the uniform, as used in the uniform block in the shader.
  29751. */
  29752. addMatrix2x2(name: string): void;
  29753. /**
  29754. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29755. */
  29756. create(): void;
  29757. /** @hidden */
  29758. _rebuild(): void;
  29759. /**
  29760. * Updates the WebGL Uniform Buffer on the GPU.
  29761. * If the `dynamic` flag is set to true, no cache comparison is done.
  29762. * Otherwise, the buffer will be updated only if the cache differs.
  29763. */
  29764. update(): void;
  29765. /**
  29766. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29767. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29768. * @param data Define the flattened data
  29769. * @param size Define the size of the data.
  29770. */
  29771. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29772. private _valueCache;
  29773. private _cacheMatrix;
  29774. private _updateMatrix3x3ForUniform;
  29775. private _updateMatrix3x3ForEffect;
  29776. private _updateMatrix2x2ForEffect;
  29777. private _updateMatrix2x2ForUniform;
  29778. private _updateFloatForEffect;
  29779. private _updateFloatForUniform;
  29780. private _updateFloat2ForEffect;
  29781. private _updateFloat2ForUniform;
  29782. private _updateFloat3ForEffect;
  29783. private _updateFloat3ForUniform;
  29784. private _updateFloat4ForEffect;
  29785. private _updateFloat4ForUniform;
  29786. private _updateMatrixForEffect;
  29787. private _updateMatrixForUniform;
  29788. private _updateVector3ForEffect;
  29789. private _updateVector3ForUniform;
  29790. private _updateVector4ForEffect;
  29791. private _updateVector4ForUniform;
  29792. private _updateColor3ForEffect;
  29793. private _updateColor3ForUniform;
  29794. private _updateColor4ForEffect;
  29795. private _updateColor4ForUniform;
  29796. /**
  29797. * Sets a sampler uniform on the effect.
  29798. * @param name Define the name of the sampler.
  29799. * @param texture Define the texture to set in the sampler
  29800. */
  29801. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29802. /**
  29803. * Directly updates the value of the uniform in the cache AND on the GPU.
  29804. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29805. * @param data Define the flattened data
  29806. */
  29807. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29808. /**
  29809. * Binds this uniform buffer to an effect.
  29810. * @param effect Define the effect to bind the buffer to
  29811. * @param name Name of the uniform block in the shader.
  29812. */
  29813. bindToEffect(effect: Effect, name: string): void;
  29814. /**
  29815. * Disposes the uniform buffer.
  29816. */
  29817. dispose(): void;
  29818. }
  29819. }
  29820. declare module "babylonjs/Audio/analyser" {
  29821. import { Scene } from "babylonjs/scene";
  29822. /**
  29823. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29825. */
  29826. export class Analyser {
  29827. /**
  29828. * Gets or sets the smoothing
  29829. * @ignorenaming
  29830. */
  29831. SMOOTHING: number;
  29832. /**
  29833. * Gets or sets the FFT table size
  29834. * @ignorenaming
  29835. */
  29836. FFT_SIZE: number;
  29837. /**
  29838. * Gets or sets the bar graph amplitude
  29839. * @ignorenaming
  29840. */
  29841. BARGRAPHAMPLITUDE: number;
  29842. /**
  29843. * Gets or sets the position of the debug canvas
  29844. * @ignorenaming
  29845. */
  29846. DEBUGCANVASPOS: {
  29847. x: number;
  29848. y: number;
  29849. };
  29850. /**
  29851. * Gets or sets the debug canvas size
  29852. * @ignorenaming
  29853. */
  29854. DEBUGCANVASSIZE: {
  29855. width: number;
  29856. height: number;
  29857. };
  29858. private _byteFreqs;
  29859. private _byteTime;
  29860. private _floatFreqs;
  29861. private _webAudioAnalyser;
  29862. private _debugCanvas;
  29863. private _debugCanvasContext;
  29864. private _scene;
  29865. private _registerFunc;
  29866. private _audioEngine;
  29867. /**
  29868. * Creates a new analyser
  29869. * @param scene defines hosting scene
  29870. */
  29871. constructor(scene: Scene);
  29872. /**
  29873. * Get the number of data values you will have to play with for the visualization
  29874. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29875. * @returns a number
  29876. */
  29877. getFrequencyBinCount(): number;
  29878. /**
  29879. * Gets the current frequency data as a byte array
  29880. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29881. * @returns a Uint8Array
  29882. */
  29883. getByteFrequencyData(): Uint8Array;
  29884. /**
  29885. * Gets the current waveform as a byte array
  29886. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29887. * @returns a Uint8Array
  29888. */
  29889. getByteTimeDomainData(): Uint8Array;
  29890. /**
  29891. * Gets the current frequency data as a float array
  29892. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29893. * @returns a Float32Array
  29894. */
  29895. getFloatFrequencyData(): Float32Array;
  29896. /**
  29897. * Renders the debug canvas
  29898. */
  29899. drawDebugCanvas(): void;
  29900. /**
  29901. * Stops rendering the debug canvas and removes it
  29902. */
  29903. stopDebugCanvas(): void;
  29904. /**
  29905. * Connects two audio nodes
  29906. * @param inputAudioNode defines first node to connect
  29907. * @param outputAudioNode defines second node to connect
  29908. */
  29909. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29910. /**
  29911. * Releases all associated resources
  29912. */
  29913. dispose(): void;
  29914. }
  29915. }
  29916. declare module "babylonjs/Audio/audioEngine" {
  29917. import { IDisposable } from "babylonjs/scene";
  29918. import { Analyser } from "babylonjs/Audio/analyser";
  29919. import { Nullable } from "babylonjs/types";
  29920. import { Observable } from "babylonjs/Misc/observable";
  29921. /**
  29922. * This represents an audio engine and it is responsible
  29923. * to play, synchronize and analyse sounds throughout the application.
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export interface IAudioEngine extends IDisposable {
  29927. /**
  29928. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29929. */
  29930. readonly canUseWebAudio: boolean;
  29931. /**
  29932. * Gets the current AudioContext if available.
  29933. */
  29934. readonly audioContext: Nullable<AudioContext>;
  29935. /**
  29936. * The master gain node defines the global audio volume of your audio engine.
  29937. */
  29938. readonly masterGain: GainNode;
  29939. /**
  29940. * Gets whether or not mp3 are supported by your browser.
  29941. */
  29942. readonly isMP3supported: boolean;
  29943. /**
  29944. * Gets whether or not ogg are supported by your browser.
  29945. */
  29946. readonly isOGGsupported: boolean;
  29947. /**
  29948. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29949. * @ignoreNaming
  29950. */
  29951. WarnedWebAudioUnsupported: boolean;
  29952. /**
  29953. * Defines if the audio engine relies on a custom unlocked button.
  29954. * In this case, the embedded button will not be displayed.
  29955. */
  29956. useCustomUnlockedButton: boolean;
  29957. /**
  29958. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29959. */
  29960. readonly unlocked: boolean;
  29961. /**
  29962. * Event raised when audio has been unlocked on the browser.
  29963. */
  29964. onAudioUnlockedObservable: Observable<AudioEngine>;
  29965. /**
  29966. * Event raised when audio has been locked on the browser.
  29967. */
  29968. onAudioLockedObservable: Observable<AudioEngine>;
  29969. /**
  29970. * Flags the audio engine in Locked state.
  29971. * This happens due to new browser policies preventing audio to autoplay.
  29972. */
  29973. lock(): void;
  29974. /**
  29975. * Unlocks the audio engine once a user action has been done on the dom.
  29976. * This is helpful to resume play once browser policies have been satisfied.
  29977. */
  29978. unlock(): void;
  29979. }
  29980. /**
  29981. * This represents the default audio engine used in babylon.
  29982. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29984. */
  29985. export class AudioEngine implements IAudioEngine {
  29986. private _audioContext;
  29987. private _audioContextInitialized;
  29988. private _muteButton;
  29989. private _hostElement;
  29990. /**
  29991. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29992. */
  29993. canUseWebAudio: boolean;
  29994. /**
  29995. * The master gain node defines the global audio volume of your audio engine.
  29996. */
  29997. masterGain: GainNode;
  29998. /**
  29999. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30000. * @ignoreNaming
  30001. */
  30002. WarnedWebAudioUnsupported: boolean;
  30003. /**
  30004. * Gets whether or not mp3 are supported by your browser.
  30005. */
  30006. isMP3supported: boolean;
  30007. /**
  30008. * Gets whether or not ogg are supported by your browser.
  30009. */
  30010. isOGGsupported: boolean;
  30011. /**
  30012. * Gets whether audio has been unlocked on the device.
  30013. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30014. * a user interaction has happened.
  30015. */
  30016. unlocked: boolean;
  30017. /**
  30018. * Defines if the audio engine relies on a custom unlocked button.
  30019. * In this case, the embedded button will not be displayed.
  30020. */
  30021. useCustomUnlockedButton: boolean;
  30022. /**
  30023. * Event raised when audio has been unlocked on the browser.
  30024. */
  30025. onAudioUnlockedObservable: Observable<AudioEngine>;
  30026. /**
  30027. * Event raised when audio has been locked on the browser.
  30028. */
  30029. onAudioLockedObservable: Observable<AudioEngine>;
  30030. /**
  30031. * Gets the current AudioContext if available.
  30032. */
  30033. readonly audioContext: Nullable<AudioContext>;
  30034. private _connectedAnalyser;
  30035. /**
  30036. * Instantiates a new audio engine.
  30037. *
  30038. * There should be only one per page as some browsers restrict the number
  30039. * of audio contexts you can create.
  30040. * @param hostElement defines the host element where to display the mute icon if necessary
  30041. */
  30042. constructor(hostElement?: Nullable<HTMLElement>);
  30043. /**
  30044. * Flags the audio engine in Locked state.
  30045. * This happens due to new browser policies preventing audio to autoplay.
  30046. */
  30047. lock(): void;
  30048. /**
  30049. * Unlocks the audio engine once a user action has been done on the dom.
  30050. * This is helpful to resume play once browser policies have been satisfied.
  30051. */
  30052. unlock(): void;
  30053. private _resumeAudioContext;
  30054. private _initializeAudioContext;
  30055. private _tryToRun;
  30056. private _triggerRunningState;
  30057. private _triggerSuspendedState;
  30058. private _displayMuteButton;
  30059. private _moveButtonToTopLeft;
  30060. private _onResize;
  30061. private _hideMuteButton;
  30062. /**
  30063. * Destroy and release the resources associated with the audio ccontext.
  30064. */
  30065. dispose(): void;
  30066. /**
  30067. * Gets the global volume sets on the master gain.
  30068. * @returns the global volume if set or -1 otherwise
  30069. */
  30070. getGlobalVolume(): number;
  30071. /**
  30072. * Sets the global volume of your experience (sets on the master gain).
  30073. * @param newVolume Defines the new global volume of the application
  30074. */
  30075. setGlobalVolume(newVolume: number): void;
  30076. /**
  30077. * Connect the audio engine to an audio analyser allowing some amazing
  30078. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30080. * @param analyser The analyser to connect to the engine
  30081. */
  30082. connectToAnalyser(analyser: Analyser): void;
  30083. }
  30084. }
  30085. declare module "babylonjs/Loading/loadingScreen" {
  30086. /**
  30087. * Interface used to present a loading screen while loading a scene
  30088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30089. */
  30090. export interface ILoadingScreen {
  30091. /**
  30092. * Function called to display the loading screen
  30093. */
  30094. displayLoadingUI: () => void;
  30095. /**
  30096. * Function called to hide the loading screen
  30097. */
  30098. hideLoadingUI: () => void;
  30099. /**
  30100. * Gets or sets the color to use for the background
  30101. */
  30102. loadingUIBackgroundColor: string;
  30103. /**
  30104. * Gets or sets the text to display while loading
  30105. */
  30106. loadingUIText: string;
  30107. }
  30108. /**
  30109. * Class used for the default loading screen
  30110. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30111. */
  30112. export class DefaultLoadingScreen implements ILoadingScreen {
  30113. private _renderingCanvas;
  30114. private _loadingText;
  30115. private _loadingDivBackgroundColor;
  30116. private _loadingDiv;
  30117. private _loadingTextDiv;
  30118. /** Gets or sets the logo url to use for the default loading screen */
  30119. static DefaultLogoUrl: string;
  30120. /** Gets or sets the spinner url to use for the default loading screen */
  30121. static DefaultSpinnerUrl: string;
  30122. /**
  30123. * Creates a new default loading screen
  30124. * @param _renderingCanvas defines the canvas used to render the scene
  30125. * @param _loadingText defines the default text to display
  30126. * @param _loadingDivBackgroundColor defines the default background color
  30127. */
  30128. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30129. /**
  30130. * Function called to display the loading screen
  30131. */
  30132. displayLoadingUI(): void;
  30133. /**
  30134. * Function called to hide the loading screen
  30135. */
  30136. hideLoadingUI(): void;
  30137. /**
  30138. * Gets or sets the text to display while loading
  30139. */
  30140. loadingUIText: string;
  30141. /**
  30142. * Gets or sets the color to use for the background
  30143. */
  30144. loadingUIBackgroundColor: string;
  30145. private _resizeLoadingUI;
  30146. }
  30147. }
  30148. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30149. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30150. import { Engine } from "babylonjs/Engines/engine";
  30151. import { Nullable } from "babylonjs/types";
  30152. /** @hidden */
  30153. export class WebGLPipelineContext implements IPipelineContext {
  30154. engine: Engine;
  30155. program: Nullable<WebGLProgram>;
  30156. context?: WebGLRenderingContext;
  30157. vertexShader?: WebGLShader;
  30158. fragmentShader?: WebGLShader;
  30159. isParallelCompiled: boolean;
  30160. onCompiled?: () => void;
  30161. transformFeedback?: WebGLTransformFeedback | null;
  30162. readonly isAsync: boolean;
  30163. readonly isReady: boolean;
  30164. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30165. }
  30166. }
  30167. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30168. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30169. /** @hidden */
  30170. export class WebGLDataBuffer extends DataBuffer {
  30171. private _buffer;
  30172. constructor(resource: WebGLBuffer);
  30173. readonly underlyingResource: any;
  30174. }
  30175. }
  30176. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30177. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30178. /** @hidden */
  30179. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30180. attributeProcessor(attribute: string): string;
  30181. varyingProcessor(varying: string, isFragment: boolean): string;
  30182. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30183. }
  30184. }
  30185. declare module "babylonjs/Misc/perfCounter" {
  30186. /**
  30187. * This class is used to track a performance counter which is number based.
  30188. * The user has access to many properties which give statistics of different nature.
  30189. *
  30190. * The implementer can track two kinds of Performance Counter: time and count.
  30191. * 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.
  30192. * 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.
  30193. */
  30194. export class PerfCounter {
  30195. /**
  30196. * Gets or sets a global boolean to turn on and off all the counters
  30197. */
  30198. static Enabled: boolean;
  30199. /**
  30200. * Returns the smallest value ever
  30201. */
  30202. readonly min: number;
  30203. /**
  30204. * Returns the biggest value ever
  30205. */
  30206. readonly max: number;
  30207. /**
  30208. * Returns the average value since the performance counter is running
  30209. */
  30210. readonly average: number;
  30211. /**
  30212. * Returns the average value of the last second the counter was monitored
  30213. */
  30214. readonly lastSecAverage: number;
  30215. /**
  30216. * Returns the current value
  30217. */
  30218. readonly current: number;
  30219. /**
  30220. * Gets the accumulated total
  30221. */
  30222. readonly total: number;
  30223. /**
  30224. * Gets the total value count
  30225. */
  30226. readonly count: number;
  30227. /**
  30228. * Creates a new counter
  30229. */
  30230. constructor();
  30231. /**
  30232. * Call this method to start monitoring a new frame.
  30233. * 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.
  30234. */
  30235. fetchNewFrame(): void;
  30236. /**
  30237. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30238. * @param newCount the count value to add to the monitored count
  30239. * @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.
  30240. */
  30241. addCount(newCount: number, fetchResult: boolean): void;
  30242. /**
  30243. * Start monitoring this performance counter
  30244. */
  30245. beginMonitoring(): void;
  30246. /**
  30247. * Compute the time lapsed since the previous beginMonitoring() call.
  30248. * @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
  30249. */
  30250. endMonitoring(newFrame?: boolean): void;
  30251. private _fetchResult;
  30252. private _startMonitoringTime;
  30253. private _min;
  30254. private _max;
  30255. private _average;
  30256. private _current;
  30257. private _totalValueCount;
  30258. private _totalAccumulated;
  30259. private _lastSecAverage;
  30260. private _lastSecAccumulated;
  30261. private _lastSecTime;
  30262. private _lastSecValueCount;
  30263. }
  30264. }
  30265. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30266. /**
  30267. * Interface for any object that can request an animation frame
  30268. */
  30269. export interface ICustomAnimationFrameRequester {
  30270. /**
  30271. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30272. */
  30273. renderFunction?: Function;
  30274. /**
  30275. * Called to request the next frame to render to
  30276. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30277. */
  30278. requestAnimationFrame: Function;
  30279. /**
  30280. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30281. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30282. */
  30283. requestID?: number;
  30284. }
  30285. }
  30286. declare module "babylonjs/Materials/Textures/videoTexture" {
  30287. import { Observable } from "babylonjs/Misc/observable";
  30288. import { Nullable } from "babylonjs/types";
  30289. import { Scene } from "babylonjs/scene";
  30290. import { Texture } from "babylonjs/Materials/Textures/texture";
  30291. /**
  30292. * Settings for finer control over video usage
  30293. */
  30294. export interface VideoTextureSettings {
  30295. /**
  30296. * Applies `autoplay` to video, if specified
  30297. */
  30298. autoPlay?: boolean;
  30299. /**
  30300. * Applies `loop` to video, if specified
  30301. */
  30302. loop?: boolean;
  30303. /**
  30304. * Automatically updates internal texture from video at every frame in the render loop
  30305. */
  30306. autoUpdateTexture: boolean;
  30307. /**
  30308. * Image src displayed during the video loading or until the user interacts with the video.
  30309. */
  30310. poster?: string;
  30311. }
  30312. /**
  30313. * If you want to display a video in your scene, this is the special texture for that.
  30314. * This special texture works similar to other textures, with the exception of a few parameters.
  30315. * @see https://doc.babylonjs.com/how_to/video_texture
  30316. */
  30317. export class VideoTexture extends Texture {
  30318. /**
  30319. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30320. */
  30321. readonly autoUpdateTexture: boolean;
  30322. /**
  30323. * The video instance used by the texture internally
  30324. */
  30325. readonly video: HTMLVideoElement;
  30326. private _onUserActionRequestedObservable;
  30327. /**
  30328. * Event triggerd when a dom action is required by the user to play the video.
  30329. * This happens due to recent changes in browser policies preventing video to auto start.
  30330. */
  30331. readonly onUserActionRequestedObservable: Observable<Texture>;
  30332. private _generateMipMaps;
  30333. private _engine;
  30334. private _stillImageCaptured;
  30335. private _displayingPosterTexture;
  30336. private _settings;
  30337. private _createInternalTextureOnEvent;
  30338. private _frameId;
  30339. /**
  30340. * Creates a video texture.
  30341. * If you want to display a video in your scene, this is the special texture for that.
  30342. * This special texture works similar to other textures, with the exception of a few parameters.
  30343. * @see https://doc.babylonjs.com/how_to/video_texture
  30344. * @param name optional name, will detect from video source, if not defined
  30345. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30346. * @param scene is obviously the current scene.
  30347. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30348. * @param invertY is false by default but can be used to invert video on Y axis
  30349. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30350. * @param settings allows finer control over video usage
  30351. */
  30352. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30353. private _getName;
  30354. private _getVideo;
  30355. private _createInternalTexture;
  30356. private reset;
  30357. /**
  30358. * @hidden Internal method to initiate `update`.
  30359. */
  30360. _rebuild(): void;
  30361. /**
  30362. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30363. */
  30364. update(): void;
  30365. /**
  30366. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30367. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30368. */
  30369. updateTexture(isVisible: boolean): void;
  30370. protected _updateInternalTexture: () => void;
  30371. /**
  30372. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30373. * @param url New url.
  30374. */
  30375. updateURL(url: string): void;
  30376. /**
  30377. * Dispose the texture and release its associated resources.
  30378. */
  30379. dispose(): void;
  30380. /**
  30381. * Creates a video texture straight from a stream.
  30382. * @param scene Define the scene the texture should be created in
  30383. * @param stream Define the stream the texture should be created from
  30384. * @returns The created video texture as a promise
  30385. */
  30386. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30387. /**
  30388. * Creates a video texture straight from your WebCam video feed.
  30389. * @param scene Define the scene the texture should be created in
  30390. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30391. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30392. * @returns The created video texture as a promise
  30393. */
  30394. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30395. minWidth: number;
  30396. maxWidth: number;
  30397. minHeight: number;
  30398. maxHeight: number;
  30399. deviceId: string;
  30400. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30401. /**
  30402. * Creates a video texture straight from your WebCam video feed.
  30403. * @param scene Define the scene the texture should be created in
  30404. * @param onReady Define a callback to triggered once the texture will be ready
  30405. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30406. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30407. */
  30408. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30409. minWidth: number;
  30410. maxWidth: number;
  30411. minHeight: number;
  30412. maxHeight: number;
  30413. deviceId: string;
  30414. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30415. }
  30416. }
  30417. declare module "babylonjs/Engines/engine" {
  30418. import { Observable } from "babylonjs/Misc/observable";
  30419. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30420. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30421. import { Scene } from "babylonjs/scene";
  30422. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30423. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30424. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30425. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30426. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30428. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30429. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30430. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30431. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30432. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30433. import { WebRequest } from "babylonjs/Misc/webRequest";
  30434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30435. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30436. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30437. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30438. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30439. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30440. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30441. import { Material } from "babylonjs/Materials/material";
  30442. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30444. /**
  30445. * Defines the interface used by objects containing a viewport (like a camera)
  30446. */
  30447. interface IViewportOwnerLike {
  30448. /**
  30449. * Gets or sets the viewport
  30450. */
  30451. viewport: IViewportLike;
  30452. }
  30453. /**
  30454. * Interface for attribute information associated with buffer instanciation
  30455. */
  30456. export class InstancingAttributeInfo {
  30457. /**
  30458. * Index/offset of the attribute in the vertex shader
  30459. */
  30460. index: number;
  30461. /**
  30462. * size of the attribute, 1, 2, 3 or 4
  30463. */
  30464. attributeSize: number;
  30465. /**
  30466. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30467. * default is FLOAT
  30468. */
  30469. attribyteType: number;
  30470. /**
  30471. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30472. */
  30473. normalized: boolean;
  30474. /**
  30475. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30476. */
  30477. offset: number;
  30478. /**
  30479. * Name of the GLSL attribute, for debugging purpose only
  30480. */
  30481. attributeName: string;
  30482. }
  30483. /**
  30484. * Define options used to create a depth texture
  30485. */
  30486. export class DepthTextureCreationOptions {
  30487. /** Specifies whether or not a stencil should be allocated in the texture */
  30488. generateStencil?: boolean;
  30489. /** Specifies whether or not bilinear filtering is enable on the texture */
  30490. bilinearFiltering?: boolean;
  30491. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30492. comparisonFunction?: number;
  30493. /** Specifies if the created texture is a cube texture */
  30494. isCube?: boolean;
  30495. }
  30496. /**
  30497. * Class used to describe the capabilities of the engine relatively to the current browser
  30498. */
  30499. export class EngineCapabilities {
  30500. /** Maximum textures units per fragment shader */
  30501. maxTexturesImageUnits: number;
  30502. /** Maximum texture units per vertex shader */
  30503. maxVertexTextureImageUnits: number;
  30504. /** Maximum textures units in the entire pipeline */
  30505. maxCombinedTexturesImageUnits: number;
  30506. /** Maximum texture size */
  30507. maxTextureSize: number;
  30508. /** Maximum cube texture size */
  30509. maxCubemapTextureSize: number;
  30510. /** Maximum render texture size */
  30511. maxRenderTextureSize: number;
  30512. /** Maximum number of vertex attributes */
  30513. maxVertexAttribs: number;
  30514. /** Maximum number of varyings */
  30515. maxVaryingVectors: number;
  30516. /** Maximum number of uniforms per vertex shader */
  30517. maxVertexUniformVectors: number;
  30518. /** Maximum number of uniforms per fragment shader */
  30519. maxFragmentUniformVectors: number;
  30520. /** Defines if standard derivates (dx/dy) are supported */
  30521. standardDerivatives: boolean;
  30522. /** Defines if s3tc texture compression is supported */
  30523. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30524. /** Defines if pvrtc texture compression is supported */
  30525. pvrtc: any;
  30526. /** Defines if etc1 texture compression is supported */
  30527. etc1: any;
  30528. /** Defines if etc2 texture compression is supported */
  30529. etc2: any;
  30530. /** Defines if astc texture compression is supported */
  30531. astc: any;
  30532. /** Defines if float textures are supported */
  30533. textureFloat: boolean;
  30534. /** Defines if vertex array objects are supported */
  30535. vertexArrayObject: boolean;
  30536. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30537. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30538. /** Gets the maximum level of anisotropy supported */
  30539. maxAnisotropy: number;
  30540. /** Defines if instancing is supported */
  30541. instancedArrays: boolean;
  30542. /** Defines if 32 bits indices are supported */
  30543. uintIndices: boolean;
  30544. /** Defines if high precision shaders are supported */
  30545. highPrecisionShaderSupported: boolean;
  30546. /** Defines if depth reading in the fragment shader is supported */
  30547. fragmentDepthSupported: boolean;
  30548. /** Defines if float texture linear filtering is supported*/
  30549. textureFloatLinearFiltering: boolean;
  30550. /** Defines if rendering to float textures is supported */
  30551. textureFloatRender: boolean;
  30552. /** Defines if half float textures are supported*/
  30553. textureHalfFloat: boolean;
  30554. /** Defines if half float texture linear filtering is supported*/
  30555. textureHalfFloatLinearFiltering: boolean;
  30556. /** Defines if rendering to half float textures is supported */
  30557. textureHalfFloatRender: boolean;
  30558. /** Defines if textureLOD shader command is supported */
  30559. textureLOD: boolean;
  30560. /** Defines if draw buffers extension is supported */
  30561. drawBuffersExtension: boolean;
  30562. /** Defines if depth textures are supported */
  30563. depthTextureExtension: boolean;
  30564. /** Defines if float color buffer are supported */
  30565. colorBufferFloat: boolean;
  30566. /** Gets disjoint timer query extension (null if not supported) */
  30567. timerQuery: EXT_disjoint_timer_query;
  30568. /** Defines if timestamp can be used with timer query */
  30569. canUseTimestampForTimerQuery: boolean;
  30570. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30571. multiview: any;
  30572. /** Function used to let the system compiles shaders in background */
  30573. parallelShaderCompile: {
  30574. COMPLETION_STATUS_KHR: number;
  30575. };
  30576. /** Max number of texture samples for MSAA */
  30577. maxMSAASamples: number;
  30578. }
  30579. /** Interface defining initialization parameters for Engine class */
  30580. export interface EngineOptions extends WebGLContextAttributes {
  30581. /**
  30582. * Defines if the engine should no exceed a specified device ratio
  30583. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30584. */
  30585. limitDeviceRatio?: number;
  30586. /**
  30587. * Defines if webvr should be enabled automatically
  30588. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30589. */
  30590. autoEnableWebVR?: boolean;
  30591. /**
  30592. * Defines if webgl2 should be turned off even if supported
  30593. * @see http://doc.babylonjs.com/features/webgl2
  30594. */
  30595. disableWebGL2Support?: boolean;
  30596. /**
  30597. * Defines if webaudio should be initialized as well
  30598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30599. */
  30600. audioEngine?: boolean;
  30601. /**
  30602. * Defines if animations should run using a deterministic lock step
  30603. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30604. */
  30605. deterministicLockstep?: boolean;
  30606. /** Defines the maximum steps to use with deterministic lock step mode */
  30607. lockstepMaxSteps?: number;
  30608. /**
  30609. * Defines that engine should ignore context lost events
  30610. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30611. */
  30612. doNotHandleContextLost?: boolean;
  30613. /**
  30614. * Defines that engine should ignore modifying touch action attribute and style
  30615. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30616. */
  30617. doNotHandleTouchAction?: boolean;
  30618. /**
  30619. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30620. */
  30621. useHighPrecisionFloats?: boolean;
  30622. }
  30623. /**
  30624. * Defines the interface used by display changed events
  30625. */
  30626. export interface IDisplayChangedEventArgs {
  30627. /** Gets the vrDisplay object (if any) */
  30628. vrDisplay: Nullable<any>;
  30629. /** Gets a boolean indicating if webVR is supported */
  30630. vrSupported: boolean;
  30631. }
  30632. /**
  30633. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30634. */
  30635. export class Engine {
  30636. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30637. static ExceptionList: ({
  30638. key: string;
  30639. capture: string;
  30640. captureConstraint: number;
  30641. targets: string[];
  30642. } | {
  30643. key: string;
  30644. capture: null;
  30645. captureConstraint: null;
  30646. targets: string[];
  30647. })[];
  30648. /** Gets the list of created engines */
  30649. static readonly Instances: Engine[];
  30650. /**
  30651. * Gets the latest created engine
  30652. */
  30653. static readonly LastCreatedEngine: Nullable<Engine>;
  30654. /**
  30655. * Gets the latest created scene
  30656. */
  30657. static readonly LastCreatedScene: Nullable<Scene>;
  30658. /**
  30659. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30660. * @param flag defines which part of the materials must be marked as dirty
  30661. * @param predicate defines a predicate used to filter which materials should be affected
  30662. */
  30663. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30664. /** @hidden */
  30665. static _TextureLoaders: IInternalTextureLoader[];
  30666. /** Defines that alpha blending is disabled */
  30667. static readonly ALPHA_DISABLE: number;
  30668. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30669. static readonly ALPHA_ADD: number;
  30670. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30671. static readonly ALPHA_COMBINE: number;
  30672. /** Defines that alpha blending to DEST - SRC * DEST */
  30673. static readonly ALPHA_SUBTRACT: number;
  30674. /** Defines that alpha blending to SRC * DEST */
  30675. static readonly ALPHA_MULTIPLY: number;
  30676. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30677. static readonly ALPHA_MAXIMIZED: number;
  30678. /** Defines that alpha blending to SRC + DEST */
  30679. static readonly ALPHA_ONEONE: number;
  30680. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30681. static readonly ALPHA_PREMULTIPLIED: number;
  30682. /**
  30683. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30684. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30685. */
  30686. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30687. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30688. static readonly ALPHA_INTERPOLATE: number;
  30689. /**
  30690. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30691. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30692. */
  30693. static readonly ALPHA_SCREENMODE: number;
  30694. /** Defines that the ressource is not delayed*/
  30695. static readonly DELAYLOADSTATE_NONE: number;
  30696. /** Defines that the ressource was successfully delay loaded */
  30697. static readonly DELAYLOADSTATE_LOADED: number;
  30698. /** Defines that the ressource is currently delay loading */
  30699. static readonly DELAYLOADSTATE_LOADING: number;
  30700. /** Defines that the ressource is delayed and has not started loading */
  30701. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30703. static readonly NEVER: number;
  30704. /** 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 */
  30705. static readonly ALWAYS: number;
  30706. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30707. static readonly LESS: number;
  30708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30709. static readonly EQUAL: number;
  30710. /** 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 */
  30711. static readonly LEQUAL: number;
  30712. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30713. static readonly GREATER: number;
  30714. /** 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 */
  30715. static readonly GEQUAL: number;
  30716. /** 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 */
  30717. static readonly NOTEQUAL: number;
  30718. /** Passed to stencilOperation to specify that stencil value must be kept */
  30719. static readonly KEEP: number;
  30720. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30721. static readonly REPLACE: number;
  30722. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30723. static readonly INCR: number;
  30724. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30725. static readonly DECR: number;
  30726. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30727. static readonly INVERT: number;
  30728. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30729. static readonly INCR_WRAP: number;
  30730. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30731. static readonly DECR_WRAP: number;
  30732. /** Texture is not repeating outside of 0..1 UVs */
  30733. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30734. /** Texture is repeating outside of 0..1 UVs */
  30735. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30736. /** Texture is repeating and mirrored */
  30737. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30738. /** ALPHA */
  30739. static readonly TEXTUREFORMAT_ALPHA: number;
  30740. /** LUMINANCE */
  30741. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30742. /** LUMINANCE_ALPHA */
  30743. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30744. /** RGB */
  30745. static readonly TEXTUREFORMAT_RGB: number;
  30746. /** RGBA */
  30747. static readonly TEXTUREFORMAT_RGBA: number;
  30748. /** RED */
  30749. static readonly TEXTUREFORMAT_RED: number;
  30750. /** RED (2nd reference) */
  30751. static readonly TEXTUREFORMAT_R: number;
  30752. /** RG */
  30753. static readonly TEXTUREFORMAT_RG: number;
  30754. /** RED_INTEGER */
  30755. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30756. /** RED_INTEGER (2nd reference) */
  30757. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30758. /** RG_INTEGER */
  30759. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30760. /** RGB_INTEGER */
  30761. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30762. /** RGBA_INTEGER */
  30763. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30764. /** UNSIGNED_BYTE */
  30765. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30766. /** UNSIGNED_BYTE (2nd reference) */
  30767. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30768. /** FLOAT */
  30769. static readonly TEXTURETYPE_FLOAT: number;
  30770. /** HALF_FLOAT */
  30771. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30772. /** BYTE */
  30773. static readonly TEXTURETYPE_BYTE: number;
  30774. /** SHORT */
  30775. static readonly TEXTURETYPE_SHORT: number;
  30776. /** UNSIGNED_SHORT */
  30777. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30778. /** INT */
  30779. static readonly TEXTURETYPE_INT: number;
  30780. /** UNSIGNED_INT */
  30781. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30782. /** UNSIGNED_SHORT_4_4_4_4 */
  30783. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30784. /** UNSIGNED_SHORT_5_5_5_1 */
  30785. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30786. /** UNSIGNED_SHORT_5_6_5 */
  30787. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30788. /** UNSIGNED_INT_2_10_10_10_REV */
  30789. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30790. /** UNSIGNED_INT_24_8 */
  30791. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30792. /** UNSIGNED_INT_10F_11F_11F_REV */
  30793. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30794. /** UNSIGNED_INT_5_9_9_9_REV */
  30795. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30796. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30797. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30798. /** nearest is mag = nearest and min = nearest and mip = linear */
  30799. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30800. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30801. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30802. /** Trilinear is mag = linear and min = linear and mip = linear */
  30803. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30804. /** nearest is mag = nearest and min = nearest and mip = linear */
  30805. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30807. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30808. /** Trilinear is mag = linear and min = linear and mip = linear */
  30809. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30810. /** mag = nearest and min = nearest and mip = nearest */
  30811. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30812. /** mag = nearest and min = linear and mip = nearest */
  30813. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30814. /** mag = nearest and min = linear and mip = linear */
  30815. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30816. /** mag = nearest and min = linear and mip = none */
  30817. static readonly TEXTURE_NEAREST_LINEAR: number;
  30818. /** mag = nearest and min = nearest and mip = none */
  30819. static readonly TEXTURE_NEAREST_NEAREST: number;
  30820. /** mag = linear and min = nearest and mip = nearest */
  30821. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30822. /** mag = linear and min = nearest and mip = linear */
  30823. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30824. /** mag = linear and min = linear and mip = none */
  30825. static readonly TEXTURE_LINEAR_LINEAR: number;
  30826. /** mag = linear and min = nearest and mip = none */
  30827. static readonly TEXTURE_LINEAR_NEAREST: number;
  30828. /** Explicit coordinates mode */
  30829. static readonly TEXTURE_EXPLICIT_MODE: number;
  30830. /** Spherical coordinates mode */
  30831. static readonly TEXTURE_SPHERICAL_MODE: number;
  30832. /** Planar coordinates mode */
  30833. static readonly TEXTURE_PLANAR_MODE: number;
  30834. /** Cubic coordinates mode */
  30835. static readonly TEXTURE_CUBIC_MODE: number;
  30836. /** Projection coordinates mode */
  30837. static readonly TEXTURE_PROJECTION_MODE: number;
  30838. /** Skybox coordinates mode */
  30839. static readonly TEXTURE_SKYBOX_MODE: number;
  30840. /** Inverse Cubic coordinates mode */
  30841. static readonly TEXTURE_INVCUBIC_MODE: number;
  30842. /** Equirectangular coordinates mode */
  30843. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30844. /** Equirectangular Fixed coordinates mode */
  30845. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30846. /** Equirectangular Fixed Mirrored coordinates mode */
  30847. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30848. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30849. static readonly SCALEMODE_FLOOR: number;
  30850. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30851. static readonly SCALEMODE_NEAREST: number;
  30852. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30853. static readonly SCALEMODE_CEILING: number;
  30854. /**
  30855. * Returns the current npm package of the sdk
  30856. */
  30857. static readonly NpmPackage: string;
  30858. /**
  30859. * Returns the current version of the framework
  30860. */
  30861. static readonly Version: string;
  30862. /**
  30863. * Returns a string describing the current engine
  30864. */
  30865. readonly description: string;
  30866. /**
  30867. * Gets or sets the epsilon value used by collision engine
  30868. */
  30869. static CollisionsEpsilon: number;
  30870. /**
  30871. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30872. */
  30873. static ShadersRepository: string;
  30874. /**
  30875. * Method called to create the default loading screen.
  30876. * This can be overriden in your own app.
  30877. * @param canvas The rendering canvas element
  30878. * @returns The loading screen
  30879. */
  30880. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30881. /**
  30882. * Method called to create the default rescale post process on each engine.
  30883. */
  30884. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30885. /** @hidden */
  30886. _shaderProcessor: IShaderProcessor;
  30887. /**
  30888. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30889. */
  30890. forcePOTTextures: boolean;
  30891. /**
  30892. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30893. */
  30894. isFullscreen: boolean;
  30895. /**
  30896. * Gets a boolean indicating if the pointer is currently locked
  30897. */
  30898. isPointerLock: boolean;
  30899. /**
  30900. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30901. */
  30902. cullBackFaces: boolean;
  30903. /**
  30904. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30905. */
  30906. renderEvenInBackground: boolean;
  30907. /**
  30908. * Gets or sets a boolean indicating that cache can be kept between frames
  30909. */
  30910. preventCacheWipeBetweenFrames: boolean;
  30911. /**
  30912. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30913. **/
  30914. enableOfflineSupport: boolean;
  30915. /**
  30916. * 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)
  30917. **/
  30918. disableManifestCheck: boolean;
  30919. /**
  30920. * Gets the list of created scenes
  30921. */
  30922. scenes: Scene[];
  30923. /**
  30924. * Event raised when a new scene is created
  30925. */
  30926. onNewSceneAddedObservable: Observable<Scene>;
  30927. /**
  30928. * Gets the list of created postprocesses
  30929. */
  30930. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30931. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30932. validateShaderPrograms: boolean;
  30933. /**
  30934. * Observable event triggered each time the rendering canvas is resized
  30935. */
  30936. onResizeObservable: Observable<Engine>;
  30937. /**
  30938. * Observable event triggered each time the canvas loses focus
  30939. */
  30940. onCanvasBlurObservable: Observable<Engine>;
  30941. /**
  30942. * Observable event triggered each time the canvas gains focus
  30943. */
  30944. onCanvasFocusObservable: Observable<Engine>;
  30945. /**
  30946. * Observable event triggered each time the canvas receives pointerout event
  30947. */
  30948. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30949. /**
  30950. * Observable event triggered before each texture is initialized
  30951. */
  30952. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30953. /**
  30954. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30955. */
  30956. disableUniformBuffers: boolean;
  30957. /** @hidden */
  30958. _uniformBuffers: UniformBuffer[];
  30959. /**
  30960. * Gets a boolean indicating that the engine supports uniform buffers
  30961. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30962. */
  30963. readonly supportsUniformBuffers: boolean;
  30964. /**
  30965. * Observable raised when the engine begins a new frame
  30966. */
  30967. onBeginFrameObservable: Observable<Engine>;
  30968. /**
  30969. * If set, will be used to request the next animation frame for the render loop
  30970. */
  30971. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30972. /**
  30973. * Observable raised when the engine ends the current frame
  30974. */
  30975. onEndFrameObservable: Observable<Engine>;
  30976. /**
  30977. * Observable raised when the engine is about to compile a shader
  30978. */
  30979. onBeforeShaderCompilationObservable: Observable<Engine>;
  30980. /**
  30981. * Observable raised when the engine has jsut compiled a shader
  30982. */
  30983. onAfterShaderCompilationObservable: Observable<Engine>;
  30984. /** @hidden */
  30985. _gl: WebGLRenderingContext;
  30986. private _renderingCanvas;
  30987. private _windowIsBackground;
  30988. protected _webGLVersion: number;
  30989. protected _highPrecisionShadersAllowed: boolean;
  30990. /** @hidden */
  30991. readonly _shouldUseHighPrecisionShader: boolean;
  30992. /**
  30993. * Gets a boolean indicating that only power of 2 textures are supported
  30994. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30995. */
  30996. readonly needPOTTextures: boolean;
  30997. /** @hidden */
  30998. _badOS: boolean;
  30999. /** @hidden */
  31000. _badDesktopOS: boolean;
  31001. /**
  31002. * Gets the audio engine
  31003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31004. * @ignorenaming
  31005. */
  31006. static audioEngine: IAudioEngine;
  31007. /**
  31008. * Default AudioEngine factory responsible of creating the Audio Engine.
  31009. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31010. */
  31011. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31012. /**
  31013. * Default offline support factory responsible of creating a tool used to store data locally.
  31014. * By default, this will create a Database object if the workload has been embedded.
  31015. */
  31016. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31017. private _onFocus;
  31018. private _onBlur;
  31019. private _onCanvasPointerOut;
  31020. private _onCanvasBlur;
  31021. private _onCanvasFocus;
  31022. private _onFullscreenChange;
  31023. private _onPointerLockChange;
  31024. private _hardwareScalingLevel;
  31025. /** @hidden */
  31026. _caps: EngineCapabilities;
  31027. private _pointerLockRequested;
  31028. private _isStencilEnable;
  31029. protected _colorWrite: boolean;
  31030. private _loadingScreen;
  31031. /** @hidden */
  31032. _drawCalls: PerfCounter;
  31033. private _glVersion;
  31034. private _glRenderer;
  31035. private _glVendor;
  31036. private _videoTextureSupported;
  31037. private _renderingQueueLaunched;
  31038. private _activeRenderLoops;
  31039. private _deterministicLockstep;
  31040. private _lockstepMaxSteps;
  31041. /**
  31042. * Observable signaled when a context lost event is raised
  31043. */
  31044. onContextLostObservable: Observable<Engine>;
  31045. /**
  31046. * Observable signaled when a context restored event is raised
  31047. */
  31048. onContextRestoredObservable: Observable<Engine>;
  31049. private _onContextLost;
  31050. private _onContextRestored;
  31051. private _contextWasLost;
  31052. /** @hidden */
  31053. _doNotHandleContextLost: boolean;
  31054. /**
  31055. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31057. */
  31058. doNotHandleContextLost: boolean;
  31059. private _performanceMonitor;
  31060. private _fps;
  31061. private _deltaTime;
  31062. /**
  31063. * Turn this value on if you want to pause FPS computation when in background
  31064. */
  31065. disablePerformanceMonitorInBackground: boolean;
  31066. /**
  31067. * Gets the performance monitor attached to this engine
  31068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31069. */
  31070. readonly performanceMonitor: PerformanceMonitor;
  31071. /**
  31072. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31073. */
  31074. disableVertexArrayObjects: boolean;
  31075. /** @hidden */
  31076. protected _depthCullingState: _DepthCullingState;
  31077. /** @hidden */
  31078. protected _stencilState: _StencilState;
  31079. /** @hidden */
  31080. protected _alphaState: _AlphaState;
  31081. /** @hidden */
  31082. protected _alphaMode: number;
  31083. /** @hidden */
  31084. _internalTexturesCache: InternalTexture[];
  31085. /** @hidden */
  31086. protected _activeChannel: number;
  31087. private _currentTextureChannel;
  31088. /** @hidden */
  31089. protected _boundTexturesCache: {
  31090. [key: string]: Nullable<InternalTexture>;
  31091. };
  31092. /** @hidden */
  31093. protected _currentEffect: Nullable<Effect>;
  31094. /** @hidden */
  31095. protected _currentProgram: Nullable<WebGLProgram>;
  31096. private _compiledEffects;
  31097. private _vertexAttribArraysEnabled;
  31098. /** @hidden */
  31099. protected _cachedViewport: Nullable<IViewportLike>;
  31100. private _cachedVertexArrayObject;
  31101. /** @hidden */
  31102. protected _cachedVertexBuffers: any;
  31103. /** @hidden */
  31104. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31105. /** @hidden */
  31106. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31107. /** @hidden */
  31108. _currentRenderTarget: Nullable<InternalTexture>;
  31109. private _uintIndicesCurrentlySet;
  31110. private _currentBoundBuffer;
  31111. /** @hidden */
  31112. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31113. private _currentBufferPointers;
  31114. private _currentInstanceLocations;
  31115. private _currentInstanceBuffers;
  31116. private _textureUnits;
  31117. /** @hidden */
  31118. _workingCanvas: Nullable<HTMLCanvasElement>;
  31119. /** @hidden */
  31120. _workingContext: Nullable<CanvasRenderingContext2D>;
  31121. private _rescalePostProcess;
  31122. private _dummyFramebuffer;
  31123. private _externalData;
  31124. /** @hidden */
  31125. _bindedRenderFunction: any;
  31126. private _vaoRecordInProgress;
  31127. private _mustWipeVertexAttributes;
  31128. private _emptyTexture;
  31129. private _emptyCubeTexture;
  31130. private _emptyTexture3D;
  31131. /** @hidden */
  31132. _frameHandler: number;
  31133. private _nextFreeTextureSlots;
  31134. private _maxSimultaneousTextures;
  31135. private _activeRequests;
  31136. private _texturesSupported;
  31137. /** @hidden */
  31138. _textureFormatInUse: Nullable<string>;
  31139. /**
  31140. * Gets the list of texture formats supported
  31141. */
  31142. readonly texturesSupported: Array<string>;
  31143. /**
  31144. * Gets the list of texture formats in use
  31145. */
  31146. readonly textureFormatInUse: Nullable<string>;
  31147. /**
  31148. * Gets the current viewport
  31149. */
  31150. readonly currentViewport: Nullable<IViewportLike>;
  31151. /**
  31152. * Gets the default empty texture
  31153. */
  31154. readonly emptyTexture: InternalTexture;
  31155. /**
  31156. * Gets the default empty 3D texture
  31157. */
  31158. readonly emptyTexture3D: InternalTexture;
  31159. /**
  31160. * Gets the default empty cube texture
  31161. */
  31162. readonly emptyCubeTexture: InternalTexture;
  31163. /**
  31164. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31165. */
  31166. readonly premultipliedAlpha: boolean;
  31167. /**
  31168. * Creates a new engine
  31169. * @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
  31170. * @param antialias defines enable antialiasing (default: false)
  31171. * @param options defines further options to be sent to the getContext() function
  31172. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31173. */
  31174. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31175. /**
  31176. * Initializes a webVR display and starts listening to display change events
  31177. * The onVRDisplayChangedObservable will be notified upon these changes
  31178. * @returns The onVRDisplayChangedObservable
  31179. */
  31180. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31181. /** @hidden */
  31182. _prepareVRComponent(): void;
  31183. /** @hidden */
  31184. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31185. /** @hidden */
  31186. _submitVRFrame(): void;
  31187. /**
  31188. * Call this function to leave webVR mode
  31189. * Will do nothing if webVR is not supported or if there is no webVR device
  31190. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31191. */
  31192. disableVR(): void;
  31193. /**
  31194. * Gets a boolean indicating that the system is in VR mode and is presenting
  31195. * @returns true if VR mode is engaged
  31196. */
  31197. isVRPresenting(): boolean;
  31198. /** @hidden */
  31199. _requestVRFrame(): void;
  31200. private _disableTouchAction;
  31201. private _rebuildInternalTextures;
  31202. private _rebuildEffects;
  31203. /**
  31204. * Gets a boolean indicating if all created effects are ready
  31205. * @returns true if all effects are ready
  31206. */
  31207. areAllEffectsReady(): boolean;
  31208. private _rebuildBuffers;
  31209. private _initGLContext;
  31210. /**
  31211. * Gets version of the current webGL context
  31212. */
  31213. readonly webGLVersion: number;
  31214. /**
  31215. * Gets a string idenfifying the name of the class
  31216. * @returns "Engine" string
  31217. */
  31218. getClassName(): string;
  31219. /**
  31220. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31221. */
  31222. readonly isStencilEnable: boolean;
  31223. /** @hidden */
  31224. _prepareWorkingCanvas(): void;
  31225. /**
  31226. * Reset the texture cache to empty state
  31227. */
  31228. resetTextureCache(): void;
  31229. /**
  31230. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31231. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31232. * @returns true if engine is in deterministic lock step mode
  31233. */
  31234. isDeterministicLockStep(): boolean;
  31235. /**
  31236. * Gets the max steps when engine is running in deterministic lock step
  31237. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31238. * @returns the max steps
  31239. */
  31240. getLockstepMaxSteps(): number;
  31241. /**
  31242. * Gets an object containing information about the current webGL context
  31243. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31244. */
  31245. getGlInfo(): {
  31246. vendor: string;
  31247. renderer: string;
  31248. version: string;
  31249. };
  31250. /**
  31251. * Gets current aspect ratio
  31252. * @param viewportOwner defines the camera to use to get the aspect ratio
  31253. * @param useScreen defines if screen size must be used (or the current render target if any)
  31254. * @returns a number defining the aspect ratio
  31255. */
  31256. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31257. /**
  31258. * Gets current screen aspect ratio
  31259. * @returns a number defining the aspect ratio
  31260. */
  31261. getScreenAspectRatio(): number;
  31262. /**
  31263. * Gets the current render width
  31264. * @param useScreen defines if screen size must be used (or the current render target if any)
  31265. * @returns a number defining the current render width
  31266. */
  31267. getRenderWidth(useScreen?: boolean): number;
  31268. /**
  31269. * Gets the current render height
  31270. * @param useScreen defines if screen size must be used (or the current render target if any)
  31271. * @returns a number defining the current render height
  31272. */
  31273. getRenderHeight(useScreen?: boolean): number;
  31274. /**
  31275. * Gets the HTML canvas attached with the current webGL context
  31276. * @returns a HTML canvas
  31277. */
  31278. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31279. /**
  31280. * Gets host window
  31281. * @returns the host window object
  31282. */
  31283. getHostWindow(): Window;
  31284. /**
  31285. * Gets host document
  31286. * @returns the host document object
  31287. */
  31288. getHostDocument(): Document;
  31289. /**
  31290. * Gets the client rect of the HTML canvas attached with the current webGL context
  31291. * @returns a client rectanglee
  31292. */
  31293. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31294. /**
  31295. * Defines the hardware scaling level.
  31296. * By default the hardware scaling level is computed from the window device ratio.
  31297. * 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.
  31298. * @param level defines the level to use
  31299. */
  31300. setHardwareScalingLevel(level: number): void;
  31301. /**
  31302. * Gets the current hardware scaling level.
  31303. * By default the hardware scaling level is computed from the window device ratio.
  31304. * 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.
  31305. * @returns a number indicating the current hardware scaling level
  31306. */
  31307. getHardwareScalingLevel(): number;
  31308. /**
  31309. * Gets the list of loaded textures
  31310. * @returns an array containing all loaded textures
  31311. */
  31312. getLoadedTexturesCache(): InternalTexture[];
  31313. /**
  31314. * Gets the object containing all engine capabilities
  31315. * @returns the EngineCapabilities object
  31316. */
  31317. getCaps(): EngineCapabilities;
  31318. /**
  31319. * Gets the current depth function
  31320. * @returns a number defining the depth function
  31321. */
  31322. getDepthFunction(): Nullable<number>;
  31323. /**
  31324. * Sets the current depth function
  31325. * @param depthFunc defines the function to use
  31326. */
  31327. setDepthFunction(depthFunc: number): void;
  31328. /**
  31329. * Sets the current depth function to GREATER
  31330. */
  31331. setDepthFunctionToGreater(): void;
  31332. /**
  31333. * Sets the current depth function to GEQUAL
  31334. */
  31335. setDepthFunctionToGreaterOrEqual(): void;
  31336. /**
  31337. * Sets the current depth function to LESS
  31338. */
  31339. setDepthFunctionToLess(): void;
  31340. private _cachedStencilBuffer;
  31341. private _cachedStencilFunction;
  31342. private _cachedStencilMask;
  31343. private _cachedStencilOperationPass;
  31344. private _cachedStencilOperationFail;
  31345. private _cachedStencilOperationDepthFail;
  31346. private _cachedStencilReference;
  31347. /**
  31348. * Caches the the state of the stencil buffer
  31349. */
  31350. cacheStencilState(): void;
  31351. /**
  31352. * Restores the state of the stencil buffer
  31353. */
  31354. restoreStencilState(): void;
  31355. /**
  31356. * Sets the current depth function to LEQUAL
  31357. */
  31358. setDepthFunctionToLessOrEqual(): void;
  31359. /**
  31360. * Gets a boolean indicating if stencil buffer is enabled
  31361. * @returns the current stencil buffer state
  31362. */
  31363. getStencilBuffer(): boolean;
  31364. /**
  31365. * Enable or disable the stencil buffer
  31366. * @param enable defines if the stencil buffer must be enabled or disabled
  31367. */
  31368. setStencilBuffer(enable: boolean): void;
  31369. /**
  31370. * Gets the current stencil mask
  31371. * @returns a number defining the new stencil mask to use
  31372. */
  31373. getStencilMask(): number;
  31374. /**
  31375. * Sets the current stencil mask
  31376. * @param mask defines the new stencil mask to use
  31377. */
  31378. setStencilMask(mask: number): void;
  31379. /**
  31380. * Gets the current stencil function
  31381. * @returns a number defining the stencil function to use
  31382. */
  31383. getStencilFunction(): number;
  31384. /**
  31385. * Gets the current stencil reference value
  31386. * @returns a number defining the stencil reference value to use
  31387. */
  31388. getStencilFunctionReference(): number;
  31389. /**
  31390. * Gets the current stencil mask
  31391. * @returns a number defining the stencil mask to use
  31392. */
  31393. getStencilFunctionMask(): number;
  31394. /**
  31395. * Sets the current stencil function
  31396. * @param stencilFunc defines the new stencil function to use
  31397. */
  31398. setStencilFunction(stencilFunc: number): void;
  31399. /**
  31400. * Sets the current stencil reference
  31401. * @param reference defines the new stencil reference to use
  31402. */
  31403. setStencilFunctionReference(reference: number): void;
  31404. /**
  31405. * Sets the current stencil mask
  31406. * @param mask defines the new stencil mask to use
  31407. */
  31408. setStencilFunctionMask(mask: number): void;
  31409. /**
  31410. * Gets the current stencil operation when stencil fails
  31411. * @returns a number defining stencil operation to use when stencil fails
  31412. */
  31413. getStencilOperationFail(): number;
  31414. /**
  31415. * Gets the current stencil operation when depth fails
  31416. * @returns a number defining stencil operation to use when depth fails
  31417. */
  31418. getStencilOperationDepthFail(): number;
  31419. /**
  31420. * Gets the current stencil operation when stencil passes
  31421. * @returns a number defining stencil operation to use when stencil passes
  31422. */
  31423. getStencilOperationPass(): number;
  31424. /**
  31425. * Sets the stencil operation to use when stencil fails
  31426. * @param operation defines the stencil operation to use when stencil fails
  31427. */
  31428. setStencilOperationFail(operation: number): void;
  31429. /**
  31430. * Sets the stencil operation to use when depth fails
  31431. * @param operation defines the stencil operation to use when depth fails
  31432. */
  31433. setStencilOperationDepthFail(operation: number): void;
  31434. /**
  31435. * Sets the stencil operation to use when stencil passes
  31436. * @param operation defines the stencil operation to use when stencil passes
  31437. */
  31438. setStencilOperationPass(operation: number): void;
  31439. /**
  31440. * Sets a boolean indicating if the dithering state is enabled or disabled
  31441. * @param value defines the dithering state
  31442. */
  31443. setDitheringState(value: boolean): void;
  31444. /**
  31445. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31446. * @param value defines the rasterizer state
  31447. */
  31448. setRasterizerState(value: boolean): void;
  31449. /**
  31450. * stop executing a render loop function and remove it from the execution array
  31451. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31452. */
  31453. stopRenderLoop(renderFunction?: () => void): void;
  31454. /** @hidden */
  31455. _renderLoop(): void;
  31456. /**
  31457. * Can be used to override the current requestAnimationFrame requester.
  31458. * @hidden
  31459. */
  31460. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31461. /**
  31462. * Register and execute a render loop. The engine can have more than one render function
  31463. * @param renderFunction defines the function to continuously execute
  31464. */
  31465. runRenderLoop(renderFunction: () => void): void;
  31466. /**
  31467. * Toggle full screen mode
  31468. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31469. */
  31470. switchFullscreen(requestPointerLock: boolean): void;
  31471. /**
  31472. * Enters full screen mode
  31473. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31474. */
  31475. enterFullscreen(requestPointerLock: boolean): void;
  31476. /**
  31477. * Exits full screen mode
  31478. */
  31479. exitFullscreen(): void;
  31480. /**
  31481. * Enters Pointerlock mode
  31482. */
  31483. enterPointerlock(): void;
  31484. /**
  31485. * Exits Pointerlock mode
  31486. */
  31487. exitPointerlock(): void;
  31488. /**
  31489. * Clear the current render buffer or the current render target (if any is set up)
  31490. * @param color defines the color to use
  31491. * @param backBuffer defines if the back buffer must be cleared
  31492. * @param depth defines if the depth buffer must be cleared
  31493. * @param stencil defines if the stencil buffer must be cleared
  31494. */
  31495. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31496. /**
  31497. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31498. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31499. * @param y defines the y-coordinate of the corner of the clear rectangle
  31500. * @param width defines the width of the clear rectangle
  31501. * @param height defines the height of the clear rectangle
  31502. * @param clearColor defines the clear color
  31503. */
  31504. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31505. /**
  31506. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31507. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31508. * @param y defines the y-coordinate of the corner of the clear rectangle
  31509. * @param width defines the width of the clear rectangle
  31510. * @param height defines the height of the clear rectangle
  31511. */
  31512. enableScissor(x: number, y: number, width: number, height: number): void;
  31513. /**
  31514. * Disable previously set scissor test rectangle
  31515. */
  31516. disableScissor(): void;
  31517. private _viewportCached;
  31518. /** @hidden */
  31519. _viewport(x: number, y: number, width: number, height: number): void;
  31520. /**
  31521. * Set the WebGL's viewport
  31522. * @param viewport defines the viewport element to be used
  31523. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31524. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31525. */
  31526. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31527. /**
  31528. * Directly set the WebGL Viewport
  31529. * @param x defines the x coordinate of the viewport (in screen space)
  31530. * @param y defines the y coordinate of the viewport (in screen space)
  31531. * @param width defines the width of the viewport (in screen space)
  31532. * @param height defines the height of the viewport (in screen space)
  31533. * @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
  31534. */
  31535. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31536. /**
  31537. * Begin a new frame
  31538. */
  31539. beginFrame(): void;
  31540. /**
  31541. * Enf the current frame
  31542. */
  31543. endFrame(): void;
  31544. /**
  31545. * Resize the view according to the canvas' size
  31546. */
  31547. resize(): void;
  31548. /**
  31549. * Force a specific size of the canvas
  31550. * @param width defines the new canvas' width
  31551. * @param height defines the new canvas' height
  31552. */
  31553. setSize(width: number, height: number): void;
  31554. /**
  31555. * Binds the frame buffer to the specified texture.
  31556. * @param texture The texture to render to or null for the default canvas
  31557. * @param faceIndex The face of the texture to render to in case of cube texture
  31558. * @param requiredWidth The width of the target to render to
  31559. * @param requiredHeight The height of the target to render to
  31560. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31561. * @param depthStencilTexture The depth stencil texture to use to render
  31562. * @param lodLevel defines le lod level to bind to the frame buffer
  31563. */
  31564. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31565. /** @hidden */
  31566. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31567. /**
  31568. * Unbind the current render target texture from the webGL context
  31569. * @param texture defines the render target texture to unbind
  31570. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31571. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31572. */
  31573. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31574. /**
  31575. * Force the mipmap generation for the given render target texture
  31576. * @param texture defines the render target texture to use
  31577. */
  31578. generateMipMapsForCubemap(texture: InternalTexture): void;
  31579. /**
  31580. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31581. */
  31582. flushFramebuffer(): void;
  31583. /**
  31584. * Unbind the current render target and bind the default framebuffer
  31585. */
  31586. restoreDefaultFramebuffer(): void;
  31587. /**
  31588. * Create an uniform buffer
  31589. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31590. * @param elements defines the content of the uniform buffer
  31591. * @returns the webGL uniform buffer
  31592. */
  31593. createUniformBuffer(elements: FloatArray): DataBuffer;
  31594. /**
  31595. * Create a dynamic uniform buffer
  31596. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31597. * @param elements defines the content of the uniform buffer
  31598. * @returns the webGL uniform buffer
  31599. */
  31600. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31601. /**
  31602. * Update an existing uniform buffer
  31603. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31604. * @param uniformBuffer defines the target uniform buffer
  31605. * @param elements defines the content to update
  31606. * @param offset defines the offset in the uniform buffer where update should start
  31607. * @param count defines the size of the data to update
  31608. */
  31609. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31610. private _resetVertexBufferBinding;
  31611. /**
  31612. * Creates a vertex buffer
  31613. * @param data the data for the vertex buffer
  31614. * @returns the new WebGL static buffer
  31615. */
  31616. createVertexBuffer(data: DataArray): DataBuffer;
  31617. /**
  31618. * Creates a dynamic vertex buffer
  31619. * @param data the data for the dynamic vertex buffer
  31620. * @returns the new WebGL dynamic buffer
  31621. */
  31622. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31623. /**
  31624. * Update a dynamic index buffer
  31625. * @param indexBuffer defines the target index buffer
  31626. * @param indices defines the data to update
  31627. * @param offset defines the offset in the target index buffer where update should start
  31628. */
  31629. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31630. /**
  31631. * Updates a dynamic vertex buffer.
  31632. * @param vertexBuffer the vertex buffer to update
  31633. * @param data the data used to update the vertex buffer
  31634. * @param byteOffset the byte offset of the data
  31635. * @param byteLength the byte length of the data
  31636. */
  31637. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31638. private _resetIndexBufferBinding;
  31639. /**
  31640. * Creates a new index buffer
  31641. * @param indices defines the content of the index buffer
  31642. * @param updatable defines if the index buffer must be updatable
  31643. * @returns a new webGL buffer
  31644. */
  31645. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31646. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31647. /**
  31648. * Bind a webGL buffer to the webGL context
  31649. * @param buffer defines the buffer to bind
  31650. */
  31651. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31652. /**
  31653. * Bind an uniform buffer to the current webGL context
  31654. * @param buffer defines the buffer to bind
  31655. */
  31656. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31657. /**
  31658. * Bind a buffer to the current webGL context at a given location
  31659. * @param buffer defines the buffer to bind
  31660. * @param location defines the index where to bind the buffer
  31661. */
  31662. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31663. /**
  31664. * Bind a specific block at a given index in a specific shader program
  31665. * @param pipelineContext defines the pipeline context to use
  31666. * @param blockName defines the block name
  31667. * @param index defines the index where to bind the block
  31668. */
  31669. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31670. private bindIndexBuffer;
  31671. private bindBuffer;
  31672. /**
  31673. * update the bound buffer with the given data
  31674. * @param data defines the data to update
  31675. */
  31676. updateArrayBuffer(data: Float32Array): void;
  31677. private _vertexAttribPointer;
  31678. private _bindIndexBufferWithCache;
  31679. private _bindVertexBuffersAttributes;
  31680. /**
  31681. * Records a vertex array object
  31682. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31683. * @param vertexBuffers defines the list of vertex buffers to store
  31684. * @param indexBuffer defines the index buffer to store
  31685. * @param effect defines the effect to store
  31686. * @returns the new vertex array object
  31687. */
  31688. recordVertexArrayObject(vertexBuffers: {
  31689. [key: string]: VertexBuffer;
  31690. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31691. /**
  31692. * Bind a specific vertex array object
  31693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31694. * @param vertexArrayObject defines the vertex array object to bind
  31695. * @param indexBuffer defines the index buffer to bind
  31696. */
  31697. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31698. /**
  31699. * Bind webGl buffers directly to the webGL context
  31700. * @param vertexBuffer defines the vertex buffer to bind
  31701. * @param indexBuffer defines the index buffer to bind
  31702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31704. * @param effect defines the effect associated with the vertex buffer
  31705. */
  31706. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31707. private _unbindVertexArrayObject;
  31708. /**
  31709. * Bind a list of vertex buffers to the webGL context
  31710. * @param vertexBuffers defines the list of vertex buffers to bind
  31711. * @param indexBuffer defines the index buffer to bind
  31712. * @param effect defines the effect associated with the vertex buffers
  31713. */
  31714. bindBuffers(vertexBuffers: {
  31715. [key: string]: Nullable<VertexBuffer>;
  31716. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31717. /**
  31718. * Unbind all instance attributes
  31719. */
  31720. unbindInstanceAttributes(): void;
  31721. /**
  31722. * Release and free the memory of a vertex array object
  31723. * @param vao defines the vertex array object to delete
  31724. */
  31725. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31726. /** @hidden */
  31727. _releaseBuffer(buffer: DataBuffer): boolean;
  31728. protected _deleteBuffer(buffer: DataBuffer): void;
  31729. /**
  31730. * Creates a webGL buffer to use with instanciation
  31731. * @param capacity defines the size of the buffer
  31732. * @returns the webGL buffer
  31733. */
  31734. createInstancesBuffer(capacity: number): DataBuffer;
  31735. /**
  31736. * Delete a webGL buffer used with instanciation
  31737. * @param buffer defines the webGL buffer to delete
  31738. */
  31739. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31740. /**
  31741. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31742. * @param instancesBuffer defines the webGL buffer to update and bind
  31743. * @param data defines the data to store in the buffer
  31744. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31745. */
  31746. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31747. /**
  31748. * Apply all cached states (depth, culling, stencil and alpha)
  31749. */
  31750. applyStates(): void;
  31751. /**
  31752. * Send a draw order
  31753. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31754. * @param indexStart defines the starting index
  31755. * @param indexCount defines the number of index to draw
  31756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31757. */
  31758. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31759. /**
  31760. * Draw a list of points
  31761. * @param verticesStart defines the index of first vertex to draw
  31762. * @param verticesCount defines the count of vertices to draw
  31763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31764. */
  31765. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31766. /**
  31767. * Draw a list of unindexed primitives
  31768. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31769. * @param verticesStart defines the index of first vertex to draw
  31770. * @param verticesCount defines the count of vertices to draw
  31771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31772. */
  31773. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31774. /**
  31775. * Draw a list of indexed primitives
  31776. * @param fillMode defines the primitive to use
  31777. * @param indexStart defines the starting index
  31778. * @param indexCount defines the number of index to draw
  31779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31780. */
  31781. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31782. /**
  31783. * Draw a list of unindexed primitives
  31784. * @param fillMode defines the primitive to use
  31785. * @param verticesStart defines the index of first vertex to draw
  31786. * @param verticesCount defines the count of vertices to draw
  31787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31788. */
  31789. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31790. private _drawMode;
  31791. /** @hidden */
  31792. _releaseEffect(effect: Effect): void;
  31793. /** @hidden */
  31794. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31795. /**
  31796. * Create a new effect (used to store vertex/fragment shaders)
  31797. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31798. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31799. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31800. * @param samplers defines an array of string used to represent textures
  31801. * @param defines defines the string containing the defines to use to compile the shaders
  31802. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31803. * @param onCompiled defines a function to call when the effect creation is successful
  31804. * @param onError defines a function to call when the effect creation has failed
  31805. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31806. * @returns the new Effect
  31807. */
  31808. 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;
  31809. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31810. private _compileShader;
  31811. private _compileRawShader;
  31812. /**
  31813. * Directly creates a webGL program
  31814. * @param pipelineContext defines the pipeline context to attach to
  31815. * @param vertexCode defines the vertex shader code to use
  31816. * @param fragmentCode defines the fragment shader code to use
  31817. * @param context defines the webGL context to use (if not set, the current one will be used)
  31818. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31819. * @returns the new webGL program
  31820. */
  31821. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31822. /**
  31823. * Creates a webGL program
  31824. * @param pipelineContext defines the pipeline context to attach to
  31825. * @param vertexCode defines the vertex shader code to use
  31826. * @param fragmentCode defines the fragment shader code to use
  31827. * @param defines defines the string containing the defines to use to compile the shaders
  31828. * @param context defines the webGL context to use (if not set, the current one will be used)
  31829. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31830. * @returns the new webGL program
  31831. */
  31832. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31833. /**
  31834. * Creates a new pipeline context
  31835. * @returns the new pipeline
  31836. */
  31837. createPipelineContext(): IPipelineContext;
  31838. private _createShaderProgram;
  31839. private _finalizePipelineContext;
  31840. /** @hidden */
  31841. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31842. /** @hidden */
  31843. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31844. /** @hidden */
  31845. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31846. /**
  31847. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31848. * @param pipelineContext defines the pipeline context to use
  31849. * @param uniformsNames defines the list of uniform names
  31850. * @returns an array of webGL uniform locations
  31851. */
  31852. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31853. /**
  31854. * Gets the lsit of active attributes for a given webGL program
  31855. * @param pipelineContext defines the pipeline context to use
  31856. * @param attributesNames defines the list of attribute names to get
  31857. * @returns an array of indices indicating the offset of each attribute
  31858. */
  31859. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31860. /**
  31861. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31862. * @param effect defines the effect to activate
  31863. */
  31864. enableEffect(effect: Nullable<Effect>): void;
  31865. /**
  31866. * Set the value of an uniform to an array of int32
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param array defines the array of int32 to store
  31869. */
  31870. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31871. /**
  31872. * Set the value of an uniform to an array of int32 (stored as vec2)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param array defines the array of int32 to store
  31875. */
  31876. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31877. /**
  31878. * Set the value of an uniform to an array of int32 (stored as vec3)
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param array defines the array of int32 to store
  31881. */
  31882. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31883. /**
  31884. * Set the value of an uniform to an array of int32 (stored as vec4)
  31885. * @param uniform defines the webGL uniform location where to store the value
  31886. * @param array defines the array of int32 to store
  31887. */
  31888. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31889. /**
  31890. * Set the value of an uniform to an array of float32
  31891. * @param uniform defines the webGL uniform location where to store the value
  31892. * @param array defines the array of float32 to store
  31893. */
  31894. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31895. /**
  31896. * Set the value of an uniform to an array of float32 (stored as vec2)
  31897. * @param uniform defines the webGL uniform location where to store the value
  31898. * @param array defines the array of float32 to store
  31899. */
  31900. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31901. /**
  31902. * Set the value of an uniform to an array of float32 (stored as vec3)
  31903. * @param uniform defines the webGL uniform location where to store the value
  31904. * @param array defines the array of float32 to store
  31905. */
  31906. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31907. /**
  31908. * Set the value of an uniform to an array of float32 (stored as vec4)
  31909. * @param uniform defines the webGL uniform location where to store the value
  31910. * @param array defines the array of float32 to store
  31911. */
  31912. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31913. /**
  31914. * Set the value of an uniform to an array of number
  31915. * @param uniform defines the webGL uniform location where to store the value
  31916. * @param array defines the array of number to store
  31917. */
  31918. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31919. /**
  31920. * Set the value of an uniform to an array of number (stored as vec2)
  31921. * @param uniform defines the webGL uniform location where to store the value
  31922. * @param array defines the array of number to store
  31923. */
  31924. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31925. /**
  31926. * Set the value of an uniform to an array of number (stored as vec3)
  31927. * @param uniform defines the webGL uniform location where to store the value
  31928. * @param array defines the array of number to store
  31929. */
  31930. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31931. /**
  31932. * Set the value of an uniform to an array of number (stored as vec4)
  31933. * @param uniform defines the webGL uniform location where to store the value
  31934. * @param array defines the array of number to store
  31935. */
  31936. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31937. /**
  31938. * Set the value of an uniform to an array of float32 (stored as matrices)
  31939. * @param uniform defines the webGL uniform location where to store the value
  31940. * @param matrices defines the array of float32 to store
  31941. */
  31942. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31943. /**
  31944. * Set the value of an uniform to a matrix (3x3)
  31945. * @param uniform defines the webGL uniform location where to store the value
  31946. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31947. */
  31948. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31949. /**
  31950. * Set the value of an uniform to a matrix (2x2)
  31951. * @param uniform defines the webGL uniform location where to store the value
  31952. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31953. */
  31954. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31955. /**
  31956. * Set the value of an uniform to a number (int)
  31957. * @param uniform defines the webGL uniform location where to store the value
  31958. * @param value defines the int number to store
  31959. */
  31960. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31961. /**
  31962. * Set the value of an uniform to a number (float)
  31963. * @param uniform defines the webGL uniform location where to store the value
  31964. * @param value defines the float number to store
  31965. */
  31966. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31967. /**
  31968. * Set the value of an uniform to a vec2
  31969. * @param uniform defines the webGL uniform location where to store the value
  31970. * @param x defines the 1st component of the value
  31971. * @param y defines the 2nd component of the value
  31972. */
  31973. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31974. /**
  31975. * Set the value of an uniform to a vec3
  31976. * @param uniform defines the webGL uniform location where to store the value
  31977. * @param x defines the 1st component of the value
  31978. * @param y defines the 2nd component of the value
  31979. * @param z defines the 3rd component of the value
  31980. */
  31981. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31982. /**
  31983. * Set the value of an uniform to a boolean
  31984. * @param uniform defines the webGL uniform location where to store the value
  31985. * @param bool defines the boolean to store
  31986. */
  31987. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31988. /**
  31989. * Set the value of an uniform to a vec4
  31990. * @param uniform defines the webGL uniform location where to store the value
  31991. * @param x defines the 1st component of the value
  31992. * @param y defines the 2nd component of the value
  31993. * @param z defines the 3rd component of the value
  31994. * @param w defines the 4th component of the value
  31995. */
  31996. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31997. /**
  31998. * Sets a Color4 on a uniform variable
  31999. * @param uniform defines the uniform location
  32000. * @param color4 defines the value to be set
  32001. */
  32002. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32003. /**
  32004. * Set various states to the webGL context
  32005. * @param culling defines backface culling state
  32006. * @param zOffset defines the value to apply to zOffset (0 by default)
  32007. * @param force defines if states must be applied even if cache is up to date
  32008. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32009. */
  32010. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32011. /**
  32012. * Set the z offset to apply to current rendering
  32013. * @param value defines the offset to apply
  32014. */
  32015. setZOffset(value: number): void;
  32016. /**
  32017. * Gets the current value of the zOffset
  32018. * @returns the current zOffset state
  32019. */
  32020. getZOffset(): number;
  32021. /**
  32022. * Enable or disable depth buffering
  32023. * @param enable defines the state to set
  32024. */
  32025. setDepthBuffer(enable: boolean): void;
  32026. /**
  32027. * Gets a boolean indicating if depth writing is enabled
  32028. * @returns the current depth writing state
  32029. */
  32030. getDepthWrite(): boolean;
  32031. /**
  32032. * Enable or disable depth writing
  32033. * @param enable defines the state to set
  32034. */
  32035. setDepthWrite(enable: boolean): void;
  32036. /**
  32037. * Enable or disable color writing
  32038. * @param enable defines the state to set
  32039. */
  32040. setColorWrite(enable: boolean): void;
  32041. /**
  32042. * Gets a boolean indicating if color writing is enabled
  32043. * @returns the current color writing state
  32044. */
  32045. getColorWrite(): boolean;
  32046. /**
  32047. * Sets alpha constants used by some alpha blending modes
  32048. * @param r defines the red component
  32049. * @param g defines the green component
  32050. * @param b defines the blue component
  32051. * @param a defines the alpha component
  32052. */
  32053. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32054. /**
  32055. * Sets the current alpha mode
  32056. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32057. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32059. */
  32060. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32061. /**
  32062. * Gets the current alpha mode
  32063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32064. * @returns the current alpha mode
  32065. */
  32066. getAlphaMode(): number;
  32067. /**
  32068. * Clears the list of texture accessible through engine.
  32069. * This can help preventing texture load conflict due to name collision.
  32070. */
  32071. clearInternalTexturesCache(): void;
  32072. /**
  32073. * Force the entire cache to be cleared
  32074. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32075. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32076. */
  32077. wipeCaches(bruteForce?: boolean): void;
  32078. /**
  32079. * Set the compressed texture format to use, based on the formats you have, and the formats
  32080. * supported by the hardware / browser.
  32081. *
  32082. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32083. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32084. * to API arguments needed to compressed textures. This puts the burden on the container
  32085. * generator to house the arcane code for determining these for current & future formats.
  32086. *
  32087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32089. *
  32090. * Note: The result of this call is not taken into account when a texture is base64.
  32091. *
  32092. * @param formatsAvailable defines the list of those format families you have created
  32093. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32094. *
  32095. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32096. * @returns The extension selected.
  32097. */
  32098. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32099. /** @hidden */
  32100. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32101. min: number;
  32102. mag: number;
  32103. };
  32104. /** @hidden */
  32105. _createTexture(): WebGLTexture;
  32106. /**
  32107. * Usually called from Texture.ts.
  32108. * Passed information to create a WebGLTexture
  32109. * @param urlArg defines a value which contains one of the following:
  32110. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32111. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32112. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32113. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32114. * @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)
  32115. * @param scene needed for loading to the correct scene
  32116. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32117. * @param onLoad optional callback to be called upon successful completion
  32118. * @param onError optional callback to be called upon failure
  32119. * @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
  32120. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32121. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32122. * @param forcedExtension defines the extension to use to pick the right loader
  32123. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32124. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32125. */
  32126. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32127. /**
  32128. * @hidden
  32129. * Rescales a texture
  32130. * @param source input texutre
  32131. * @param destination destination texture
  32132. * @param scene scene to use to render the resize
  32133. * @param internalFormat format to use when resizing
  32134. * @param onComplete callback to be called when resize has completed
  32135. */
  32136. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32137. private _unpackFlipYCached;
  32138. /**
  32139. * In case you are sharing the context with other applications, it might
  32140. * be interested to not cache the unpack flip y state to ensure a consistent
  32141. * value would be set.
  32142. */
  32143. enableUnpackFlipYCached: boolean;
  32144. /** @hidden */
  32145. _unpackFlipY(value: boolean): void;
  32146. /** @hidden */
  32147. _getUnpackAlignement(): number;
  32148. /**
  32149. * Creates a dynamic texture
  32150. * @param width defines the width of the texture
  32151. * @param height defines the height of the texture
  32152. * @param generateMipMaps defines if the engine should generate the mip levels
  32153. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32154. * @returns the dynamic texture inside an InternalTexture
  32155. */
  32156. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32157. /**
  32158. * Update the sampling mode of a given texture
  32159. * @param samplingMode defines the required sampling mode
  32160. * @param texture defines the texture to update
  32161. */
  32162. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32163. /**
  32164. * Update the content of a dynamic texture
  32165. * @param texture defines the texture to update
  32166. * @param canvas defines the canvas containing the source
  32167. * @param invertY defines if data must be stored with Y axis inverted
  32168. * @param premulAlpha defines if alpha is stored as premultiplied
  32169. * @param format defines the format of the data
  32170. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32171. */
  32172. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32173. /**
  32174. * Update a video texture
  32175. * @param texture defines the texture to update
  32176. * @param video defines the video element to use
  32177. * @param invertY defines if data must be stored with Y axis inverted
  32178. */
  32179. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32180. /**
  32181. * Updates a depth texture Comparison Mode and Function.
  32182. * If the comparison Function is equal to 0, the mode will be set to none.
  32183. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32184. * @param texture The texture to set the comparison function for
  32185. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32186. */
  32187. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32188. /** @hidden */
  32189. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32190. width: number;
  32191. height: number;
  32192. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32193. /**
  32194. * Creates a depth stencil texture.
  32195. * This is only available in WebGL 2 or with the depth texture extension available.
  32196. * @param size The size of face edge in the texture.
  32197. * @param options The options defining the texture.
  32198. * @returns The texture
  32199. */
  32200. createDepthStencilTexture(size: number | {
  32201. width: number;
  32202. height: number;
  32203. }, options: DepthTextureCreationOptions): InternalTexture;
  32204. /**
  32205. * Creates a depth stencil texture.
  32206. * This is only available in WebGL 2 or with the depth texture extension available.
  32207. * @param size The size of face edge in the texture.
  32208. * @param options The options defining the texture.
  32209. * @returns The texture
  32210. */
  32211. private _createDepthStencilTexture;
  32212. /**
  32213. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32214. * @param renderTarget The render target to set the frame buffer for
  32215. */
  32216. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32217. /**
  32218. * Creates a new render target texture
  32219. * @param size defines the size of the texture
  32220. * @param options defines the options used to create the texture
  32221. * @returns a new render target texture stored in an InternalTexture
  32222. */
  32223. createRenderTargetTexture(size: number | {
  32224. width: number;
  32225. height: number;
  32226. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32227. /** @hidden */
  32228. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32229. /**
  32230. * Updates the sample count of a render target texture
  32231. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32232. * @param texture defines the texture to update
  32233. * @param samples defines the sample count to set
  32234. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32235. */
  32236. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32237. /** @hidden */
  32238. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32239. /** @hidden */
  32240. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32241. /** @hidden */
  32242. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32243. /** @hidden */
  32244. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32245. /**
  32246. * @hidden
  32247. */
  32248. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32249. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32250. private _prepareWebGLTexture;
  32251. /** @hidden */
  32252. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32253. /** @hidden */
  32254. _releaseFramebufferObjects(texture: InternalTexture): void;
  32255. /** @hidden */
  32256. _releaseTexture(texture: InternalTexture): void;
  32257. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32258. protected _setProgram(program: WebGLProgram): void;
  32259. protected _boundUniforms: {
  32260. [key: number]: WebGLUniformLocation;
  32261. };
  32262. /**
  32263. * Binds an effect to the webGL context
  32264. * @param effect defines the effect to bind
  32265. */
  32266. bindSamplers(effect: Effect): void;
  32267. private _activateCurrentTexture;
  32268. /** @hidden */
  32269. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32270. /** @hidden */
  32271. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32272. /**
  32273. * Sets a texture to the webGL context from a postprocess
  32274. * @param channel defines the channel to use
  32275. * @param postProcess defines the source postprocess
  32276. */
  32277. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32278. /**
  32279. * Binds the output of the passed in post process to the texture channel specified
  32280. * @param channel The channel the texture should be bound to
  32281. * @param postProcess The post process which's output should be bound
  32282. */
  32283. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32284. /**
  32285. * Unbind all textures from the webGL context
  32286. */
  32287. unbindAllTextures(): void;
  32288. /**
  32289. * Sets a texture to the according uniform.
  32290. * @param channel The texture channel
  32291. * @param uniform The uniform to set
  32292. * @param texture The texture to apply
  32293. */
  32294. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32295. /**
  32296. * Sets a depth stencil texture from a render target to the according uniform.
  32297. * @param channel The texture channel
  32298. * @param uniform The uniform to set
  32299. * @param texture The render target texture containing the depth stencil texture to apply
  32300. */
  32301. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32302. private _bindSamplerUniformToChannel;
  32303. private _getTextureWrapMode;
  32304. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32305. /**
  32306. * Sets an array of texture to the webGL context
  32307. * @param channel defines the channel where the texture array must be set
  32308. * @param uniform defines the associated uniform location
  32309. * @param textures defines the array of textures to bind
  32310. */
  32311. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32312. /** @hidden */
  32313. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32314. private _setTextureParameterFloat;
  32315. private _setTextureParameterInteger;
  32316. /**
  32317. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32318. * @param x defines the x coordinate of the rectangle where pixels must be read
  32319. * @param y defines the y coordinate of the rectangle where pixels must be read
  32320. * @param width defines the width of the rectangle where pixels must be read
  32321. * @param height defines the height of the rectangle where pixels must be read
  32322. * @returns a Uint8Array containing RGBA colors
  32323. */
  32324. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32325. /**
  32326. * Add an externaly attached data from its key.
  32327. * This method call will fail and return false, if such key already exists.
  32328. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32329. * @param key the unique key that identifies the data
  32330. * @param data the data object to associate to the key for this Engine instance
  32331. * @return true if no such key were already present and the data was added successfully, false otherwise
  32332. */
  32333. addExternalData<T>(key: string, data: T): boolean;
  32334. /**
  32335. * Get an externaly attached data from its key
  32336. * @param key the unique key that identifies the data
  32337. * @return the associated data, if present (can be null), or undefined if not present
  32338. */
  32339. getExternalData<T>(key: string): T;
  32340. /**
  32341. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32342. * @param key the unique key that identifies the data
  32343. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32344. * @return the associated data, can be null if the factory returned null.
  32345. */
  32346. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32347. /**
  32348. * Remove an externaly attached data from the Engine instance
  32349. * @param key the unique key that identifies the data
  32350. * @return true if the data was successfully removed, false if it doesn't exist
  32351. */
  32352. removeExternalData(key: string): boolean;
  32353. /**
  32354. * Unbind all vertex attributes from the webGL context
  32355. */
  32356. unbindAllAttributes(): void;
  32357. /**
  32358. * 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
  32359. */
  32360. releaseEffects(): void;
  32361. /**
  32362. * Dispose and release all associated resources
  32363. */
  32364. dispose(): void;
  32365. /**
  32366. * Display the loading screen
  32367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32368. */
  32369. displayLoadingUI(): void;
  32370. /**
  32371. * Hide the loading screen
  32372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32373. */
  32374. hideLoadingUI(): void;
  32375. /**
  32376. * Gets the current loading screen object
  32377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32378. */
  32379. /**
  32380. * Sets the current loading screen object
  32381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32382. */
  32383. loadingScreen: ILoadingScreen;
  32384. /**
  32385. * Sets the current loading screen text
  32386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32387. */
  32388. loadingUIText: string;
  32389. /**
  32390. * Sets the current loading screen background color
  32391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32392. */
  32393. loadingUIBackgroundColor: string;
  32394. /**
  32395. * Attach a new callback raised when context lost event is fired
  32396. * @param callback defines the callback to call
  32397. */
  32398. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32399. /**
  32400. * Attach a new callback raised when context restored event is fired
  32401. * @param callback defines the callback to call
  32402. */
  32403. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32404. /**
  32405. * Gets the source code of the vertex shader associated with a specific webGL program
  32406. * @param program defines the program to use
  32407. * @returns a string containing the source code of the vertex shader associated with the program
  32408. */
  32409. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32410. /**
  32411. * Gets the source code of the fragment shader associated with a specific webGL program
  32412. * @param program defines the program to use
  32413. * @returns a string containing the source code of the fragment shader associated with the program
  32414. */
  32415. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32416. /**
  32417. * Get the current error code of the webGL context
  32418. * @returns the error code
  32419. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32420. */
  32421. getError(): number;
  32422. /**
  32423. * Gets the current framerate
  32424. * @returns a number representing the framerate
  32425. */
  32426. getFps(): number;
  32427. /**
  32428. * Gets the time spent between current and previous frame
  32429. * @returns a number representing the delta time in ms
  32430. */
  32431. getDeltaTime(): number;
  32432. private _measureFps;
  32433. /** @hidden */
  32434. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32435. private _canRenderToFloatFramebuffer;
  32436. private _canRenderToHalfFloatFramebuffer;
  32437. private _canRenderToFramebuffer;
  32438. /** @hidden */
  32439. _getWebGLTextureType(type: number): number;
  32440. /** @hidden */
  32441. _getInternalFormat(format: number): number;
  32442. /** @hidden */
  32443. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32444. /** @hidden */
  32445. _getRGBAMultiSampleBufferFormat(type: number): number;
  32446. /** @hidden */
  32447. _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;
  32448. /** @hidden */
  32449. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32450. /**
  32451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32452. * @returns true if the engine can be created
  32453. * @ignorenaming
  32454. */
  32455. static isSupported(): boolean;
  32456. /**
  32457. * Find the next highest power of two.
  32458. * @param x Number to start search from.
  32459. * @return Next highest power of two.
  32460. */
  32461. static CeilingPOT(x: number): number;
  32462. /**
  32463. * Find the next lowest power of two.
  32464. * @param x Number to start search from.
  32465. * @return Next lowest power of two.
  32466. */
  32467. static FloorPOT(x: number): number;
  32468. /**
  32469. * Find the nearest power of two.
  32470. * @param x Number to start search from.
  32471. * @return Next nearest power of two.
  32472. */
  32473. static NearestPOT(x: number): number;
  32474. /**
  32475. * Get the closest exponent of two
  32476. * @param value defines the value to approximate
  32477. * @param max defines the maximum value to return
  32478. * @param mode defines how to define the closest value
  32479. * @returns closest exponent of two of the given value
  32480. */
  32481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32482. /**
  32483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32484. * @param func - the function to be called
  32485. * @param requester - the object that will request the next frame. Falls back to window.
  32486. * @returns frame number
  32487. */
  32488. static QueueNewFrame(func: () => void, requester?: any): number;
  32489. /**
  32490. * Ask the browser to promote the current element to pointerlock mode
  32491. * @param element defines the DOM element to promote
  32492. */
  32493. static _RequestPointerlock(element: HTMLElement): void;
  32494. /**
  32495. * Asks the browser to exit pointerlock mode
  32496. */
  32497. static _ExitPointerlock(): void;
  32498. /**
  32499. * Ask the browser to promote the current element to fullscreen rendering mode
  32500. * @param element defines the DOM element to promote
  32501. */
  32502. static _RequestFullscreen(element: HTMLElement): void;
  32503. /**
  32504. * Asks the browser to exit fullscreen mode
  32505. */
  32506. static _ExitFullscreen(): void;
  32507. }
  32508. }
  32509. declare module "babylonjs/Engines/engineStore" {
  32510. import { Nullable } from "babylonjs/types";
  32511. import { Engine } from "babylonjs/Engines/engine";
  32512. import { Scene } from "babylonjs/scene";
  32513. /**
  32514. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32515. * during the life time of the application.
  32516. */
  32517. export class EngineStore {
  32518. /** Gets the list of created engines */
  32519. static Instances: import("babylonjs/Engines/engine").Engine[];
  32520. /** @hidden */
  32521. static _LastCreatedScene: Nullable<Scene>;
  32522. /**
  32523. * Gets the latest created engine
  32524. */
  32525. static readonly LastCreatedEngine: Nullable<Engine>;
  32526. /**
  32527. * Gets the latest created scene
  32528. */
  32529. static readonly LastCreatedScene: Nullable<Scene>;
  32530. /**
  32531. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32532. * @ignorenaming
  32533. */
  32534. static UseFallbackTexture: boolean;
  32535. /**
  32536. * Texture content used if a texture cannot loaded
  32537. * @ignorenaming
  32538. */
  32539. static FallbackTexture: string;
  32540. }
  32541. }
  32542. declare module "babylonjs/Misc/promise" {
  32543. /**
  32544. * Helper class that provides a small promise polyfill
  32545. */
  32546. export class PromisePolyfill {
  32547. /**
  32548. * Static function used to check if the polyfill is required
  32549. * If this is the case then the function will inject the polyfill to window.Promise
  32550. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32551. */
  32552. static Apply(force?: boolean): void;
  32553. }
  32554. }
  32555. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32556. /**
  32557. * Interface for screenshot methods with describe argument called `size` as object with options
  32558. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32559. */
  32560. export interface IScreenshotSize {
  32561. /**
  32562. * number in pixels for canvas height
  32563. */
  32564. height?: number;
  32565. /**
  32566. * multiplier allowing render at a higher or lower resolution
  32567. * If value is defined then height and width will be ignored and taken from camera
  32568. */
  32569. precision?: number;
  32570. /**
  32571. * number in pixels for canvas width
  32572. */
  32573. width?: number;
  32574. }
  32575. }
  32576. declare module "babylonjs/Misc/tools" {
  32577. import { Nullable, float } from "babylonjs/types";
  32578. import { DomManagement } from "babylonjs/Misc/domManagement";
  32579. import { WebRequest } from "babylonjs/Misc/webRequest";
  32580. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32581. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32582. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32583. import { Camera } from "babylonjs/Cameras/camera";
  32584. import { Engine } from "babylonjs/Engines/engine";
  32585. interface IColor4Like {
  32586. r: float;
  32587. g: float;
  32588. b: float;
  32589. a: float;
  32590. }
  32591. /**
  32592. * Class containing a set of static utilities functions
  32593. */
  32594. export class Tools {
  32595. /**
  32596. * Gets or sets the base URL to use to load assets
  32597. */
  32598. static BaseUrl: string;
  32599. /**
  32600. * Enable/Disable Custom HTTP Request Headers globally.
  32601. * default = false
  32602. * @see CustomRequestHeaders
  32603. */
  32604. static UseCustomRequestHeaders: boolean;
  32605. /**
  32606. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32607. * i.e. when loading files, where the server/service expects an Authorization header
  32608. */
  32609. static CustomRequestHeaders: {
  32610. [key: string]: string;
  32611. };
  32612. /**
  32613. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32614. */
  32615. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32616. /**
  32617. * Default behaviour for cors in the application.
  32618. * It can be a string if the expected behavior is identical in the entire app.
  32619. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32620. */
  32621. static CorsBehavior: string | ((url: string | string[]) => string);
  32622. /**
  32623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32624. * @ignorenaming
  32625. */
  32626. static UseFallbackTexture: boolean;
  32627. /**
  32628. * Use this object to register external classes like custom textures or material
  32629. * to allow the laoders to instantiate them
  32630. */
  32631. static RegisteredExternalClasses: {
  32632. [key: string]: Object;
  32633. };
  32634. /**
  32635. * Texture content used if a texture cannot loaded
  32636. * @ignorenaming
  32637. */
  32638. static fallbackTexture: string;
  32639. /**
  32640. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32641. * @param u defines the coordinate on X axis
  32642. * @param v defines the coordinate on Y axis
  32643. * @param width defines the width of the source data
  32644. * @param height defines the height of the source data
  32645. * @param pixels defines the source byte array
  32646. * @param color defines the output color
  32647. */
  32648. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32649. /**
  32650. * Interpolates between a and b via alpha
  32651. * @param a The lower value (returned when alpha = 0)
  32652. * @param b The upper value (returned when alpha = 1)
  32653. * @param alpha The interpolation-factor
  32654. * @return The mixed value
  32655. */
  32656. static Mix(a: number, b: number, alpha: number): number;
  32657. /**
  32658. * Tries to instantiate a new object from a given class name
  32659. * @param className defines the class name to instantiate
  32660. * @returns the new object or null if the system was not able to do the instantiation
  32661. */
  32662. static Instantiate(className: string): any;
  32663. /**
  32664. * Provides a slice function that will work even on IE
  32665. * @param data defines the array to slice
  32666. * @param start defines the start of the data (optional)
  32667. * @param end defines the end of the data (optional)
  32668. * @returns the new sliced array
  32669. */
  32670. static Slice<T>(data: T, start?: number, end?: number): T;
  32671. /**
  32672. * Polyfill for setImmediate
  32673. * @param action defines the action to execute after the current execution block
  32674. */
  32675. static SetImmediate(action: () => void): void;
  32676. /**
  32677. * Function indicating if a number is an exponent of 2
  32678. * @param value defines the value to test
  32679. * @returns true if the value is an exponent of 2
  32680. */
  32681. static IsExponentOfTwo(value: number): boolean;
  32682. private static _tmpFloatArray;
  32683. /**
  32684. * Returns the nearest 32-bit single precision float representation of a Number
  32685. * @param value A Number. If the parameter is of a different type, it will get converted
  32686. * to a number or to NaN if it cannot be converted
  32687. * @returns number
  32688. */
  32689. static FloatRound(value: number): number;
  32690. /**
  32691. * Extracts the filename from a path
  32692. * @param path defines the path to use
  32693. * @returns the filename
  32694. */
  32695. static GetFilename(path: string): string;
  32696. /**
  32697. * Extracts the "folder" part of a path (everything before the filename).
  32698. * @param uri The URI to extract the info from
  32699. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32700. * @returns The "folder" part of the path
  32701. */
  32702. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32703. /**
  32704. * Extracts text content from a DOM element hierarchy
  32705. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32706. */
  32707. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32708. /**
  32709. * Convert an angle in radians to degrees
  32710. * @param angle defines the angle to convert
  32711. * @returns the angle in degrees
  32712. */
  32713. static ToDegrees(angle: number): number;
  32714. /**
  32715. * Convert an angle in degrees to radians
  32716. * @param angle defines the angle to convert
  32717. * @returns the angle in radians
  32718. */
  32719. static ToRadians(angle: number): number;
  32720. /**
  32721. * Encode a buffer to a base64 string
  32722. * @param buffer defines the buffer to encode
  32723. * @returns the encoded string
  32724. */
  32725. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32726. /**
  32727. * Returns an array if obj is not an array
  32728. * @param obj defines the object to evaluate as an array
  32729. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32730. * @returns either obj directly if obj is an array or a new array containing obj
  32731. */
  32732. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32733. /**
  32734. * Gets the pointer prefix to use
  32735. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32736. */
  32737. static GetPointerPrefix(): string;
  32738. /**
  32739. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32740. * @param url define the url we are trying
  32741. * @param element define the dom element where to configure the cors policy
  32742. */
  32743. static SetCorsBehavior(url: string | string[], element: {
  32744. crossOrigin: string | null;
  32745. }): void;
  32746. /**
  32747. * Removes unwanted characters from an url
  32748. * @param url defines the url to clean
  32749. * @returns the cleaned url
  32750. */
  32751. static CleanUrl(url: string): string;
  32752. /**
  32753. * Gets or sets a function used to pre-process url before using them to load assets
  32754. */
  32755. static PreprocessUrl: (url: string) => string;
  32756. /**
  32757. * Loads an image as an HTMLImageElement.
  32758. * @param input url string, ArrayBuffer, or Blob to load
  32759. * @param onLoad callback called when the image successfully loads
  32760. * @param onError callback called when the image fails to load
  32761. * @param offlineProvider offline provider for caching
  32762. * @returns the HTMLImageElement of the loaded image
  32763. */
  32764. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32765. /**
  32766. * Loads a file
  32767. * @param url url string, ArrayBuffer, or Blob to load
  32768. * @param onSuccess callback called when the file successfully loads
  32769. * @param onProgress callback called while file is loading (if the server supports this mode)
  32770. * @param offlineProvider defines the offline provider for caching
  32771. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32772. * @param onError callback called when the file fails to load
  32773. * @returns a file request object
  32774. */
  32775. 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;
  32776. /**
  32777. * Loads a file from a url
  32778. * @param url the file url to load
  32779. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32780. */
  32781. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32782. /**
  32783. * Load a script (identified by an url). When the url returns, the
  32784. * content of this file is added into a new script element, attached to the DOM (body element)
  32785. * @param scriptUrl defines the url of the script to laod
  32786. * @param onSuccess defines the callback called when the script is loaded
  32787. * @param onError defines the callback to call if an error occurs
  32788. * @param scriptId defines the id of the script element
  32789. */
  32790. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32791. /**
  32792. * Load an asynchronous script (identified by an url). When the url returns, the
  32793. * content of this file is added into a new script element, attached to the DOM (body element)
  32794. * @param scriptUrl defines the url of the script to laod
  32795. * @param scriptId defines the id of the script element
  32796. * @returns a promise request object
  32797. */
  32798. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32799. /**
  32800. * Loads a file from a blob
  32801. * @param fileToLoad defines the blob to use
  32802. * @param callback defines the callback to call when data is loaded
  32803. * @param progressCallback defines the callback to call during loading process
  32804. * @returns a file request object
  32805. */
  32806. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32807. /**
  32808. * Loads a file
  32809. * @param fileToLoad defines the file to load
  32810. * @param callback defines the callback to call when data is loaded
  32811. * @param progressCallBack defines the callback to call during loading process
  32812. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32813. * @returns a file request object
  32814. */
  32815. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32816. /**
  32817. * Creates a data url from a given string content
  32818. * @param content defines the content to convert
  32819. * @returns the new data url link
  32820. */
  32821. static FileAsURL(content: string): string;
  32822. /**
  32823. * Format the given number to a specific decimal format
  32824. * @param value defines the number to format
  32825. * @param decimals defines the number of decimals to use
  32826. * @returns the formatted string
  32827. */
  32828. static Format(value: number, decimals?: number): string;
  32829. /**
  32830. * Tries to copy an object by duplicating every property
  32831. * @param source defines the source object
  32832. * @param destination defines the target object
  32833. * @param doNotCopyList defines a list of properties to avoid
  32834. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32835. */
  32836. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32837. /**
  32838. * Gets a boolean indicating if the given object has no own property
  32839. * @param obj defines the object to test
  32840. * @returns true if object has no own property
  32841. */
  32842. static IsEmpty(obj: any): boolean;
  32843. /**
  32844. * Function used to register events at window level
  32845. * @param windowElement defines the Window object to use
  32846. * @param events defines the events to register
  32847. */
  32848. static RegisterTopRootEvents(windowElement: Window, events: {
  32849. name: string;
  32850. handler: Nullable<(e: FocusEvent) => any>;
  32851. }[]): void;
  32852. /**
  32853. * Function used to unregister events from window level
  32854. * @param windowElement defines the Window object to use
  32855. * @param events defines the events to unregister
  32856. */
  32857. static UnregisterTopRootEvents(windowElement: Window, events: {
  32858. name: string;
  32859. handler: Nullable<(e: FocusEvent) => any>;
  32860. }[]): void;
  32861. /**
  32862. * @ignore
  32863. */
  32864. static _ScreenshotCanvas: HTMLCanvasElement;
  32865. /**
  32866. * Dumps the current bound framebuffer
  32867. * @param width defines the rendering width
  32868. * @param height defines the rendering height
  32869. * @param engine defines the hosting engine
  32870. * @param successCallback defines the callback triggered once the data are available
  32871. * @param mimeType defines the mime type of the result
  32872. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32873. */
  32874. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32875. /**
  32876. * Converts the canvas data to blob.
  32877. * This acts as a polyfill for browsers not supporting the to blob function.
  32878. * @param canvas Defines the canvas to extract the data from
  32879. * @param successCallback Defines the callback triggered once the data are available
  32880. * @param mimeType Defines the mime type of the result
  32881. */
  32882. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32883. /**
  32884. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32885. * @param successCallback defines the callback triggered once the data are available
  32886. * @param mimeType defines the mime type of the result
  32887. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32888. */
  32889. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32890. /**
  32891. * Downloads a blob in the browser
  32892. * @param blob defines the blob to download
  32893. * @param fileName defines the name of the downloaded file
  32894. */
  32895. static Download(blob: Blob, fileName: string): void;
  32896. /**
  32897. * Captures a screenshot of the current rendering
  32898. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32899. * @param engine defines the rendering engine
  32900. * @param camera defines the source camera
  32901. * @param size This parameter can be set to a single number or to an object with the
  32902. * following (optional) properties: precision, width, height. If a single number is passed,
  32903. * it will be used for both width and height. If an object is passed, the screenshot size
  32904. * will be derived from the parameters. The precision property is a multiplier allowing
  32905. * rendering at a higher or lower resolution
  32906. * @param successCallback defines the callback receives a single parameter which contains the
  32907. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32908. * src parameter of an <img> to display it
  32909. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32910. * Check your browser for supported MIME types
  32911. */
  32912. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32913. /**
  32914. * Captures a screenshot of the current rendering
  32915. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32916. * @param engine defines the rendering engine
  32917. * @param camera defines the source camera
  32918. * @param size This parameter can be set to a single number or to an object with the
  32919. * following (optional) properties: precision, width, height. If a single number is passed,
  32920. * it will be used for both width and height. If an object is passed, the screenshot size
  32921. * will be derived from the parameters. The precision property is a multiplier allowing
  32922. * rendering at a higher or lower resolution
  32923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32924. * Check your browser for supported MIME types
  32925. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32926. * to the src parameter of an <img> to display it
  32927. */
  32928. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32929. /**
  32930. * Generates an image screenshot from the specified camera.
  32931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32932. * @param engine The engine to use for rendering
  32933. * @param camera The camera to use for rendering
  32934. * @param size This parameter can be set to a single number or to an object with the
  32935. * following (optional) properties: precision, width, height. If a single number is passed,
  32936. * it will be used for both width and height. If an object is passed, the screenshot size
  32937. * will be derived from the parameters. The precision property is a multiplier allowing
  32938. * rendering at a higher or lower resolution
  32939. * @param successCallback The callback receives a single parameter which contains the
  32940. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32941. * src parameter of an <img> to display it
  32942. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32943. * Check your browser for supported MIME types
  32944. * @param samples Texture samples (default: 1)
  32945. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32946. * @param fileName A name for for the downloaded file.
  32947. */
  32948. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32949. /**
  32950. * Generates an image screenshot from the specified camera.
  32951. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32952. * @param engine The engine to use for rendering
  32953. * @param camera The camera to use for rendering
  32954. * @param size This parameter can be set to a single number or to an object with the
  32955. * following (optional) properties: precision, width, height. If a single number is passed,
  32956. * it will be used for both width and height. If an object is passed, the screenshot size
  32957. * will be derived from the parameters. The precision property is a multiplier allowing
  32958. * rendering at a higher or lower resolution
  32959. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32960. * Check your browser for supported MIME types
  32961. * @param samples Texture samples (default: 1)
  32962. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32963. * @param fileName A name for for the downloaded file.
  32964. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32965. * to the src parameter of an <img> to display it
  32966. */
  32967. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32968. /**
  32969. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32970. * Be aware Math.random() could cause collisions, but:
  32971. * "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"
  32972. * @returns a pseudo random id
  32973. */
  32974. static RandomId(): string;
  32975. /**
  32976. * Test if the given uri is a base64 string
  32977. * @param uri The uri to test
  32978. * @return True if the uri is a base64 string or false otherwise
  32979. */
  32980. static IsBase64(uri: string): boolean;
  32981. /**
  32982. * Decode the given base64 uri.
  32983. * @param uri The uri to decode
  32984. * @return The decoded base64 data.
  32985. */
  32986. static DecodeBase64(uri: string): ArrayBuffer;
  32987. /**
  32988. * Gets the absolute url.
  32989. * @param url the input url
  32990. * @return the absolute url
  32991. */
  32992. static GetAbsoluteUrl(url: string): string;
  32993. /**
  32994. * No log
  32995. */
  32996. static readonly NoneLogLevel: number;
  32997. /**
  32998. * Only message logs
  32999. */
  33000. static readonly MessageLogLevel: number;
  33001. /**
  33002. * Only warning logs
  33003. */
  33004. static readonly WarningLogLevel: number;
  33005. /**
  33006. * Only error logs
  33007. */
  33008. static readonly ErrorLogLevel: number;
  33009. /**
  33010. * All logs
  33011. */
  33012. static readonly AllLogLevel: number;
  33013. /**
  33014. * Gets a value indicating the number of loading errors
  33015. * @ignorenaming
  33016. */
  33017. static readonly errorsCount: number;
  33018. /**
  33019. * Callback called when a new log is added
  33020. */
  33021. static OnNewCacheEntry: (entry: string) => void;
  33022. /**
  33023. * Log a message to the console
  33024. * @param message defines the message to log
  33025. */
  33026. static Log(message: string): void;
  33027. /**
  33028. * Write a warning message to the console
  33029. * @param message defines the message to log
  33030. */
  33031. static Warn(message: string): void;
  33032. /**
  33033. * Write an error message to the console
  33034. * @param message defines the message to log
  33035. */
  33036. static Error(message: string): void;
  33037. /**
  33038. * Gets current log cache (list of logs)
  33039. */
  33040. static readonly LogCache: string;
  33041. /**
  33042. * Clears the log cache
  33043. */
  33044. static ClearLogCache(): void;
  33045. /**
  33046. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33047. */
  33048. static LogLevels: number;
  33049. /**
  33050. * Checks if the window object exists
  33051. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33052. */
  33053. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33054. /**
  33055. * No performance log
  33056. */
  33057. static readonly PerformanceNoneLogLevel: number;
  33058. /**
  33059. * Use user marks to log performance
  33060. */
  33061. static readonly PerformanceUserMarkLogLevel: number;
  33062. /**
  33063. * Log performance to the console
  33064. */
  33065. static readonly PerformanceConsoleLogLevel: number;
  33066. private static _performance;
  33067. /**
  33068. * Sets the current performance log level
  33069. */
  33070. static PerformanceLogLevel: number;
  33071. private static _StartPerformanceCounterDisabled;
  33072. private static _EndPerformanceCounterDisabled;
  33073. private static _StartUserMark;
  33074. private static _EndUserMark;
  33075. private static _StartPerformanceConsole;
  33076. private static _EndPerformanceConsole;
  33077. /**
  33078. * Starts a performance counter
  33079. */
  33080. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33081. /**
  33082. * Ends a specific performance coutner
  33083. */
  33084. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33085. /**
  33086. * Gets either window.performance.now() if supported or Date.now() else
  33087. */
  33088. static readonly Now: number;
  33089. /**
  33090. * This method will return the name of the class used to create the instance of the given object.
  33091. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33092. * @param object the object to get the class name from
  33093. * @param isType defines if the object is actually a type
  33094. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33095. */
  33096. static GetClassName(object: any, isType?: boolean): string;
  33097. /**
  33098. * Gets the first element of an array satisfying a given predicate
  33099. * @param array defines the array to browse
  33100. * @param predicate defines the predicate to use
  33101. * @returns null if not found or the element
  33102. */
  33103. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33104. /**
  33105. * This method will return the name of the full name of the class, including its owning module (if any).
  33106. * 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).
  33107. * @param object the object to get the class name from
  33108. * @param isType defines if the object is actually a type
  33109. * @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.
  33110. * @ignorenaming
  33111. */
  33112. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33113. /**
  33114. * Returns a promise that resolves after the given amount of time.
  33115. * @param delay Number of milliseconds to delay
  33116. * @returns Promise that resolves after the given amount of time
  33117. */
  33118. static DelayAsync(delay: number): Promise<void>;
  33119. }
  33120. /**
  33121. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33122. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33123. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33124. * @param name The name of the class, case should be preserved
  33125. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33126. */
  33127. export function className(name: string, module?: string): (target: Object) => void;
  33128. /**
  33129. * An implementation of a loop for asynchronous functions.
  33130. */
  33131. export class AsyncLoop {
  33132. /**
  33133. * Defines the number of iterations for the loop
  33134. */
  33135. iterations: number;
  33136. /**
  33137. * Defines the current index of the loop.
  33138. */
  33139. index: number;
  33140. private _done;
  33141. private _fn;
  33142. private _successCallback;
  33143. /**
  33144. * Constructor.
  33145. * @param iterations the number of iterations.
  33146. * @param func the function to run each iteration
  33147. * @param successCallback the callback that will be called upon succesful execution
  33148. * @param offset starting offset.
  33149. */
  33150. constructor(
  33151. /**
  33152. * Defines the number of iterations for the loop
  33153. */
  33154. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33155. /**
  33156. * Execute the next iteration. Must be called after the last iteration was finished.
  33157. */
  33158. executeNext(): void;
  33159. /**
  33160. * Break the loop and run the success callback.
  33161. */
  33162. breakLoop(): void;
  33163. /**
  33164. * Create and run an async loop.
  33165. * @param iterations the number of iterations.
  33166. * @param fn the function to run each iteration
  33167. * @param successCallback the callback that will be called upon succesful execution
  33168. * @param offset starting offset.
  33169. * @returns the created async loop object
  33170. */
  33171. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33172. /**
  33173. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33174. * @param iterations total number of iterations
  33175. * @param syncedIterations number of synchronous iterations in each async iteration.
  33176. * @param fn the function to call each iteration.
  33177. * @param callback a success call back that will be called when iterating stops.
  33178. * @param breakFunction a break condition (optional)
  33179. * @param timeout timeout settings for the setTimeout function. default - 0.
  33180. * @returns the created async loop object
  33181. */
  33182. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33183. }
  33184. }
  33185. declare module "babylonjs/Collisions/collisionCoordinator" {
  33186. import { Nullable } from "babylonjs/types";
  33187. import { Scene } from "babylonjs/scene";
  33188. import { Vector3 } from "babylonjs/Maths/math.vector";
  33189. import { Collider } from "babylonjs/Collisions/collider";
  33190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33191. /** @hidden */
  33192. export interface ICollisionCoordinator {
  33193. createCollider(): Collider;
  33194. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33195. init(scene: Scene): void;
  33196. }
  33197. /** @hidden */
  33198. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33199. private _scene;
  33200. private _scaledPosition;
  33201. private _scaledVelocity;
  33202. private _finalPosition;
  33203. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33204. createCollider(): Collider;
  33205. init(scene: Scene): void;
  33206. private _collideWithWorld;
  33207. }
  33208. }
  33209. declare module "babylonjs/Inputs/scene.inputManager" {
  33210. import { Nullable } from "babylonjs/types";
  33211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33212. import { Vector2 } from "babylonjs/Maths/math.vector";
  33213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33214. import { Scene } from "babylonjs/scene";
  33215. /**
  33216. * Class used to manage all inputs for the scene.
  33217. */
  33218. export class InputManager {
  33219. /** The distance in pixel that you have to move to prevent some events */
  33220. static DragMovementThreshold: number;
  33221. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33222. static LongPressDelay: number;
  33223. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33224. static DoubleClickDelay: number;
  33225. /** If you need to check double click without raising a single click at first click, enable this flag */
  33226. static ExclusiveDoubleClickMode: boolean;
  33227. private _wheelEventName;
  33228. private _onPointerMove;
  33229. private _onPointerDown;
  33230. private _onPointerUp;
  33231. private _initClickEvent;
  33232. private _initActionManager;
  33233. private _delayedSimpleClick;
  33234. private _delayedSimpleClickTimeout;
  33235. private _previousDelayedSimpleClickTimeout;
  33236. private _meshPickProceed;
  33237. private _previousButtonPressed;
  33238. private _currentPickResult;
  33239. private _previousPickResult;
  33240. private _totalPointersPressed;
  33241. private _doubleClickOccured;
  33242. private _pointerOverMesh;
  33243. private _pickedDownMesh;
  33244. private _pickedUpMesh;
  33245. private _pointerX;
  33246. private _pointerY;
  33247. private _unTranslatedPointerX;
  33248. private _unTranslatedPointerY;
  33249. private _startingPointerPosition;
  33250. private _previousStartingPointerPosition;
  33251. private _startingPointerTime;
  33252. private _previousStartingPointerTime;
  33253. private _pointerCaptures;
  33254. private _onKeyDown;
  33255. private _onKeyUp;
  33256. private _onCanvasFocusObserver;
  33257. private _onCanvasBlurObserver;
  33258. private _scene;
  33259. /**
  33260. * Creates a new InputManager
  33261. * @param scene defines the hosting scene
  33262. */
  33263. constructor(scene: Scene);
  33264. /**
  33265. * Gets the mesh that is currently under the pointer
  33266. */
  33267. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33268. /**
  33269. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33270. */
  33271. readonly unTranslatedPointer: Vector2;
  33272. /**
  33273. * Gets or sets the current on-screen X position of the pointer
  33274. */
  33275. pointerX: number;
  33276. /**
  33277. * Gets or sets the current on-screen Y position of the pointer
  33278. */
  33279. pointerY: number;
  33280. private _updatePointerPosition;
  33281. private _processPointerMove;
  33282. private _setRayOnPointerInfo;
  33283. private _checkPrePointerObservable;
  33284. /**
  33285. * Use this method to simulate a pointer move on a mesh
  33286. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33287. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33288. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33289. */
  33290. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33291. /**
  33292. * Use this method to simulate a pointer down on a mesh
  33293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33296. */
  33297. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33298. private _processPointerDown;
  33299. /** @hidden */
  33300. _isPointerSwiping(): boolean;
  33301. /**
  33302. * Use this method to simulate a pointer up on a mesh
  33303. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33304. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33305. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33306. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33307. */
  33308. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33309. private _processPointerUp;
  33310. /**
  33311. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33312. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33313. * @returns true if the pointer was captured
  33314. */
  33315. isPointerCaptured(pointerId?: number): boolean;
  33316. /**
  33317. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33318. * @param attachUp defines if you want to attach events to pointerup
  33319. * @param attachDown defines if you want to attach events to pointerdown
  33320. * @param attachMove defines if you want to attach events to pointermove
  33321. */
  33322. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33323. /**
  33324. * Detaches all event handlers
  33325. */
  33326. detachControl(): void;
  33327. /**
  33328. * Force the value of meshUnderPointer
  33329. * @param mesh defines the mesh to use
  33330. */
  33331. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33332. /**
  33333. * Gets the mesh under the pointer
  33334. * @returns a Mesh or null if no mesh is under the pointer
  33335. */
  33336. getPointerOverMesh(): Nullable<AbstractMesh>;
  33337. }
  33338. }
  33339. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33340. /**
  33341. * Helper class used to generate session unique ID
  33342. */
  33343. export class UniqueIdGenerator {
  33344. private static _UniqueIdCounter;
  33345. /**
  33346. * Gets an unique (relatively to the current scene) Id
  33347. */
  33348. static readonly UniqueId: number;
  33349. }
  33350. }
  33351. declare module "babylonjs/Animations/animationGroup" {
  33352. import { Animatable } from "babylonjs/Animations/animatable";
  33353. import { Animation } from "babylonjs/Animations/animation";
  33354. import { Scene, IDisposable } from "babylonjs/scene";
  33355. import { Observable } from "babylonjs/Misc/observable";
  33356. import { Nullable } from "babylonjs/types";
  33357. import "babylonjs/Animations/animatable";
  33358. /**
  33359. * This class defines the direct association between an animation and a target
  33360. */
  33361. export class TargetedAnimation {
  33362. /**
  33363. * Animation to perform
  33364. */
  33365. animation: Animation;
  33366. /**
  33367. * Target to animate
  33368. */
  33369. target: any;
  33370. /**
  33371. * Serialize the object
  33372. * @returns the JSON object representing the current entity
  33373. */
  33374. serialize(): any;
  33375. }
  33376. /**
  33377. * Use this class to create coordinated animations on multiple targets
  33378. */
  33379. export class AnimationGroup implements IDisposable {
  33380. /** The name of the animation group */
  33381. name: string;
  33382. private _scene;
  33383. private _targetedAnimations;
  33384. private _animatables;
  33385. private _from;
  33386. private _to;
  33387. private _isStarted;
  33388. private _isPaused;
  33389. private _speedRatio;
  33390. private _loopAnimation;
  33391. /**
  33392. * Gets or sets the unique id of the node
  33393. */
  33394. uniqueId: number;
  33395. /**
  33396. * This observable will notify when one animation have ended
  33397. */
  33398. onAnimationEndObservable: Observable<TargetedAnimation>;
  33399. /**
  33400. * Observer raised when one animation loops
  33401. */
  33402. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33403. /**
  33404. * This observable will notify when all animations have ended.
  33405. */
  33406. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33407. /**
  33408. * This observable will notify when all animations have paused.
  33409. */
  33410. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33411. /**
  33412. * This observable will notify when all animations are playing.
  33413. */
  33414. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33415. /**
  33416. * Gets the first frame
  33417. */
  33418. readonly from: number;
  33419. /**
  33420. * Gets the last frame
  33421. */
  33422. readonly to: number;
  33423. /**
  33424. * Define if the animations are started
  33425. */
  33426. readonly isStarted: boolean;
  33427. /**
  33428. * Gets a value indicating that the current group is playing
  33429. */
  33430. readonly isPlaying: boolean;
  33431. /**
  33432. * Gets or sets the speed ratio to use for all animations
  33433. */
  33434. /**
  33435. * Gets or sets the speed ratio to use for all animations
  33436. */
  33437. speedRatio: number;
  33438. /**
  33439. * Gets or sets if all animations should loop or not
  33440. */
  33441. loopAnimation: boolean;
  33442. /**
  33443. * Gets the targeted animations for this animation group
  33444. */
  33445. readonly targetedAnimations: Array<TargetedAnimation>;
  33446. /**
  33447. * returning the list of animatables controlled by this animation group.
  33448. */
  33449. readonly animatables: Array<Animatable>;
  33450. /**
  33451. * Instantiates a new Animation Group.
  33452. * This helps managing several animations at once.
  33453. * @see http://doc.babylonjs.com/how_to/group
  33454. * @param name Defines the name of the group
  33455. * @param scene Defines the scene the group belongs to
  33456. */
  33457. constructor(
  33458. /** The name of the animation group */
  33459. name: string, scene?: Nullable<Scene>);
  33460. /**
  33461. * Add an animation (with its target) in the group
  33462. * @param animation defines the animation we want to add
  33463. * @param target defines the target of the animation
  33464. * @returns the TargetedAnimation object
  33465. */
  33466. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33467. /**
  33468. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33469. * It can add constant keys at begin or end
  33470. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33471. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33472. * @returns the animation group
  33473. */
  33474. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33475. /**
  33476. * Start all animations on given targets
  33477. * @param loop defines if animations must loop
  33478. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33479. * @param from defines the from key (optional)
  33480. * @param to defines the to key (optional)
  33481. * @returns the current animation group
  33482. */
  33483. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33484. /**
  33485. * Pause all animations
  33486. * @returns the animation group
  33487. */
  33488. pause(): AnimationGroup;
  33489. /**
  33490. * Play all animations to initial state
  33491. * This function will start() the animations if they were not started or will restart() them if they were paused
  33492. * @param loop defines if animations must loop
  33493. * @returns the animation group
  33494. */
  33495. play(loop?: boolean): AnimationGroup;
  33496. /**
  33497. * Reset all animations to initial state
  33498. * @returns the animation group
  33499. */
  33500. reset(): AnimationGroup;
  33501. /**
  33502. * Restart animations from key 0
  33503. * @returns the animation group
  33504. */
  33505. restart(): AnimationGroup;
  33506. /**
  33507. * Stop all animations
  33508. * @returns the animation group
  33509. */
  33510. stop(): AnimationGroup;
  33511. /**
  33512. * Set animation weight for all animatables
  33513. * @param weight defines the weight to use
  33514. * @return the animationGroup
  33515. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33516. */
  33517. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33518. /**
  33519. * Synchronize and normalize all animatables with a source animatable
  33520. * @param root defines the root animatable to synchronize with
  33521. * @return the animationGroup
  33522. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33523. */
  33524. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33525. /**
  33526. * Goes to a specific frame in this animation group
  33527. * @param frame the frame number to go to
  33528. * @return the animationGroup
  33529. */
  33530. goToFrame(frame: number): AnimationGroup;
  33531. /**
  33532. * Dispose all associated resources
  33533. */
  33534. dispose(): void;
  33535. private _checkAnimationGroupEnded;
  33536. /**
  33537. * Clone the current animation group and returns a copy
  33538. * @param newName defines the name of the new group
  33539. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33540. * @returns the new aniamtion group
  33541. */
  33542. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33543. /**
  33544. * Serializes the animationGroup to an object
  33545. * @returns Serialized object
  33546. */
  33547. serialize(): any;
  33548. /**
  33549. * Returns a new AnimationGroup object parsed from the source provided.
  33550. * @param parsedAnimationGroup defines the source
  33551. * @param scene defines the scene that will receive the animationGroup
  33552. * @returns a new AnimationGroup
  33553. */
  33554. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33555. /**
  33556. * Returns the string "AnimationGroup"
  33557. * @returns "AnimationGroup"
  33558. */
  33559. getClassName(): string;
  33560. /**
  33561. * Creates a detailled string about the object
  33562. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33563. * @returns a string representing the object
  33564. */
  33565. toString(fullDetails?: boolean): string;
  33566. }
  33567. }
  33568. declare module "babylonjs/scene" {
  33569. import { Nullable } from "babylonjs/types";
  33570. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33571. import { Observable } from "babylonjs/Misc/observable";
  33572. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33573. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33574. import { Geometry } from "babylonjs/Meshes/geometry";
  33575. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33576. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33578. import { Mesh } from "babylonjs/Meshes/mesh";
  33579. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33580. import { Bone } from "babylonjs/Bones/bone";
  33581. import { Skeleton } from "babylonjs/Bones/skeleton";
  33582. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33583. import { Camera } from "babylonjs/Cameras/camera";
  33584. import { AbstractScene } from "babylonjs/abstractScene";
  33585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33587. import { Material } from "babylonjs/Materials/material";
  33588. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33589. import { Effect } from "babylonjs/Materials/effect";
  33590. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33591. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33592. import { Light } from "babylonjs/Lights/light";
  33593. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33594. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33595. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33596. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33598. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33599. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33600. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33601. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33602. import { Engine } from "babylonjs/Engines/engine";
  33603. import { Node } from "babylonjs/node";
  33604. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33605. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33606. import { WebRequest } from "babylonjs/Misc/webRequest";
  33607. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33608. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33609. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33610. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33611. import { Plane } from "babylonjs/Maths/math.plane";
  33612. import { Ray } from "babylonjs/Culling/ray";
  33613. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33614. import { Animation } from "babylonjs/Animations/animation";
  33615. import { Animatable } from "babylonjs/Animations/animatable";
  33616. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33617. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33618. import { Collider } from "babylonjs/Collisions/collider";
  33619. /**
  33620. * Define an interface for all classes that will hold resources
  33621. */
  33622. export interface IDisposable {
  33623. /**
  33624. * Releases all held resources
  33625. */
  33626. dispose(): void;
  33627. }
  33628. /** Interface defining initialization parameters for Scene class */
  33629. export interface SceneOptions {
  33630. /**
  33631. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33632. * It will improve performance when the number of geometries becomes important.
  33633. */
  33634. useGeometryUniqueIdsMap?: boolean;
  33635. /**
  33636. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33637. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33638. */
  33639. useMaterialMeshMap?: boolean;
  33640. /**
  33641. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33643. */
  33644. useClonedMeshhMap?: boolean;
  33645. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33646. virtual?: boolean;
  33647. }
  33648. /**
  33649. * Represents a scene to be rendered by the engine.
  33650. * @see http://doc.babylonjs.com/features/scene
  33651. */
  33652. export class Scene extends AbstractScene implements IAnimatable {
  33653. /** The fog is deactivated */
  33654. static readonly FOGMODE_NONE: number;
  33655. /** The fog density is following an exponential function */
  33656. static readonly FOGMODE_EXP: number;
  33657. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33658. static readonly FOGMODE_EXP2: number;
  33659. /** The fog density is following a linear function. */
  33660. static readonly FOGMODE_LINEAR: number;
  33661. /**
  33662. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33664. */
  33665. static MinDeltaTime: number;
  33666. /**
  33667. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33669. */
  33670. static MaxDeltaTime: number;
  33671. /**
  33672. * Factory used to create the default material.
  33673. * @param name The name of the material to create
  33674. * @param scene The scene to create the material for
  33675. * @returns The default material
  33676. */
  33677. static DefaultMaterialFactory(scene: Scene): Material;
  33678. /**
  33679. * Factory used to create the a collision coordinator.
  33680. * @returns The collision coordinator
  33681. */
  33682. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33683. /** @hidden */
  33684. _inputManager: InputManager;
  33685. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33686. cameraToUseForPointers: Nullable<Camera>;
  33687. /** @hidden */
  33688. readonly _isScene: boolean;
  33689. /**
  33690. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33691. */
  33692. autoClear: boolean;
  33693. /**
  33694. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33695. */
  33696. autoClearDepthAndStencil: boolean;
  33697. /**
  33698. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33699. */
  33700. clearColor: Color4;
  33701. /**
  33702. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33703. */
  33704. ambientColor: Color3;
  33705. /**
  33706. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33707. * It should only be one of the following (if not the default embedded one):
  33708. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33709. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33710. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33711. * The material properties need to be setup according to the type of texture in use.
  33712. */
  33713. environmentBRDFTexture: BaseTexture;
  33714. /** @hidden */
  33715. protected _environmentTexture: Nullable<BaseTexture>;
  33716. /**
  33717. * Texture used in all pbr material as the reflection texture.
  33718. * As in the majority of the scene they are the same (exception for multi room and so on),
  33719. * this is easier to reference from here than from all the materials.
  33720. */
  33721. /**
  33722. * Texture used in all pbr material as the reflection texture.
  33723. * As in the majority of the scene they are the same (exception for multi room and so on),
  33724. * this is easier to set here than in all the materials.
  33725. */
  33726. environmentTexture: Nullable<BaseTexture>;
  33727. /** @hidden */
  33728. protected _environmentIntensity: number;
  33729. /**
  33730. * Intensity of the environment in all pbr material.
  33731. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33732. * As in the majority of the scene they are the same (exception for multi room and so on),
  33733. * this is easier to reference from here than from all the materials.
  33734. */
  33735. /**
  33736. * Intensity of the environment in all pbr material.
  33737. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33738. * As in the majority of the scene they are the same (exception for multi room and so on),
  33739. * this is easier to set here than in all the materials.
  33740. */
  33741. environmentIntensity: number;
  33742. /** @hidden */
  33743. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33744. /**
  33745. * Default image processing configuration used either in the rendering
  33746. * Forward main pass or through the imageProcessingPostProcess if present.
  33747. * As in the majority of the scene they are the same (exception for multi camera),
  33748. * this is easier to reference from here than from all the materials and post process.
  33749. *
  33750. * No setter as we it is a shared configuration, you can set the values instead.
  33751. */
  33752. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33753. private _forceWireframe;
  33754. /**
  33755. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33756. */
  33757. forceWireframe: boolean;
  33758. private _forcePointsCloud;
  33759. /**
  33760. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33761. */
  33762. forcePointsCloud: boolean;
  33763. /**
  33764. * Gets or sets the active clipplane 1
  33765. */
  33766. clipPlane: Nullable<Plane>;
  33767. /**
  33768. * Gets or sets the active clipplane 2
  33769. */
  33770. clipPlane2: Nullable<Plane>;
  33771. /**
  33772. * Gets or sets the active clipplane 3
  33773. */
  33774. clipPlane3: Nullable<Plane>;
  33775. /**
  33776. * Gets or sets the active clipplane 4
  33777. */
  33778. clipPlane4: Nullable<Plane>;
  33779. /**
  33780. * Gets or sets a boolean indicating if animations are enabled
  33781. */
  33782. animationsEnabled: boolean;
  33783. private _animationPropertiesOverride;
  33784. /**
  33785. * Gets or sets the animation properties override
  33786. */
  33787. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33788. /**
  33789. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33790. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33791. */
  33792. useConstantAnimationDeltaTime: boolean;
  33793. /**
  33794. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33795. * Please note that it requires to run a ray cast through the scene on every frame
  33796. */
  33797. constantlyUpdateMeshUnderPointer: boolean;
  33798. /**
  33799. * Defines the HTML cursor to use when hovering over interactive elements
  33800. */
  33801. hoverCursor: string;
  33802. /**
  33803. * Defines the HTML default cursor to use (empty by default)
  33804. */
  33805. defaultCursor: string;
  33806. /**
  33807. * This is used to call preventDefault() on pointer down
  33808. * in order to block unwanted artifacts like system double clicks
  33809. */
  33810. preventDefaultOnPointerDown: boolean;
  33811. /**
  33812. * This is used to call preventDefault() on pointer up
  33813. * in order to block unwanted artifacts like system double clicks
  33814. */
  33815. preventDefaultOnPointerUp: boolean;
  33816. /**
  33817. * Gets or sets user defined metadata
  33818. */
  33819. metadata: any;
  33820. /**
  33821. * For internal use only. Please do not use.
  33822. */
  33823. reservedDataStore: any;
  33824. /**
  33825. * Gets the name of the plugin used to load this scene (null by default)
  33826. */
  33827. loadingPluginName: string;
  33828. /**
  33829. * Use this array to add regular expressions used to disable offline support for specific urls
  33830. */
  33831. disableOfflineSupportExceptionRules: RegExp[];
  33832. /**
  33833. * An event triggered when the scene is disposed.
  33834. */
  33835. onDisposeObservable: Observable<Scene>;
  33836. private _onDisposeObserver;
  33837. /** Sets a function to be executed when this scene is disposed. */
  33838. onDispose: () => void;
  33839. /**
  33840. * An event triggered before rendering the scene (right after animations and physics)
  33841. */
  33842. onBeforeRenderObservable: Observable<Scene>;
  33843. private _onBeforeRenderObserver;
  33844. /** Sets a function to be executed before rendering this scene */
  33845. beforeRender: Nullable<() => void>;
  33846. /**
  33847. * An event triggered after rendering the scene
  33848. */
  33849. onAfterRenderObservable: Observable<Scene>;
  33850. /**
  33851. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33852. */
  33853. onAfterRenderCameraObservable: Observable<Camera>;
  33854. private _onAfterRenderObserver;
  33855. /** Sets a function to be executed after rendering this scene */
  33856. afterRender: Nullable<() => void>;
  33857. /**
  33858. * An event triggered before animating the scene
  33859. */
  33860. onBeforeAnimationsObservable: Observable<Scene>;
  33861. /**
  33862. * An event triggered after animations processing
  33863. */
  33864. onAfterAnimationsObservable: Observable<Scene>;
  33865. /**
  33866. * An event triggered before draw calls are ready to be sent
  33867. */
  33868. onBeforeDrawPhaseObservable: Observable<Scene>;
  33869. /**
  33870. * An event triggered after draw calls have been sent
  33871. */
  33872. onAfterDrawPhaseObservable: Observable<Scene>;
  33873. /**
  33874. * An event triggered when the scene is ready
  33875. */
  33876. onReadyObservable: Observable<Scene>;
  33877. /**
  33878. * An event triggered before rendering a camera
  33879. */
  33880. onBeforeCameraRenderObservable: Observable<Camera>;
  33881. private _onBeforeCameraRenderObserver;
  33882. /** Sets a function to be executed before rendering a camera*/
  33883. beforeCameraRender: () => void;
  33884. /**
  33885. * An event triggered after rendering a camera
  33886. */
  33887. onAfterCameraRenderObservable: Observable<Camera>;
  33888. private _onAfterCameraRenderObserver;
  33889. /** Sets a function to be executed after rendering a camera*/
  33890. afterCameraRender: () => void;
  33891. /**
  33892. * An event triggered when active meshes evaluation is about to start
  33893. */
  33894. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33895. /**
  33896. * An event triggered when active meshes evaluation is done
  33897. */
  33898. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33899. /**
  33900. * An event triggered when particles rendering is about to start
  33901. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33902. */
  33903. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33904. /**
  33905. * An event triggered when particles rendering is done
  33906. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33907. */
  33908. onAfterParticlesRenderingObservable: Observable<Scene>;
  33909. /**
  33910. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33911. */
  33912. onDataLoadedObservable: Observable<Scene>;
  33913. /**
  33914. * An event triggered when a camera is created
  33915. */
  33916. onNewCameraAddedObservable: Observable<Camera>;
  33917. /**
  33918. * An event triggered when a camera is removed
  33919. */
  33920. onCameraRemovedObservable: Observable<Camera>;
  33921. /**
  33922. * An event triggered when a light is created
  33923. */
  33924. onNewLightAddedObservable: Observable<Light>;
  33925. /**
  33926. * An event triggered when a light is removed
  33927. */
  33928. onLightRemovedObservable: Observable<Light>;
  33929. /**
  33930. * An event triggered when a geometry is created
  33931. */
  33932. onNewGeometryAddedObservable: Observable<Geometry>;
  33933. /**
  33934. * An event triggered when a geometry is removed
  33935. */
  33936. onGeometryRemovedObservable: Observable<Geometry>;
  33937. /**
  33938. * An event triggered when a transform node is created
  33939. */
  33940. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33941. /**
  33942. * An event triggered when a transform node is removed
  33943. */
  33944. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33945. /**
  33946. * An event triggered when a mesh is created
  33947. */
  33948. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33949. /**
  33950. * An event triggered when a mesh is removed
  33951. */
  33952. onMeshRemovedObservable: Observable<AbstractMesh>;
  33953. /**
  33954. * An event triggered when a skeleton is created
  33955. */
  33956. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33957. /**
  33958. * An event triggered when a skeleton is removed
  33959. */
  33960. onSkeletonRemovedObservable: Observable<Skeleton>;
  33961. /**
  33962. * An event triggered when a material is created
  33963. */
  33964. onNewMaterialAddedObservable: Observable<Material>;
  33965. /**
  33966. * An event triggered when a material is removed
  33967. */
  33968. onMaterialRemovedObservable: Observable<Material>;
  33969. /**
  33970. * An event triggered when a texture is created
  33971. */
  33972. onNewTextureAddedObservable: Observable<BaseTexture>;
  33973. /**
  33974. * An event triggered when a texture is removed
  33975. */
  33976. onTextureRemovedObservable: Observable<BaseTexture>;
  33977. /**
  33978. * An event triggered when render targets are about to be rendered
  33979. * Can happen multiple times per frame.
  33980. */
  33981. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33982. /**
  33983. * An event triggered when render targets were rendered.
  33984. * Can happen multiple times per frame.
  33985. */
  33986. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33987. /**
  33988. * An event triggered before calculating deterministic simulation step
  33989. */
  33990. onBeforeStepObservable: Observable<Scene>;
  33991. /**
  33992. * An event triggered after calculating deterministic simulation step
  33993. */
  33994. onAfterStepObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when the activeCamera property is updated
  33997. */
  33998. onActiveCameraChanged: Observable<Scene>;
  33999. /**
  34000. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34001. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34002. * 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)
  34003. */
  34004. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34005. /**
  34006. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34007. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34008. * 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)
  34009. */
  34010. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34011. /**
  34012. * This Observable will when a mesh has been imported into the scene.
  34013. */
  34014. onMeshImportedObservable: Observable<AbstractMesh>;
  34015. /**
  34016. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34017. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34018. */
  34019. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34020. /** @hidden */
  34021. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34022. /**
  34023. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34024. */
  34025. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34026. /**
  34027. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34028. */
  34029. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34030. /**
  34031. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34032. */
  34033. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34034. /** Callback called when a pointer move is detected */
  34035. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34036. /** Callback called when a pointer down is detected */
  34037. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34038. /** Callback called when a pointer up is detected */
  34039. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34040. /** Callback called when a pointer pick is detected */
  34041. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34042. /**
  34043. * 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).
  34044. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34045. */
  34046. onPrePointerObservable: Observable<PointerInfoPre>;
  34047. /**
  34048. * Observable event triggered each time an input event is received from the rendering canvas
  34049. */
  34050. onPointerObservable: Observable<PointerInfo>;
  34051. /**
  34052. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34053. */
  34054. readonly unTranslatedPointer: Vector2;
  34055. /**
  34056. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34057. */
  34058. static DragMovementThreshold: number;
  34059. /**
  34060. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34061. */
  34062. static LongPressDelay: number;
  34063. /**
  34064. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34065. */
  34066. static DoubleClickDelay: number;
  34067. /** If you need to check double click without raising a single click at first click, enable this flag */
  34068. static ExclusiveDoubleClickMode: boolean;
  34069. /** @hidden */
  34070. _mirroredCameraPosition: Nullable<Vector3>;
  34071. /**
  34072. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34073. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34074. */
  34075. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34076. /**
  34077. * Observable event triggered each time an keyboard event is received from the hosting window
  34078. */
  34079. onKeyboardObservable: Observable<KeyboardInfo>;
  34080. private _useRightHandedSystem;
  34081. /**
  34082. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34083. */
  34084. useRightHandedSystem: boolean;
  34085. private _timeAccumulator;
  34086. private _currentStepId;
  34087. private _currentInternalStep;
  34088. /**
  34089. * Sets the step Id used by deterministic lock step
  34090. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34091. * @param newStepId defines the step Id
  34092. */
  34093. setStepId(newStepId: number): void;
  34094. /**
  34095. * Gets the step Id used by deterministic lock step
  34096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34097. * @returns the step Id
  34098. */
  34099. getStepId(): number;
  34100. /**
  34101. * Gets the internal step used by deterministic lock step
  34102. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34103. * @returns the internal step
  34104. */
  34105. getInternalStep(): number;
  34106. private _fogEnabled;
  34107. /**
  34108. * Gets or sets a boolean indicating if fog is enabled on this scene
  34109. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34110. * (Default is true)
  34111. */
  34112. fogEnabled: boolean;
  34113. private _fogMode;
  34114. /**
  34115. * Gets or sets the fog mode to use
  34116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34117. * | mode | value |
  34118. * | --- | --- |
  34119. * | FOGMODE_NONE | 0 |
  34120. * | FOGMODE_EXP | 1 |
  34121. * | FOGMODE_EXP2 | 2 |
  34122. * | FOGMODE_LINEAR | 3 |
  34123. */
  34124. fogMode: number;
  34125. /**
  34126. * Gets or sets the fog color to use
  34127. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34128. * (Default is Color3(0.2, 0.2, 0.3))
  34129. */
  34130. fogColor: Color3;
  34131. /**
  34132. * Gets or sets the fog density to use
  34133. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34134. * (Default is 0.1)
  34135. */
  34136. fogDensity: number;
  34137. /**
  34138. * Gets or sets the fog start distance to use
  34139. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34140. * (Default is 0)
  34141. */
  34142. fogStart: number;
  34143. /**
  34144. * Gets or sets the fog end distance to use
  34145. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34146. * (Default is 1000)
  34147. */
  34148. fogEnd: number;
  34149. private _shadowsEnabled;
  34150. /**
  34151. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34152. */
  34153. shadowsEnabled: boolean;
  34154. private _lightsEnabled;
  34155. /**
  34156. * Gets or sets a boolean indicating if lights are enabled on this scene
  34157. */
  34158. lightsEnabled: boolean;
  34159. /** All of the active cameras added to this scene. */
  34160. activeCameras: Camera[];
  34161. /** @hidden */
  34162. _activeCamera: Nullable<Camera>;
  34163. /** Gets or sets the current active camera */
  34164. activeCamera: Nullable<Camera>;
  34165. private _defaultMaterial;
  34166. /** The default material used on meshes when no material is affected */
  34167. /** The default material used on meshes when no material is affected */
  34168. defaultMaterial: Material;
  34169. private _texturesEnabled;
  34170. /**
  34171. * Gets or sets a boolean indicating if textures are enabled on this scene
  34172. */
  34173. texturesEnabled: boolean;
  34174. /**
  34175. * Gets or sets a boolean indicating if particles are enabled on this scene
  34176. */
  34177. particlesEnabled: boolean;
  34178. /**
  34179. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34180. */
  34181. spritesEnabled: boolean;
  34182. private _skeletonsEnabled;
  34183. /**
  34184. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34185. */
  34186. skeletonsEnabled: boolean;
  34187. /**
  34188. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34189. */
  34190. lensFlaresEnabled: boolean;
  34191. /**
  34192. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34194. */
  34195. collisionsEnabled: boolean;
  34196. private _collisionCoordinator;
  34197. /** @hidden */
  34198. readonly collisionCoordinator: ICollisionCoordinator;
  34199. /**
  34200. * Defines the gravity applied to this scene (used only for collisions)
  34201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34202. */
  34203. gravity: Vector3;
  34204. /**
  34205. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34206. */
  34207. postProcessesEnabled: boolean;
  34208. /**
  34209. * The list of postprocesses added to the scene
  34210. */
  34211. postProcesses: PostProcess[];
  34212. /**
  34213. * Gets the current postprocess manager
  34214. */
  34215. postProcessManager: PostProcessManager;
  34216. /**
  34217. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34218. */
  34219. renderTargetsEnabled: boolean;
  34220. /**
  34221. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34222. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34223. */
  34224. dumpNextRenderTargets: boolean;
  34225. /**
  34226. * The list of user defined render targets added to the scene
  34227. */
  34228. customRenderTargets: RenderTargetTexture[];
  34229. /**
  34230. * Defines if texture loading must be delayed
  34231. * If true, textures will only be loaded when they need to be rendered
  34232. */
  34233. useDelayedTextureLoading: boolean;
  34234. /**
  34235. * Gets the list of meshes imported to the scene through SceneLoader
  34236. */
  34237. importedMeshesFiles: String[];
  34238. /**
  34239. * Gets or sets a boolean indicating if probes are enabled on this scene
  34240. */
  34241. probesEnabled: boolean;
  34242. /**
  34243. * Gets or sets the current offline provider to use to store scene data
  34244. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34245. */
  34246. offlineProvider: IOfflineProvider;
  34247. /**
  34248. * Gets or sets the action manager associated with the scene
  34249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34250. */
  34251. actionManager: AbstractActionManager;
  34252. private _meshesForIntersections;
  34253. /**
  34254. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34255. */
  34256. proceduralTexturesEnabled: boolean;
  34257. private _engine;
  34258. private _totalVertices;
  34259. /** @hidden */
  34260. _activeIndices: PerfCounter;
  34261. /** @hidden */
  34262. _activeParticles: PerfCounter;
  34263. /** @hidden */
  34264. _activeBones: PerfCounter;
  34265. private _animationRatio;
  34266. /** @hidden */
  34267. _animationTimeLast: number;
  34268. /** @hidden */
  34269. _animationTime: number;
  34270. /**
  34271. * Gets or sets a general scale for animation speed
  34272. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34273. */
  34274. animationTimeScale: number;
  34275. /** @hidden */
  34276. _cachedMaterial: Nullable<Material>;
  34277. /** @hidden */
  34278. _cachedEffect: Nullable<Effect>;
  34279. /** @hidden */
  34280. _cachedVisibility: Nullable<number>;
  34281. private _renderId;
  34282. private _frameId;
  34283. private _executeWhenReadyTimeoutId;
  34284. private _intermediateRendering;
  34285. private _viewUpdateFlag;
  34286. private _projectionUpdateFlag;
  34287. /** @hidden */
  34288. _toBeDisposed: Nullable<IDisposable>[];
  34289. private _activeRequests;
  34290. /** @hidden */
  34291. _pendingData: any[];
  34292. private _isDisposed;
  34293. /**
  34294. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34295. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34296. */
  34297. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34298. private _activeMeshes;
  34299. private _processedMaterials;
  34300. private _renderTargets;
  34301. /** @hidden */
  34302. _activeParticleSystems: SmartArray<IParticleSystem>;
  34303. private _activeSkeletons;
  34304. private _softwareSkinnedMeshes;
  34305. private _renderingManager;
  34306. /** @hidden */
  34307. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34308. private _transformMatrix;
  34309. private _sceneUbo;
  34310. /** @hidden */
  34311. _viewMatrix: Matrix;
  34312. private _projectionMatrix;
  34313. /** @hidden */
  34314. _forcedViewPosition: Nullable<Vector3>;
  34315. /** @hidden */
  34316. _frustumPlanes: Plane[];
  34317. /**
  34318. * Gets the list of frustum planes (built from the active camera)
  34319. */
  34320. readonly frustumPlanes: Plane[];
  34321. /**
  34322. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34323. * This is useful if there are more lights that the maximum simulteanous authorized
  34324. */
  34325. requireLightSorting: boolean;
  34326. /** @hidden */
  34327. readonly useMaterialMeshMap: boolean;
  34328. /** @hidden */
  34329. readonly useClonedMeshhMap: boolean;
  34330. private _externalData;
  34331. private _uid;
  34332. /**
  34333. * @hidden
  34334. * Backing store of defined scene components.
  34335. */
  34336. _components: ISceneComponent[];
  34337. /**
  34338. * @hidden
  34339. * Backing store of defined scene components.
  34340. */
  34341. _serializableComponents: ISceneSerializableComponent[];
  34342. /**
  34343. * List of components to register on the next registration step.
  34344. */
  34345. private _transientComponents;
  34346. /**
  34347. * Registers the transient components if needed.
  34348. */
  34349. private _registerTransientComponents;
  34350. /**
  34351. * @hidden
  34352. * Add a component to the scene.
  34353. * Note that the ccomponent could be registered on th next frame if this is called after
  34354. * the register component stage.
  34355. * @param component Defines the component to add to the scene
  34356. */
  34357. _addComponent(component: ISceneComponent): void;
  34358. /**
  34359. * @hidden
  34360. * Gets a component from the scene.
  34361. * @param name defines the name of the component to retrieve
  34362. * @returns the component or null if not present
  34363. */
  34364. _getComponent(name: string): Nullable<ISceneComponent>;
  34365. /**
  34366. * @hidden
  34367. * Defines the actions happening before camera updates.
  34368. */
  34369. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34370. /**
  34371. * @hidden
  34372. * Defines the actions happening before clear the canvas.
  34373. */
  34374. _beforeClearStage: Stage<SimpleStageAction>;
  34375. /**
  34376. * @hidden
  34377. * Defines the actions when collecting render targets for the frame.
  34378. */
  34379. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34380. /**
  34381. * @hidden
  34382. * Defines the actions happening for one camera in the frame.
  34383. */
  34384. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34385. /**
  34386. * @hidden
  34387. * Defines the actions happening during the per mesh ready checks.
  34388. */
  34389. _isReadyForMeshStage: Stage<MeshStageAction>;
  34390. /**
  34391. * @hidden
  34392. * Defines the actions happening before evaluate active mesh checks.
  34393. */
  34394. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34395. /**
  34396. * @hidden
  34397. * Defines the actions happening during the evaluate sub mesh checks.
  34398. */
  34399. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34400. /**
  34401. * @hidden
  34402. * Defines the actions happening during the active mesh stage.
  34403. */
  34404. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34405. /**
  34406. * @hidden
  34407. * Defines the actions happening during the per camera render target step.
  34408. */
  34409. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34410. /**
  34411. * @hidden
  34412. * Defines the actions happening just before the active camera is drawing.
  34413. */
  34414. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34415. /**
  34416. * @hidden
  34417. * Defines the actions happening just before a render target is drawing.
  34418. */
  34419. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34420. /**
  34421. * @hidden
  34422. * Defines the actions happening just before a rendering group is drawing.
  34423. */
  34424. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34425. /**
  34426. * @hidden
  34427. * Defines the actions happening just before a mesh is drawing.
  34428. */
  34429. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34430. /**
  34431. * @hidden
  34432. * Defines the actions happening just after a mesh has been drawn.
  34433. */
  34434. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34435. /**
  34436. * @hidden
  34437. * Defines the actions happening just after a rendering group has been drawn.
  34438. */
  34439. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34440. /**
  34441. * @hidden
  34442. * Defines the actions happening just after the active camera has been drawn.
  34443. */
  34444. _afterCameraDrawStage: Stage<CameraStageAction>;
  34445. /**
  34446. * @hidden
  34447. * Defines the actions happening just after a render target has been drawn.
  34448. */
  34449. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34450. /**
  34451. * @hidden
  34452. * Defines the actions happening just after rendering all cameras and computing intersections.
  34453. */
  34454. _afterRenderStage: Stage<SimpleStageAction>;
  34455. /**
  34456. * @hidden
  34457. * Defines the actions happening when a pointer move event happens.
  34458. */
  34459. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34460. /**
  34461. * @hidden
  34462. * Defines the actions happening when a pointer down event happens.
  34463. */
  34464. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening when a pointer up event happens.
  34468. */
  34469. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34470. /**
  34471. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34472. */
  34473. private geometriesByUniqueId;
  34474. /**
  34475. * Creates a new Scene
  34476. * @param engine defines the engine to use to render this scene
  34477. * @param options defines the scene options
  34478. */
  34479. constructor(engine: Engine, options?: SceneOptions);
  34480. /**
  34481. * Gets a string idenfifying the name of the class
  34482. * @returns "Scene" string
  34483. */
  34484. getClassName(): string;
  34485. private _defaultMeshCandidates;
  34486. /**
  34487. * @hidden
  34488. */
  34489. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34490. private _defaultSubMeshCandidates;
  34491. /**
  34492. * @hidden
  34493. */
  34494. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34495. /**
  34496. * Sets the default candidate providers for the scene.
  34497. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34498. * and getCollidingSubMeshCandidates to their default function
  34499. */
  34500. setDefaultCandidateProviders(): void;
  34501. /**
  34502. * Gets the mesh that is currently under the pointer
  34503. */
  34504. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34505. /**
  34506. * Gets or sets the current on-screen X position of the pointer
  34507. */
  34508. pointerX: number;
  34509. /**
  34510. * Gets or sets the current on-screen Y position of the pointer
  34511. */
  34512. pointerY: number;
  34513. /**
  34514. * Gets the cached material (ie. the latest rendered one)
  34515. * @returns the cached material
  34516. */
  34517. getCachedMaterial(): Nullable<Material>;
  34518. /**
  34519. * Gets the cached effect (ie. the latest rendered one)
  34520. * @returns the cached effect
  34521. */
  34522. getCachedEffect(): Nullable<Effect>;
  34523. /**
  34524. * Gets the cached visibility state (ie. the latest rendered one)
  34525. * @returns the cached visibility state
  34526. */
  34527. getCachedVisibility(): Nullable<number>;
  34528. /**
  34529. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34530. * @param material defines the current material
  34531. * @param effect defines the current effect
  34532. * @param visibility defines the current visibility state
  34533. * @returns true if one parameter is not cached
  34534. */
  34535. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34536. /**
  34537. * Gets the engine associated with the scene
  34538. * @returns an Engine
  34539. */
  34540. getEngine(): Engine;
  34541. /**
  34542. * Gets the total number of vertices rendered per frame
  34543. * @returns the total number of vertices rendered per frame
  34544. */
  34545. getTotalVertices(): number;
  34546. /**
  34547. * Gets the performance counter for total vertices
  34548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34549. */
  34550. readonly totalVerticesPerfCounter: PerfCounter;
  34551. /**
  34552. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34553. * @returns the total number of active indices rendered per frame
  34554. */
  34555. getActiveIndices(): number;
  34556. /**
  34557. * Gets the performance counter for active indices
  34558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34559. */
  34560. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34561. /**
  34562. * Gets the total number of active particles rendered per frame
  34563. * @returns the total number of active particles rendered per frame
  34564. */
  34565. getActiveParticles(): number;
  34566. /**
  34567. * Gets the performance counter for active particles
  34568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34569. */
  34570. readonly activeParticlesPerfCounter: PerfCounter;
  34571. /**
  34572. * Gets the total number of active bones rendered per frame
  34573. * @returns the total number of active bones rendered per frame
  34574. */
  34575. getActiveBones(): number;
  34576. /**
  34577. * Gets the performance counter for active bones
  34578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34579. */
  34580. readonly activeBonesPerfCounter: PerfCounter;
  34581. /**
  34582. * Gets the array of active meshes
  34583. * @returns an array of AbstractMesh
  34584. */
  34585. getActiveMeshes(): SmartArray<AbstractMesh>;
  34586. /**
  34587. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34588. * @returns a number
  34589. */
  34590. getAnimationRatio(): number;
  34591. /**
  34592. * Gets an unique Id for the current render phase
  34593. * @returns a number
  34594. */
  34595. getRenderId(): number;
  34596. /**
  34597. * Gets an unique Id for the current frame
  34598. * @returns a number
  34599. */
  34600. getFrameId(): number;
  34601. /** Call this function if you want to manually increment the render Id*/
  34602. incrementRenderId(): void;
  34603. private _createUbo;
  34604. /**
  34605. * Use this method to simulate a pointer move on a mesh
  34606. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34607. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34608. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34609. * @returns the current scene
  34610. */
  34611. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34612. /**
  34613. * Use this method to simulate a pointer down on a mesh
  34614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34617. * @returns the current scene
  34618. */
  34619. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34620. /**
  34621. * Use this method to simulate a pointer up on a mesh
  34622. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34623. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34624. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34625. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34626. * @returns the current scene
  34627. */
  34628. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34629. /**
  34630. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34631. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34632. * @returns true if the pointer was captured
  34633. */
  34634. isPointerCaptured(pointerId?: number): boolean;
  34635. /**
  34636. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34637. * @param attachUp defines if you want to attach events to pointerup
  34638. * @param attachDown defines if you want to attach events to pointerdown
  34639. * @param attachMove defines if you want to attach events to pointermove
  34640. */
  34641. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34642. /** Detaches all event handlers*/
  34643. detachControl(): void;
  34644. /**
  34645. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34646. * Delay loaded resources are not taking in account
  34647. * @return true if all required resources are ready
  34648. */
  34649. isReady(): boolean;
  34650. /** Resets all cached information relative to material (including effect and visibility) */
  34651. resetCachedMaterial(): void;
  34652. /**
  34653. * Registers a function to be called before every frame render
  34654. * @param func defines the function to register
  34655. */
  34656. registerBeforeRender(func: () => void): void;
  34657. /**
  34658. * Unregisters a function called before every frame render
  34659. * @param func defines the function to unregister
  34660. */
  34661. unregisterBeforeRender(func: () => void): void;
  34662. /**
  34663. * Registers a function to be called after every frame render
  34664. * @param func defines the function to register
  34665. */
  34666. registerAfterRender(func: () => void): void;
  34667. /**
  34668. * Unregisters a function called after every frame render
  34669. * @param func defines the function to unregister
  34670. */
  34671. unregisterAfterRender(func: () => void): void;
  34672. private _executeOnceBeforeRender;
  34673. /**
  34674. * The provided function will run before render once and will be disposed afterwards.
  34675. * A timeout delay can be provided so that the function will be executed in N ms.
  34676. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34677. * @param func The function to be executed.
  34678. * @param timeout optional delay in ms
  34679. */
  34680. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34681. /** @hidden */
  34682. _addPendingData(data: any): void;
  34683. /** @hidden */
  34684. _removePendingData(data: any): void;
  34685. /**
  34686. * Returns the number of items waiting to be loaded
  34687. * @returns the number of items waiting to be loaded
  34688. */
  34689. getWaitingItemsCount(): number;
  34690. /**
  34691. * Returns a boolean indicating if the scene is still loading data
  34692. */
  34693. readonly isLoading: boolean;
  34694. /**
  34695. * Registers a function to be executed when the scene is ready
  34696. * @param {Function} func - the function to be executed
  34697. */
  34698. executeWhenReady(func: () => void): void;
  34699. /**
  34700. * Returns a promise that resolves when the scene is ready
  34701. * @returns A promise that resolves when the scene is ready
  34702. */
  34703. whenReadyAsync(): Promise<void>;
  34704. /** @hidden */
  34705. _checkIsReady(): void;
  34706. /**
  34707. * Gets all animatable attached to the scene
  34708. */
  34709. readonly animatables: Animatable[];
  34710. /**
  34711. * Resets the last animation time frame.
  34712. * Useful to override when animations start running when loading a scene for the first time.
  34713. */
  34714. resetLastAnimationTimeFrame(): void;
  34715. /**
  34716. * Gets the current view matrix
  34717. * @returns a Matrix
  34718. */
  34719. getViewMatrix(): Matrix;
  34720. /**
  34721. * Gets the current projection matrix
  34722. * @returns a Matrix
  34723. */
  34724. getProjectionMatrix(): Matrix;
  34725. /**
  34726. * Gets the current transform matrix
  34727. * @returns a Matrix made of View * Projection
  34728. */
  34729. getTransformMatrix(): Matrix;
  34730. /**
  34731. * Sets the current transform matrix
  34732. * @param viewL defines the View matrix to use
  34733. * @param projectionL defines the Projection matrix to use
  34734. * @param viewR defines the right View matrix to use (if provided)
  34735. * @param projectionR defines the right Projection matrix to use (if provided)
  34736. */
  34737. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34738. /**
  34739. * Gets the uniform buffer used to store scene data
  34740. * @returns a UniformBuffer
  34741. */
  34742. getSceneUniformBuffer(): UniformBuffer;
  34743. /**
  34744. * Gets an unique (relatively to the current scene) Id
  34745. * @returns an unique number for the scene
  34746. */
  34747. getUniqueId(): number;
  34748. /**
  34749. * Add a mesh to the list of scene's meshes
  34750. * @param newMesh defines the mesh to add
  34751. * @param recursive if all child meshes should also be added to the scene
  34752. */
  34753. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34754. /**
  34755. * Remove a mesh for the list of scene's meshes
  34756. * @param toRemove defines the mesh to remove
  34757. * @param recursive if all child meshes should also be removed from the scene
  34758. * @returns the index where the mesh was in the mesh list
  34759. */
  34760. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34761. /**
  34762. * Add a transform node to the list of scene's transform nodes
  34763. * @param newTransformNode defines the transform node to add
  34764. */
  34765. addTransformNode(newTransformNode: TransformNode): void;
  34766. /**
  34767. * Remove a transform node for the list of scene's transform nodes
  34768. * @param toRemove defines the transform node to remove
  34769. * @returns the index where the transform node was in the transform node list
  34770. */
  34771. removeTransformNode(toRemove: TransformNode): number;
  34772. /**
  34773. * Remove a skeleton for the list of scene's skeletons
  34774. * @param toRemove defines the skeleton to remove
  34775. * @returns the index where the skeleton was in the skeleton list
  34776. */
  34777. removeSkeleton(toRemove: Skeleton): number;
  34778. /**
  34779. * Remove a morph target for the list of scene's morph targets
  34780. * @param toRemove defines the morph target to remove
  34781. * @returns the index where the morph target was in the morph target list
  34782. */
  34783. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34784. /**
  34785. * Remove a light for the list of scene's lights
  34786. * @param toRemove defines the light to remove
  34787. * @returns the index where the light was in the light list
  34788. */
  34789. removeLight(toRemove: Light): number;
  34790. /**
  34791. * Remove a camera for the list of scene's cameras
  34792. * @param toRemove defines the camera to remove
  34793. * @returns the index where the camera was in the camera list
  34794. */
  34795. removeCamera(toRemove: Camera): number;
  34796. /**
  34797. * Remove a particle system for the list of scene's particle systems
  34798. * @param toRemove defines the particle system to remove
  34799. * @returns the index where the particle system was in the particle system list
  34800. */
  34801. removeParticleSystem(toRemove: IParticleSystem): number;
  34802. /**
  34803. * Remove a animation for the list of scene's animations
  34804. * @param toRemove defines the animation to remove
  34805. * @returns the index where the animation was in the animation list
  34806. */
  34807. removeAnimation(toRemove: Animation): number;
  34808. /**
  34809. * Will stop the animation of the given target
  34810. * @param target - the target
  34811. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34812. * @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)
  34813. */
  34814. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34815. /**
  34816. * Removes the given animation group from this scene.
  34817. * @param toRemove The animation group to remove
  34818. * @returns The index of the removed animation group
  34819. */
  34820. removeAnimationGroup(toRemove: AnimationGroup): number;
  34821. /**
  34822. * Removes the given multi-material from this scene.
  34823. * @param toRemove The multi-material to remove
  34824. * @returns The index of the removed multi-material
  34825. */
  34826. removeMultiMaterial(toRemove: MultiMaterial): number;
  34827. /**
  34828. * Removes the given material from this scene.
  34829. * @param toRemove The material to remove
  34830. * @returns The index of the removed material
  34831. */
  34832. removeMaterial(toRemove: Material): number;
  34833. /**
  34834. * Removes the given action manager from this scene.
  34835. * @param toRemove The action manager to remove
  34836. * @returns The index of the removed action manager
  34837. */
  34838. removeActionManager(toRemove: AbstractActionManager): number;
  34839. /**
  34840. * Removes the given texture from this scene.
  34841. * @param toRemove The texture to remove
  34842. * @returns The index of the removed texture
  34843. */
  34844. removeTexture(toRemove: BaseTexture): number;
  34845. /**
  34846. * Adds the given light to this scene
  34847. * @param newLight The light to add
  34848. */
  34849. addLight(newLight: Light): void;
  34850. /**
  34851. * Sorts the list list based on light priorities
  34852. */
  34853. sortLightsByPriority(): void;
  34854. /**
  34855. * Adds the given camera to this scene
  34856. * @param newCamera The camera to add
  34857. */
  34858. addCamera(newCamera: Camera): void;
  34859. /**
  34860. * Adds the given skeleton to this scene
  34861. * @param newSkeleton The skeleton to add
  34862. */
  34863. addSkeleton(newSkeleton: Skeleton): void;
  34864. /**
  34865. * Adds the given particle system to this scene
  34866. * @param newParticleSystem The particle system to add
  34867. */
  34868. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34869. /**
  34870. * Adds the given animation to this scene
  34871. * @param newAnimation The animation to add
  34872. */
  34873. addAnimation(newAnimation: Animation): void;
  34874. /**
  34875. * Adds the given animation group to this scene.
  34876. * @param newAnimationGroup The animation group to add
  34877. */
  34878. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34879. /**
  34880. * Adds the given multi-material to this scene
  34881. * @param newMultiMaterial The multi-material to add
  34882. */
  34883. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34884. /**
  34885. * Adds the given material to this scene
  34886. * @param newMaterial The material to add
  34887. */
  34888. addMaterial(newMaterial: Material): void;
  34889. /**
  34890. * Adds the given morph target to this scene
  34891. * @param newMorphTargetManager The morph target to add
  34892. */
  34893. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34894. /**
  34895. * Adds the given geometry to this scene
  34896. * @param newGeometry The geometry to add
  34897. */
  34898. addGeometry(newGeometry: Geometry): void;
  34899. /**
  34900. * Adds the given action manager to this scene
  34901. * @param newActionManager The action manager to add
  34902. */
  34903. addActionManager(newActionManager: AbstractActionManager): void;
  34904. /**
  34905. * Adds the given texture to this scene.
  34906. * @param newTexture The texture to add
  34907. */
  34908. addTexture(newTexture: BaseTexture): void;
  34909. /**
  34910. * Switch active camera
  34911. * @param newCamera defines the new active camera
  34912. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34913. */
  34914. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34915. /**
  34916. * sets the active camera of the scene using its ID
  34917. * @param id defines the camera's ID
  34918. * @return the new active camera or null if none found.
  34919. */
  34920. setActiveCameraByID(id: string): Nullable<Camera>;
  34921. /**
  34922. * sets the active camera of the scene using its name
  34923. * @param name defines the camera's name
  34924. * @returns the new active camera or null if none found.
  34925. */
  34926. setActiveCameraByName(name: string): Nullable<Camera>;
  34927. /**
  34928. * get an animation group using its name
  34929. * @param name defines the material's name
  34930. * @return the animation group or null if none found.
  34931. */
  34932. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34933. /**
  34934. * Get a material using its unique id
  34935. * @param uniqueId defines the material's unique id
  34936. * @return the material or null if none found.
  34937. */
  34938. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34939. /**
  34940. * get a material using its id
  34941. * @param id defines the material's ID
  34942. * @return the material or null if none found.
  34943. */
  34944. getMaterialByID(id: string): Nullable<Material>;
  34945. /**
  34946. * Gets a the last added material using a given id
  34947. * @param id defines the material's ID
  34948. * @return the last material with the given id or null if none found.
  34949. */
  34950. getLastMaterialByID(id: string): Nullable<Material>;
  34951. /**
  34952. * Gets a material using its name
  34953. * @param name defines the material's name
  34954. * @return the material or null if none found.
  34955. */
  34956. getMaterialByName(name: string): Nullable<Material>;
  34957. /**
  34958. * Get a texture using its unique id
  34959. * @param uniqueId defines the texture's unique id
  34960. * @return the texture or null if none found.
  34961. */
  34962. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34963. /**
  34964. * Gets a camera using its id
  34965. * @param id defines the id to look for
  34966. * @returns the camera or null if not found
  34967. */
  34968. getCameraByID(id: string): Nullable<Camera>;
  34969. /**
  34970. * Gets a camera using its unique id
  34971. * @param uniqueId defines the unique id to look for
  34972. * @returns the camera or null if not found
  34973. */
  34974. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34975. /**
  34976. * Gets a camera using its name
  34977. * @param name defines the camera's name
  34978. * @return the camera or null if none found.
  34979. */
  34980. getCameraByName(name: string): Nullable<Camera>;
  34981. /**
  34982. * Gets a bone using its id
  34983. * @param id defines the bone's id
  34984. * @return the bone or null if not found
  34985. */
  34986. getBoneByID(id: string): Nullable<Bone>;
  34987. /**
  34988. * Gets a bone using its id
  34989. * @param name defines the bone's name
  34990. * @return the bone or null if not found
  34991. */
  34992. getBoneByName(name: string): Nullable<Bone>;
  34993. /**
  34994. * Gets a light node using its name
  34995. * @param name defines the the light's name
  34996. * @return the light or null if none found.
  34997. */
  34998. getLightByName(name: string): Nullable<Light>;
  34999. /**
  35000. * Gets a light node using its id
  35001. * @param id defines the light's id
  35002. * @return the light or null if none found.
  35003. */
  35004. getLightByID(id: string): Nullable<Light>;
  35005. /**
  35006. * Gets a light node using its scene-generated unique ID
  35007. * @param uniqueId defines the light's unique id
  35008. * @return the light or null if none found.
  35009. */
  35010. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35011. /**
  35012. * Gets a particle system by id
  35013. * @param id defines the particle system id
  35014. * @return the corresponding system or null if none found
  35015. */
  35016. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35017. /**
  35018. * Gets a geometry using its ID
  35019. * @param id defines the geometry's id
  35020. * @return the geometry or null if none found.
  35021. */
  35022. getGeometryByID(id: string): Nullable<Geometry>;
  35023. private _getGeometryByUniqueID;
  35024. /**
  35025. * Add a new geometry to this scene
  35026. * @param geometry defines the geometry to be added to the scene.
  35027. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35028. * @return a boolean defining if the geometry was added or not
  35029. */
  35030. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35031. /**
  35032. * Removes an existing geometry
  35033. * @param geometry defines the geometry to be removed from the scene
  35034. * @return a boolean defining if the geometry was removed or not
  35035. */
  35036. removeGeometry(geometry: Geometry): boolean;
  35037. /**
  35038. * Gets the list of geometries attached to the scene
  35039. * @returns an array of Geometry
  35040. */
  35041. getGeometries(): Geometry[];
  35042. /**
  35043. * Gets the first added mesh found of a given ID
  35044. * @param id defines the id to search for
  35045. * @return the mesh found or null if not found at all
  35046. */
  35047. getMeshByID(id: string): Nullable<AbstractMesh>;
  35048. /**
  35049. * Gets a list of meshes using their id
  35050. * @param id defines the id to search for
  35051. * @returns a list of meshes
  35052. */
  35053. getMeshesByID(id: string): Array<AbstractMesh>;
  35054. /**
  35055. * Gets the first added transform node found of a given ID
  35056. * @param id defines the id to search for
  35057. * @return the found transform node or null if not found at all.
  35058. */
  35059. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35060. /**
  35061. * Gets a transform node with its auto-generated unique id
  35062. * @param uniqueId efines the unique id to search for
  35063. * @return the found transform node or null if not found at all.
  35064. */
  35065. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35066. /**
  35067. * Gets a list of transform nodes using their id
  35068. * @param id defines the id to search for
  35069. * @returns a list of transform nodes
  35070. */
  35071. getTransformNodesByID(id: string): Array<TransformNode>;
  35072. /**
  35073. * Gets a mesh with its auto-generated unique id
  35074. * @param uniqueId defines the unique id to search for
  35075. * @return the found mesh or null if not found at all.
  35076. */
  35077. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35078. /**
  35079. * Gets a the last added mesh using a given id
  35080. * @param id defines the id to search for
  35081. * @return the found mesh or null if not found at all.
  35082. */
  35083. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35084. /**
  35085. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35086. * @param id defines the id to search for
  35087. * @return the found node or null if not found at all
  35088. */
  35089. getLastEntryByID(id: string): Nullable<Node>;
  35090. /**
  35091. * Gets a node (Mesh, Camera, Light) using a given id
  35092. * @param id defines the id to search for
  35093. * @return the found node or null if not found at all
  35094. */
  35095. getNodeByID(id: string): Nullable<Node>;
  35096. /**
  35097. * Gets a node (Mesh, Camera, Light) using a given name
  35098. * @param name defines the name to search for
  35099. * @return the found node or null if not found at all.
  35100. */
  35101. getNodeByName(name: string): Nullable<Node>;
  35102. /**
  35103. * Gets a mesh using a given name
  35104. * @param name defines the name to search for
  35105. * @return the found mesh or null if not found at all.
  35106. */
  35107. getMeshByName(name: string): Nullable<AbstractMesh>;
  35108. /**
  35109. * Gets a transform node using a given name
  35110. * @param name defines the name to search for
  35111. * @return the found transform node or null if not found at all.
  35112. */
  35113. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35114. /**
  35115. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35116. * @param id defines the id to search for
  35117. * @return the found skeleton or null if not found at all.
  35118. */
  35119. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35120. /**
  35121. * Gets a skeleton using a given auto generated unique id
  35122. * @param uniqueId defines the unique id to search for
  35123. * @return the found skeleton or null if not found at all.
  35124. */
  35125. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35126. /**
  35127. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35128. * @param id defines the id to search for
  35129. * @return the found skeleton or null if not found at all.
  35130. */
  35131. getSkeletonById(id: string): Nullable<Skeleton>;
  35132. /**
  35133. * Gets a skeleton using a given name
  35134. * @param name defines the name to search for
  35135. * @return the found skeleton or null if not found at all.
  35136. */
  35137. getSkeletonByName(name: string): Nullable<Skeleton>;
  35138. /**
  35139. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35140. * @param id defines the id to search for
  35141. * @return the found morph target manager or null if not found at all.
  35142. */
  35143. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35144. /**
  35145. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35146. * @param id defines the id to search for
  35147. * @return the found morph target or null if not found at all.
  35148. */
  35149. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35150. /**
  35151. * Gets a boolean indicating if the given mesh is active
  35152. * @param mesh defines the mesh to look for
  35153. * @returns true if the mesh is in the active list
  35154. */
  35155. isActiveMesh(mesh: AbstractMesh): boolean;
  35156. /**
  35157. * Return a unique id as a string which can serve as an identifier for the scene
  35158. */
  35159. readonly uid: string;
  35160. /**
  35161. * Add an externaly attached data from its key.
  35162. * This method call will fail and return false, if such key already exists.
  35163. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35164. * @param key the unique key that identifies the data
  35165. * @param data the data object to associate to the key for this Engine instance
  35166. * @return true if no such key were already present and the data was added successfully, false otherwise
  35167. */
  35168. addExternalData<T>(key: string, data: T): boolean;
  35169. /**
  35170. * Get an externaly attached data from its key
  35171. * @param key the unique key that identifies the data
  35172. * @return the associated data, if present (can be null), or undefined if not present
  35173. */
  35174. getExternalData<T>(key: string): Nullable<T>;
  35175. /**
  35176. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35177. * @param key the unique key that identifies the data
  35178. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35179. * @return the associated data, can be null if the factory returned null.
  35180. */
  35181. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35182. /**
  35183. * Remove an externaly attached data from the Engine instance
  35184. * @param key the unique key that identifies the data
  35185. * @return true if the data was successfully removed, false if it doesn't exist
  35186. */
  35187. removeExternalData(key: string): boolean;
  35188. private _evaluateSubMesh;
  35189. /**
  35190. * Clear the processed materials smart array preventing retention point in material dispose.
  35191. */
  35192. freeProcessedMaterials(): void;
  35193. private _preventFreeActiveMeshesAndRenderingGroups;
  35194. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35195. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35196. * when disposing several meshes in a row or a hierarchy of meshes.
  35197. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35198. */
  35199. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35200. /**
  35201. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35202. */
  35203. freeActiveMeshes(): void;
  35204. /**
  35205. * Clear the info related to rendering groups preventing retention points during dispose.
  35206. */
  35207. freeRenderingGroups(): void;
  35208. /** @hidden */
  35209. _isInIntermediateRendering(): boolean;
  35210. /**
  35211. * Lambda returning the list of potentially active meshes.
  35212. */
  35213. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35214. /**
  35215. * Lambda returning the list of potentially active sub meshes.
  35216. */
  35217. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35218. /**
  35219. * Lambda returning the list of potentially intersecting sub meshes.
  35220. */
  35221. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35222. /**
  35223. * Lambda returning the list of potentially colliding sub meshes.
  35224. */
  35225. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35226. private _activeMeshesFrozen;
  35227. /**
  35228. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35229. * @returns the current scene
  35230. */
  35231. freezeActiveMeshes(): Scene;
  35232. /**
  35233. * Use this function to restart evaluating active meshes on every frame
  35234. * @returns the current scene
  35235. */
  35236. unfreezeActiveMeshes(): Scene;
  35237. private _evaluateActiveMeshes;
  35238. private _activeMesh;
  35239. /**
  35240. * Update the transform matrix to update from the current active camera
  35241. * @param force defines a boolean used to force the update even if cache is up to date
  35242. */
  35243. updateTransformMatrix(force?: boolean): void;
  35244. private _bindFrameBuffer;
  35245. /** @hidden */
  35246. _allowPostProcessClearColor: boolean;
  35247. /** @hidden */
  35248. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35249. private _processSubCameras;
  35250. private _checkIntersections;
  35251. /** @hidden */
  35252. _advancePhysicsEngineStep(step: number): void;
  35253. /**
  35254. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35255. */
  35256. getDeterministicFrameTime: () => number;
  35257. /** @hidden */
  35258. _animate(): void;
  35259. /** Execute all animations (for a frame) */
  35260. animate(): void;
  35261. /**
  35262. * Render the scene
  35263. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35264. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35265. */
  35266. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35267. /**
  35268. * Freeze all materials
  35269. * A frozen material will not be updatable but should be faster to render
  35270. */
  35271. freezeMaterials(): void;
  35272. /**
  35273. * Unfreeze all materials
  35274. * A frozen material will not be updatable but should be faster to render
  35275. */
  35276. unfreezeMaterials(): void;
  35277. /**
  35278. * Releases all held ressources
  35279. */
  35280. dispose(): void;
  35281. /**
  35282. * Gets if the scene is already disposed
  35283. */
  35284. readonly isDisposed: boolean;
  35285. /**
  35286. * Call this function to reduce memory footprint of the scene.
  35287. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35288. */
  35289. clearCachedVertexData(): void;
  35290. /**
  35291. * This function will remove the local cached buffer data from texture.
  35292. * It will save memory but will prevent the texture from being rebuilt
  35293. */
  35294. cleanCachedTextureBuffer(): void;
  35295. /**
  35296. * Get the world extend vectors with an optional filter
  35297. *
  35298. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35299. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35300. */
  35301. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35302. min: Vector3;
  35303. max: Vector3;
  35304. };
  35305. /**
  35306. * Creates a ray that can be used to pick in the scene
  35307. * @param x defines the x coordinate of the origin (on-screen)
  35308. * @param y defines the y coordinate of the origin (on-screen)
  35309. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35310. * @param camera defines the camera to use for the picking
  35311. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35312. * @returns a Ray
  35313. */
  35314. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35315. /**
  35316. * Creates a ray that can be used to pick in the scene
  35317. * @param x defines the x coordinate of the origin (on-screen)
  35318. * @param y defines the y coordinate of the origin (on-screen)
  35319. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35320. * @param result defines the ray where to store the picking ray
  35321. * @param camera defines the camera to use for the picking
  35322. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35323. * @returns the current scene
  35324. */
  35325. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35326. /**
  35327. * Creates a ray that can be used to pick in the scene
  35328. * @param x defines the x coordinate of the origin (on-screen)
  35329. * @param y defines the y coordinate of the origin (on-screen)
  35330. * @param camera defines the camera to use for the picking
  35331. * @returns a Ray
  35332. */
  35333. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35334. /**
  35335. * Creates a ray that can be used to pick in the scene
  35336. * @param x defines the x coordinate of the origin (on-screen)
  35337. * @param y defines the y coordinate of the origin (on-screen)
  35338. * @param result defines the ray where to store the picking ray
  35339. * @param camera defines the camera to use for the picking
  35340. * @returns the current scene
  35341. */
  35342. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35343. /** Launch a ray to try to pick a mesh in the scene
  35344. * @param x position on screen
  35345. * @param y position on screen
  35346. * @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
  35347. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35348. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35349. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35350. * @returns a PickingInfo
  35351. */
  35352. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35353. /** Use the given ray to pick a mesh in the scene
  35354. * @param ray The ray to use to pick meshes
  35355. * @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
  35356. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35358. * @returns a PickingInfo
  35359. */
  35360. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35361. /**
  35362. * Launch a ray to try to pick a mesh in the scene
  35363. * @param x X position on screen
  35364. * @param y Y position on screen
  35365. * @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
  35366. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35367. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35368. * @returns an array of PickingInfo
  35369. */
  35370. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35371. /**
  35372. * Launch a ray to try to pick a mesh in the scene
  35373. * @param ray Ray to use
  35374. * @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
  35375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35376. * @returns an array of PickingInfo
  35377. */
  35378. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35379. /**
  35380. * Force the value of meshUnderPointer
  35381. * @param mesh defines the mesh to use
  35382. */
  35383. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35384. /**
  35385. * Gets the mesh under the pointer
  35386. * @returns a Mesh or null if no mesh is under the pointer
  35387. */
  35388. getPointerOverMesh(): Nullable<AbstractMesh>;
  35389. /** @hidden */
  35390. _rebuildGeometries(): void;
  35391. /** @hidden */
  35392. _rebuildTextures(): void;
  35393. private _getByTags;
  35394. /**
  35395. * Get a list of meshes by tags
  35396. * @param tagsQuery defines the tags query to use
  35397. * @param forEach defines a predicate used to filter results
  35398. * @returns an array of Mesh
  35399. */
  35400. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35401. /**
  35402. * Get a list of cameras by tags
  35403. * @param tagsQuery defines the tags query to use
  35404. * @param forEach defines a predicate used to filter results
  35405. * @returns an array of Camera
  35406. */
  35407. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35408. /**
  35409. * Get a list of lights by tags
  35410. * @param tagsQuery defines the tags query to use
  35411. * @param forEach defines a predicate used to filter results
  35412. * @returns an array of Light
  35413. */
  35414. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35415. /**
  35416. * Get a list of materials by tags
  35417. * @param tagsQuery defines the tags query to use
  35418. * @param forEach defines a predicate used to filter results
  35419. * @returns an array of Material
  35420. */
  35421. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35422. /**
  35423. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35424. * This allowed control for front to back rendering or reversly depending of the special needs.
  35425. *
  35426. * @param renderingGroupId The rendering group id corresponding to its index
  35427. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35428. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35429. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35430. */
  35431. 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;
  35432. /**
  35433. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35434. *
  35435. * @param renderingGroupId The rendering group id corresponding to its index
  35436. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35437. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35438. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35439. */
  35440. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35441. /**
  35442. * Gets the current auto clear configuration for one rendering group of the rendering
  35443. * manager.
  35444. * @param index the rendering group index to get the information for
  35445. * @returns The auto clear setup for the requested rendering group
  35446. */
  35447. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35448. private _blockMaterialDirtyMechanism;
  35449. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35450. blockMaterialDirtyMechanism: boolean;
  35451. /**
  35452. * Will flag all materials as dirty to trigger new shader compilation
  35453. * @param flag defines the flag used to specify which material part must be marked as dirty
  35454. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35455. */
  35456. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35457. /** @hidden */
  35458. _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;
  35459. /** @hidden */
  35460. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35461. }
  35462. }
  35463. declare module "babylonjs/assetContainer" {
  35464. import { AbstractScene } from "babylonjs/abstractScene";
  35465. import { Scene } from "babylonjs/scene";
  35466. import { Mesh } from "babylonjs/Meshes/mesh";
  35467. /**
  35468. * Set of assets to keep when moving a scene into an asset container.
  35469. */
  35470. export class KeepAssets extends AbstractScene {
  35471. }
  35472. /**
  35473. * Container with a set of assets that can be added or removed from a scene.
  35474. */
  35475. export class AssetContainer extends AbstractScene {
  35476. /**
  35477. * The scene the AssetContainer belongs to.
  35478. */
  35479. scene: Scene;
  35480. /**
  35481. * Instantiates an AssetContainer.
  35482. * @param scene The scene the AssetContainer belongs to.
  35483. */
  35484. constructor(scene: Scene);
  35485. /**
  35486. * Adds all the assets from the container to the scene.
  35487. */
  35488. addAllToScene(): void;
  35489. /**
  35490. * Removes all the assets in the container from the scene
  35491. */
  35492. removeAllFromScene(): void;
  35493. /**
  35494. * Disposes all the assets in the container
  35495. */
  35496. dispose(): void;
  35497. private _moveAssets;
  35498. /**
  35499. * Removes all the assets contained in the scene and adds them to the container.
  35500. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35501. */
  35502. moveAllFromScene(keepAssets?: KeepAssets): void;
  35503. /**
  35504. * 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.
  35505. * @returns the root mesh
  35506. */
  35507. createRootMesh(): Mesh;
  35508. }
  35509. }
  35510. declare module "babylonjs/abstractScene" {
  35511. import { Scene } from "babylonjs/scene";
  35512. import { Nullable } from "babylonjs/types";
  35513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35514. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35515. import { Geometry } from "babylonjs/Meshes/geometry";
  35516. import { Skeleton } from "babylonjs/Bones/skeleton";
  35517. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35518. import { AssetContainer } from "babylonjs/assetContainer";
  35519. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35520. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35522. import { Material } from "babylonjs/Materials/material";
  35523. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35524. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35525. import { Camera } from "babylonjs/Cameras/camera";
  35526. import { Light } from "babylonjs/Lights/light";
  35527. import { Node } from "babylonjs/node";
  35528. import { Animation } from "babylonjs/Animations/animation";
  35529. /**
  35530. * Defines how the parser contract is defined.
  35531. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35532. */
  35533. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35534. /**
  35535. * Defines how the individual parser contract is defined.
  35536. * These parser can parse an individual asset
  35537. */
  35538. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35539. /**
  35540. * Base class of the scene acting as a container for the different elements composing a scene.
  35541. * This class is dynamically extended by the different components of the scene increasing
  35542. * flexibility and reducing coupling
  35543. */
  35544. export abstract class AbstractScene {
  35545. /**
  35546. * Stores the list of available parsers in the application.
  35547. */
  35548. private static _BabylonFileParsers;
  35549. /**
  35550. * Stores the list of available individual parsers in the application.
  35551. */
  35552. private static _IndividualBabylonFileParsers;
  35553. /**
  35554. * Adds a parser in the list of available ones
  35555. * @param name Defines the name of the parser
  35556. * @param parser Defines the parser to add
  35557. */
  35558. static AddParser(name: string, parser: BabylonFileParser): void;
  35559. /**
  35560. * Gets a general parser from the list of avaialble ones
  35561. * @param name Defines the name of the parser
  35562. * @returns the requested parser or null
  35563. */
  35564. static GetParser(name: string): Nullable<BabylonFileParser>;
  35565. /**
  35566. * Adds n individual parser in the list of available ones
  35567. * @param name Defines the name of the parser
  35568. * @param parser Defines the parser to add
  35569. */
  35570. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35571. /**
  35572. * Gets an individual parser from the list of avaialble ones
  35573. * @param name Defines the name of the parser
  35574. * @returns the requested parser or null
  35575. */
  35576. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35577. /**
  35578. * Parser json data and populate both a scene and its associated container object
  35579. * @param jsonData Defines the data to parse
  35580. * @param scene Defines the scene to parse the data for
  35581. * @param container Defines the container attached to the parsing sequence
  35582. * @param rootUrl Defines the root url of the data
  35583. */
  35584. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35585. /**
  35586. * Gets the list of root nodes (ie. nodes with no parent)
  35587. */
  35588. rootNodes: Node[];
  35589. /** All of the cameras added to this scene
  35590. * @see http://doc.babylonjs.com/babylon101/cameras
  35591. */
  35592. cameras: Camera[];
  35593. /**
  35594. * All of the lights added to this scene
  35595. * @see http://doc.babylonjs.com/babylon101/lights
  35596. */
  35597. lights: Light[];
  35598. /**
  35599. * All of the (abstract) meshes added to this scene
  35600. */
  35601. meshes: AbstractMesh[];
  35602. /**
  35603. * The list of skeletons added to the scene
  35604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35605. */
  35606. skeletons: Skeleton[];
  35607. /**
  35608. * All of the particle systems added to this scene
  35609. * @see http://doc.babylonjs.com/babylon101/particles
  35610. */
  35611. particleSystems: IParticleSystem[];
  35612. /**
  35613. * Gets a list of Animations associated with the scene
  35614. */
  35615. animations: Animation[];
  35616. /**
  35617. * All of the animation groups added to this scene
  35618. * @see http://doc.babylonjs.com/how_to/group
  35619. */
  35620. animationGroups: AnimationGroup[];
  35621. /**
  35622. * All of the multi-materials added to this scene
  35623. * @see http://doc.babylonjs.com/how_to/multi_materials
  35624. */
  35625. multiMaterials: MultiMaterial[];
  35626. /**
  35627. * All of the materials added to this scene
  35628. * In the context of a Scene, it is not supposed to be modified manually.
  35629. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35630. * Note also that the order of the Material wihin the array is not significant and might change.
  35631. * @see http://doc.babylonjs.com/babylon101/materials
  35632. */
  35633. materials: Material[];
  35634. /**
  35635. * The list of morph target managers added to the scene
  35636. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35637. */
  35638. morphTargetManagers: MorphTargetManager[];
  35639. /**
  35640. * The list of geometries used in the scene.
  35641. */
  35642. geometries: Geometry[];
  35643. /**
  35644. * All of the tranform nodes added to this scene
  35645. * In the context of a Scene, it is not supposed to be modified manually.
  35646. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35647. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35648. * @see http://doc.babylonjs.com/how_to/transformnode
  35649. */
  35650. transformNodes: TransformNode[];
  35651. /**
  35652. * ActionManagers available on the scene.
  35653. */
  35654. actionManagers: AbstractActionManager[];
  35655. /**
  35656. * Textures to keep.
  35657. */
  35658. textures: BaseTexture[];
  35659. /**
  35660. * Environment texture for the scene
  35661. */
  35662. environmentTexture: Nullable<BaseTexture>;
  35663. }
  35664. }
  35665. declare module "babylonjs/Audio/sound" {
  35666. import { Observable } from "babylonjs/Misc/observable";
  35667. import { Vector3 } from "babylonjs/Maths/math.vector";
  35668. import { Nullable } from "babylonjs/types";
  35669. import { Scene } from "babylonjs/scene";
  35670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35671. /**
  35672. * Interface used to define options for Sound class
  35673. */
  35674. export interface ISoundOptions {
  35675. /**
  35676. * Does the sound autoplay once loaded.
  35677. */
  35678. autoplay?: boolean;
  35679. /**
  35680. * Does the sound loop after it finishes playing once.
  35681. */
  35682. loop?: boolean;
  35683. /**
  35684. * Sound's volume
  35685. */
  35686. volume?: number;
  35687. /**
  35688. * Is it a spatial sound?
  35689. */
  35690. spatialSound?: boolean;
  35691. /**
  35692. * Maximum distance to hear that sound
  35693. */
  35694. maxDistance?: number;
  35695. /**
  35696. * Uses user defined attenuation function
  35697. */
  35698. useCustomAttenuation?: boolean;
  35699. /**
  35700. * Define the roll off factor of spatial sounds.
  35701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35702. */
  35703. rolloffFactor?: number;
  35704. /**
  35705. * Define the reference distance the sound should be heard perfectly.
  35706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35707. */
  35708. refDistance?: number;
  35709. /**
  35710. * Define the distance attenuation model the sound will follow.
  35711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35712. */
  35713. distanceModel?: string;
  35714. /**
  35715. * Defines the playback speed (1 by default)
  35716. */
  35717. playbackRate?: number;
  35718. /**
  35719. * Defines if the sound is from a streaming source
  35720. */
  35721. streaming?: boolean;
  35722. /**
  35723. * Defines an optional length (in seconds) inside the sound file
  35724. */
  35725. length?: number;
  35726. /**
  35727. * Defines an optional offset (in seconds) inside the sound file
  35728. */
  35729. offset?: number;
  35730. /**
  35731. * If true, URLs will not be required to state the audio file codec to use.
  35732. */
  35733. skipCodecCheck?: boolean;
  35734. }
  35735. /**
  35736. * Defines a sound that can be played in the application.
  35737. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35739. */
  35740. export class Sound {
  35741. /**
  35742. * The name of the sound in the scene.
  35743. */
  35744. name: string;
  35745. /**
  35746. * Does the sound autoplay once loaded.
  35747. */
  35748. autoplay: boolean;
  35749. /**
  35750. * Does the sound loop after it finishes playing once.
  35751. */
  35752. loop: boolean;
  35753. /**
  35754. * Does the sound use a custom attenuation curve to simulate the falloff
  35755. * happening when the source gets further away from the camera.
  35756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35757. */
  35758. useCustomAttenuation: boolean;
  35759. /**
  35760. * The sound track id this sound belongs to.
  35761. */
  35762. soundTrackId: number;
  35763. /**
  35764. * Is this sound currently played.
  35765. */
  35766. isPlaying: boolean;
  35767. /**
  35768. * Is this sound currently paused.
  35769. */
  35770. isPaused: boolean;
  35771. /**
  35772. * Does this sound enables spatial sound.
  35773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35774. */
  35775. spatialSound: boolean;
  35776. /**
  35777. * Define the reference distance the sound should be heard perfectly.
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35779. */
  35780. refDistance: number;
  35781. /**
  35782. * Define the roll off factor of spatial sounds.
  35783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35784. */
  35785. rolloffFactor: number;
  35786. /**
  35787. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35789. */
  35790. maxDistance: number;
  35791. /**
  35792. * Define the distance attenuation model the sound will follow.
  35793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35794. */
  35795. distanceModel: string;
  35796. /**
  35797. * @hidden
  35798. * Back Compat
  35799. **/
  35800. onended: () => any;
  35801. /**
  35802. * Observable event when the current playing sound finishes.
  35803. */
  35804. onEndedObservable: Observable<Sound>;
  35805. private _panningModel;
  35806. private _playbackRate;
  35807. private _streaming;
  35808. private _startTime;
  35809. private _startOffset;
  35810. private _position;
  35811. /** @hidden */
  35812. _positionInEmitterSpace: boolean;
  35813. private _localDirection;
  35814. private _volume;
  35815. private _isReadyToPlay;
  35816. private _isDirectional;
  35817. private _readyToPlayCallback;
  35818. private _audioBuffer;
  35819. private _soundSource;
  35820. private _streamingSource;
  35821. private _soundPanner;
  35822. private _soundGain;
  35823. private _inputAudioNode;
  35824. private _outputAudioNode;
  35825. private _coneInnerAngle;
  35826. private _coneOuterAngle;
  35827. private _coneOuterGain;
  35828. private _scene;
  35829. private _connectedTransformNode;
  35830. private _customAttenuationFunction;
  35831. private _registerFunc;
  35832. private _isOutputConnected;
  35833. private _htmlAudioElement;
  35834. private _urlType;
  35835. private _length?;
  35836. private _offset?;
  35837. /** @hidden */
  35838. static _SceneComponentInitialization: (scene: Scene) => void;
  35839. /**
  35840. * Create a sound and attach it to a scene
  35841. * @param name Name of your sound
  35842. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35843. * @param scene defines the scene the sound belongs to
  35844. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35845. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35846. */
  35847. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35848. /**
  35849. * Release the sound and its associated resources
  35850. */
  35851. dispose(): void;
  35852. /**
  35853. * Gets if the sounds is ready to be played or not.
  35854. * @returns true if ready, otherwise false
  35855. */
  35856. isReady(): boolean;
  35857. private _soundLoaded;
  35858. /**
  35859. * Sets the data of the sound from an audiobuffer
  35860. * @param audioBuffer The audioBuffer containing the data
  35861. */
  35862. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35863. /**
  35864. * Updates the current sounds options such as maxdistance, loop...
  35865. * @param options A JSON object containing values named as the object properties
  35866. */
  35867. updateOptions(options: ISoundOptions): void;
  35868. private _createSpatialParameters;
  35869. private _updateSpatialParameters;
  35870. /**
  35871. * Switch the panning model to HRTF:
  35872. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. switchPanningModelToHRTF(): void;
  35876. /**
  35877. * Switch the panning model to Equal Power:
  35878. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35880. */
  35881. switchPanningModelToEqualPower(): void;
  35882. private _switchPanningModel;
  35883. /**
  35884. * Connect this sound to a sound track audio node like gain...
  35885. * @param soundTrackAudioNode the sound track audio node to connect to
  35886. */
  35887. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35888. /**
  35889. * Transform this sound into a directional source
  35890. * @param coneInnerAngle Size of the inner cone in degree
  35891. * @param coneOuterAngle Size of the outer cone in degree
  35892. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35893. */
  35894. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35895. /**
  35896. * Gets or sets the inner angle for the directional cone.
  35897. */
  35898. /**
  35899. * Gets or sets the inner angle for the directional cone.
  35900. */
  35901. directionalConeInnerAngle: number;
  35902. /**
  35903. * Gets or sets the outer angle for the directional cone.
  35904. */
  35905. /**
  35906. * Gets or sets the outer angle for the directional cone.
  35907. */
  35908. directionalConeOuterAngle: number;
  35909. /**
  35910. * Sets the position of the emitter if spatial sound is enabled
  35911. * @param newPosition Defines the new posisiton
  35912. */
  35913. setPosition(newPosition: Vector3): void;
  35914. /**
  35915. * Sets the local direction of the emitter if spatial sound is enabled
  35916. * @param newLocalDirection Defines the new local direction
  35917. */
  35918. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35919. private _updateDirection;
  35920. /** @hidden */
  35921. updateDistanceFromListener(): void;
  35922. /**
  35923. * Sets a new custom attenuation function for the sound.
  35924. * @param callback Defines the function used for the attenuation
  35925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35926. */
  35927. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35928. /**
  35929. * Play the sound
  35930. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35931. * @param offset (optional) Start the sound at a specific time in seconds
  35932. * @param length (optional) Sound duration (in seconds)
  35933. */
  35934. play(time?: number, offset?: number, length?: number): void;
  35935. private _onended;
  35936. /**
  35937. * Stop the sound
  35938. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35939. */
  35940. stop(time?: number): void;
  35941. /**
  35942. * Put the sound in pause
  35943. */
  35944. pause(): void;
  35945. /**
  35946. * Sets a dedicated volume for this sounds
  35947. * @param newVolume Define the new volume of the sound
  35948. * @param time Define time for gradual change to new volume
  35949. */
  35950. setVolume(newVolume: number, time?: number): void;
  35951. /**
  35952. * Set the sound play back rate
  35953. * @param newPlaybackRate Define the playback rate the sound should be played at
  35954. */
  35955. setPlaybackRate(newPlaybackRate: number): void;
  35956. /**
  35957. * Gets the volume of the sound.
  35958. * @returns the volume of the sound
  35959. */
  35960. getVolume(): number;
  35961. /**
  35962. * Attach the sound to a dedicated mesh
  35963. * @param transformNode The transform node to connect the sound with
  35964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35965. */
  35966. attachToMesh(transformNode: TransformNode): void;
  35967. /**
  35968. * Detach the sound from the previously attached mesh
  35969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35970. */
  35971. detachFromMesh(): void;
  35972. private _onRegisterAfterWorldMatrixUpdate;
  35973. /**
  35974. * Clone the current sound in the scene.
  35975. * @returns the new sound clone
  35976. */
  35977. clone(): Nullable<Sound>;
  35978. /**
  35979. * Gets the current underlying audio buffer containing the data
  35980. * @returns the audio buffer
  35981. */
  35982. getAudioBuffer(): Nullable<AudioBuffer>;
  35983. /**
  35984. * Serializes the Sound in a JSON representation
  35985. * @returns the JSON representation of the sound
  35986. */
  35987. serialize(): any;
  35988. /**
  35989. * Parse a JSON representation of a sound to innstantiate in a given scene
  35990. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35991. * @param scene Define the scene the new parsed sound should be created in
  35992. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35993. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35994. * @returns the newly parsed sound
  35995. */
  35996. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35997. }
  35998. }
  35999. declare module "babylonjs/Actions/directAudioActions" {
  36000. import { Action } from "babylonjs/Actions/action";
  36001. import { Condition } from "babylonjs/Actions/condition";
  36002. import { Sound } from "babylonjs/Audio/sound";
  36003. /**
  36004. * This defines an action helpful to play a defined sound on a triggered action.
  36005. */
  36006. export class PlaySoundAction extends Action {
  36007. private _sound;
  36008. /**
  36009. * Instantiate the action
  36010. * @param triggerOptions defines the trigger options
  36011. * @param sound defines the sound to play
  36012. * @param condition defines the trigger related conditions
  36013. */
  36014. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36015. /** @hidden */
  36016. _prepare(): void;
  36017. /**
  36018. * Execute the action and play the sound.
  36019. */
  36020. execute(): void;
  36021. /**
  36022. * Serializes the actions and its related information.
  36023. * @param parent defines the object to serialize in
  36024. * @returns the serialized object
  36025. */
  36026. serialize(parent: any): any;
  36027. }
  36028. /**
  36029. * This defines an action helpful to stop a defined sound on a triggered action.
  36030. */
  36031. export class StopSoundAction extends Action {
  36032. private _sound;
  36033. /**
  36034. * Instantiate the action
  36035. * @param triggerOptions defines the trigger options
  36036. * @param sound defines the sound to stop
  36037. * @param condition defines the trigger related conditions
  36038. */
  36039. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36040. /** @hidden */
  36041. _prepare(): void;
  36042. /**
  36043. * Execute the action and stop the sound.
  36044. */
  36045. execute(): void;
  36046. /**
  36047. * Serializes the actions and its related information.
  36048. * @param parent defines the object to serialize in
  36049. * @returns the serialized object
  36050. */
  36051. serialize(parent: any): any;
  36052. }
  36053. }
  36054. declare module "babylonjs/Actions/interpolateValueAction" {
  36055. import { Action } from "babylonjs/Actions/action";
  36056. import { Condition } from "babylonjs/Actions/condition";
  36057. import { Observable } from "babylonjs/Misc/observable";
  36058. /**
  36059. * This defines an action responsible to change the value of a property
  36060. * by interpolating between its current value and the newly set one once triggered.
  36061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36062. */
  36063. export class InterpolateValueAction extends Action {
  36064. /**
  36065. * Defines the path of the property where the value should be interpolated
  36066. */
  36067. propertyPath: string;
  36068. /**
  36069. * Defines the target value at the end of the interpolation.
  36070. */
  36071. value: any;
  36072. /**
  36073. * Defines the time it will take for the property to interpolate to the value.
  36074. */
  36075. duration: number;
  36076. /**
  36077. * Defines if the other scene animations should be stopped when the action has been triggered
  36078. */
  36079. stopOtherAnimations?: boolean;
  36080. /**
  36081. * Defines a callback raised once the interpolation animation has been done.
  36082. */
  36083. onInterpolationDone?: () => void;
  36084. /**
  36085. * Observable triggered once the interpolation animation has been done.
  36086. */
  36087. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36088. private _target;
  36089. private _effectiveTarget;
  36090. private _property;
  36091. /**
  36092. * Instantiate the action
  36093. * @param triggerOptions defines the trigger options
  36094. * @param target defines the object containing the value to interpolate
  36095. * @param propertyPath defines the path to the property in the target object
  36096. * @param value defines the target value at the end of the interpolation
  36097. * @param duration deines the time it will take for the property to interpolate to the value.
  36098. * @param condition defines the trigger related conditions
  36099. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36100. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36101. */
  36102. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36103. /** @hidden */
  36104. _prepare(): void;
  36105. /**
  36106. * Execute the action starts the value interpolation.
  36107. */
  36108. execute(): void;
  36109. /**
  36110. * Serializes the actions and its related information.
  36111. * @param parent defines the object to serialize in
  36112. * @returns the serialized object
  36113. */
  36114. serialize(parent: any): any;
  36115. }
  36116. }
  36117. declare module "babylonjs/Actions/index" {
  36118. export * from "babylonjs/Actions/abstractActionManager";
  36119. export * from "babylonjs/Actions/action";
  36120. export * from "babylonjs/Actions/actionEvent";
  36121. export * from "babylonjs/Actions/actionManager";
  36122. export * from "babylonjs/Actions/condition";
  36123. export * from "babylonjs/Actions/directActions";
  36124. export * from "babylonjs/Actions/directAudioActions";
  36125. export * from "babylonjs/Actions/interpolateValueAction";
  36126. }
  36127. declare module "babylonjs/Animations/index" {
  36128. export * from "babylonjs/Animations/animatable";
  36129. export * from "babylonjs/Animations/animation";
  36130. export * from "babylonjs/Animations/animationGroup";
  36131. export * from "babylonjs/Animations/animationPropertiesOverride";
  36132. export * from "babylonjs/Animations/easing";
  36133. export * from "babylonjs/Animations/runtimeAnimation";
  36134. export * from "babylonjs/Animations/animationEvent";
  36135. export * from "babylonjs/Animations/animationGroup";
  36136. export * from "babylonjs/Animations/animationKey";
  36137. export * from "babylonjs/Animations/animationRange";
  36138. export * from "babylonjs/Animations/animatable.interface";
  36139. }
  36140. declare module "babylonjs/Audio/soundTrack" {
  36141. import { Sound } from "babylonjs/Audio/sound";
  36142. import { Analyser } from "babylonjs/Audio/analyser";
  36143. import { Scene } from "babylonjs/scene";
  36144. /**
  36145. * Options allowed during the creation of a sound track.
  36146. */
  36147. export interface ISoundTrackOptions {
  36148. /**
  36149. * The volume the sound track should take during creation
  36150. */
  36151. volume?: number;
  36152. /**
  36153. * Define if the sound track is the main sound track of the scene
  36154. */
  36155. mainTrack?: boolean;
  36156. }
  36157. /**
  36158. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36159. * It will be also used in a future release to apply effects on a specific track.
  36160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36161. */
  36162. export class SoundTrack {
  36163. /**
  36164. * The unique identifier of the sound track in the scene.
  36165. */
  36166. id: number;
  36167. /**
  36168. * The list of sounds included in the sound track.
  36169. */
  36170. soundCollection: Array<Sound>;
  36171. private _outputAudioNode;
  36172. private _scene;
  36173. private _isMainTrack;
  36174. private _connectedAnalyser;
  36175. private _options;
  36176. private _isInitialized;
  36177. /**
  36178. * Creates a new sound track.
  36179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36180. * @param scene Define the scene the sound track belongs to
  36181. * @param options
  36182. */
  36183. constructor(scene: Scene, options?: ISoundTrackOptions);
  36184. private _initializeSoundTrackAudioGraph;
  36185. /**
  36186. * Release the sound track and its associated resources
  36187. */
  36188. dispose(): void;
  36189. /**
  36190. * Adds a sound to this sound track
  36191. * @param sound define the cound to add
  36192. * @ignoreNaming
  36193. */
  36194. AddSound(sound: Sound): void;
  36195. /**
  36196. * Removes a sound to this sound track
  36197. * @param sound define the cound to remove
  36198. * @ignoreNaming
  36199. */
  36200. RemoveSound(sound: Sound): void;
  36201. /**
  36202. * Set a global volume for the full sound track.
  36203. * @param newVolume Define the new volume of the sound track
  36204. */
  36205. setVolume(newVolume: number): void;
  36206. /**
  36207. * Switch the panning model to HRTF:
  36208. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36210. */
  36211. switchPanningModelToHRTF(): void;
  36212. /**
  36213. * Switch the panning model to Equal Power:
  36214. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36216. */
  36217. switchPanningModelToEqualPower(): void;
  36218. /**
  36219. * Connect the sound track to an audio analyser allowing some amazing
  36220. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36222. * @param analyser The analyser to connect to the engine
  36223. */
  36224. connectToAnalyser(analyser: Analyser): void;
  36225. }
  36226. }
  36227. declare module "babylonjs/Audio/audioSceneComponent" {
  36228. import { Sound } from "babylonjs/Audio/sound";
  36229. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36230. import { Nullable } from "babylonjs/types";
  36231. import { Vector3 } from "babylonjs/Maths/math.vector";
  36232. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36233. import { Scene } from "babylonjs/scene";
  36234. import { AbstractScene } from "babylonjs/abstractScene";
  36235. import "babylonjs/Audio/audioEngine";
  36236. module "babylonjs/abstractScene" {
  36237. interface AbstractScene {
  36238. /**
  36239. * The list of sounds used in the scene.
  36240. */
  36241. sounds: Nullable<Array<Sound>>;
  36242. }
  36243. }
  36244. module "babylonjs/scene" {
  36245. interface Scene {
  36246. /**
  36247. * @hidden
  36248. * Backing field
  36249. */
  36250. _mainSoundTrack: SoundTrack;
  36251. /**
  36252. * The main sound track played by the scene.
  36253. * It cotains your primary collection of sounds.
  36254. */
  36255. mainSoundTrack: SoundTrack;
  36256. /**
  36257. * The list of sound tracks added to the scene
  36258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36259. */
  36260. soundTracks: Nullable<Array<SoundTrack>>;
  36261. /**
  36262. * Gets a sound using a given name
  36263. * @param name defines the name to search for
  36264. * @return the found sound or null if not found at all.
  36265. */
  36266. getSoundByName(name: string): Nullable<Sound>;
  36267. /**
  36268. * Gets or sets if audio support is enabled
  36269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36270. */
  36271. audioEnabled: boolean;
  36272. /**
  36273. * Gets or sets if audio will be output to headphones
  36274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36275. */
  36276. headphone: boolean;
  36277. /**
  36278. * Gets or sets custom audio listener position provider
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36280. */
  36281. audioListenerPositionProvider: Nullable<() => Vector3>;
  36282. }
  36283. }
  36284. /**
  36285. * Defines the sound scene component responsible to manage any sounds
  36286. * in a given scene.
  36287. */
  36288. export class AudioSceneComponent implements ISceneSerializableComponent {
  36289. /**
  36290. * The component name helpfull to identify the component in the list of scene components.
  36291. */
  36292. readonly name: string;
  36293. /**
  36294. * The scene the component belongs to.
  36295. */
  36296. scene: Scene;
  36297. private _audioEnabled;
  36298. /**
  36299. * Gets whether audio is enabled or not.
  36300. * Please use related enable/disable method to switch state.
  36301. */
  36302. readonly audioEnabled: boolean;
  36303. private _headphone;
  36304. /**
  36305. * Gets whether audio is outputing to headphone or not.
  36306. * Please use the according Switch methods to change output.
  36307. */
  36308. readonly headphone: boolean;
  36309. private _audioListenerPositionProvider;
  36310. /**
  36311. * Gets the current audio listener position provider
  36312. */
  36313. /**
  36314. * Sets a custom listener position for all sounds in the scene
  36315. * By default, this is the position of the first active camera
  36316. */
  36317. audioListenerPositionProvider: Nullable<() => Vector3>;
  36318. /**
  36319. * Creates a new instance of the component for the given scene
  36320. * @param scene Defines the scene to register the component in
  36321. */
  36322. constructor(scene: Scene);
  36323. /**
  36324. * Registers the component in a given scene
  36325. */
  36326. register(): void;
  36327. /**
  36328. * Rebuilds the elements related to this component in case of
  36329. * context lost for instance.
  36330. */
  36331. rebuild(): void;
  36332. /**
  36333. * Serializes the component data to the specified json object
  36334. * @param serializationObject The object to serialize to
  36335. */
  36336. serialize(serializationObject: any): void;
  36337. /**
  36338. * Adds all the elements from the container to the scene
  36339. * @param container the container holding the elements
  36340. */
  36341. addFromContainer(container: AbstractScene): void;
  36342. /**
  36343. * Removes all the elements in the container from the scene
  36344. * @param container contains the elements to remove
  36345. * @param dispose if the removed element should be disposed (default: false)
  36346. */
  36347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36348. /**
  36349. * Disposes the component and the associated ressources.
  36350. */
  36351. dispose(): void;
  36352. /**
  36353. * Disables audio in the associated scene.
  36354. */
  36355. disableAudio(): void;
  36356. /**
  36357. * Enables audio in the associated scene.
  36358. */
  36359. enableAudio(): void;
  36360. /**
  36361. * Switch audio to headphone output.
  36362. */
  36363. switchAudioModeForHeadphones(): void;
  36364. /**
  36365. * Switch audio to normal speakers.
  36366. */
  36367. switchAudioModeForNormalSpeakers(): void;
  36368. private _afterRender;
  36369. }
  36370. }
  36371. declare module "babylonjs/Audio/weightedsound" {
  36372. import { Sound } from "babylonjs/Audio/sound";
  36373. /**
  36374. * Wraps one or more Sound objects and selects one with random weight for playback.
  36375. */
  36376. export class WeightedSound {
  36377. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36378. loop: boolean;
  36379. private _coneInnerAngle;
  36380. private _coneOuterAngle;
  36381. private _volume;
  36382. /** A Sound is currently playing. */
  36383. isPlaying: boolean;
  36384. /** A Sound is currently paused. */
  36385. isPaused: boolean;
  36386. private _sounds;
  36387. private _weights;
  36388. private _currentIndex?;
  36389. /**
  36390. * Creates a new WeightedSound from the list of sounds given.
  36391. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36392. * @param sounds Array of Sounds that will be selected from.
  36393. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36394. */
  36395. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36396. /**
  36397. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36398. */
  36399. /**
  36400. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36401. */
  36402. directionalConeInnerAngle: number;
  36403. /**
  36404. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36405. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36406. */
  36407. /**
  36408. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36409. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36410. */
  36411. directionalConeOuterAngle: number;
  36412. /**
  36413. * Playback volume.
  36414. */
  36415. /**
  36416. * Playback volume.
  36417. */
  36418. volume: number;
  36419. private _onended;
  36420. /**
  36421. * Suspend playback
  36422. */
  36423. pause(): void;
  36424. /**
  36425. * Stop playback
  36426. */
  36427. stop(): void;
  36428. /**
  36429. * Start playback.
  36430. * @param startOffset Position the clip head at a specific time in seconds.
  36431. */
  36432. play(startOffset?: number): void;
  36433. }
  36434. }
  36435. declare module "babylonjs/Audio/index" {
  36436. export * from "babylonjs/Audio/analyser";
  36437. export * from "babylonjs/Audio/audioEngine";
  36438. export * from "babylonjs/Audio/audioSceneComponent";
  36439. export * from "babylonjs/Audio/sound";
  36440. export * from "babylonjs/Audio/soundTrack";
  36441. export * from "babylonjs/Audio/weightedsound";
  36442. }
  36443. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36444. import { Behavior } from "babylonjs/Behaviors/behavior";
  36445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36446. import { BackEase } from "babylonjs/Animations/easing";
  36447. /**
  36448. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36449. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36450. */
  36451. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36452. /**
  36453. * Gets the name of the behavior.
  36454. */
  36455. readonly name: string;
  36456. /**
  36457. * The easing function used by animations
  36458. */
  36459. static EasingFunction: BackEase;
  36460. /**
  36461. * The easing mode used by animations
  36462. */
  36463. static EasingMode: number;
  36464. /**
  36465. * The duration of the animation, in milliseconds
  36466. */
  36467. transitionDuration: number;
  36468. /**
  36469. * Length of the distance animated by the transition when lower radius is reached
  36470. */
  36471. lowerRadiusTransitionRange: number;
  36472. /**
  36473. * Length of the distance animated by the transition when upper radius is reached
  36474. */
  36475. upperRadiusTransitionRange: number;
  36476. private _autoTransitionRange;
  36477. /**
  36478. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36479. */
  36480. /**
  36481. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36482. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36483. */
  36484. autoTransitionRange: boolean;
  36485. private _attachedCamera;
  36486. private _onAfterCheckInputsObserver;
  36487. private _onMeshTargetChangedObserver;
  36488. /**
  36489. * Initializes the behavior.
  36490. */
  36491. init(): void;
  36492. /**
  36493. * Attaches the behavior to its arc rotate camera.
  36494. * @param camera Defines the camera to attach the behavior to
  36495. */
  36496. attach(camera: ArcRotateCamera): void;
  36497. /**
  36498. * Detaches the behavior from its current arc rotate camera.
  36499. */
  36500. detach(): void;
  36501. private _radiusIsAnimating;
  36502. private _radiusBounceTransition;
  36503. private _animatables;
  36504. private _cachedWheelPrecision;
  36505. /**
  36506. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36507. * @param radiusLimit The limit to check against.
  36508. * @return Bool to indicate if at limit.
  36509. */
  36510. private _isRadiusAtLimit;
  36511. /**
  36512. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36513. * @param radiusDelta The delta by which to animate to. Can be negative.
  36514. */
  36515. private _applyBoundRadiusAnimation;
  36516. /**
  36517. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36518. */
  36519. protected _clearAnimationLocks(): void;
  36520. /**
  36521. * Stops and removes all animations that have been applied to the camera
  36522. */
  36523. stopAllAnimations(): void;
  36524. }
  36525. }
  36526. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36527. import { Behavior } from "babylonjs/Behaviors/behavior";
  36528. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36529. import { ExponentialEase } from "babylonjs/Animations/easing";
  36530. import { Nullable } from "babylonjs/types";
  36531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36532. import { Vector3 } from "babylonjs/Maths/math.vector";
  36533. /**
  36534. * 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.
  36535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36536. */
  36537. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36538. /**
  36539. * Gets the name of the behavior.
  36540. */
  36541. readonly name: string;
  36542. private _mode;
  36543. private _radiusScale;
  36544. private _positionScale;
  36545. private _defaultElevation;
  36546. private _elevationReturnTime;
  36547. private _elevationReturnWaitTime;
  36548. private _zoomStopsAnimation;
  36549. private _framingTime;
  36550. /**
  36551. * The easing function used by animations
  36552. */
  36553. static EasingFunction: ExponentialEase;
  36554. /**
  36555. * The easing mode used by animations
  36556. */
  36557. static EasingMode: number;
  36558. /**
  36559. * Sets the current mode used by the behavior
  36560. */
  36561. /**
  36562. * Gets current mode used by the behavior.
  36563. */
  36564. mode: number;
  36565. /**
  36566. * Sets the scale applied to the radius (1 by default)
  36567. */
  36568. /**
  36569. * Gets the scale applied to the radius
  36570. */
  36571. radiusScale: number;
  36572. /**
  36573. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36574. */
  36575. /**
  36576. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36577. */
  36578. positionScale: number;
  36579. /**
  36580. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36581. * behaviour is triggered, in radians.
  36582. */
  36583. /**
  36584. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36585. * behaviour is triggered, in radians.
  36586. */
  36587. defaultElevation: number;
  36588. /**
  36589. * Sets the time (in milliseconds) taken to return to the default beta position.
  36590. * Negative value indicates camera should not return to default.
  36591. */
  36592. /**
  36593. * Gets the time (in milliseconds) taken to return to the default beta position.
  36594. * Negative value indicates camera should not return to default.
  36595. */
  36596. elevationReturnTime: number;
  36597. /**
  36598. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36599. */
  36600. /**
  36601. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36602. */
  36603. elevationReturnWaitTime: number;
  36604. /**
  36605. * Sets the flag that indicates if user zooming should stop animation.
  36606. */
  36607. /**
  36608. * Gets the flag that indicates if user zooming should stop animation.
  36609. */
  36610. zoomStopsAnimation: boolean;
  36611. /**
  36612. * Sets the transition time when framing the mesh, in milliseconds
  36613. */
  36614. /**
  36615. * Gets the transition time when framing the mesh, in milliseconds
  36616. */
  36617. framingTime: number;
  36618. /**
  36619. * Define if the behavior should automatically change the configured
  36620. * camera limits and sensibilities.
  36621. */
  36622. autoCorrectCameraLimitsAndSensibility: boolean;
  36623. private _onPrePointerObservableObserver;
  36624. private _onAfterCheckInputsObserver;
  36625. private _onMeshTargetChangedObserver;
  36626. private _attachedCamera;
  36627. private _isPointerDown;
  36628. private _lastInteractionTime;
  36629. /**
  36630. * Initializes the behavior.
  36631. */
  36632. init(): void;
  36633. /**
  36634. * Attaches the behavior to its arc rotate camera.
  36635. * @param camera Defines the camera to attach the behavior to
  36636. */
  36637. attach(camera: ArcRotateCamera): void;
  36638. /**
  36639. * Detaches the behavior from its current arc rotate camera.
  36640. */
  36641. detach(): void;
  36642. private _animatables;
  36643. private _betaIsAnimating;
  36644. private _betaTransition;
  36645. private _radiusTransition;
  36646. private _vectorTransition;
  36647. /**
  36648. * Targets the given mesh and updates zoom level accordingly.
  36649. * @param mesh The mesh to target.
  36650. * @param radius Optional. If a cached radius position already exists, overrides default.
  36651. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36652. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36653. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36654. */
  36655. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36656. /**
  36657. * Targets the given mesh with its children and updates zoom level accordingly.
  36658. * @param mesh The mesh to target.
  36659. * @param radius Optional. If a cached radius position already exists, overrides default.
  36660. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36663. */
  36664. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36665. /**
  36666. * Targets the given meshes with their children and updates zoom level accordingly.
  36667. * @param meshes The mesh to target.
  36668. * @param radius Optional. If a cached radius position already exists, overrides default.
  36669. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36670. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36671. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36672. */
  36673. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36674. /**
  36675. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36676. * @param minimumWorld Determines the smaller position of the bounding box extend
  36677. * @param maximumWorld Determines the bigger position of the bounding box extend
  36678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36680. */
  36681. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36682. /**
  36683. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36684. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36685. * frustum width.
  36686. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36687. * to fully enclose the mesh in the viewing frustum.
  36688. */
  36689. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36690. /**
  36691. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36692. * is automatically returned to its default position (expected to be above ground plane).
  36693. */
  36694. private _maintainCameraAboveGround;
  36695. /**
  36696. * Returns the frustum slope based on the canvas ratio and camera FOV
  36697. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36698. */
  36699. private _getFrustumSlope;
  36700. /**
  36701. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36702. */
  36703. private _clearAnimationLocks;
  36704. /**
  36705. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36706. */
  36707. private _applyUserInteraction;
  36708. /**
  36709. * Stops and removes all animations that have been applied to the camera
  36710. */
  36711. stopAllAnimations(): void;
  36712. /**
  36713. * Gets a value indicating if the user is moving the camera
  36714. */
  36715. readonly isUserIsMoving: boolean;
  36716. /**
  36717. * The camera can move all the way towards the mesh.
  36718. */
  36719. static IgnoreBoundsSizeMode: number;
  36720. /**
  36721. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36722. */
  36723. static FitFrustumSidesMode: number;
  36724. }
  36725. }
  36726. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36727. import { Nullable } from "babylonjs/types";
  36728. import { Camera } from "babylonjs/Cameras/camera";
  36729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36730. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36731. /**
  36732. * Base class for Camera Pointer Inputs.
  36733. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36734. * for example usage.
  36735. */
  36736. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36737. /**
  36738. * Defines the camera the input is attached to.
  36739. */
  36740. abstract camera: Camera;
  36741. /**
  36742. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36743. */
  36744. protected _altKey: boolean;
  36745. protected _ctrlKey: boolean;
  36746. protected _metaKey: boolean;
  36747. protected _shiftKey: boolean;
  36748. /**
  36749. * Which mouse buttons were pressed at time of last mouse event.
  36750. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36751. */
  36752. protected _buttonsPressed: number;
  36753. /**
  36754. * Defines the buttons associated with the input to handle camera move.
  36755. */
  36756. buttons: number[];
  36757. /**
  36758. * Attach the input controls to a specific dom element to get the input from.
  36759. * @param element Defines the element the controls should be listened from
  36760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36761. */
  36762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36763. /**
  36764. * Detach the current controls from the specified dom element.
  36765. * @param element Defines the element to stop listening the inputs from
  36766. */
  36767. detachControl(element: Nullable<HTMLElement>): void;
  36768. /**
  36769. * Gets the class name of the current input.
  36770. * @returns the class name
  36771. */
  36772. getClassName(): string;
  36773. /**
  36774. * Get the friendly name associated with the input class.
  36775. * @returns the input friendly name
  36776. */
  36777. getSimpleName(): string;
  36778. /**
  36779. * Called on pointer POINTERDOUBLETAP event.
  36780. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36781. */
  36782. protected onDoubleTap(type: string): void;
  36783. /**
  36784. * Called on pointer POINTERMOVE event if only a single touch is active.
  36785. * Override this method to provide functionality.
  36786. */
  36787. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36788. /**
  36789. * Called on pointer POINTERMOVE event if multiple touches are active.
  36790. * Override this method to provide functionality.
  36791. */
  36792. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36793. /**
  36794. * Called on JS contextmenu event.
  36795. * Override this method to provide functionality.
  36796. */
  36797. protected onContextMenu(evt: PointerEvent): void;
  36798. /**
  36799. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36800. * press.
  36801. * Override this method to provide functionality.
  36802. */
  36803. protected onButtonDown(evt: PointerEvent): void;
  36804. /**
  36805. * Called each time a new POINTERUP event occurs. Ie, for each button
  36806. * release.
  36807. * Override this method to provide functionality.
  36808. */
  36809. protected onButtonUp(evt: PointerEvent): void;
  36810. /**
  36811. * Called when window becomes inactive.
  36812. * Override this method to provide functionality.
  36813. */
  36814. protected onLostFocus(): void;
  36815. private _pointerInput;
  36816. private _observer;
  36817. private _onLostFocus;
  36818. private pointA;
  36819. private pointB;
  36820. }
  36821. }
  36822. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36823. import { Nullable } from "babylonjs/types";
  36824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36825. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36826. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36827. /**
  36828. * Manage the pointers inputs to control an arc rotate camera.
  36829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36830. */
  36831. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36832. /**
  36833. * Defines the camera the input is attached to.
  36834. */
  36835. camera: ArcRotateCamera;
  36836. /**
  36837. * Gets the class name of the current input.
  36838. * @returns the class name
  36839. */
  36840. getClassName(): string;
  36841. /**
  36842. * Defines the buttons associated with the input to handle camera move.
  36843. */
  36844. buttons: number[];
  36845. /**
  36846. * Defines the pointer angular sensibility along the X axis or how fast is
  36847. * the camera rotating.
  36848. */
  36849. angularSensibilityX: number;
  36850. /**
  36851. * Defines the pointer angular sensibility along the Y axis or how fast is
  36852. * the camera rotating.
  36853. */
  36854. angularSensibilityY: number;
  36855. /**
  36856. * Defines the pointer pinch precision or how fast is the camera zooming.
  36857. */
  36858. pinchPrecision: number;
  36859. /**
  36860. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36861. * from 0.
  36862. * It defines the percentage of current camera.radius to use as delta when
  36863. * pinch zoom is used.
  36864. */
  36865. pinchDeltaPercentage: number;
  36866. /**
  36867. * Defines the pointer panning sensibility or how fast is the camera moving.
  36868. */
  36869. panningSensibility: number;
  36870. /**
  36871. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36872. */
  36873. multiTouchPanning: boolean;
  36874. /**
  36875. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36876. * zoom (pinch) through multitouch.
  36877. */
  36878. multiTouchPanAndZoom: boolean;
  36879. /**
  36880. * Revers pinch action direction.
  36881. */
  36882. pinchInwards: boolean;
  36883. private _isPanClick;
  36884. private _twoFingerActivityCount;
  36885. private _isPinching;
  36886. /**
  36887. * Called on pointer POINTERMOVE event if only a single touch is active.
  36888. */
  36889. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36890. /**
  36891. * Called on pointer POINTERDOUBLETAP event.
  36892. */
  36893. protected onDoubleTap(type: string): void;
  36894. /**
  36895. * Called on pointer POINTERMOVE event if multiple touches are active.
  36896. */
  36897. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. */
  36902. protected onButtonDown(evt: PointerEvent): void;
  36903. /**
  36904. * Called each time a new POINTERUP event occurs. Ie, for each button
  36905. * release.
  36906. */
  36907. protected onButtonUp(evt: PointerEvent): void;
  36908. /**
  36909. * Called when window becomes inactive.
  36910. */
  36911. protected onLostFocus(): void;
  36912. }
  36913. }
  36914. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36915. import { Nullable } from "babylonjs/types";
  36916. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36918. /**
  36919. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36921. */
  36922. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36923. /**
  36924. * Defines the camera the input is attached to.
  36925. */
  36926. camera: ArcRotateCamera;
  36927. /**
  36928. * Defines the list of key codes associated with the up action (increase alpha)
  36929. */
  36930. keysUp: number[];
  36931. /**
  36932. * Defines the list of key codes associated with the down action (decrease alpha)
  36933. */
  36934. keysDown: number[];
  36935. /**
  36936. * Defines the list of key codes associated with the left action (increase beta)
  36937. */
  36938. keysLeft: number[];
  36939. /**
  36940. * Defines the list of key codes associated with the right action (decrease beta)
  36941. */
  36942. keysRight: number[];
  36943. /**
  36944. * Defines the list of key codes associated with the reset action.
  36945. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36946. */
  36947. keysReset: number[];
  36948. /**
  36949. * Defines the panning sensibility of the inputs.
  36950. * (How fast is the camera paning)
  36951. */
  36952. panningSensibility: number;
  36953. /**
  36954. * Defines the zooming sensibility of the inputs.
  36955. * (How fast is the camera zooming)
  36956. */
  36957. zoomingSensibility: number;
  36958. /**
  36959. * Defines wether maintaining the alt key down switch the movement mode from
  36960. * orientation to zoom.
  36961. */
  36962. useAltToZoom: boolean;
  36963. /**
  36964. * Rotation speed of the camera
  36965. */
  36966. angularSpeed: number;
  36967. private _keys;
  36968. private _ctrlPressed;
  36969. private _altPressed;
  36970. private _onCanvasBlurObserver;
  36971. private _onKeyboardObserver;
  36972. private _engine;
  36973. private _scene;
  36974. /**
  36975. * Attach the input controls to a specific dom element to get the input from.
  36976. * @param element Defines the element the controls should be listened from
  36977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36978. */
  36979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36980. /**
  36981. * Detach the current controls from the specified dom element.
  36982. * @param element Defines the element to stop listening the inputs from
  36983. */
  36984. detachControl(element: Nullable<HTMLElement>): void;
  36985. /**
  36986. * Update the current camera state depending on the inputs that have been used this frame.
  36987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36988. */
  36989. checkInputs(): void;
  36990. /**
  36991. * Gets the class name of the current intput.
  36992. * @returns the class name
  36993. */
  36994. getClassName(): string;
  36995. /**
  36996. * Get the friendly name associated with the input class.
  36997. * @returns the input friendly name
  36998. */
  36999. getSimpleName(): string;
  37000. }
  37001. }
  37002. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37003. import { Nullable } from "babylonjs/types";
  37004. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37005. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37006. /**
  37007. * Manage the mouse wheel inputs to control an arc rotate camera.
  37008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37009. */
  37010. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37011. /**
  37012. * Defines the camera the input is attached to.
  37013. */
  37014. camera: ArcRotateCamera;
  37015. /**
  37016. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37017. */
  37018. wheelPrecision: number;
  37019. /**
  37020. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37021. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37022. */
  37023. wheelDeltaPercentage: number;
  37024. private _wheel;
  37025. private _observer;
  37026. private computeDeltaFromMouseWheelLegacyEvent;
  37027. /**
  37028. * Attach the input controls to a specific dom element to get the input from.
  37029. * @param element Defines the element the controls should be listened from
  37030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37031. */
  37032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37033. /**
  37034. * Detach the current controls from the specified dom element.
  37035. * @param element Defines the element to stop listening the inputs from
  37036. */
  37037. detachControl(element: Nullable<HTMLElement>): void;
  37038. /**
  37039. * Gets the class name of the current intput.
  37040. * @returns the class name
  37041. */
  37042. getClassName(): string;
  37043. /**
  37044. * Get the friendly name associated with the input class.
  37045. * @returns the input friendly name
  37046. */
  37047. getSimpleName(): string;
  37048. }
  37049. }
  37050. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37051. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37052. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37053. /**
  37054. * Default Inputs manager for the ArcRotateCamera.
  37055. * It groups all the default supported inputs for ease of use.
  37056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37057. */
  37058. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37059. /**
  37060. * Instantiates a new ArcRotateCameraInputsManager.
  37061. * @param camera Defines the camera the inputs belong to
  37062. */
  37063. constructor(camera: ArcRotateCamera);
  37064. /**
  37065. * Add mouse wheel input support to the input manager.
  37066. * @returns the current input manager
  37067. */
  37068. addMouseWheel(): ArcRotateCameraInputsManager;
  37069. /**
  37070. * Add pointers input support to the input manager.
  37071. * @returns the current input manager
  37072. */
  37073. addPointers(): ArcRotateCameraInputsManager;
  37074. /**
  37075. * Add keyboard input support to the input manager.
  37076. * @returns the current input manager
  37077. */
  37078. addKeyboard(): ArcRotateCameraInputsManager;
  37079. }
  37080. }
  37081. declare module "babylonjs/Cameras/arcRotateCamera" {
  37082. import { Observable } from "babylonjs/Misc/observable";
  37083. import { Nullable } from "babylonjs/types";
  37084. import { Scene } from "babylonjs/scene";
  37085. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37087. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37088. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37089. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37090. import { Camera } from "babylonjs/Cameras/camera";
  37091. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37092. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37093. import { Collider } from "babylonjs/Collisions/collider";
  37094. /**
  37095. * This represents an orbital type of camera.
  37096. *
  37097. * 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.
  37098. * 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.
  37099. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37100. */
  37101. export class ArcRotateCamera extends TargetCamera {
  37102. /**
  37103. * Defines the rotation angle of the camera along the longitudinal axis.
  37104. */
  37105. alpha: number;
  37106. /**
  37107. * Defines the rotation angle of the camera along the latitudinal axis.
  37108. */
  37109. beta: number;
  37110. /**
  37111. * Defines the radius of the camera from it s target point.
  37112. */
  37113. radius: number;
  37114. protected _target: Vector3;
  37115. protected _targetHost: Nullable<AbstractMesh>;
  37116. /**
  37117. * Defines the target point of the camera.
  37118. * The camera looks towards it form the radius distance.
  37119. */
  37120. target: Vector3;
  37121. /**
  37122. * Define the current local position of the camera in the scene
  37123. */
  37124. position: Vector3;
  37125. protected _upVector: Vector3;
  37126. protected _upToYMatrix: Matrix;
  37127. protected _YToUpMatrix: Matrix;
  37128. /**
  37129. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37130. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37131. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37132. */
  37133. upVector: Vector3;
  37134. /**
  37135. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37136. */
  37137. setMatUp(): void;
  37138. /**
  37139. * Current inertia value on the longitudinal axis.
  37140. * The bigger this number the longer it will take for the camera to stop.
  37141. */
  37142. inertialAlphaOffset: number;
  37143. /**
  37144. * Current inertia value on the latitudinal axis.
  37145. * The bigger this number the longer it will take for the camera to stop.
  37146. */
  37147. inertialBetaOffset: number;
  37148. /**
  37149. * Current inertia value on the radius axis.
  37150. * The bigger this number the longer it will take for the camera to stop.
  37151. */
  37152. inertialRadiusOffset: number;
  37153. /**
  37154. * Minimum allowed angle on the longitudinal axis.
  37155. * This can help limiting how the Camera is able to move in the scene.
  37156. */
  37157. lowerAlphaLimit: Nullable<number>;
  37158. /**
  37159. * Maximum allowed angle on the longitudinal axis.
  37160. * This can help limiting how the Camera is able to move in the scene.
  37161. */
  37162. upperAlphaLimit: Nullable<number>;
  37163. /**
  37164. * Minimum allowed angle on the latitudinal axis.
  37165. * This can help limiting how the Camera is able to move in the scene.
  37166. */
  37167. lowerBetaLimit: number;
  37168. /**
  37169. * Maximum allowed angle on the latitudinal axis.
  37170. * This can help limiting how the Camera is able to move in the scene.
  37171. */
  37172. upperBetaLimit: number;
  37173. /**
  37174. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37175. * This can help limiting how the Camera is able to move in the scene.
  37176. */
  37177. lowerRadiusLimit: Nullable<number>;
  37178. /**
  37179. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37180. * This can help limiting how the Camera is able to move in the scene.
  37181. */
  37182. upperRadiusLimit: Nullable<number>;
  37183. /**
  37184. * Defines the current inertia value used during panning of the camera along the X axis.
  37185. */
  37186. inertialPanningX: number;
  37187. /**
  37188. * Defines the current inertia value used during panning of the camera along the Y axis.
  37189. */
  37190. inertialPanningY: number;
  37191. /**
  37192. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37193. * Basically if your fingers moves away from more than this distance you will be considered
  37194. * in pinch mode.
  37195. */
  37196. pinchToPanMaxDistance: number;
  37197. /**
  37198. * Defines the maximum distance the camera can pan.
  37199. * This could help keeping the cammera always in your scene.
  37200. */
  37201. panningDistanceLimit: Nullable<number>;
  37202. /**
  37203. * Defines the target of the camera before paning.
  37204. */
  37205. panningOriginTarget: Vector3;
  37206. /**
  37207. * Defines the value of the inertia used during panning.
  37208. * 0 would mean stop inertia and one would mean no decelleration at all.
  37209. */
  37210. panningInertia: number;
  37211. /**
  37212. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37213. */
  37214. angularSensibilityX: number;
  37215. /**
  37216. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37217. */
  37218. angularSensibilityY: number;
  37219. /**
  37220. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37221. */
  37222. pinchPrecision: number;
  37223. /**
  37224. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37225. * It will be used instead of pinchDeltaPrecision if different from 0.
  37226. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37227. */
  37228. pinchDeltaPercentage: number;
  37229. /**
  37230. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37231. */
  37232. panningSensibility: number;
  37233. /**
  37234. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37235. */
  37236. keysUp: number[];
  37237. /**
  37238. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37239. */
  37240. keysDown: number[];
  37241. /**
  37242. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37243. */
  37244. keysLeft: number[];
  37245. /**
  37246. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37247. */
  37248. keysRight: number[];
  37249. /**
  37250. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37251. */
  37252. wheelPrecision: number;
  37253. /**
  37254. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37255. * It will be used instead of pinchDeltaPrecision if different from 0.
  37256. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37257. */
  37258. wheelDeltaPercentage: number;
  37259. /**
  37260. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37261. */
  37262. zoomOnFactor: number;
  37263. /**
  37264. * Defines a screen offset for the camera position.
  37265. */
  37266. targetScreenOffset: Vector2;
  37267. /**
  37268. * Allows the camera to be completely reversed.
  37269. * If false the camera can not arrive upside down.
  37270. */
  37271. allowUpsideDown: boolean;
  37272. /**
  37273. * Define if double tap/click is used to restore the previously saved state of the camera.
  37274. */
  37275. useInputToRestoreState: boolean;
  37276. /** @hidden */
  37277. _viewMatrix: Matrix;
  37278. /** @hidden */
  37279. _useCtrlForPanning: boolean;
  37280. /** @hidden */
  37281. _panningMouseButton: number;
  37282. /**
  37283. * Defines the input associated to the camera.
  37284. */
  37285. inputs: ArcRotateCameraInputsManager;
  37286. /** @hidden */
  37287. _reset: () => void;
  37288. /**
  37289. * Defines the allowed panning axis.
  37290. */
  37291. panningAxis: Vector3;
  37292. protected _localDirection: Vector3;
  37293. protected _transformedDirection: Vector3;
  37294. private _bouncingBehavior;
  37295. /**
  37296. * Gets the bouncing behavior of the camera if it has been enabled.
  37297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37298. */
  37299. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37300. /**
  37301. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37303. */
  37304. useBouncingBehavior: boolean;
  37305. private _framingBehavior;
  37306. /**
  37307. * Gets the framing behavior of the camera if it has been enabled.
  37308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37309. */
  37310. readonly framingBehavior: Nullable<FramingBehavior>;
  37311. /**
  37312. * Defines if the framing behavior of the camera is enabled on the camera.
  37313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37314. */
  37315. useFramingBehavior: boolean;
  37316. private _autoRotationBehavior;
  37317. /**
  37318. * Gets the auto rotation behavior of the camera if it has been enabled.
  37319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37320. */
  37321. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37322. /**
  37323. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37325. */
  37326. useAutoRotationBehavior: boolean;
  37327. /**
  37328. * Observable triggered when the mesh target has been changed on the camera.
  37329. */
  37330. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37331. /**
  37332. * Event raised when the camera is colliding with a mesh.
  37333. */
  37334. onCollide: (collidedMesh: AbstractMesh) => void;
  37335. /**
  37336. * Defines whether the camera should check collision with the objects oh the scene.
  37337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37338. */
  37339. checkCollisions: boolean;
  37340. /**
  37341. * Defines the collision radius of the camera.
  37342. * This simulates a sphere around the camera.
  37343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37344. */
  37345. collisionRadius: Vector3;
  37346. protected _collider: Collider;
  37347. protected _previousPosition: Vector3;
  37348. protected _collisionVelocity: Vector3;
  37349. protected _newPosition: Vector3;
  37350. protected _previousAlpha: number;
  37351. protected _previousBeta: number;
  37352. protected _previousRadius: number;
  37353. protected _collisionTriggered: boolean;
  37354. protected _targetBoundingCenter: Nullable<Vector3>;
  37355. private _computationVector;
  37356. /**
  37357. * Instantiates a new ArcRotateCamera in a given scene
  37358. * @param name Defines the name of the camera
  37359. * @param alpha Defines the camera rotation along the logitudinal axis
  37360. * @param beta Defines the camera rotation along the latitudinal axis
  37361. * @param radius Defines the camera distance from its target
  37362. * @param target Defines the camera target
  37363. * @param scene Defines the scene the camera belongs to
  37364. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37365. */
  37366. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37367. /** @hidden */
  37368. _initCache(): void;
  37369. /** @hidden */
  37370. _updateCache(ignoreParentClass?: boolean): void;
  37371. protected _getTargetPosition(): Vector3;
  37372. private _storedAlpha;
  37373. private _storedBeta;
  37374. private _storedRadius;
  37375. private _storedTarget;
  37376. private _storedTargetScreenOffset;
  37377. /**
  37378. * Stores the current state of the camera (alpha, beta, radius and target)
  37379. * @returns the camera itself
  37380. */
  37381. storeState(): Camera;
  37382. /**
  37383. * @hidden
  37384. * Restored camera state. You must call storeState() first
  37385. */
  37386. _restoreStateValues(): boolean;
  37387. /** @hidden */
  37388. _isSynchronizedViewMatrix(): boolean;
  37389. /**
  37390. * Attached controls to the current camera.
  37391. * @param element Defines the element the controls should be listened from
  37392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37393. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37394. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37395. */
  37396. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37397. /**
  37398. * Detach the current controls from the camera.
  37399. * The camera will stop reacting to inputs.
  37400. * @param element Defines the element to stop listening the inputs from
  37401. */
  37402. detachControl(element: HTMLElement): void;
  37403. /** @hidden */
  37404. _checkInputs(): void;
  37405. protected _checkLimits(): void;
  37406. /**
  37407. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37408. */
  37409. rebuildAnglesAndRadius(): void;
  37410. /**
  37411. * Use a position to define the current camera related information like aplha, beta and radius
  37412. * @param position Defines the position to set the camera at
  37413. */
  37414. setPosition(position: Vector3): void;
  37415. /**
  37416. * Defines the target the camera should look at.
  37417. * This will automatically adapt alpha beta and radius to fit within the new target.
  37418. * @param target Defines the new target as a Vector or a mesh
  37419. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37420. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37421. */
  37422. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37423. /** @hidden */
  37424. _getViewMatrix(): Matrix;
  37425. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37426. /**
  37427. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37428. * @param meshes Defines the mesh to zoom on
  37429. * @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)
  37430. */
  37431. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37432. /**
  37433. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37434. * The target will be changed but the radius
  37435. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37436. * @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)
  37437. */
  37438. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37439. min: Vector3;
  37440. max: Vector3;
  37441. distance: number;
  37442. }, doNotUpdateMaxZ?: boolean): void;
  37443. /**
  37444. * @override
  37445. * Override Camera.createRigCamera
  37446. */
  37447. createRigCamera(name: string, cameraIndex: number): Camera;
  37448. /**
  37449. * @hidden
  37450. * @override
  37451. * Override Camera._updateRigCameras
  37452. */
  37453. _updateRigCameras(): void;
  37454. /**
  37455. * Destroy the camera and release the current resources hold by it.
  37456. */
  37457. dispose(): void;
  37458. /**
  37459. * Gets the current object class name.
  37460. * @return the class name
  37461. */
  37462. getClassName(): string;
  37463. }
  37464. }
  37465. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37466. import { Behavior } from "babylonjs/Behaviors/behavior";
  37467. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37468. /**
  37469. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37471. */
  37472. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37473. /**
  37474. * Gets the name of the behavior.
  37475. */
  37476. readonly name: string;
  37477. private _zoomStopsAnimation;
  37478. private _idleRotationSpeed;
  37479. private _idleRotationWaitTime;
  37480. private _idleRotationSpinupTime;
  37481. /**
  37482. * Sets the flag that indicates if user zooming should stop animation.
  37483. */
  37484. /**
  37485. * Gets the flag that indicates if user zooming should stop animation.
  37486. */
  37487. zoomStopsAnimation: boolean;
  37488. /**
  37489. * Sets the default speed at which the camera rotates around the model.
  37490. */
  37491. /**
  37492. * Gets the default speed at which the camera rotates around the model.
  37493. */
  37494. idleRotationSpeed: number;
  37495. /**
  37496. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37497. */
  37498. /**
  37499. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37500. */
  37501. idleRotationWaitTime: number;
  37502. /**
  37503. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37504. */
  37505. /**
  37506. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37507. */
  37508. idleRotationSpinupTime: number;
  37509. /**
  37510. * Gets a value indicating if the camera is currently rotating because of this behavior
  37511. */
  37512. readonly rotationInProgress: boolean;
  37513. private _onPrePointerObservableObserver;
  37514. private _onAfterCheckInputsObserver;
  37515. private _attachedCamera;
  37516. private _isPointerDown;
  37517. private _lastFrameTime;
  37518. private _lastInteractionTime;
  37519. private _cameraRotationSpeed;
  37520. /**
  37521. * Initializes the behavior.
  37522. */
  37523. init(): void;
  37524. /**
  37525. * Attaches the behavior to its arc rotate camera.
  37526. * @param camera Defines the camera to attach the behavior to
  37527. */
  37528. attach(camera: ArcRotateCamera): void;
  37529. /**
  37530. * Detaches the behavior from its current arc rotate camera.
  37531. */
  37532. detach(): void;
  37533. /**
  37534. * Returns true if user is scrolling.
  37535. * @return true if user is scrolling.
  37536. */
  37537. private _userIsZooming;
  37538. private _lastFrameRadius;
  37539. private _shouldAnimationStopForInteraction;
  37540. /**
  37541. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37542. */
  37543. private _applyUserInteraction;
  37544. private _userIsMoving;
  37545. }
  37546. }
  37547. declare module "babylonjs/Behaviors/Cameras/index" {
  37548. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37549. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37550. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37551. }
  37552. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37553. import { Mesh } from "babylonjs/Meshes/mesh";
  37554. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37555. import { Behavior } from "babylonjs/Behaviors/behavior";
  37556. /**
  37557. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37558. */
  37559. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37560. private ui;
  37561. /**
  37562. * The name of the behavior
  37563. */
  37564. name: string;
  37565. /**
  37566. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37567. */
  37568. distanceAwayFromFace: number;
  37569. /**
  37570. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37571. */
  37572. distanceAwayFromBottomOfFace: number;
  37573. private _faceVectors;
  37574. private _target;
  37575. private _scene;
  37576. private _onRenderObserver;
  37577. private _tmpMatrix;
  37578. private _tmpVector;
  37579. /**
  37580. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37581. * @param ui The transform node that should be attched to the mesh
  37582. */
  37583. constructor(ui: TransformNode);
  37584. /**
  37585. * Initializes the behavior
  37586. */
  37587. init(): void;
  37588. private _closestFace;
  37589. private _zeroVector;
  37590. private _lookAtTmpMatrix;
  37591. private _lookAtToRef;
  37592. /**
  37593. * Attaches the AttachToBoxBehavior to the passed in mesh
  37594. * @param target The mesh that the specified node will be attached to
  37595. */
  37596. attach(target: Mesh): void;
  37597. /**
  37598. * Detaches the behavior from the mesh
  37599. */
  37600. detach(): void;
  37601. }
  37602. }
  37603. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37604. import { Behavior } from "babylonjs/Behaviors/behavior";
  37605. import { Mesh } from "babylonjs/Meshes/mesh";
  37606. /**
  37607. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37608. */
  37609. export class FadeInOutBehavior implements Behavior<Mesh> {
  37610. /**
  37611. * Time in milliseconds to delay before fading in (Default: 0)
  37612. */
  37613. delay: number;
  37614. /**
  37615. * Time in milliseconds for the mesh to fade in (Default: 300)
  37616. */
  37617. fadeInTime: number;
  37618. private _millisecondsPerFrame;
  37619. private _hovered;
  37620. private _hoverValue;
  37621. private _ownerNode;
  37622. /**
  37623. * Instatiates the FadeInOutBehavior
  37624. */
  37625. constructor();
  37626. /**
  37627. * The name of the behavior
  37628. */
  37629. readonly name: string;
  37630. /**
  37631. * Initializes the behavior
  37632. */
  37633. init(): void;
  37634. /**
  37635. * Attaches the fade behavior on the passed in mesh
  37636. * @param ownerNode The mesh that will be faded in/out once attached
  37637. */
  37638. attach(ownerNode: Mesh): void;
  37639. /**
  37640. * Detaches the behavior from the mesh
  37641. */
  37642. detach(): void;
  37643. /**
  37644. * Triggers the mesh to begin fading in or out
  37645. * @param value if the object should fade in or out (true to fade in)
  37646. */
  37647. fadeIn(value: boolean): void;
  37648. private _update;
  37649. private _setAllVisibility;
  37650. }
  37651. }
  37652. declare module "babylonjs/Misc/pivotTools" {
  37653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37654. /**
  37655. * Class containing a set of static utilities functions for managing Pivots
  37656. * @hidden
  37657. */
  37658. export class PivotTools {
  37659. private static _PivotCached;
  37660. private static _OldPivotPoint;
  37661. private static _PivotTranslation;
  37662. private static _PivotTmpVector;
  37663. /** @hidden */
  37664. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37665. /** @hidden */
  37666. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37667. }
  37668. }
  37669. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37670. import { Scene } from "babylonjs/scene";
  37671. import { Vector4 } from "babylonjs/Maths/math.vector";
  37672. import { Mesh } from "babylonjs/Meshes/mesh";
  37673. import { Nullable } from "babylonjs/types";
  37674. import { Plane } from "babylonjs/Maths/math.plane";
  37675. /**
  37676. * Class containing static functions to help procedurally build meshes
  37677. */
  37678. export class PlaneBuilder {
  37679. /**
  37680. * Creates a plane mesh
  37681. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37682. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37683. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37687. * @param name defines the name of the mesh
  37688. * @param options defines the options used to create the mesh
  37689. * @param scene defines the hosting scene
  37690. * @returns the plane mesh
  37691. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37692. */
  37693. static CreatePlane(name: string, options: {
  37694. size?: number;
  37695. width?: number;
  37696. height?: number;
  37697. sideOrientation?: number;
  37698. frontUVs?: Vector4;
  37699. backUVs?: Vector4;
  37700. updatable?: boolean;
  37701. sourcePlane?: Plane;
  37702. }, scene?: Nullable<Scene>): Mesh;
  37703. }
  37704. }
  37705. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37706. import { Behavior } from "babylonjs/Behaviors/behavior";
  37707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37708. import { Observable } from "babylonjs/Misc/observable";
  37709. import { Vector3 } from "babylonjs/Maths/math.vector";
  37710. import { Ray } from "babylonjs/Culling/ray";
  37711. import "babylonjs/Meshes/Builders/planeBuilder";
  37712. /**
  37713. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37714. */
  37715. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37716. private static _AnyMouseID;
  37717. /**
  37718. * Abstract mesh the behavior is set on
  37719. */
  37720. attachedNode: AbstractMesh;
  37721. private _dragPlane;
  37722. private _scene;
  37723. private _pointerObserver;
  37724. private _beforeRenderObserver;
  37725. private static _planeScene;
  37726. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37727. /**
  37728. * 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)
  37729. */
  37730. maxDragAngle: number;
  37731. /**
  37732. * @hidden
  37733. */
  37734. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37735. /**
  37736. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37737. */
  37738. currentDraggingPointerID: number;
  37739. /**
  37740. * The last position where the pointer hit the drag plane in world space
  37741. */
  37742. lastDragPosition: Vector3;
  37743. /**
  37744. * If the behavior is currently in a dragging state
  37745. */
  37746. dragging: boolean;
  37747. /**
  37748. * 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)
  37749. */
  37750. dragDeltaRatio: number;
  37751. /**
  37752. * If the drag plane orientation should be updated during the dragging (Default: true)
  37753. */
  37754. updateDragPlane: boolean;
  37755. private _debugMode;
  37756. private _moving;
  37757. /**
  37758. * Fires each time the attached mesh is dragged with the pointer
  37759. * * delta between last drag position and current drag position in world space
  37760. * * dragDistance along the drag axis
  37761. * * dragPlaneNormal normal of the current drag plane used during the drag
  37762. * * dragPlanePoint in world space where the drag intersects the drag plane
  37763. */
  37764. onDragObservable: Observable<{
  37765. delta: Vector3;
  37766. dragPlanePoint: Vector3;
  37767. dragPlaneNormal: Vector3;
  37768. dragDistance: number;
  37769. pointerId: number;
  37770. }>;
  37771. /**
  37772. * Fires each time a drag begins (eg. mouse down on mesh)
  37773. */
  37774. onDragStartObservable: Observable<{
  37775. dragPlanePoint: Vector3;
  37776. pointerId: number;
  37777. }>;
  37778. /**
  37779. * Fires each time a drag ends (eg. mouse release after drag)
  37780. */
  37781. onDragEndObservable: Observable<{
  37782. dragPlanePoint: Vector3;
  37783. pointerId: number;
  37784. }>;
  37785. /**
  37786. * If the attached mesh should be moved when dragged
  37787. */
  37788. moveAttached: boolean;
  37789. /**
  37790. * If the drag behavior will react to drag events (Default: true)
  37791. */
  37792. enabled: boolean;
  37793. /**
  37794. * If pointer events should start and release the drag (Default: true)
  37795. */
  37796. startAndReleaseDragOnPointerEvents: boolean;
  37797. /**
  37798. * If camera controls should be detached during the drag
  37799. */
  37800. detachCameraControls: boolean;
  37801. /**
  37802. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37803. */
  37804. useObjectOrienationForDragging: boolean;
  37805. private _options;
  37806. /**
  37807. * Creates a pointer drag behavior that can be attached to a mesh
  37808. * @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)
  37809. */
  37810. constructor(options?: {
  37811. dragAxis?: Vector3;
  37812. dragPlaneNormal?: Vector3;
  37813. });
  37814. /**
  37815. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37816. */
  37817. validateDrag: (targetPosition: Vector3) => boolean;
  37818. /**
  37819. * The name of the behavior
  37820. */
  37821. readonly name: string;
  37822. /**
  37823. * Initializes the behavior
  37824. */
  37825. init(): void;
  37826. private _tmpVector;
  37827. private _alternatePickedPoint;
  37828. private _worldDragAxis;
  37829. private _targetPosition;
  37830. private _attachedElement;
  37831. /**
  37832. * Attaches the drag behavior the passed in mesh
  37833. * @param ownerNode The mesh that will be dragged around once attached
  37834. */
  37835. attach(ownerNode: AbstractMesh): void;
  37836. /**
  37837. * Force relase the drag action by code.
  37838. */
  37839. releaseDrag(): void;
  37840. private _startDragRay;
  37841. private _lastPointerRay;
  37842. /**
  37843. * Simulates the start of a pointer drag event on the behavior
  37844. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37845. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37846. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37847. */
  37848. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37849. private _startDrag;
  37850. private _dragDelta;
  37851. private _moveDrag;
  37852. private _pickWithRayOnDragPlane;
  37853. private _pointA;
  37854. private _pointB;
  37855. private _pointC;
  37856. private _lineA;
  37857. private _lineB;
  37858. private _localAxis;
  37859. private _lookAt;
  37860. private _updateDragPlanePosition;
  37861. /**
  37862. * Detaches the behavior from the mesh
  37863. */
  37864. detach(): void;
  37865. }
  37866. }
  37867. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37868. import { Mesh } from "babylonjs/Meshes/mesh";
  37869. import { Behavior } from "babylonjs/Behaviors/behavior";
  37870. /**
  37871. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37872. */
  37873. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37874. private _dragBehaviorA;
  37875. private _dragBehaviorB;
  37876. private _startDistance;
  37877. private _initialScale;
  37878. private _targetScale;
  37879. private _ownerNode;
  37880. private _sceneRenderObserver;
  37881. /**
  37882. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37883. */
  37884. constructor();
  37885. /**
  37886. * The name of the behavior
  37887. */
  37888. readonly name: string;
  37889. /**
  37890. * Initializes the behavior
  37891. */
  37892. init(): void;
  37893. private _getCurrentDistance;
  37894. /**
  37895. * Attaches the scale behavior the passed in mesh
  37896. * @param ownerNode The mesh that will be scaled around once attached
  37897. */
  37898. attach(ownerNode: Mesh): void;
  37899. /**
  37900. * Detaches the behavior from the mesh
  37901. */
  37902. detach(): void;
  37903. }
  37904. }
  37905. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37906. import { Behavior } from "babylonjs/Behaviors/behavior";
  37907. import { Mesh } from "babylonjs/Meshes/mesh";
  37908. import { Observable } from "babylonjs/Misc/observable";
  37909. /**
  37910. * 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
  37911. */
  37912. export class SixDofDragBehavior implements Behavior<Mesh> {
  37913. private static _virtualScene;
  37914. private _ownerNode;
  37915. private _sceneRenderObserver;
  37916. private _scene;
  37917. private _targetPosition;
  37918. private _virtualOriginMesh;
  37919. private _virtualDragMesh;
  37920. private _pointerObserver;
  37921. private _moving;
  37922. private _startingOrientation;
  37923. /**
  37924. * 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)
  37925. */
  37926. private zDragFactor;
  37927. /**
  37928. * If the object should rotate to face the drag origin
  37929. */
  37930. rotateDraggedObject: boolean;
  37931. /**
  37932. * If the behavior is currently in a dragging state
  37933. */
  37934. dragging: boolean;
  37935. /**
  37936. * 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)
  37937. */
  37938. dragDeltaRatio: number;
  37939. /**
  37940. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37941. */
  37942. currentDraggingPointerID: number;
  37943. /**
  37944. * If camera controls should be detached during the drag
  37945. */
  37946. detachCameraControls: boolean;
  37947. /**
  37948. * Fires each time a drag starts
  37949. */
  37950. onDragStartObservable: Observable<{}>;
  37951. /**
  37952. * Fires each time a drag ends (eg. mouse release after drag)
  37953. */
  37954. onDragEndObservable: Observable<{}>;
  37955. /**
  37956. * 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
  37957. */
  37958. constructor();
  37959. /**
  37960. * The name of the behavior
  37961. */
  37962. readonly name: string;
  37963. /**
  37964. * Initializes the behavior
  37965. */
  37966. init(): void;
  37967. /**
  37968. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37969. */
  37970. private readonly _pointerCamera;
  37971. /**
  37972. * Attaches the scale behavior the passed in mesh
  37973. * @param ownerNode The mesh that will be scaled around once attached
  37974. */
  37975. attach(ownerNode: Mesh): void;
  37976. /**
  37977. * Detaches the behavior from the mesh
  37978. */
  37979. detach(): void;
  37980. }
  37981. }
  37982. declare module "babylonjs/Behaviors/Meshes/index" {
  37983. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37984. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37985. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37986. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37987. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37988. }
  37989. declare module "babylonjs/Behaviors/index" {
  37990. export * from "babylonjs/Behaviors/behavior";
  37991. export * from "babylonjs/Behaviors/Cameras/index";
  37992. export * from "babylonjs/Behaviors/Meshes/index";
  37993. }
  37994. declare module "babylonjs/Bones/boneIKController" {
  37995. import { Bone } from "babylonjs/Bones/bone";
  37996. import { Vector3 } from "babylonjs/Maths/math.vector";
  37997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37998. import { Nullable } from "babylonjs/types";
  37999. /**
  38000. * Class used to apply inverse kinematics to bones
  38001. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38002. */
  38003. export class BoneIKController {
  38004. private static _tmpVecs;
  38005. private static _tmpQuat;
  38006. private static _tmpMats;
  38007. /**
  38008. * Gets or sets the target mesh
  38009. */
  38010. targetMesh: AbstractMesh;
  38011. /** Gets or sets the mesh used as pole */
  38012. poleTargetMesh: AbstractMesh;
  38013. /**
  38014. * Gets or sets the bone used as pole
  38015. */
  38016. poleTargetBone: Nullable<Bone>;
  38017. /**
  38018. * Gets or sets the target position
  38019. */
  38020. targetPosition: Vector3;
  38021. /**
  38022. * Gets or sets the pole target position
  38023. */
  38024. poleTargetPosition: Vector3;
  38025. /**
  38026. * Gets or sets the pole target local offset
  38027. */
  38028. poleTargetLocalOffset: Vector3;
  38029. /**
  38030. * Gets or sets the pole angle
  38031. */
  38032. poleAngle: number;
  38033. /**
  38034. * Gets or sets the mesh associated with the controller
  38035. */
  38036. mesh: AbstractMesh;
  38037. /**
  38038. * 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)
  38039. */
  38040. slerpAmount: number;
  38041. private _bone1Quat;
  38042. private _bone1Mat;
  38043. private _bone2Ang;
  38044. private _bone1;
  38045. private _bone2;
  38046. private _bone1Length;
  38047. private _bone2Length;
  38048. private _maxAngle;
  38049. private _maxReach;
  38050. private _rightHandedSystem;
  38051. private _bendAxis;
  38052. private _slerping;
  38053. private _adjustRoll;
  38054. /**
  38055. * Gets or sets maximum allowed angle
  38056. */
  38057. maxAngle: number;
  38058. /**
  38059. * Creates a new BoneIKController
  38060. * @param mesh defines the mesh to control
  38061. * @param bone defines the bone to control
  38062. * @param options defines options to set up the controller
  38063. */
  38064. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38065. targetMesh?: AbstractMesh;
  38066. poleTargetMesh?: AbstractMesh;
  38067. poleTargetBone?: Bone;
  38068. poleTargetLocalOffset?: Vector3;
  38069. poleAngle?: number;
  38070. bendAxis?: Vector3;
  38071. maxAngle?: number;
  38072. slerpAmount?: number;
  38073. });
  38074. private _setMaxAngle;
  38075. /**
  38076. * Force the controller to update the bones
  38077. */
  38078. update(): void;
  38079. }
  38080. }
  38081. declare module "babylonjs/Bones/boneLookController" {
  38082. import { Vector3 } from "babylonjs/Maths/math.vector";
  38083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38084. import { Bone } from "babylonjs/Bones/bone";
  38085. import { Space } from "babylonjs/Maths/math.axis";
  38086. /**
  38087. * Class used to make a bone look toward a point in space
  38088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38089. */
  38090. export class BoneLookController {
  38091. private static _tmpVecs;
  38092. private static _tmpQuat;
  38093. private static _tmpMats;
  38094. /**
  38095. * The target Vector3 that the bone will look at
  38096. */
  38097. target: Vector3;
  38098. /**
  38099. * The mesh that the bone is attached to
  38100. */
  38101. mesh: AbstractMesh;
  38102. /**
  38103. * The bone that will be looking to the target
  38104. */
  38105. bone: Bone;
  38106. /**
  38107. * The up axis of the coordinate system that is used when the bone is rotated
  38108. */
  38109. upAxis: Vector3;
  38110. /**
  38111. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38112. */
  38113. upAxisSpace: Space;
  38114. /**
  38115. * Used to make an adjustment to the yaw of the bone
  38116. */
  38117. adjustYaw: number;
  38118. /**
  38119. * Used to make an adjustment to the pitch of the bone
  38120. */
  38121. adjustPitch: number;
  38122. /**
  38123. * Used to make an adjustment to the roll of the bone
  38124. */
  38125. adjustRoll: number;
  38126. /**
  38127. * 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)
  38128. */
  38129. slerpAmount: number;
  38130. private _minYaw;
  38131. private _maxYaw;
  38132. private _minPitch;
  38133. private _maxPitch;
  38134. private _minYawSin;
  38135. private _minYawCos;
  38136. private _maxYawSin;
  38137. private _maxYawCos;
  38138. private _midYawConstraint;
  38139. private _minPitchTan;
  38140. private _maxPitchTan;
  38141. private _boneQuat;
  38142. private _slerping;
  38143. private _transformYawPitch;
  38144. private _transformYawPitchInv;
  38145. private _firstFrameSkipped;
  38146. private _yawRange;
  38147. private _fowardAxis;
  38148. /**
  38149. * Gets or sets the minimum yaw angle that the bone can look to
  38150. */
  38151. minYaw: number;
  38152. /**
  38153. * Gets or sets the maximum yaw angle that the bone can look to
  38154. */
  38155. maxYaw: number;
  38156. /**
  38157. * Gets or sets the minimum pitch angle that the bone can look to
  38158. */
  38159. minPitch: number;
  38160. /**
  38161. * Gets or sets the maximum pitch angle that the bone can look to
  38162. */
  38163. maxPitch: number;
  38164. /**
  38165. * Create a BoneLookController
  38166. * @param mesh the mesh that the bone belongs to
  38167. * @param bone the bone that will be looking to the target
  38168. * @param target the target Vector3 to look at
  38169. * @param options optional settings:
  38170. * * maxYaw: the maximum angle the bone will yaw to
  38171. * * minYaw: the minimum angle the bone will yaw to
  38172. * * maxPitch: the maximum angle the bone will pitch to
  38173. * * minPitch: the minimum angle the bone will yaw to
  38174. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38175. * * upAxis: the up axis of the coordinate system
  38176. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38177. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38178. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38179. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38180. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38181. * * adjustRoll: used to make an adjustment to the roll of the bone
  38182. **/
  38183. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38184. maxYaw?: number;
  38185. minYaw?: number;
  38186. maxPitch?: number;
  38187. minPitch?: number;
  38188. slerpAmount?: number;
  38189. upAxis?: Vector3;
  38190. upAxisSpace?: Space;
  38191. yawAxis?: Vector3;
  38192. pitchAxis?: Vector3;
  38193. adjustYaw?: number;
  38194. adjustPitch?: number;
  38195. adjustRoll?: number;
  38196. });
  38197. /**
  38198. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38199. */
  38200. update(): void;
  38201. private _getAngleDiff;
  38202. private _getAngleBetween;
  38203. private _isAngleBetween;
  38204. }
  38205. }
  38206. declare module "babylonjs/Bones/index" {
  38207. export * from "babylonjs/Bones/bone";
  38208. export * from "babylonjs/Bones/boneIKController";
  38209. export * from "babylonjs/Bones/boneLookController";
  38210. export * from "babylonjs/Bones/skeleton";
  38211. }
  38212. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38213. import { Nullable } from "babylonjs/types";
  38214. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38215. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38216. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38217. /**
  38218. * Manage the gamepad inputs to control an arc rotate camera.
  38219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38220. */
  38221. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38222. /**
  38223. * Defines the camera the input is attached to.
  38224. */
  38225. camera: ArcRotateCamera;
  38226. /**
  38227. * Defines the gamepad the input is gathering event from.
  38228. */
  38229. gamepad: Nullable<Gamepad>;
  38230. /**
  38231. * Defines the gamepad rotation sensiblity.
  38232. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38233. */
  38234. gamepadRotationSensibility: number;
  38235. /**
  38236. * Defines the gamepad move sensiblity.
  38237. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38238. */
  38239. gamepadMoveSensibility: number;
  38240. private _onGamepadConnectedObserver;
  38241. private _onGamepadDisconnectedObserver;
  38242. /**
  38243. * Attach the input controls to a specific dom element to get the input from.
  38244. * @param element Defines the element the controls should be listened from
  38245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38246. */
  38247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38248. /**
  38249. * Detach the current controls from the specified dom element.
  38250. * @param element Defines the element to stop listening the inputs from
  38251. */
  38252. detachControl(element: Nullable<HTMLElement>): void;
  38253. /**
  38254. * Update the current camera state depending on the inputs that have been used this frame.
  38255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38256. */
  38257. checkInputs(): void;
  38258. /**
  38259. * Gets the class name of the current intput.
  38260. * @returns the class name
  38261. */
  38262. getClassName(): string;
  38263. /**
  38264. * Get the friendly name associated with the input class.
  38265. * @returns the input friendly name
  38266. */
  38267. getSimpleName(): string;
  38268. }
  38269. }
  38270. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38271. import { Nullable } from "babylonjs/types";
  38272. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38273. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38274. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38275. interface ArcRotateCameraInputsManager {
  38276. /**
  38277. * Add orientation input support to the input manager.
  38278. * @returns the current input manager
  38279. */
  38280. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38281. }
  38282. }
  38283. /**
  38284. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38286. */
  38287. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38288. /**
  38289. * Defines the camera the input is attached to.
  38290. */
  38291. camera: ArcRotateCamera;
  38292. /**
  38293. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38294. */
  38295. alphaCorrection: number;
  38296. /**
  38297. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38298. */
  38299. gammaCorrection: number;
  38300. private _alpha;
  38301. private _gamma;
  38302. private _dirty;
  38303. private _deviceOrientationHandler;
  38304. /**
  38305. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38306. */
  38307. constructor();
  38308. /**
  38309. * Attach the input controls to a specific dom element to get the input from.
  38310. * @param element Defines the element the controls should be listened from
  38311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38312. */
  38313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38314. /** @hidden */
  38315. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38316. /**
  38317. * Update the current camera state depending on the inputs that have been used this frame.
  38318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38319. */
  38320. checkInputs(): void;
  38321. /**
  38322. * Detach the current controls from the specified dom element.
  38323. * @param element Defines the element to stop listening the inputs from
  38324. */
  38325. detachControl(element: Nullable<HTMLElement>): void;
  38326. /**
  38327. * Gets the class name of the current intput.
  38328. * @returns the class name
  38329. */
  38330. getClassName(): string;
  38331. /**
  38332. * Get the friendly name associated with the input class.
  38333. * @returns the input friendly name
  38334. */
  38335. getSimpleName(): string;
  38336. }
  38337. }
  38338. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38339. import { Nullable } from "babylonjs/types";
  38340. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38341. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38342. /**
  38343. * Listen to mouse events to control the camera.
  38344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38345. */
  38346. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38347. /**
  38348. * Defines the camera the input is attached to.
  38349. */
  38350. camera: FlyCamera;
  38351. /**
  38352. * Defines if touch is enabled. (Default is true.)
  38353. */
  38354. touchEnabled: boolean;
  38355. /**
  38356. * Defines the buttons associated with the input to handle camera rotation.
  38357. */
  38358. buttons: number[];
  38359. /**
  38360. * Assign buttons for Yaw control.
  38361. */
  38362. buttonsYaw: number[];
  38363. /**
  38364. * Assign buttons for Pitch control.
  38365. */
  38366. buttonsPitch: number[];
  38367. /**
  38368. * Assign buttons for Roll control.
  38369. */
  38370. buttonsRoll: number[];
  38371. /**
  38372. * Detect if any button is being pressed while mouse is moved.
  38373. * -1 = Mouse locked.
  38374. * 0 = Left button.
  38375. * 1 = Middle Button.
  38376. * 2 = Right Button.
  38377. */
  38378. activeButton: number;
  38379. /**
  38380. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38381. * Higher values reduce its sensitivity.
  38382. */
  38383. angularSensibility: number;
  38384. private _mousemoveCallback;
  38385. private _observer;
  38386. private _rollObserver;
  38387. private previousPosition;
  38388. private noPreventDefault;
  38389. private element;
  38390. /**
  38391. * Listen to mouse events to control the camera.
  38392. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38394. */
  38395. constructor(touchEnabled?: boolean);
  38396. /**
  38397. * Attach the mouse control to the HTML DOM element.
  38398. * @param element Defines the element that listens to the input events.
  38399. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38400. */
  38401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38402. /**
  38403. * Detach the current controls from the specified dom element.
  38404. * @param element Defines the element to stop listening the inputs from
  38405. */
  38406. detachControl(element: Nullable<HTMLElement>): void;
  38407. /**
  38408. * Gets the class name of the current input.
  38409. * @returns the class name.
  38410. */
  38411. getClassName(): string;
  38412. /**
  38413. * Get the friendly name associated with the input class.
  38414. * @returns the input's friendly name.
  38415. */
  38416. getSimpleName(): string;
  38417. private _pointerInput;
  38418. private _onMouseMove;
  38419. /**
  38420. * Rotate camera by mouse offset.
  38421. */
  38422. private rotateCamera;
  38423. }
  38424. }
  38425. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38426. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38427. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38428. /**
  38429. * Default Inputs manager for the FlyCamera.
  38430. * It groups all the default supported inputs for ease of use.
  38431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38432. */
  38433. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38434. /**
  38435. * Instantiates a new FlyCameraInputsManager.
  38436. * @param camera Defines the camera the inputs belong to.
  38437. */
  38438. constructor(camera: FlyCamera);
  38439. /**
  38440. * Add keyboard input support to the input manager.
  38441. * @returns the new FlyCameraKeyboardMoveInput().
  38442. */
  38443. addKeyboard(): FlyCameraInputsManager;
  38444. /**
  38445. * Add mouse input support to the input manager.
  38446. * @param touchEnabled Enable touch screen support.
  38447. * @returns the new FlyCameraMouseInput().
  38448. */
  38449. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38450. }
  38451. }
  38452. declare module "babylonjs/Cameras/flyCamera" {
  38453. import { Scene } from "babylonjs/scene";
  38454. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38456. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38457. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38458. /**
  38459. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38460. * such as in a 3D Space Shooter or a Flight Simulator.
  38461. */
  38462. export class FlyCamera extends TargetCamera {
  38463. /**
  38464. * Define the collision ellipsoid of the camera.
  38465. * This is helpful for simulating a camera body, like a player's body.
  38466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38467. */
  38468. ellipsoid: Vector3;
  38469. /**
  38470. * Define an offset for the position of the ellipsoid around the camera.
  38471. * This can be helpful if the camera is attached away from the player's body center,
  38472. * such as at its head.
  38473. */
  38474. ellipsoidOffset: Vector3;
  38475. /**
  38476. * Enable or disable collisions of the camera with the rest of the scene objects.
  38477. */
  38478. checkCollisions: boolean;
  38479. /**
  38480. * Enable or disable gravity on the camera.
  38481. */
  38482. applyGravity: boolean;
  38483. /**
  38484. * Define the current direction the camera is moving to.
  38485. */
  38486. cameraDirection: Vector3;
  38487. /**
  38488. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38489. * This overrides and empties cameraRotation.
  38490. */
  38491. rotationQuaternion: Quaternion;
  38492. /**
  38493. * Track Roll to maintain the wanted Rolling when looking around.
  38494. */
  38495. _trackRoll: number;
  38496. /**
  38497. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38498. */
  38499. rollCorrect: number;
  38500. /**
  38501. * Mimic a banked turn, Rolling the camera when Yawing.
  38502. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38503. */
  38504. bankedTurn: boolean;
  38505. /**
  38506. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38507. */
  38508. bankedTurnLimit: number;
  38509. /**
  38510. * Value of 0 disables the banked Roll.
  38511. * Value of 1 is equal to the Yaw angle in radians.
  38512. */
  38513. bankedTurnMultiplier: number;
  38514. /**
  38515. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38516. */
  38517. inputs: FlyCameraInputsManager;
  38518. /**
  38519. * Gets the input sensibility for mouse input.
  38520. * Higher values reduce sensitivity.
  38521. */
  38522. /**
  38523. * Sets the input sensibility for a mouse input.
  38524. * Higher values reduce sensitivity.
  38525. */
  38526. angularSensibility: number;
  38527. /**
  38528. * Get the keys for camera movement forward.
  38529. */
  38530. /**
  38531. * Set the keys for camera movement forward.
  38532. */
  38533. keysForward: number[];
  38534. /**
  38535. * Get the keys for camera movement backward.
  38536. */
  38537. keysBackward: number[];
  38538. /**
  38539. * Get the keys for camera movement up.
  38540. */
  38541. /**
  38542. * Set the keys for camera movement up.
  38543. */
  38544. keysUp: number[];
  38545. /**
  38546. * Get the keys for camera movement down.
  38547. */
  38548. /**
  38549. * Set the keys for camera movement down.
  38550. */
  38551. keysDown: number[];
  38552. /**
  38553. * Get the keys for camera movement left.
  38554. */
  38555. /**
  38556. * Set the keys for camera movement left.
  38557. */
  38558. keysLeft: number[];
  38559. /**
  38560. * Set the keys for camera movement right.
  38561. */
  38562. /**
  38563. * Set the keys for camera movement right.
  38564. */
  38565. keysRight: number[];
  38566. /**
  38567. * Event raised when the camera collides with a mesh in the scene.
  38568. */
  38569. onCollide: (collidedMesh: AbstractMesh) => void;
  38570. private _collider;
  38571. private _needMoveForGravity;
  38572. private _oldPosition;
  38573. private _diffPosition;
  38574. private _newPosition;
  38575. /** @hidden */
  38576. _localDirection: Vector3;
  38577. /** @hidden */
  38578. _transformedDirection: Vector3;
  38579. /**
  38580. * Instantiates a FlyCamera.
  38581. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38582. * such as in a 3D Space Shooter or a Flight Simulator.
  38583. * @param name Define the name of the camera in the scene.
  38584. * @param position Define the starting position of the camera in the scene.
  38585. * @param scene Define the scene the camera belongs to.
  38586. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38587. */
  38588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38589. /**
  38590. * Attach a control to the HTML DOM element.
  38591. * @param element Defines the element that listens to the input events.
  38592. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38593. */
  38594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38595. /**
  38596. * Detach a control from the HTML DOM element.
  38597. * The camera will stop reacting to that input.
  38598. * @param element Defines the element that listens to the input events.
  38599. */
  38600. detachControl(element: HTMLElement): void;
  38601. private _collisionMask;
  38602. /**
  38603. * Get the mask that the camera ignores in collision events.
  38604. */
  38605. /**
  38606. * Set the mask that the camera ignores in collision events.
  38607. */
  38608. collisionMask: number;
  38609. /** @hidden */
  38610. _collideWithWorld(displacement: Vector3): void;
  38611. /** @hidden */
  38612. private _onCollisionPositionChange;
  38613. /** @hidden */
  38614. _checkInputs(): void;
  38615. /** @hidden */
  38616. _decideIfNeedsToMove(): boolean;
  38617. /** @hidden */
  38618. _updatePosition(): void;
  38619. /**
  38620. * Restore the Roll to its target value at the rate specified.
  38621. * @param rate - Higher means slower restoring.
  38622. * @hidden
  38623. */
  38624. restoreRoll(rate: number): void;
  38625. /**
  38626. * Destroy the camera and release the current resources held by it.
  38627. */
  38628. dispose(): void;
  38629. /**
  38630. * Get the current object class name.
  38631. * @returns the class name.
  38632. */
  38633. getClassName(): string;
  38634. }
  38635. }
  38636. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38637. import { Nullable } from "babylonjs/types";
  38638. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38639. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38640. /**
  38641. * Listen to keyboard events to control the camera.
  38642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38643. */
  38644. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38645. /**
  38646. * Defines the camera the input is attached to.
  38647. */
  38648. camera: FlyCamera;
  38649. /**
  38650. * The list of keyboard keys used to control the forward move of the camera.
  38651. */
  38652. keysForward: number[];
  38653. /**
  38654. * The list of keyboard keys used to control the backward move of the camera.
  38655. */
  38656. keysBackward: number[];
  38657. /**
  38658. * The list of keyboard keys used to control the forward move of the camera.
  38659. */
  38660. keysUp: number[];
  38661. /**
  38662. * The list of keyboard keys used to control the backward move of the camera.
  38663. */
  38664. keysDown: number[];
  38665. /**
  38666. * The list of keyboard keys used to control the right strafe move of the camera.
  38667. */
  38668. keysRight: number[];
  38669. /**
  38670. * The list of keyboard keys used to control the left strafe move of the camera.
  38671. */
  38672. keysLeft: number[];
  38673. private _keys;
  38674. private _onCanvasBlurObserver;
  38675. private _onKeyboardObserver;
  38676. private _engine;
  38677. private _scene;
  38678. /**
  38679. * Attach the input controls to a specific dom element to get the input from.
  38680. * @param element Defines the element the controls should be listened from
  38681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38682. */
  38683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38684. /**
  38685. * Detach the current controls from the specified dom element.
  38686. * @param element Defines the element to stop listening the inputs from
  38687. */
  38688. detachControl(element: Nullable<HTMLElement>): void;
  38689. /**
  38690. * Gets the class name of the current intput.
  38691. * @returns the class name
  38692. */
  38693. getClassName(): string;
  38694. /** @hidden */
  38695. _onLostFocus(e: FocusEvent): void;
  38696. /**
  38697. * Get the friendly name associated with the input class.
  38698. * @returns the input friendly name
  38699. */
  38700. getSimpleName(): string;
  38701. /**
  38702. * Update the current camera state depending on the inputs that have been used this frame.
  38703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38704. */
  38705. checkInputs(): void;
  38706. }
  38707. }
  38708. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38709. import { Nullable } from "babylonjs/types";
  38710. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38711. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38712. /**
  38713. * Manage the mouse wheel inputs to control a follow camera.
  38714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38715. */
  38716. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38717. /**
  38718. * Defines the camera the input is attached to.
  38719. */
  38720. camera: FollowCamera;
  38721. /**
  38722. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38723. */
  38724. axisControlRadius: boolean;
  38725. /**
  38726. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38727. */
  38728. axisControlHeight: boolean;
  38729. /**
  38730. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38731. */
  38732. axisControlRotation: boolean;
  38733. /**
  38734. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38735. * relation to mouseWheel events.
  38736. */
  38737. wheelPrecision: number;
  38738. /**
  38739. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38740. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38741. */
  38742. wheelDeltaPercentage: number;
  38743. private _wheel;
  38744. private _observer;
  38745. /**
  38746. * Attach the input controls to a specific dom element to get the input from.
  38747. * @param element Defines the element the controls should be listened from
  38748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38749. */
  38750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38751. /**
  38752. * Detach the current controls from the specified dom element.
  38753. * @param element Defines the element to stop listening the inputs from
  38754. */
  38755. detachControl(element: Nullable<HTMLElement>): void;
  38756. /**
  38757. * Gets the class name of the current intput.
  38758. * @returns the class name
  38759. */
  38760. getClassName(): string;
  38761. /**
  38762. * Get the friendly name associated with the input class.
  38763. * @returns the input friendly name
  38764. */
  38765. getSimpleName(): string;
  38766. }
  38767. }
  38768. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38769. import { Nullable } from "babylonjs/types";
  38770. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38771. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38772. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38773. /**
  38774. * Manage the pointers inputs to control an follow camera.
  38775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38776. */
  38777. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38778. /**
  38779. * Defines the camera the input is attached to.
  38780. */
  38781. camera: FollowCamera;
  38782. /**
  38783. * Gets the class name of the current input.
  38784. * @returns the class name
  38785. */
  38786. getClassName(): string;
  38787. /**
  38788. * Defines the pointer angular sensibility along the X axis or how fast is
  38789. * the camera rotating.
  38790. * A negative number will reverse the axis direction.
  38791. */
  38792. angularSensibilityX: number;
  38793. /**
  38794. * Defines the pointer angular sensibility along the Y axis or how fast is
  38795. * the camera rotating.
  38796. * A negative number will reverse the axis direction.
  38797. */
  38798. angularSensibilityY: number;
  38799. /**
  38800. * Defines the pointer pinch precision or how fast is the camera zooming.
  38801. * A negative number will reverse the axis direction.
  38802. */
  38803. pinchPrecision: number;
  38804. /**
  38805. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38806. * from 0.
  38807. * It defines the percentage of current camera.radius to use as delta when
  38808. * pinch zoom is used.
  38809. */
  38810. pinchDeltaPercentage: number;
  38811. /**
  38812. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38813. */
  38814. axisXControlRadius: boolean;
  38815. /**
  38816. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38817. */
  38818. axisXControlHeight: boolean;
  38819. /**
  38820. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38821. */
  38822. axisXControlRotation: boolean;
  38823. /**
  38824. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38825. */
  38826. axisYControlRadius: boolean;
  38827. /**
  38828. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38829. */
  38830. axisYControlHeight: boolean;
  38831. /**
  38832. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38833. */
  38834. axisYControlRotation: boolean;
  38835. /**
  38836. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38837. */
  38838. axisPinchControlRadius: boolean;
  38839. /**
  38840. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38841. */
  38842. axisPinchControlHeight: boolean;
  38843. /**
  38844. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38845. */
  38846. axisPinchControlRotation: boolean;
  38847. /**
  38848. * Log error messages if basic misconfiguration has occurred.
  38849. */
  38850. warningEnable: boolean;
  38851. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38852. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38853. private _warningCounter;
  38854. private _warning;
  38855. }
  38856. }
  38857. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38858. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38859. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38860. /**
  38861. * Default Inputs manager for the FollowCamera.
  38862. * It groups all the default supported inputs for ease of use.
  38863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38864. */
  38865. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38866. /**
  38867. * Instantiates a new FollowCameraInputsManager.
  38868. * @param camera Defines the camera the inputs belong to
  38869. */
  38870. constructor(camera: FollowCamera);
  38871. /**
  38872. * Add keyboard input support to the input manager.
  38873. * @returns the current input manager
  38874. */
  38875. addKeyboard(): FollowCameraInputsManager;
  38876. /**
  38877. * Add mouse wheel input support to the input manager.
  38878. * @returns the current input manager
  38879. */
  38880. addMouseWheel(): FollowCameraInputsManager;
  38881. /**
  38882. * Add pointers input support to the input manager.
  38883. * @returns the current input manager
  38884. */
  38885. addPointers(): FollowCameraInputsManager;
  38886. /**
  38887. * Add orientation input support to the input manager.
  38888. * @returns the current input manager
  38889. */
  38890. addVRDeviceOrientation(): FollowCameraInputsManager;
  38891. }
  38892. }
  38893. declare module "babylonjs/Cameras/followCamera" {
  38894. import { Nullable } from "babylonjs/types";
  38895. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38896. import { Scene } from "babylonjs/scene";
  38897. import { Vector3 } from "babylonjs/Maths/math.vector";
  38898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38899. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38900. /**
  38901. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38902. * an arc rotate version arcFollowCamera are available.
  38903. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38904. */
  38905. export class FollowCamera extends TargetCamera {
  38906. /**
  38907. * Distance the follow camera should follow an object at
  38908. */
  38909. radius: number;
  38910. /**
  38911. * Minimum allowed distance of the camera to the axis of rotation
  38912. * (The camera can not get closer).
  38913. * This can help limiting how the Camera is able to move in the scene.
  38914. */
  38915. lowerRadiusLimit: Nullable<number>;
  38916. /**
  38917. * Maximum allowed distance of the camera to the axis of rotation
  38918. * (The camera can not get further).
  38919. * This can help limiting how the Camera is able to move in the scene.
  38920. */
  38921. upperRadiusLimit: Nullable<number>;
  38922. /**
  38923. * Define a rotation offset between the camera and the object it follows
  38924. */
  38925. rotationOffset: number;
  38926. /**
  38927. * Minimum allowed angle to camera position relative to target object.
  38928. * This can help limiting how the Camera is able to move in the scene.
  38929. */
  38930. lowerRotationOffsetLimit: Nullable<number>;
  38931. /**
  38932. * Maximum allowed angle to camera position relative to target object.
  38933. * This can help limiting how the Camera is able to move in the scene.
  38934. */
  38935. upperRotationOffsetLimit: Nullable<number>;
  38936. /**
  38937. * Define a height offset between the camera and the object it follows.
  38938. * It can help following an object from the top (like a car chaing a plane)
  38939. */
  38940. heightOffset: number;
  38941. /**
  38942. * Minimum allowed height of camera position relative to target object.
  38943. * This can help limiting how the Camera is able to move in the scene.
  38944. */
  38945. lowerHeightOffsetLimit: Nullable<number>;
  38946. /**
  38947. * Maximum allowed height of camera position relative to target object.
  38948. * This can help limiting how the Camera is able to move in the scene.
  38949. */
  38950. upperHeightOffsetLimit: Nullable<number>;
  38951. /**
  38952. * Define how fast the camera can accelerate to follow it s target.
  38953. */
  38954. cameraAcceleration: number;
  38955. /**
  38956. * Define the speed limit of the camera following an object.
  38957. */
  38958. maxCameraSpeed: number;
  38959. /**
  38960. * Define the target of the camera.
  38961. */
  38962. lockedTarget: Nullable<AbstractMesh>;
  38963. /**
  38964. * Defines the input associated with the camera.
  38965. */
  38966. inputs: FollowCameraInputsManager;
  38967. /**
  38968. * Instantiates the follow camera.
  38969. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38970. * @param name Define the name of the camera in the scene
  38971. * @param position Define the position of the camera
  38972. * @param scene Define the scene the camera belong to
  38973. * @param lockedTarget Define the target of the camera
  38974. */
  38975. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38976. private _follow;
  38977. /**
  38978. * Attached controls to the current camera.
  38979. * @param element Defines the element the controls should be listened from
  38980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38981. */
  38982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38983. /**
  38984. * Detach the current controls from the camera.
  38985. * The camera will stop reacting to inputs.
  38986. * @param element Defines the element to stop listening the inputs from
  38987. */
  38988. detachControl(element: HTMLElement): void;
  38989. /** @hidden */
  38990. _checkInputs(): void;
  38991. private _checkLimits;
  38992. /**
  38993. * Gets the camera class name.
  38994. * @returns the class name
  38995. */
  38996. getClassName(): string;
  38997. }
  38998. /**
  38999. * Arc Rotate version of the follow camera.
  39000. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39001. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39002. */
  39003. export class ArcFollowCamera extends TargetCamera {
  39004. /** The longitudinal angle of the camera */
  39005. alpha: number;
  39006. /** The latitudinal angle of the camera */
  39007. beta: number;
  39008. /** The radius of the camera from its target */
  39009. radius: number;
  39010. /** Define the camera target (the messh it should follow) */
  39011. target: Nullable<AbstractMesh>;
  39012. private _cartesianCoordinates;
  39013. /**
  39014. * Instantiates a new ArcFollowCamera
  39015. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39016. * @param name Define the name of the camera
  39017. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39018. * @param beta Define the rotation angle of the camera around the elevation axis
  39019. * @param radius Define the radius of the camera from its target point
  39020. * @param target Define the target of the camera
  39021. * @param scene Define the scene the camera belongs to
  39022. */
  39023. constructor(name: string,
  39024. /** The longitudinal angle of the camera */
  39025. alpha: number,
  39026. /** The latitudinal angle of the camera */
  39027. beta: number,
  39028. /** The radius of the camera from its target */
  39029. radius: number,
  39030. /** Define the camera target (the messh it should follow) */
  39031. target: Nullable<AbstractMesh>, scene: Scene);
  39032. private _follow;
  39033. /** @hidden */
  39034. _checkInputs(): void;
  39035. /**
  39036. * Returns the class name of the object.
  39037. * It is mostly used internally for serialization purposes.
  39038. */
  39039. getClassName(): string;
  39040. }
  39041. }
  39042. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39044. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39045. import { Nullable } from "babylonjs/types";
  39046. /**
  39047. * Manage the keyboard inputs to control the movement of a follow camera.
  39048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39049. */
  39050. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39051. /**
  39052. * Defines the camera the input is attached to.
  39053. */
  39054. camera: FollowCamera;
  39055. /**
  39056. * Defines the list of key codes associated with the up action (increase heightOffset)
  39057. */
  39058. keysHeightOffsetIncr: number[];
  39059. /**
  39060. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39061. */
  39062. keysHeightOffsetDecr: number[];
  39063. /**
  39064. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39065. */
  39066. keysHeightOffsetModifierAlt: boolean;
  39067. /**
  39068. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39069. */
  39070. keysHeightOffsetModifierCtrl: boolean;
  39071. /**
  39072. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39073. */
  39074. keysHeightOffsetModifierShift: boolean;
  39075. /**
  39076. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39077. */
  39078. keysRotationOffsetIncr: number[];
  39079. /**
  39080. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39081. */
  39082. keysRotationOffsetDecr: number[];
  39083. /**
  39084. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39085. */
  39086. keysRotationOffsetModifierAlt: boolean;
  39087. /**
  39088. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39089. */
  39090. keysRotationOffsetModifierCtrl: boolean;
  39091. /**
  39092. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39093. */
  39094. keysRotationOffsetModifierShift: boolean;
  39095. /**
  39096. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39097. */
  39098. keysRadiusIncr: number[];
  39099. /**
  39100. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39101. */
  39102. keysRadiusDecr: number[];
  39103. /**
  39104. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39105. */
  39106. keysRadiusModifierAlt: boolean;
  39107. /**
  39108. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39109. */
  39110. keysRadiusModifierCtrl: boolean;
  39111. /**
  39112. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39113. */
  39114. keysRadiusModifierShift: boolean;
  39115. /**
  39116. * Defines the rate of change of heightOffset.
  39117. */
  39118. heightSensibility: number;
  39119. /**
  39120. * Defines the rate of change of rotationOffset.
  39121. */
  39122. rotationSensibility: number;
  39123. /**
  39124. * Defines the rate of change of radius.
  39125. */
  39126. radiusSensibility: number;
  39127. private _keys;
  39128. private _ctrlPressed;
  39129. private _altPressed;
  39130. private _shiftPressed;
  39131. private _onCanvasBlurObserver;
  39132. private _onKeyboardObserver;
  39133. private _engine;
  39134. private _scene;
  39135. /**
  39136. * Attach the input controls to a specific dom element to get the input from.
  39137. * @param element Defines the element the controls should be listened from
  39138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39139. */
  39140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39141. /**
  39142. * Detach the current controls from the specified dom element.
  39143. * @param element Defines the element to stop listening the inputs from
  39144. */
  39145. detachControl(element: Nullable<HTMLElement>): void;
  39146. /**
  39147. * Update the current camera state depending on the inputs that have been used this frame.
  39148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39149. */
  39150. checkInputs(): void;
  39151. /**
  39152. * Gets the class name of the current input.
  39153. * @returns the class name
  39154. */
  39155. getClassName(): string;
  39156. /**
  39157. * Get the friendly name associated with the input class.
  39158. * @returns the input friendly name
  39159. */
  39160. getSimpleName(): string;
  39161. /**
  39162. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39163. * allow modification of the heightOffset value.
  39164. */
  39165. private _modifierHeightOffset;
  39166. /**
  39167. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39168. * allow modification of the rotationOffset value.
  39169. */
  39170. private _modifierRotationOffset;
  39171. /**
  39172. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39173. * allow modification of the radius value.
  39174. */
  39175. private _modifierRadius;
  39176. }
  39177. }
  39178. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39179. import { Nullable } from "babylonjs/types";
  39180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39182. import { Observable } from "babylonjs/Misc/observable";
  39183. module "babylonjs/Cameras/freeCameraInputsManager" {
  39184. interface FreeCameraInputsManager {
  39185. /**
  39186. * @hidden
  39187. */
  39188. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39189. /**
  39190. * Add orientation input support to the input manager.
  39191. * @returns the current input manager
  39192. */
  39193. addDeviceOrientation(): FreeCameraInputsManager;
  39194. }
  39195. }
  39196. /**
  39197. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39198. * Screen rotation is taken into account.
  39199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39200. */
  39201. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39202. private _camera;
  39203. private _screenOrientationAngle;
  39204. private _constantTranform;
  39205. private _screenQuaternion;
  39206. private _alpha;
  39207. private _beta;
  39208. private _gamma;
  39209. /**
  39210. * Can be used to detect if a device orientation sensor is availible on a device
  39211. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39212. * @returns a promise that will resolve on orientation change
  39213. */
  39214. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39215. /**
  39216. * @hidden
  39217. */
  39218. _onDeviceOrientationChangedObservable: Observable<void>;
  39219. /**
  39220. * Instantiates a new input
  39221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39222. */
  39223. constructor();
  39224. /**
  39225. * Define the camera controlled by the input.
  39226. */
  39227. camera: FreeCamera;
  39228. /**
  39229. * Attach the input controls to a specific dom element to get the input from.
  39230. * @param element Defines the element the controls should be listened from
  39231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39232. */
  39233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39234. private _orientationChanged;
  39235. private _deviceOrientation;
  39236. /**
  39237. * Detach the current controls from the specified dom element.
  39238. * @param element Defines the element to stop listening the inputs from
  39239. */
  39240. detachControl(element: Nullable<HTMLElement>): void;
  39241. /**
  39242. * Update the current camera state depending on the inputs that have been used this frame.
  39243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39244. */
  39245. checkInputs(): void;
  39246. /**
  39247. * Gets the class name of the current intput.
  39248. * @returns the class name
  39249. */
  39250. getClassName(): string;
  39251. /**
  39252. * Get the friendly name associated with the input class.
  39253. * @returns the input friendly name
  39254. */
  39255. getSimpleName(): string;
  39256. }
  39257. }
  39258. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39259. import { Nullable } from "babylonjs/types";
  39260. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39261. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39262. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39263. /**
  39264. * Manage the gamepad inputs to control a free camera.
  39265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39266. */
  39267. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39268. /**
  39269. * Define the camera the input is attached to.
  39270. */
  39271. camera: FreeCamera;
  39272. /**
  39273. * Define the Gamepad controlling the input
  39274. */
  39275. gamepad: Nullable<Gamepad>;
  39276. /**
  39277. * Defines the gamepad rotation sensiblity.
  39278. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39279. */
  39280. gamepadAngularSensibility: number;
  39281. /**
  39282. * Defines the gamepad move sensiblity.
  39283. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39284. */
  39285. gamepadMoveSensibility: number;
  39286. private _onGamepadConnectedObserver;
  39287. private _onGamepadDisconnectedObserver;
  39288. private _cameraTransform;
  39289. private _deltaTransform;
  39290. private _vector3;
  39291. private _vector2;
  39292. /**
  39293. * Attach the input controls to a specific dom element to get the input from.
  39294. * @param element Defines the element the controls should be listened from
  39295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39296. */
  39297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39298. /**
  39299. * Detach the current controls from the specified dom element.
  39300. * @param element Defines the element to stop listening the inputs from
  39301. */
  39302. detachControl(element: Nullable<HTMLElement>): void;
  39303. /**
  39304. * Update the current camera state depending on the inputs that have been used this frame.
  39305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39306. */
  39307. checkInputs(): void;
  39308. /**
  39309. * Gets the class name of the current intput.
  39310. * @returns the class name
  39311. */
  39312. getClassName(): string;
  39313. /**
  39314. * Get the friendly name associated with the input class.
  39315. * @returns the input friendly name
  39316. */
  39317. getSimpleName(): string;
  39318. }
  39319. }
  39320. declare module "babylonjs/Misc/virtualJoystick" {
  39321. import { Nullable } from "babylonjs/types";
  39322. import { Vector3 } from "babylonjs/Maths/math.vector";
  39323. /**
  39324. * Defines the potential axis of a Joystick
  39325. */
  39326. export enum JoystickAxis {
  39327. /** X axis */
  39328. X = 0,
  39329. /** Y axis */
  39330. Y = 1,
  39331. /** Z axis */
  39332. Z = 2
  39333. }
  39334. /**
  39335. * Class used to define virtual joystick (used in touch mode)
  39336. */
  39337. export class VirtualJoystick {
  39338. /**
  39339. * Gets or sets a boolean indicating that left and right values must be inverted
  39340. */
  39341. reverseLeftRight: boolean;
  39342. /**
  39343. * Gets or sets a boolean indicating that up and down values must be inverted
  39344. */
  39345. reverseUpDown: boolean;
  39346. /**
  39347. * Gets the offset value for the position (ie. the change of the position value)
  39348. */
  39349. deltaPosition: Vector3;
  39350. /**
  39351. * Gets a boolean indicating if the virtual joystick was pressed
  39352. */
  39353. pressed: boolean;
  39354. /**
  39355. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39356. */
  39357. static Canvas: Nullable<HTMLCanvasElement>;
  39358. private static _globalJoystickIndex;
  39359. private static vjCanvasContext;
  39360. private static vjCanvasWidth;
  39361. private static vjCanvasHeight;
  39362. private static halfWidth;
  39363. private _action;
  39364. private _axisTargetedByLeftAndRight;
  39365. private _axisTargetedByUpAndDown;
  39366. private _joystickSensibility;
  39367. private _inversedSensibility;
  39368. private _joystickPointerID;
  39369. private _joystickColor;
  39370. private _joystickPointerPos;
  39371. private _joystickPreviousPointerPos;
  39372. private _joystickPointerStartPos;
  39373. private _deltaJoystickVector;
  39374. private _leftJoystick;
  39375. private _touches;
  39376. private _onPointerDownHandlerRef;
  39377. private _onPointerMoveHandlerRef;
  39378. private _onPointerUpHandlerRef;
  39379. private _onResize;
  39380. /**
  39381. * Creates a new virtual joystick
  39382. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39383. */
  39384. constructor(leftJoystick?: boolean);
  39385. /**
  39386. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39387. * @param newJoystickSensibility defines the new sensibility
  39388. */
  39389. setJoystickSensibility(newJoystickSensibility: number): void;
  39390. private _onPointerDown;
  39391. private _onPointerMove;
  39392. private _onPointerUp;
  39393. /**
  39394. * Change the color of the virtual joystick
  39395. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39396. */
  39397. setJoystickColor(newColor: string): void;
  39398. /**
  39399. * Defines a callback to call when the joystick is touched
  39400. * @param action defines the callback
  39401. */
  39402. setActionOnTouch(action: () => any): void;
  39403. /**
  39404. * Defines which axis you'd like to control for left & right
  39405. * @param axis defines the axis to use
  39406. */
  39407. setAxisForLeftRight(axis: JoystickAxis): void;
  39408. /**
  39409. * Defines which axis you'd like to control for up & down
  39410. * @param axis defines the axis to use
  39411. */
  39412. setAxisForUpDown(axis: JoystickAxis): void;
  39413. private _drawVirtualJoystick;
  39414. /**
  39415. * Release internal HTML canvas
  39416. */
  39417. releaseCanvas(): void;
  39418. }
  39419. }
  39420. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39421. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39422. import { Nullable } from "babylonjs/types";
  39423. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39424. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39425. module "babylonjs/Cameras/freeCameraInputsManager" {
  39426. interface FreeCameraInputsManager {
  39427. /**
  39428. * Add virtual joystick input support to the input manager.
  39429. * @returns the current input manager
  39430. */
  39431. addVirtualJoystick(): FreeCameraInputsManager;
  39432. }
  39433. }
  39434. /**
  39435. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39437. */
  39438. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39439. /**
  39440. * Defines the camera the input is attached to.
  39441. */
  39442. camera: FreeCamera;
  39443. private _leftjoystick;
  39444. private _rightjoystick;
  39445. /**
  39446. * Gets the left stick of the virtual joystick.
  39447. * @returns The virtual Joystick
  39448. */
  39449. getLeftJoystick(): VirtualJoystick;
  39450. /**
  39451. * Gets the right stick of the virtual joystick.
  39452. * @returns The virtual Joystick
  39453. */
  39454. getRightJoystick(): VirtualJoystick;
  39455. /**
  39456. * Update the current camera state depending on the inputs that have been used this frame.
  39457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39458. */
  39459. checkInputs(): void;
  39460. /**
  39461. * Attach the input controls to a specific dom element to get the input from.
  39462. * @param element Defines the element the controls should be listened from
  39463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39464. */
  39465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39466. /**
  39467. * Detach the current controls from the specified dom element.
  39468. * @param element Defines the element to stop listening the inputs from
  39469. */
  39470. detachControl(element: Nullable<HTMLElement>): void;
  39471. /**
  39472. * Gets the class name of the current intput.
  39473. * @returns the class name
  39474. */
  39475. getClassName(): string;
  39476. /**
  39477. * Get the friendly name associated with the input class.
  39478. * @returns the input friendly name
  39479. */
  39480. getSimpleName(): string;
  39481. }
  39482. }
  39483. declare module "babylonjs/Cameras/Inputs/index" {
  39484. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39485. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39486. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39487. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39488. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39489. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39490. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39491. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39492. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39493. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39494. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39495. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39496. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39497. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39498. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39499. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39500. }
  39501. declare module "babylonjs/Cameras/touchCamera" {
  39502. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39503. import { Scene } from "babylonjs/scene";
  39504. import { Vector3 } from "babylonjs/Maths/math.vector";
  39505. /**
  39506. * This represents a FPS type of camera controlled by touch.
  39507. * This is like a universal camera minus the Gamepad controls.
  39508. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39509. */
  39510. export class TouchCamera extends FreeCamera {
  39511. /**
  39512. * Defines the touch sensibility for rotation.
  39513. * The higher the faster.
  39514. */
  39515. touchAngularSensibility: number;
  39516. /**
  39517. * Defines the touch sensibility for move.
  39518. * The higher the faster.
  39519. */
  39520. touchMoveSensibility: number;
  39521. /**
  39522. * Instantiates a new touch camera.
  39523. * This represents a FPS type of camera controlled by touch.
  39524. * This is like a universal camera minus the Gamepad controls.
  39525. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39526. * @param name Define the name of the camera in the scene
  39527. * @param position Define the start position of the camera in the scene
  39528. * @param scene Define the scene the camera belongs to
  39529. */
  39530. constructor(name: string, position: Vector3, scene: Scene);
  39531. /**
  39532. * Gets the current object class name.
  39533. * @return the class name
  39534. */
  39535. getClassName(): string;
  39536. /** @hidden */
  39537. _setupInputs(): void;
  39538. }
  39539. }
  39540. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39541. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39542. import { Scene } from "babylonjs/scene";
  39543. import { Vector3 } from "babylonjs/Maths/math.vector";
  39544. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39545. import { Axis } from "babylonjs/Maths/math.axis";
  39546. /**
  39547. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39548. * being tilted forward or back and left or right.
  39549. */
  39550. export class DeviceOrientationCamera extends FreeCamera {
  39551. private _initialQuaternion;
  39552. private _quaternionCache;
  39553. private _tmpDragQuaternion;
  39554. private _disablePointerInputWhenUsingDeviceOrientation;
  39555. /**
  39556. * Creates a new device orientation camera
  39557. * @param name The name of the camera
  39558. * @param position The start position camera
  39559. * @param scene The scene the camera belongs to
  39560. */
  39561. constructor(name: string, position: Vector3, scene: Scene);
  39562. /**
  39563. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39564. */
  39565. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39566. private _dragFactor;
  39567. /**
  39568. * Enabled turning on the y axis when the orientation sensor is active
  39569. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39570. */
  39571. enableHorizontalDragging(dragFactor?: number): void;
  39572. /**
  39573. * Gets the current instance class name ("DeviceOrientationCamera").
  39574. * This helps avoiding instanceof at run time.
  39575. * @returns the class name
  39576. */
  39577. getClassName(): string;
  39578. /**
  39579. * @hidden
  39580. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39581. */
  39582. _checkInputs(): void;
  39583. /**
  39584. * Reset the camera to its default orientation on the specified axis only.
  39585. * @param axis The axis to reset
  39586. */
  39587. resetToCurrentRotation(axis?: Axis): void;
  39588. }
  39589. }
  39590. declare module "babylonjs/Gamepads/xboxGamepad" {
  39591. import { Observable } from "babylonjs/Misc/observable";
  39592. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39593. /**
  39594. * Defines supported buttons for XBox360 compatible gamepads
  39595. */
  39596. export enum Xbox360Button {
  39597. /** A */
  39598. A = 0,
  39599. /** B */
  39600. B = 1,
  39601. /** X */
  39602. X = 2,
  39603. /** Y */
  39604. Y = 3,
  39605. /** Start */
  39606. Start = 4,
  39607. /** Back */
  39608. Back = 5,
  39609. /** Left button */
  39610. LB = 6,
  39611. /** Right button */
  39612. RB = 7,
  39613. /** Left stick */
  39614. LeftStick = 8,
  39615. /** Right stick */
  39616. RightStick = 9
  39617. }
  39618. /** Defines values for XBox360 DPad */
  39619. export enum Xbox360Dpad {
  39620. /** Up */
  39621. Up = 0,
  39622. /** Down */
  39623. Down = 1,
  39624. /** Left */
  39625. Left = 2,
  39626. /** Right */
  39627. Right = 3
  39628. }
  39629. /**
  39630. * Defines a XBox360 gamepad
  39631. */
  39632. export class Xbox360Pad extends Gamepad {
  39633. private _leftTrigger;
  39634. private _rightTrigger;
  39635. private _onlefttriggerchanged;
  39636. private _onrighttriggerchanged;
  39637. private _onbuttondown;
  39638. private _onbuttonup;
  39639. private _ondpaddown;
  39640. private _ondpadup;
  39641. /** Observable raised when a button is pressed */
  39642. onButtonDownObservable: Observable<Xbox360Button>;
  39643. /** Observable raised when a button is released */
  39644. onButtonUpObservable: Observable<Xbox360Button>;
  39645. /** Observable raised when a pad is pressed */
  39646. onPadDownObservable: Observable<Xbox360Dpad>;
  39647. /** Observable raised when a pad is released */
  39648. onPadUpObservable: Observable<Xbox360Dpad>;
  39649. private _buttonA;
  39650. private _buttonB;
  39651. private _buttonX;
  39652. private _buttonY;
  39653. private _buttonBack;
  39654. private _buttonStart;
  39655. private _buttonLB;
  39656. private _buttonRB;
  39657. private _buttonLeftStick;
  39658. private _buttonRightStick;
  39659. private _dPadUp;
  39660. private _dPadDown;
  39661. private _dPadLeft;
  39662. private _dPadRight;
  39663. private _isXboxOnePad;
  39664. /**
  39665. * Creates a new XBox360 gamepad object
  39666. * @param id defines the id of this gamepad
  39667. * @param index defines its index
  39668. * @param gamepad defines the internal HTML gamepad object
  39669. * @param xboxOne defines if it is a XBox One gamepad
  39670. */
  39671. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39672. /**
  39673. * Defines the callback to call when left trigger is pressed
  39674. * @param callback defines the callback to use
  39675. */
  39676. onlefttriggerchanged(callback: (value: number) => void): void;
  39677. /**
  39678. * Defines the callback to call when right trigger is pressed
  39679. * @param callback defines the callback to use
  39680. */
  39681. onrighttriggerchanged(callback: (value: number) => void): void;
  39682. /**
  39683. * Gets the left trigger value
  39684. */
  39685. /**
  39686. * Sets the left trigger value
  39687. */
  39688. leftTrigger: number;
  39689. /**
  39690. * Gets the right trigger value
  39691. */
  39692. /**
  39693. * Sets the right trigger value
  39694. */
  39695. rightTrigger: number;
  39696. /**
  39697. * Defines the callback to call when a button is pressed
  39698. * @param callback defines the callback to use
  39699. */
  39700. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39701. /**
  39702. * Defines the callback to call when a button is released
  39703. * @param callback defines the callback to use
  39704. */
  39705. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39706. /**
  39707. * Defines the callback to call when a pad is pressed
  39708. * @param callback defines the callback to use
  39709. */
  39710. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39711. /**
  39712. * Defines the callback to call when a pad is released
  39713. * @param callback defines the callback to use
  39714. */
  39715. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39716. private _setButtonValue;
  39717. private _setDPadValue;
  39718. /**
  39719. * Gets the value of the `A` button
  39720. */
  39721. /**
  39722. * Sets the value of the `A` button
  39723. */
  39724. buttonA: number;
  39725. /**
  39726. * Gets the value of the `B` button
  39727. */
  39728. /**
  39729. * Sets the value of the `B` button
  39730. */
  39731. buttonB: number;
  39732. /**
  39733. * Gets the value of the `X` button
  39734. */
  39735. /**
  39736. * Sets the value of the `X` button
  39737. */
  39738. buttonX: number;
  39739. /**
  39740. * Gets the value of the `Y` button
  39741. */
  39742. /**
  39743. * Sets the value of the `Y` button
  39744. */
  39745. buttonY: number;
  39746. /**
  39747. * Gets the value of the `Start` button
  39748. */
  39749. /**
  39750. * Sets the value of the `Start` button
  39751. */
  39752. buttonStart: number;
  39753. /**
  39754. * Gets the value of the `Back` button
  39755. */
  39756. /**
  39757. * Sets the value of the `Back` button
  39758. */
  39759. buttonBack: number;
  39760. /**
  39761. * Gets the value of the `Left` button
  39762. */
  39763. /**
  39764. * Sets the value of the `Left` button
  39765. */
  39766. buttonLB: number;
  39767. /**
  39768. * Gets the value of the `Right` button
  39769. */
  39770. /**
  39771. * Sets the value of the `Right` button
  39772. */
  39773. buttonRB: number;
  39774. /**
  39775. * Gets the value of the Left joystick
  39776. */
  39777. /**
  39778. * Sets the value of the Left joystick
  39779. */
  39780. buttonLeftStick: number;
  39781. /**
  39782. * Gets the value of the Right joystick
  39783. */
  39784. /**
  39785. * Sets the value of the Right joystick
  39786. */
  39787. buttonRightStick: number;
  39788. /**
  39789. * Gets the value of D-pad up
  39790. */
  39791. /**
  39792. * Sets the value of D-pad up
  39793. */
  39794. dPadUp: number;
  39795. /**
  39796. * Gets the value of D-pad down
  39797. */
  39798. /**
  39799. * Sets the value of D-pad down
  39800. */
  39801. dPadDown: number;
  39802. /**
  39803. * Gets the value of D-pad left
  39804. */
  39805. /**
  39806. * Sets the value of D-pad left
  39807. */
  39808. dPadLeft: number;
  39809. /**
  39810. * Gets the value of D-pad right
  39811. */
  39812. /**
  39813. * Sets the value of D-pad right
  39814. */
  39815. dPadRight: number;
  39816. /**
  39817. * Force the gamepad to synchronize with device values
  39818. */
  39819. update(): void;
  39820. /**
  39821. * Disposes the gamepad
  39822. */
  39823. dispose(): void;
  39824. }
  39825. }
  39826. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39827. import { Observable } from "babylonjs/Misc/observable";
  39828. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39829. /**
  39830. * Defines supported buttons for DualShock compatible gamepads
  39831. */
  39832. export enum DualShockButton {
  39833. /** Cross */
  39834. Cross = 0,
  39835. /** Circle */
  39836. Circle = 1,
  39837. /** Square */
  39838. Square = 2,
  39839. /** Triangle */
  39840. Triangle = 3,
  39841. /** Options */
  39842. Options = 4,
  39843. /** Share */
  39844. Share = 5,
  39845. /** L1 */
  39846. L1 = 6,
  39847. /** R1 */
  39848. R1 = 7,
  39849. /** Left stick */
  39850. LeftStick = 8,
  39851. /** Right stick */
  39852. RightStick = 9
  39853. }
  39854. /** Defines values for DualShock DPad */
  39855. export enum DualShockDpad {
  39856. /** Up */
  39857. Up = 0,
  39858. /** Down */
  39859. Down = 1,
  39860. /** Left */
  39861. Left = 2,
  39862. /** Right */
  39863. Right = 3
  39864. }
  39865. /**
  39866. * Defines a DualShock gamepad
  39867. */
  39868. export class DualShockPad extends Gamepad {
  39869. private _leftTrigger;
  39870. private _rightTrigger;
  39871. private _onlefttriggerchanged;
  39872. private _onrighttriggerchanged;
  39873. private _onbuttondown;
  39874. private _onbuttonup;
  39875. private _ondpaddown;
  39876. private _ondpadup;
  39877. /** Observable raised when a button is pressed */
  39878. onButtonDownObservable: Observable<DualShockButton>;
  39879. /** Observable raised when a button is released */
  39880. onButtonUpObservable: Observable<DualShockButton>;
  39881. /** Observable raised when a pad is pressed */
  39882. onPadDownObservable: Observable<DualShockDpad>;
  39883. /** Observable raised when a pad is released */
  39884. onPadUpObservable: Observable<DualShockDpad>;
  39885. private _buttonCross;
  39886. private _buttonCircle;
  39887. private _buttonSquare;
  39888. private _buttonTriangle;
  39889. private _buttonShare;
  39890. private _buttonOptions;
  39891. private _buttonL1;
  39892. private _buttonR1;
  39893. private _buttonLeftStick;
  39894. private _buttonRightStick;
  39895. private _dPadUp;
  39896. private _dPadDown;
  39897. private _dPadLeft;
  39898. private _dPadRight;
  39899. /**
  39900. * Creates a new DualShock gamepad object
  39901. * @param id defines the id of this gamepad
  39902. * @param index defines its index
  39903. * @param gamepad defines the internal HTML gamepad object
  39904. */
  39905. constructor(id: string, index: number, gamepad: any);
  39906. /**
  39907. * Defines the callback to call when left trigger is pressed
  39908. * @param callback defines the callback to use
  39909. */
  39910. onlefttriggerchanged(callback: (value: number) => void): void;
  39911. /**
  39912. * Defines the callback to call when right trigger is pressed
  39913. * @param callback defines the callback to use
  39914. */
  39915. onrighttriggerchanged(callback: (value: number) => void): void;
  39916. /**
  39917. * Gets the left trigger value
  39918. */
  39919. /**
  39920. * Sets the left trigger value
  39921. */
  39922. leftTrigger: number;
  39923. /**
  39924. * Gets the right trigger value
  39925. */
  39926. /**
  39927. * Sets the right trigger value
  39928. */
  39929. rightTrigger: number;
  39930. /**
  39931. * Defines the callback to call when a button is pressed
  39932. * @param callback defines the callback to use
  39933. */
  39934. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39935. /**
  39936. * Defines the callback to call when a button is released
  39937. * @param callback defines the callback to use
  39938. */
  39939. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39940. /**
  39941. * Defines the callback to call when a pad is pressed
  39942. * @param callback defines the callback to use
  39943. */
  39944. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39945. /**
  39946. * Defines the callback to call when a pad is released
  39947. * @param callback defines the callback to use
  39948. */
  39949. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39950. private _setButtonValue;
  39951. private _setDPadValue;
  39952. /**
  39953. * Gets the value of the `Cross` button
  39954. */
  39955. /**
  39956. * Sets the value of the `Cross` button
  39957. */
  39958. buttonCross: number;
  39959. /**
  39960. * Gets the value of the `Circle` button
  39961. */
  39962. /**
  39963. * Sets the value of the `Circle` button
  39964. */
  39965. buttonCircle: number;
  39966. /**
  39967. * Gets the value of the `Square` button
  39968. */
  39969. /**
  39970. * Sets the value of the `Square` button
  39971. */
  39972. buttonSquare: number;
  39973. /**
  39974. * Gets the value of the `Triangle` button
  39975. */
  39976. /**
  39977. * Sets the value of the `Triangle` button
  39978. */
  39979. buttonTriangle: number;
  39980. /**
  39981. * Gets the value of the `Options` button
  39982. */
  39983. /**
  39984. * Sets the value of the `Options` button
  39985. */
  39986. buttonOptions: number;
  39987. /**
  39988. * Gets the value of the `Share` button
  39989. */
  39990. /**
  39991. * Sets the value of the `Share` button
  39992. */
  39993. buttonShare: number;
  39994. /**
  39995. * Gets the value of the `L1` button
  39996. */
  39997. /**
  39998. * Sets the value of the `L1` button
  39999. */
  40000. buttonL1: number;
  40001. /**
  40002. * Gets the value of the `R1` button
  40003. */
  40004. /**
  40005. * Sets the value of the `R1` button
  40006. */
  40007. buttonR1: number;
  40008. /**
  40009. * Gets the value of the Left joystick
  40010. */
  40011. /**
  40012. * Sets the value of the Left joystick
  40013. */
  40014. buttonLeftStick: number;
  40015. /**
  40016. * Gets the value of the Right joystick
  40017. */
  40018. /**
  40019. * Sets the value of the Right joystick
  40020. */
  40021. buttonRightStick: number;
  40022. /**
  40023. * Gets the value of D-pad up
  40024. */
  40025. /**
  40026. * Sets the value of D-pad up
  40027. */
  40028. dPadUp: number;
  40029. /**
  40030. * Gets the value of D-pad down
  40031. */
  40032. /**
  40033. * Sets the value of D-pad down
  40034. */
  40035. dPadDown: number;
  40036. /**
  40037. * Gets the value of D-pad left
  40038. */
  40039. /**
  40040. * Sets the value of D-pad left
  40041. */
  40042. dPadLeft: number;
  40043. /**
  40044. * Gets the value of D-pad right
  40045. */
  40046. /**
  40047. * Sets the value of D-pad right
  40048. */
  40049. dPadRight: number;
  40050. /**
  40051. * Force the gamepad to synchronize with device values
  40052. */
  40053. update(): void;
  40054. /**
  40055. * Disposes the gamepad
  40056. */
  40057. dispose(): void;
  40058. }
  40059. }
  40060. declare module "babylonjs/Gamepads/gamepadManager" {
  40061. import { Observable } from "babylonjs/Misc/observable";
  40062. import { Nullable } from "babylonjs/types";
  40063. import { Scene } from "babylonjs/scene";
  40064. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40065. /**
  40066. * Manager for handling gamepads
  40067. */
  40068. export class GamepadManager {
  40069. private _scene?;
  40070. private _babylonGamepads;
  40071. private _oneGamepadConnected;
  40072. /** @hidden */
  40073. _isMonitoring: boolean;
  40074. private _gamepadEventSupported;
  40075. private _gamepadSupport;
  40076. /**
  40077. * observable to be triggered when the gamepad controller has been connected
  40078. */
  40079. onGamepadConnectedObservable: Observable<Gamepad>;
  40080. /**
  40081. * observable to be triggered when the gamepad controller has been disconnected
  40082. */
  40083. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40084. private _onGamepadConnectedEvent;
  40085. private _onGamepadDisconnectedEvent;
  40086. /**
  40087. * Initializes the gamepad manager
  40088. * @param _scene BabylonJS scene
  40089. */
  40090. constructor(_scene?: Scene | undefined);
  40091. /**
  40092. * The gamepads in the game pad manager
  40093. */
  40094. readonly gamepads: Gamepad[];
  40095. /**
  40096. * Get the gamepad controllers based on type
  40097. * @param type The type of gamepad controller
  40098. * @returns Nullable gamepad
  40099. */
  40100. getGamepadByType(type?: number): Nullable<Gamepad>;
  40101. /**
  40102. * Disposes the gamepad manager
  40103. */
  40104. dispose(): void;
  40105. private _addNewGamepad;
  40106. private _startMonitoringGamepads;
  40107. private _stopMonitoringGamepads;
  40108. /** @hidden */
  40109. _checkGamepadsStatus(): void;
  40110. private _updateGamepadObjects;
  40111. }
  40112. }
  40113. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40114. import { Nullable } from "babylonjs/types";
  40115. import { Scene } from "babylonjs/scene";
  40116. import { ISceneComponent } from "babylonjs/sceneComponent";
  40117. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40118. module "babylonjs/scene" {
  40119. interface Scene {
  40120. /** @hidden */
  40121. _gamepadManager: Nullable<GamepadManager>;
  40122. /**
  40123. * Gets the gamepad manager associated with the scene
  40124. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40125. */
  40126. gamepadManager: GamepadManager;
  40127. }
  40128. }
  40129. module "babylonjs/Cameras/freeCameraInputsManager" {
  40130. /**
  40131. * Interface representing a free camera inputs manager
  40132. */
  40133. interface FreeCameraInputsManager {
  40134. /**
  40135. * Adds gamepad input support to the FreeCameraInputsManager.
  40136. * @returns the FreeCameraInputsManager
  40137. */
  40138. addGamepad(): FreeCameraInputsManager;
  40139. }
  40140. }
  40141. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40142. /**
  40143. * Interface representing an arc rotate camera inputs manager
  40144. */
  40145. interface ArcRotateCameraInputsManager {
  40146. /**
  40147. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40148. * @returns the camera inputs manager
  40149. */
  40150. addGamepad(): ArcRotateCameraInputsManager;
  40151. }
  40152. }
  40153. /**
  40154. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40155. */
  40156. export class GamepadSystemSceneComponent implements ISceneComponent {
  40157. /**
  40158. * The component name helpfull to identify the component in the list of scene components.
  40159. */
  40160. readonly name: string;
  40161. /**
  40162. * The scene the component belongs to.
  40163. */
  40164. scene: Scene;
  40165. /**
  40166. * Creates a new instance of the component for the given scene
  40167. * @param scene Defines the scene to register the component in
  40168. */
  40169. constructor(scene: Scene);
  40170. /**
  40171. * Registers the component in a given scene
  40172. */
  40173. register(): void;
  40174. /**
  40175. * Rebuilds the elements related to this component in case of
  40176. * context lost for instance.
  40177. */
  40178. rebuild(): void;
  40179. /**
  40180. * Disposes the component and the associated ressources
  40181. */
  40182. dispose(): void;
  40183. private _beforeCameraUpdate;
  40184. }
  40185. }
  40186. declare module "babylonjs/Cameras/universalCamera" {
  40187. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40188. import { Scene } from "babylonjs/scene";
  40189. import { Vector3 } from "babylonjs/Maths/math.vector";
  40190. import "babylonjs/Gamepads/gamepadSceneComponent";
  40191. /**
  40192. * 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,
  40193. * which still works and will still be found in many Playgrounds.
  40194. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40195. */
  40196. export class UniversalCamera extends TouchCamera {
  40197. /**
  40198. * Defines the gamepad rotation sensiblity.
  40199. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40200. */
  40201. gamepadAngularSensibility: number;
  40202. /**
  40203. * Defines the gamepad move sensiblity.
  40204. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40205. */
  40206. gamepadMoveSensibility: number;
  40207. /**
  40208. * 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,
  40209. * which still works and will still be found in many Playgrounds.
  40210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40211. * @param name Define the name of the camera in the scene
  40212. * @param position Define the start position of the camera in the scene
  40213. * @param scene Define the scene the camera belongs to
  40214. */
  40215. constructor(name: string, position: Vector3, scene: Scene);
  40216. /**
  40217. * Gets the current object class name.
  40218. * @return the class name
  40219. */
  40220. getClassName(): string;
  40221. }
  40222. }
  40223. declare module "babylonjs/Cameras/gamepadCamera" {
  40224. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40225. import { Scene } from "babylonjs/scene";
  40226. import { Vector3 } from "babylonjs/Maths/math.vector";
  40227. /**
  40228. * This represents a FPS type of camera. This is only here for back compat purpose.
  40229. * Please use the UniversalCamera instead as both are identical.
  40230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40231. */
  40232. export class GamepadCamera extends UniversalCamera {
  40233. /**
  40234. * Instantiates a new Gamepad Camera
  40235. * This represents a FPS type of camera. This is only here for back compat purpose.
  40236. * Please use the UniversalCamera instead as both are identical.
  40237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40238. * @param name Define the name of the camera in the scene
  40239. * @param position Define the start position of the camera in the scene
  40240. * @param scene Define the scene the camera belongs to
  40241. */
  40242. constructor(name: string, position: Vector3, scene: Scene);
  40243. /**
  40244. * Gets the current object class name.
  40245. * @return the class name
  40246. */
  40247. getClassName(): string;
  40248. }
  40249. }
  40250. declare module "babylonjs/Shaders/pass.fragment" {
  40251. /** @hidden */
  40252. export var passPixelShader: {
  40253. name: string;
  40254. shader: string;
  40255. };
  40256. }
  40257. declare module "babylonjs/Shaders/passCube.fragment" {
  40258. /** @hidden */
  40259. export var passCubePixelShader: {
  40260. name: string;
  40261. shader: string;
  40262. };
  40263. }
  40264. declare module "babylonjs/PostProcesses/passPostProcess" {
  40265. import { Nullable } from "babylonjs/types";
  40266. import { Camera } from "babylonjs/Cameras/camera";
  40267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40268. import { Engine } from "babylonjs/Engines/engine";
  40269. import "babylonjs/Shaders/pass.fragment";
  40270. import "babylonjs/Shaders/passCube.fragment";
  40271. /**
  40272. * PassPostProcess which produces an output the same as it's input
  40273. */
  40274. export class PassPostProcess extends PostProcess {
  40275. /**
  40276. * Creates the PassPostProcess
  40277. * @param name The name of the effect.
  40278. * @param options The required width/height ratio to downsize to before computing the render pass.
  40279. * @param camera The camera to apply the render pass to.
  40280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40281. * @param engine The engine which the post process will be applied. (default: current engine)
  40282. * @param reusable If the post process can be reused on the same frame. (default: false)
  40283. * @param textureType The type of texture to be used when performing the post processing.
  40284. * @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)
  40285. */
  40286. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40287. }
  40288. /**
  40289. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40290. */
  40291. export class PassCubePostProcess extends PostProcess {
  40292. private _face;
  40293. /**
  40294. * Gets or sets the cube face to display.
  40295. * * 0 is +X
  40296. * * 1 is -X
  40297. * * 2 is +Y
  40298. * * 3 is -Y
  40299. * * 4 is +Z
  40300. * * 5 is -Z
  40301. */
  40302. face: number;
  40303. /**
  40304. * Creates the PassCubePostProcess
  40305. * @param name The name of the effect.
  40306. * @param options The required width/height ratio to downsize to before computing the render pass.
  40307. * @param camera The camera to apply the render pass to.
  40308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40309. * @param engine The engine which the post process will be applied. (default: current engine)
  40310. * @param reusable If the post process can be reused on the same frame. (default: false)
  40311. * @param textureType The type of texture to be used when performing the post processing.
  40312. * @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)
  40313. */
  40314. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40315. }
  40316. }
  40317. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40318. /** @hidden */
  40319. export var anaglyphPixelShader: {
  40320. name: string;
  40321. shader: string;
  40322. };
  40323. }
  40324. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40325. import { Engine } from "babylonjs/Engines/engine";
  40326. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40327. import { Camera } from "babylonjs/Cameras/camera";
  40328. import "babylonjs/Shaders/anaglyph.fragment";
  40329. /**
  40330. * Postprocess used to generate anaglyphic rendering
  40331. */
  40332. export class AnaglyphPostProcess extends PostProcess {
  40333. private _passedProcess;
  40334. /**
  40335. * Creates a new AnaglyphPostProcess
  40336. * @param name defines postprocess name
  40337. * @param options defines creation options or target ratio scale
  40338. * @param rigCameras defines cameras using this postprocess
  40339. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40340. * @param engine defines hosting engine
  40341. * @param reusable defines if the postprocess will be reused multiple times per frame
  40342. */
  40343. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40344. }
  40345. }
  40346. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40347. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40349. import { Scene } from "babylonjs/scene";
  40350. import { Vector3 } from "babylonjs/Maths/math.vector";
  40351. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40352. /**
  40353. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40354. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40355. */
  40356. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40357. /**
  40358. * Creates a new AnaglyphArcRotateCamera
  40359. * @param name defines camera name
  40360. * @param alpha defines alpha angle (in radians)
  40361. * @param beta defines beta angle (in radians)
  40362. * @param radius defines radius
  40363. * @param target defines camera target
  40364. * @param interaxialDistance defines distance between each color axis
  40365. * @param scene defines the hosting scene
  40366. */
  40367. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40368. /**
  40369. * Gets camera class name
  40370. * @returns AnaglyphArcRotateCamera
  40371. */
  40372. getClassName(): string;
  40373. }
  40374. }
  40375. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40376. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40377. import { Scene } from "babylonjs/scene";
  40378. import { Vector3 } from "babylonjs/Maths/math.vector";
  40379. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40380. /**
  40381. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40382. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40383. */
  40384. export class AnaglyphFreeCamera extends FreeCamera {
  40385. /**
  40386. * Creates a new AnaglyphFreeCamera
  40387. * @param name defines camera name
  40388. * @param position defines initial position
  40389. * @param interaxialDistance defines distance between each color axis
  40390. * @param scene defines the hosting scene
  40391. */
  40392. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40393. /**
  40394. * Gets camera class name
  40395. * @returns AnaglyphFreeCamera
  40396. */
  40397. getClassName(): string;
  40398. }
  40399. }
  40400. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40401. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40402. import { Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math.vector";
  40404. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40405. /**
  40406. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40407. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40408. */
  40409. export class AnaglyphGamepadCamera extends GamepadCamera {
  40410. /**
  40411. * Creates a new AnaglyphGamepadCamera
  40412. * @param name defines camera name
  40413. * @param position defines initial position
  40414. * @param interaxialDistance defines distance between each color axis
  40415. * @param scene defines the hosting scene
  40416. */
  40417. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40418. /**
  40419. * Gets camera class name
  40420. * @returns AnaglyphGamepadCamera
  40421. */
  40422. getClassName(): string;
  40423. }
  40424. }
  40425. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40426. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40427. import { Scene } from "babylonjs/scene";
  40428. import { Vector3 } from "babylonjs/Maths/math.vector";
  40429. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40430. /**
  40431. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40432. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40433. */
  40434. export class AnaglyphUniversalCamera extends UniversalCamera {
  40435. /**
  40436. * Creates a new AnaglyphUniversalCamera
  40437. * @param name defines camera name
  40438. * @param position defines initial position
  40439. * @param interaxialDistance defines distance between each color axis
  40440. * @param scene defines the hosting scene
  40441. */
  40442. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40443. /**
  40444. * Gets camera class name
  40445. * @returns AnaglyphUniversalCamera
  40446. */
  40447. getClassName(): string;
  40448. }
  40449. }
  40450. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40451. /** @hidden */
  40452. export var stereoscopicInterlacePixelShader: {
  40453. name: string;
  40454. shader: string;
  40455. };
  40456. }
  40457. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40458. import { Camera } from "babylonjs/Cameras/camera";
  40459. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40460. import { Engine } from "babylonjs/Engines/engine";
  40461. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40462. /**
  40463. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40464. */
  40465. export class StereoscopicInterlacePostProcess extends PostProcess {
  40466. private _stepSize;
  40467. private _passedProcess;
  40468. /**
  40469. * Initializes a StereoscopicInterlacePostProcess
  40470. * @param name The name of the effect.
  40471. * @param rigCameras The rig cameras to be appled to the post process
  40472. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40474. * @param engine The engine which the post process will be applied. (default: current engine)
  40475. * @param reusable If the post process can be reused on the same frame. (default: false)
  40476. */
  40477. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40478. }
  40479. }
  40480. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40481. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40482. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40483. import { Scene } from "babylonjs/scene";
  40484. import { Vector3 } from "babylonjs/Maths/math.vector";
  40485. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40486. /**
  40487. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40488. * @see http://doc.babylonjs.com/features/cameras
  40489. */
  40490. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40491. /**
  40492. * Creates a new StereoscopicArcRotateCamera
  40493. * @param name defines camera name
  40494. * @param alpha defines alpha angle (in radians)
  40495. * @param beta defines beta angle (in radians)
  40496. * @param radius defines radius
  40497. * @param target defines camera target
  40498. * @param interaxialDistance defines distance between each color axis
  40499. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40500. * @param scene defines the hosting scene
  40501. */
  40502. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40503. /**
  40504. * Gets camera class name
  40505. * @returns StereoscopicArcRotateCamera
  40506. */
  40507. getClassName(): string;
  40508. }
  40509. }
  40510. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40512. import { Scene } from "babylonjs/scene";
  40513. import { Vector3 } from "babylonjs/Maths/math.vector";
  40514. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40515. /**
  40516. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40517. * @see http://doc.babylonjs.com/features/cameras
  40518. */
  40519. export class StereoscopicFreeCamera extends FreeCamera {
  40520. /**
  40521. * Creates a new StereoscopicFreeCamera
  40522. * @param name defines camera name
  40523. * @param position defines initial position
  40524. * @param interaxialDistance defines distance between each color axis
  40525. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40526. * @param scene defines the hosting scene
  40527. */
  40528. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40529. /**
  40530. * Gets camera class name
  40531. * @returns StereoscopicFreeCamera
  40532. */
  40533. getClassName(): string;
  40534. }
  40535. }
  40536. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40537. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40538. import { Scene } from "babylonjs/scene";
  40539. import { Vector3 } from "babylonjs/Maths/math.vector";
  40540. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40541. /**
  40542. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40543. * @see http://doc.babylonjs.com/features/cameras
  40544. */
  40545. export class StereoscopicGamepadCamera extends GamepadCamera {
  40546. /**
  40547. * Creates a new StereoscopicGamepadCamera
  40548. * @param name defines camera name
  40549. * @param position defines initial position
  40550. * @param interaxialDistance defines distance between each color axis
  40551. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40552. * @param scene defines the hosting scene
  40553. */
  40554. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40555. /**
  40556. * Gets camera class name
  40557. * @returns StereoscopicGamepadCamera
  40558. */
  40559. getClassName(): string;
  40560. }
  40561. }
  40562. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40563. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40564. import { Scene } from "babylonjs/scene";
  40565. import { Vector3 } from "babylonjs/Maths/math.vector";
  40566. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40567. /**
  40568. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40569. * @see http://doc.babylonjs.com/features/cameras
  40570. */
  40571. export class StereoscopicUniversalCamera extends UniversalCamera {
  40572. /**
  40573. * Creates a new StereoscopicUniversalCamera
  40574. * @param name defines camera name
  40575. * @param position defines initial position
  40576. * @param interaxialDistance defines distance between each color axis
  40577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40578. * @param scene defines the hosting scene
  40579. */
  40580. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40581. /**
  40582. * Gets camera class name
  40583. * @returns StereoscopicUniversalCamera
  40584. */
  40585. getClassName(): string;
  40586. }
  40587. }
  40588. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40591. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40592. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40595. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40596. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40597. }
  40598. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40600. import { Scene } from "babylonjs/scene";
  40601. import { Vector3 } from "babylonjs/Maths/math.vector";
  40602. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40603. /**
  40604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40605. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40606. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40607. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40608. */
  40609. export class VirtualJoysticksCamera extends FreeCamera {
  40610. /**
  40611. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40612. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40613. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40614. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40615. * @param name Define the name of the camera in the scene
  40616. * @param position Define the start position of the camera in the scene
  40617. * @param scene Define the scene the camera belongs to
  40618. */
  40619. constructor(name: string, position: Vector3, scene: Scene);
  40620. /**
  40621. * Gets the current object class name.
  40622. * @return the class name
  40623. */
  40624. getClassName(): string;
  40625. }
  40626. }
  40627. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40628. import { Matrix } from "babylonjs/Maths/math.vector";
  40629. /**
  40630. * This represents all the required metrics to create a VR camera.
  40631. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40632. */
  40633. export class VRCameraMetrics {
  40634. /**
  40635. * Define the horizontal resolution off the screen.
  40636. */
  40637. hResolution: number;
  40638. /**
  40639. * Define the vertical resolution off the screen.
  40640. */
  40641. vResolution: number;
  40642. /**
  40643. * Define the horizontal screen size.
  40644. */
  40645. hScreenSize: number;
  40646. /**
  40647. * Define the vertical screen size.
  40648. */
  40649. vScreenSize: number;
  40650. /**
  40651. * Define the vertical screen center position.
  40652. */
  40653. vScreenCenter: number;
  40654. /**
  40655. * Define the distance of the eyes to the screen.
  40656. */
  40657. eyeToScreenDistance: number;
  40658. /**
  40659. * Define the distance between both lenses
  40660. */
  40661. lensSeparationDistance: number;
  40662. /**
  40663. * Define the distance between both viewer's eyes.
  40664. */
  40665. interpupillaryDistance: number;
  40666. /**
  40667. * Define the distortion factor of the VR postprocess.
  40668. * Please, touch with care.
  40669. */
  40670. distortionK: number[];
  40671. /**
  40672. * Define the chromatic aberration correction factors for the VR post process.
  40673. */
  40674. chromaAbCorrection: number[];
  40675. /**
  40676. * Define the scale factor of the post process.
  40677. * The smaller the better but the slower.
  40678. */
  40679. postProcessScaleFactor: number;
  40680. /**
  40681. * Define an offset for the lens center.
  40682. */
  40683. lensCenterOffset: number;
  40684. /**
  40685. * Define if the current vr camera should compensate the distortion of the lense or not.
  40686. */
  40687. compensateDistortion: boolean;
  40688. /**
  40689. * Defines if multiview should be enabled when rendering (Default: false)
  40690. */
  40691. multiviewEnabled: boolean;
  40692. /**
  40693. * Gets the rendering aspect ratio based on the provided resolutions.
  40694. */
  40695. readonly aspectRatio: number;
  40696. /**
  40697. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40698. */
  40699. readonly aspectRatioFov: number;
  40700. /**
  40701. * @hidden
  40702. */
  40703. readonly leftHMatrix: Matrix;
  40704. /**
  40705. * @hidden
  40706. */
  40707. readonly rightHMatrix: Matrix;
  40708. /**
  40709. * @hidden
  40710. */
  40711. readonly leftPreViewMatrix: Matrix;
  40712. /**
  40713. * @hidden
  40714. */
  40715. readonly rightPreViewMatrix: Matrix;
  40716. /**
  40717. * Get the default VRMetrics based on the most generic setup.
  40718. * @returns the default vr metrics
  40719. */
  40720. static GetDefault(): VRCameraMetrics;
  40721. }
  40722. }
  40723. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40724. /** @hidden */
  40725. export var vrDistortionCorrectionPixelShader: {
  40726. name: string;
  40727. shader: string;
  40728. };
  40729. }
  40730. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40731. import { Camera } from "babylonjs/Cameras/camera";
  40732. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40734. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40735. /**
  40736. * VRDistortionCorrectionPostProcess used for mobile VR
  40737. */
  40738. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40739. private _isRightEye;
  40740. private _distortionFactors;
  40741. private _postProcessScaleFactor;
  40742. private _lensCenterOffset;
  40743. private _scaleIn;
  40744. private _scaleFactor;
  40745. private _lensCenter;
  40746. /**
  40747. * Initializes the VRDistortionCorrectionPostProcess
  40748. * @param name The name of the effect.
  40749. * @param camera The camera to apply the render pass to.
  40750. * @param isRightEye If this is for the right eye distortion
  40751. * @param vrMetrics All the required metrics for the VR camera
  40752. */
  40753. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40754. }
  40755. }
  40756. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40757. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40759. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40760. import { Scene } from "babylonjs/scene";
  40761. import { Vector3 } from "babylonjs/Maths/math.vector";
  40762. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40763. import "babylonjs/Cameras/RigModes/vrRigMode";
  40764. /**
  40765. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40766. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40767. */
  40768. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40769. /**
  40770. * Creates a new VRDeviceOrientationArcRotateCamera
  40771. * @param name defines camera name
  40772. * @param alpha defines the camera rotation along the logitudinal axis
  40773. * @param beta defines the camera rotation along the latitudinal axis
  40774. * @param radius defines the camera distance from its target
  40775. * @param target defines the camera target
  40776. * @param scene defines the scene the camera belongs to
  40777. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40778. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40779. */
  40780. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40781. /**
  40782. * Gets camera class name
  40783. * @returns VRDeviceOrientationArcRotateCamera
  40784. */
  40785. getClassName(): string;
  40786. }
  40787. }
  40788. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40789. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40790. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40791. import { Scene } from "babylonjs/scene";
  40792. import { Vector3 } from "babylonjs/Maths/math.vector";
  40793. import "babylonjs/Cameras/RigModes/vrRigMode";
  40794. /**
  40795. * Camera used to simulate VR rendering (based on FreeCamera)
  40796. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40797. */
  40798. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40799. /**
  40800. * Creates a new VRDeviceOrientationFreeCamera
  40801. * @param name defines camera name
  40802. * @param position defines the start position of the camera
  40803. * @param scene defines the scene the camera belongs to
  40804. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40805. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40806. */
  40807. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40808. /**
  40809. * Gets camera class name
  40810. * @returns VRDeviceOrientationFreeCamera
  40811. */
  40812. getClassName(): string;
  40813. }
  40814. }
  40815. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40816. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40817. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Vector3 } from "babylonjs/Maths/math.vector";
  40820. import "babylonjs/Gamepads/gamepadSceneComponent";
  40821. /**
  40822. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40823. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40824. */
  40825. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40826. /**
  40827. * Creates a new VRDeviceOrientationGamepadCamera
  40828. * @param name defines camera name
  40829. * @param position defines the start position of the camera
  40830. * @param scene defines the scene the camera belongs to
  40831. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40832. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40833. */
  40834. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40835. /**
  40836. * Gets camera class name
  40837. * @returns VRDeviceOrientationGamepadCamera
  40838. */
  40839. getClassName(): string;
  40840. }
  40841. }
  40842. declare module "babylonjs/Materials/pushMaterial" {
  40843. import { Nullable } from "babylonjs/types";
  40844. import { Scene } from "babylonjs/scene";
  40845. import { Matrix } from "babylonjs/Maths/math.vector";
  40846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40847. import { Mesh } from "babylonjs/Meshes/mesh";
  40848. import { Material } from "babylonjs/Materials/material";
  40849. import { Effect } from "babylonjs/Materials/effect";
  40850. /**
  40851. * Base class of materials working in push mode in babylon JS
  40852. * @hidden
  40853. */
  40854. export class PushMaterial extends Material {
  40855. protected _activeEffect: Effect;
  40856. protected _normalMatrix: Matrix;
  40857. /**
  40858. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40859. * This means that the material can keep using a previous shader while a new one is being compiled.
  40860. * This is mostly used when shader parallel compilation is supported (true by default)
  40861. */
  40862. allowShaderHotSwapping: boolean;
  40863. constructor(name: string, scene: Scene);
  40864. getEffect(): Effect;
  40865. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40866. /**
  40867. * Binds the given world matrix to the active effect
  40868. *
  40869. * @param world the matrix to bind
  40870. */
  40871. bindOnlyWorldMatrix(world: Matrix): void;
  40872. /**
  40873. * Binds the given normal matrix to the active effect
  40874. *
  40875. * @param normalMatrix the matrix to bind
  40876. */
  40877. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40878. bind(world: Matrix, mesh?: Mesh): void;
  40879. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40880. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40881. }
  40882. }
  40883. declare module "babylonjs/Materials/materialFlags" {
  40884. /**
  40885. * This groups all the flags used to control the materials channel.
  40886. */
  40887. export class MaterialFlags {
  40888. private static _DiffuseTextureEnabled;
  40889. /**
  40890. * Are diffuse textures enabled in the application.
  40891. */
  40892. static DiffuseTextureEnabled: boolean;
  40893. private static _AmbientTextureEnabled;
  40894. /**
  40895. * Are ambient textures enabled in the application.
  40896. */
  40897. static AmbientTextureEnabled: boolean;
  40898. private static _OpacityTextureEnabled;
  40899. /**
  40900. * Are opacity textures enabled in the application.
  40901. */
  40902. static OpacityTextureEnabled: boolean;
  40903. private static _ReflectionTextureEnabled;
  40904. /**
  40905. * Are reflection textures enabled in the application.
  40906. */
  40907. static ReflectionTextureEnabled: boolean;
  40908. private static _EmissiveTextureEnabled;
  40909. /**
  40910. * Are emissive textures enabled in the application.
  40911. */
  40912. static EmissiveTextureEnabled: boolean;
  40913. private static _SpecularTextureEnabled;
  40914. /**
  40915. * Are specular textures enabled in the application.
  40916. */
  40917. static SpecularTextureEnabled: boolean;
  40918. private static _BumpTextureEnabled;
  40919. /**
  40920. * Are bump textures enabled in the application.
  40921. */
  40922. static BumpTextureEnabled: boolean;
  40923. private static _LightmapTextureEnabled;
  40924. /**
  40925. * Are lightmap textures enabled in the application.
  40926. */
  40927. static LightmapTextureEnabled: boolean;
  40928. private static _RefractionTextureEnabled;
  40929. /**
  40930. * Are refraction textures enabled in the application.
  40931. */
  40932. static RefractionTextureEnabled: boolean;
  40933. private static _ColorGradingTextureEnabled;
  40934. /**
  40935. * Are color grading textures enabled in the application.
  40936. */
  40937. static ColorGradingTextureEnabled: boolean;
  40938. private static _FresnelEnabled;
  40939. /**
  40940. * Are fresnels enabled in the application.
  40941. */
  40942. static FresnelEnabled: boolean;
  40943. private static _ClearCoatTextureEnabled;
  40944. /**
  40945. * Are clear coat textures enabled in the application.
  40946. */
  40947. static ClearCoatTextureEnabled: boolean;
  40948. private static _ClearCoatBumpTextureEnabled;
  40949. /**
  40950. * Are clear coat bump textures enabled in the application.
  40951. */
  40952. static ClearCoatBumpTextureEnabled: boolean;
  40953. private static _ClearCoatTintTextureEnabled;
  40954. /**
  40955. * Are clear coat tint textures enabled in the application.
  40956. */
  40957. static ClearCoatTintTextureEnabled: boolean;
  40958. private static _SheenTextureEnabled;
  40959. /**
  40960. * Are sheen textures enabled in the application.
  40961. */
  40962. static SheenTextureEnabled: boolean;
  40963. private static _AnisotropicTextureEnabled;
  40964. /**
  40965. * Are anisotropic textures enabled in the application.
  40966. */
  40967. static AnisotropicTextureEnabled: boolean;
  40968. private static _ThicknessTextureEnabled;
  40969. /**
  40970. * Are thickness textures enabled in the application.
  40971. */
  40972. static ThicknessTextureEnabled: boolean;
  40973. }
  40974. }
  40975. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40976. /** @hidden */
  40977. export var defaultFragmentDeclaration: {
  40978. name: string;
  40979. shader: string;
  40980. };
  40981. }
  40982. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40983. /** @hidden */
  40984. export var defaultUboDeclaration: {
  40985. name: string;
  40986. shader: string;
  40987. };
  40988. }
  40989. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40990. /** @hidden */
  40991. export var lightFragmentDeclaration: {
  40992. name: string;
  40993. shader: string;
  40994. };
  40995. }
  40996. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40997. /** @hidden */
  40998. export var lightUboDeclaration: {
  40999. name: string;
  41000. shader: string;
  41001. };
  41002. }
  41003. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41004. /** @hidden */
  41005. export var lightsFragmentFunctions: {
  41006. name: string;
  41007. shader: string;
  41008. };
  41009. }
  41010. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41011. /** @hidden */
  41012. export var shadowsFragmentFunctions: {
  41013. name: string;
  41014. shader: string;
  41015. };
  41016. }
  41017. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41018. /** @hidden */
  41019. export var fresnelFunction: {
  41020. name: string;
  41021. shader: string;
  41022. };
  41023. }
  41024. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41025. /** @hidden */
  41026. export var reflectionFunction: {
  41027. name: string;
  41028. shader: string;
  41029. };
  41030. }
  41031. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41032. /** @hidden */
  41033. export var bumpFragmentFunctions: {
  41034. name: string;
  41035. shader: string;
  41036. };
  41037. }
  41038. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41039. /** @hidden */
  41040. export var logDepthDeclaration: {
  41041. name: string;
  41042. shader: string;
  41043. };
  41044. }
  41045. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41046. /** @hidden */
  41047. export var bumpFragment: {
  41048. name: string;
  41049. shader: string;
  41050. };
  41051. }
  41052. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41053. /** @hidden */
  41054. export var depthPrePass: {
  41055. name: string;
  41056. shader: string;
  41057. };
  41058. }
  41059. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41060. /** @hidden */
  41061. export var lightFragment: {
  41062. name: string;
  41063. shader: string;
  41064. };
  41065. }
  41066. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41067. /** @hidden */
  41068. export var logDepthFragment: {
  41069. name: string;
  41070. shader: string;
  41071. };
  41072. }
  41073. declare module "babylonjs/Shaders/default.fragment" {
  41074. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41075. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41077. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41078. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41079. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41080. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41081. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41082. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41083. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41085. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41086. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41087. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41088. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41090. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41091. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41092. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41093. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41094. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41095. /** @hidden */
  41096. export var defaultPixelShader: {
  41097. name: string;
  41098. shader: string;
  41099. };
  41100. }
  41101. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41102. /** @hidden */
  41103. export var defaultVertexDeclaration: {
  41104. name: string;
  41105. shader: string;
  41106. };
  41107. }
  41108. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41109. /** @hidden */
  41110. export var bumpVertexDeclaration: {
  41111. name: string;
  41112. shader: string;
  41113. };
  41114. }
  41115. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41116. /** @hidden */
  41117. export var bumpVertex: {
  41118. name: string;
  41119. shader: string;
  41120. };
  41121. }
  41122. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41123. /** @hidden */
  41124. export var fogVertex: {
  41125. name: string;
  41126. shader: string;
  41127. };
  41128. }
  41129. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41130. /** @hidden */
  41131. export var shadowsVertex: {
  41132. name: string;
  41133. shader: string;
  41134. };
  41135. }
  41136. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41137. /** @hidden */
  41138. export var pointCloudVertex: {
  41139. name: string;
  41140. shader: string;
  41141. };
  41142. }
  41143. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41144. /** @hidden */
  41145. export var logDepthVertex: {
  41146. name: string;
  41147. shader: string;
  41148. };
  41149. }
  41150. declare module "babylonjs/Shaders/default.vertex" {
  41151. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41152. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41154. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41155. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41156. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41158. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41159. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41160. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41163. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41164. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41165. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41166. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41167. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41168. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41169. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41170. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41171. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41172. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41173. /** @hidden */
  41174. export var defaultVertexShader: {
  41175. name: string;
  41176. shader: string;
  41177. };
  41178. }
  41179. declare module "babylonjs/Materials/standardMaterial" {
  41180. import { SmartArray } from "babylonjs/Misc/smartArray";
  41181. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41182. import { Nullable } from "babylonjs/types";
  41183. import { Scene } from "babylonjs/scene";
  41184. import { Matrix } from "babylonjs/Maths/math.vector";
  41185. import { Color3 } from "babylonjs/Maths/math.color";
  41186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41188. import { Mesh } from "babylonjs/Meshes/mesh";
  41189. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41190. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41191. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41192. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41193. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41196. import "babylonjs/Shaders/default.fragment";
  41197. import "babylonjs/Shaders/default.vertex";
  41198. /** @hidden */
  41199. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41200. MAINUV1: boolean;
  41201. MAINUV2: boolean;
  41202. DIFFUSE: boolean;
  41203. DIFFUSEDIRECTUV: number;
  41204. AMBIENT: boolean;
  41205. AMBIENTDIRECTUV: number;
  41206. OPACITY: boolean;
  41207. OPACITYDIRECTUV: number;
  41208. OPACITYRGB: boolean;
  41209. REFLECTION: boolean;
  41210. EMISSIVE: boolean;
  41211. EMISSIVEDIRECTUV: number;
  41212. SPECULAR: boolean;
  41213. SPECULARDIRECTUV: number;
  41214. BUMP: boolean;
  41215. BUMPDIRECTUV: number;
  41216. PARALLAX: boolean;
  41217. PARALLAXOCCLUSION: boolean;
  41218. SPECULAROVERALPHA: boolean;
  41219. CLIPPLANE: boolean;
  41220. CLIPPLANE2: boolean;
  41221. CLIPPLANE3: boolean;
  41222. CLIPPLANE4: boolean;
  41223. ALPHATEST: boolean;
  41224. DEPTHPREPASS: boolean;
  41225. ALPHAFROMDIFFUSE: boolean;
  41226. POINTSIZE: boolean;
  41227. FOG: boolean;
  41228. SPECULARTERM: boolean;
  41229. DIFFUSEFRESNEL: boolean;
  41230. OPACITYFRESNEL: boolean;
  41231. REFLECTIONFRESNEL: boolean;
  41232. REFRACTIONFRESNEL: boolean;
  41233. EMISSIVEFRESNEL: boolean;
  41234. FRESNEL: boolean;
  41235. NORMAL: boolean;
  41236. UV1: boolean;
  41237. UV2: boolean;
  41238. VERTEXCOLOR: boolean;
  41239. VERTEXALPHA: boolean;
  41240. NUM_BONE_INFLUENCERS: number;
  41241. BonesPerMesh: number;
  41242. BONETEXTURE: boolean;
  41243. INSTANCES: boolean;
  41244. GLOSSINESS: boolean;
  41245. ROUGHNESS: boolean;
  41246. EMISSIVEASILLUMINATION: boolean;
  41247. LINKEMISSIVEWITHDIFFUSE: boolean;
  41248. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41249. LIGHTMAP: boolean;
  41250. LIGHTMAPDIRECTUV: number;
  41251. OBJECTSPACE_NORMALMAP: boolean;
  41252. USELIGHTMAPASSHADOWMAP: boolean;
  41253. REFLECTIONMAP_3D: boolean;
  41254. REFLECTIONMAP_SPHERICAL: boolean;
  41255. REFLECTIONMAP_PLANAR: boolean;
  41256. REFLECTIONMAP_CUBIC: boolean;
  41257. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41258. REFLECTIONMAP_PROJECTION: boolean;
  41259. REFLECTIONMAP_SKYBOX: boolean;
  41260. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41261. REFLECTIONMAP_EXPLICIT: boolean;
  41262. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41263. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41264. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41265. INVERTCUBICMAP: boolean;
  41266. LOGARITHMICDEPTH: boolean;
  41267. REFRACTION: boolean;
  41268. REFRACTIONMAP_3D: boolean;
  41269. REFLECTIONOVERALPHA: boolean;
  41270. TWOSIDEDLIGHTING: boolean;
  41271. SHADOWFLOAT: boolean;
  41272. MORPHTARGETS: boolean;
  41273. MORPHTARGETS_NORMAL: boolean;
  41274. MORPHTARGETS_TANGENT: boolean;
  41275. MORPHTARGETS_UV: boolean;
  41276. NUM_MORPH_INFLUENCERS: number;
  41277. NONUNIFORMSCALING: boolean;
  41278. PREMULTIPLYALPHA: boolean;
  41279. IMAGEPROCESSING: boolean;
  41280. VIGNETTE: boolean;
  41281. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41282. VIGNETTEBLENDMODEOPAQUE: boolean;
  41283. TONEMAPPING: boolean;
  41284. TONEMAPPING_ACES: boolean;
  41285. CONTRAST: boolean;
  41286. COLORCURVES: boolean;
  41287. COLORGRADING: boolean;
  41288. COLORGRADING3D: boolean;
  41289. SAMPLER3DGREENDEPTH: boolean;
  41290. SAMPLER3DBGRMAP: boolean;
  41291. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41292. MULTIVIEW: boolean;
  41293. /**
  41294. * If the reflection texture on this material is in linear color space
  41295. * @hidden
  41296. */
  41297. IS_REFLECTION_LINEAR: boolean;
  41298. /**
  41299. * If the refraction texture on this material is in linear color space
  41300. * @hidden
  41301. */
  41302. IS_REFRACTION_LINEAR: boolean;
  41303. EXPOSURE: boolean;
  41304. constructor();
  41305. setReflectionMode(modeToEnable: string): void;
  41306. }
  41307. /**
  41308. * This is the default material used in Babylon. It is the best trade off between quality
  41309. * and performances.
  41310. * @see http://doc.babylonjs.com/babylon101/materials
  41311. */
  41312. export class StandardMaterial extends PushMaterial {
  41313. private _diffuseTexture;
  41314. /**
  41315. * The basic texture of the material as viewed under a light.
  41316. */
  41317. diffuseTexture: Nullable<BaseTexture>;
  41318. private _ambientTexture;
  41319. /**
  41320. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41321. */
  41322. ambientTexture: Nullable<BaseTexture>;
  41323. private _opacityTexture;
  41324. /**
  41325. * Define the transparency of the material from a texture.
  41326. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41327. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41328. */
  41329. opacityTexture: Nullable<BaseTexture>;
  41330. private _reflectionTexture;
  41331. /**
  41332. * Define the texture used to display the reflection.
  41333. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41334. */
  41335. reflectionTexture: Nullable<BaseTexture>;
  41336. private _emissiveTexture;
  41337. /**
  41338. * Define texture of the material as if self lit.
  41339. * This will be mixed in the final result even in the absence of light.
  41340. */
  41341. emissiveTexture: Nullable<BaseTexture>;
  41342. private _specularTexture;
  41343. /**
  41344. * Define how the color and intensity of the highlight given by the light in the material.
  41345. */
  41346. specularTexture: Nullable<BaseTexture>;
  41347. private _bumpTexture;
  41348. /**
  41349. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41350. * 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.
  41351. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41352. */
  41353. bumpTexture: Nullable<BaseTexture>;
  41354. private _lightmapTexture;
  41355. /**
  41356. * Complex lighting can be computationally expensive to compute at runtime.
  41357. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41358. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41359. */
  41360. lightmapTexture: Nullable<BaseTexture>;
  41361. private _refractionTexture;
  41362. /**
  41363. * Define the texture used to display the refraction.
  41364. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41365. */
  41366. refractionTexture: Nullable<BaseTexture>;
  41367. /**
  41368. * The color of the material lit by the environmental background lighting.
  41369. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41370. */
  41371. ambientColor: Color3;
  41372. /**
  41373. * The basic color of the material as viewed under a light.
  41374. */
  41375. diffuseColor: Color3;
  41376. /**
  41377. * Define how the color and intensity of the highlight given by the light in the material.
  41378. */
  41379. specularColor: Color3;
  41380. /**
  41381. * Define the color of the material as if self lit.
  41382. * This will be mixed in the final result even in the absence of light.
  41383. */
  41384. emissiveColor: Color3;
  41385. /**
  41386. * Defines how sharp are the highlights in the material.
  41387. * The bigger the value the sharper giving a more glossy feeling to the result.
  41388. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41389. */
  41390. specularPower: number;
  41391. private _useAlphaFromDiffuseTexture;
  41392. /**
  41393. * Does the transparency come from the diffuse texture alpha channel.
  41394. */
  41395. useAlphaFromDiffuseTexture: boolean;
  41396. private _useEmissiveAsIllumination;
  41397. /**
  41398. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41399. */
  41400. useEmissiveAsIllumination: boolean;
  41401. private _linkEmissiveWithDiffuse;
  41402. /**
  41403. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41404. * the emissive level when the final color is close to one.
  41405. */
  41406. linkEmissiveWithDiffuse: boolean;
  41407. private _useSpecularOverAlpha;
  41408. /**
  41409. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41410. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41411. */
  41412. useSpecularOverAlpha: boolean;
  41413. private _useReflectionOverAlpha;
  41414. /**
  41415. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41416. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41417. */
  41418. useReflectionOverAlpha: boolean;
  41419. private _disableLighting;
  41420. /**
  41421. * Does lights from the scene impacts this material.
  41422. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41423. */
  41424. disableLighting: boolean;
  41425. private _useObjectSpaceNormalMap;
  41426. /**
  41427. * Allows using an object space normal map (instead of tangent space).
  41428. */
  41429. useObjectSpaceNormalMap: boolean;
  41430. private _useParallax;
  41431. /**
  41432. * Is parallax enabled or not.
  41433. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41434. */
  41435. useParallax: boolean;
  41436. private _useParallaxOcclusion;
  41437. /**
  41438. * Is parallax occlusion enabled or not.
  41439. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41440. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41441. */
  41442. useParallaxOcclusion: boolean;
  41443. /**
  41444. * 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.
  41445. */
  41446. parallaxScaleBias: number;
  41447. private _roughness;
  41448. /**
  41449. * Helps to define how blurry the reflections should appears in the material.
  41450. */
  41451. roughness: number;
  41452. /**
  41453. * In case of refraction, define the value of the index of refraction.
  41454. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41455. */
  41456. indexOfRefraction: number;
  41457. /**
  41458. * Invert the refraction texture alongside the y axis.
  41459. * It can be useful with procedural textures or probe for instance.
  41460. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41461. */
  41462. invertRefractionY: boolean;
  41463. /**
  41464. * Defines the alpha limits in alpha test mode.
  41465. */
  41466. alphaCutOff: number;
  41467. private _useLightmapAsShadowmap;
  41468. /**
  41469. * In case of light mapping, define whether the map contains light or shadow informations.
  41470. */
  41471. useLightmapAsShadowmap: boolean;
  41472. private _diffuseFresnelParameters;
  41473. /**
  41474. * Define the diffuse fresnel parameters of the material.
  41475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41476. */
  41477. diffuseFresnelParameters: FresnelParameters;
  41478. private _opacityFresnelParameters;
  41479. /**
  41480. * Define the opacity fresnel parameters of the material.
  41481. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41482. */
  41483. opacityFresnelParameters: FresnelParameters;
  41484. private _reflectionFresnelParameters;
  41485. /**
  41486. * Define the reflection fresnel parameters of the material.
  41487. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41488. */
  41489. reflectionFresnelParameters: FresnelParameters;
  41490. private _refractionFresnelParameters;
  41491. /**
  41492. * Define the refraction fresnel parameters of the material.
  41493. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41494. */
  41495. refractionFresnelParameters: FresnelParameters;
  41496. private _emissiveFresnelParameters;
  41497. /**
  41498. * Define the emissive fresnel parameters of the material.
  41499. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41500. */
  41501. emissiveFresnelParameters: FresnelParameters;
  41502. private _useReflectionFresnelFromSpecular;
  41503. /**
  41504. * If true automatically deducts the fresnels values from the material specularity.
  41505. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41506. */
  41507. useReflectionFresnelFromSpecular: boolean;
  41508. private _useGlossinessFromSpecularMapAlpha;
  41509. /**
  41510. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41511. */
  41512. useGlossinessFromSpecularMapAlpha: boolean;
  41513. private _maxSimultaneousLights;
  41514. /**
  41515. * Defines the maximum number of lights that can be used in the material
  41516. */
  41517. maxSimultaneousLights: number;
  41518. private _invertNormalMapX;
  41519. /**
  41520. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41521. */
  41522. invertNormalMapX: boolean;
  41523. private _invertNormalMapY;
  41524. /**
  41525. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41526. */
  41527. invertNormalMapY: boolean;
  41528. private _twoSidedLighting;
  41529. /**
  41530. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41531. */
  41532. twoSidedLighting: boolean;
  41533. /**
  41534. * Default configuration related to image processing available in the standard Material.
  41535. */
  41536. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41537. /**
  41538. * Gets the image processing configuration used either in this material.
  41539. */
  41540. /**
  41541. * Sets the Default image processing configuration used either in the this material.
  41542. *
  41543. * If sets to null, the scene one is in use.
  41544. */
  41545. imageProcessingConfiguration: ImageProcessingConfiguration;
  41546. /**
  41547. * Keep track of the image processing observer to allow dispose and replace.
  41548. */
  41549. private _imageProcessingObserver;
  41550. /**
  41551. * Attaches a new image processing configuration to the Standard Material.
  41552. * @param configuration
  41553. */
  41554. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41555. /**
  41556. * Gets wether the color curves effect is enabled.
  41557. */
  41558. /**
  41559. * Sets wether the color curves effect is enabled.
  41560. */
  41561. cameraColorCurvesEnabled: boolean;
  41562. /**
  41563. * Gets wether the color grading effect is enabled.
  41564. */
  41565. /**
  41566. * Gets wether the color grading effect is enabled.
  41567. */
  41568. cameraColorGradingEnabled: boolean;
  41569. /**
  41570. * Gets wether tonemapping is enabled or not.
  41571. */
  41572. /**
  41573. * Sets wether tonemapping is enabled or not
  41574. */
  41575. cameraToneMappingEnabled: boolean;
  41576. /**
  41577. * The camera exposure used on this material.
  41578. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41579. * This corresponds to a photographic exposure.
  41580. */
  41581. /**
  41582. * The camera exposure used on this material.
  41583. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41584. * This corresponds to a photographic exposure.
  41585. */
  41586. cameraExposure: number;
  41587. /**
  41588. * Gets The camera contrast used on this material.
  41589. */
  41590. /**
  41591. * Sets The camera contrast used on this material.
  41592. */
  41593. cameraContrast: number;
  41594. /**
  41595. * Gets the Color Grading 2D Lookup Texture.
  41596. */
  41597. /**
  41598. * Sets the Color Grading 2D Lookup Texture.
  41599. */
  41600. cameraColorGradingTexture: Nullable<BaseTexture>;
  41601. /**
  41602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41604. * 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;
  41605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41606. */
  41607. /**
  41608. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41609. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41610. * 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;
  41611. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41612. */
  41613. cameraColorCurves: Nullable<ColorCurves>;
  41614. /**
  41615. * Custom callback helping to override the default shader used in the material.
  41616. */
  41617. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41618. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41619. protected _worldViewProjectionMatrix: Matrix;
  41620. protected _globalAmbientColor: Color3;
  41621. protected _useLogarithmicDepth: boolean;
  41622. protected _rebuildInParallel: boolean;
  41623. /**
  41624. * Instantiates a new standard material.
  41625. * This is the default material used in Babylon. It is the best trade off between quality
  41626. * and performances.
  41627. * @see http://doc.babylonjs.com/babylon101/materials
  41628. * @param name Define the name of the material in the scene
  41629. * @param scene Define the scene the material belong to
  41630. */
  41631. constructor(name: string, scene: Scene);
  41632. /**
  41633. * Gets a boolean indicating that current material needs to register RTT
  41634. */
  41635. readonly hasRenderTargetTextures: boolean;
  41636. /**
  41637. * Gets the current class name of the material e.g. "StandardMaterial"
  41638. * Mainly use in serialization.
  41639. * @returns the class name
  41640. */
  41641. getClassName(): string;
  41642. /**
  41643. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41644. * You can try switching to logarithmic depth.
  41645. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41646. */
  41647. useLogarithmicDepth: boolean;
  41648. /**
  41649. * Specifies if the material will require alpha blending
  41650. * @returns a boolean specifying if alpha blending is needed
  41651. */
  41652. needAlphaBlending(): boolean;
  41653. /**
  41654. * Specifies if this material should be rendered in alpha test mode
  41655. * @returns a boolean specifying if an alpha test is needed.
  41656. */
  41657. needAlphaTesting(): boolean;
  41658. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41659. /**
  41660. * Get the texture used for alpha test purpose.
  41661. * @returns the diffuse texture in case of the standard material.
  41662. */
  41663. getAlphaTestTexture(): Nullable<BaseTexture>;
  41664. /**
  41665. * Get if the submesh is ready to be used and all its information available.
  41666. * Child classes can use it to update shaders
  41667. * @param mesh defines the mesh to check
  41668. * @param subMesh defines which submesh to check
  41669. * @param useInstances specifies that instances should be used
  41670. * @returns a boolean indicating that the submesh is ready or not
  41671. */
  41672. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41673. /**
  41674. * Builds the material UBO layouts.
  41675. * Used internally during the effect preparation.
  41676. */
  41677. buildUniformLayout(): void;
  41678. /**
  41679. * Unbinds the material from the mesh
  41680. */
  41681. unbind(): void;
  41682. /**
  41683. * Binds the submesh to this material by preparing the effect and shader to draw
  41684. * @param world defines the world transformation matrix
  41685. * @param mesh defines the mesh containing the submesh
  41686. * @param subMesh defines the submesh to bind the material to
  41687. */
  41688. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41689. /**
  41690. * Get the list of animatables in the material.
  41691. * @returns the list of animatables object used in the material
  41692. */
  41693. getAnimatables(): IAnimatable[];
  41694. /**
  41695. * Gets the active textures from the material
  41696. * @returns an array of textures
  41697. */
  41698. getActiveTextures(): BaseTexture[];
  41699. /**
  41700. * Specifies if the material uses a texture
  41701. * @param texture defines the texture to check against the material
  41702. * @returns a boolean specifying if the material uses the texture
  41703. */
  41704. hasTexture(texture: BaseTexture): boolean;
  41705. /**
  41706. * Disposes the material
  41707. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41708. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41709. */
  41710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41711. /**
  41712. * Makes a duplicate of the material, and gives it a new name
  41713. * @param name defines the new name for the duplicated material
  41714. * @returns the cloned material
  41715. */
  41716. clone(name: string): StandardMaterial;
  41717. /**
  41718. * Serializes this material in a JSON representation
  41719. * @returns the serialized material object
  41720. */
  41721. serialize(): any;
  41722. /**
  41723. * Creates a standard material from parsed material data
  41724. * @param source defines the JSON representation of the material
  41725. * @param scene defines the hosting scene
  41726. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41727. * @returns a new standard material
  41728. */
  41729. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41730. /**
  41731. * Are diffuse textures enabled in the application.
  41732. */
  41733. static DiffuseTextureEnabled: boolean;
  41734. /**
  41735. * Are ambient textures enabled in the application.
  41736. */
  41737. static AmbientTextureEnabled: boolean;
  41738. /**
  41739. * Are opacity textures enabled in the application.
  41740. */
  41741. static OpacityTextureEnabled: boolean;
  41742. /**
  41743. * Are reflection textures enabled in the application.
  41744. */
  41745. static ReflectionTextureEnabled: boolean;
  41746. /**
  41747. * Are emissive textures enabled in the application.
  41748. */
  41749. static EmissiveTextureEnabled: boolean;
  41750. /**
  41751. * Are specular textures enabled in the application.
  41752. */
  41753. static SpecularTextureEnabled: boolean;
  41754. /**
  41755. * Are bump textures enabled in the application.
  41756. */
  41757. static BumpTextureEnabled: boolean;
  41758. /**
  41759. * Are lightmap textures enabled in the application.
  41760. */
  41761. static LightmapTextureEnabled: boolean;
  41762. /**
  41763. * Are refraction textures enabled in the application.
  41764. */
  41765. static RefractionTextureEnabled: boolean;
  41766. /**
  41767. * Are color grading textures enabled in the application.
  41768. */
  41769. static ColorGradingTextureEnabled: boolean;
  41770. /**
  41771. * Are fresnels enabled in the application.
  41772. */
  41773. static FresnelEnabled: boolean;
  41774. }
  41775. }
  41776. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41777. import { Scene } from "babylonjs/scene";
  41778. import { Texture } from "babylonjs/Materials/Textures/texture";
  41779. /**
  41780. * A class extending Texture allowing drawing on a texture
  41781. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41782. */
  41783. export class DynamicTexture extends Texture {
  41784. private _generateMipMaps;
  41785. private _canvas;
  41786. private _context;
  41787. private _engine;
  41788. /**
  41789. * Creates a DynamicTexture
  41790. * @param name defines the name of the texture
  41791. * @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
  41792. * @param scene defines the scene where you want the texture
  41793. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41794. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41795. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41796. */
  41797. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41798. /**
  41799. * Get the current class name of the texture useful for serialization or dynamic coding.
  41800. * @returns "DynamicTexture"
  41801. */
  41802. getClassName(): string;
  41803. /**
  41804. * Gets the current state of canRescale
  41805. */
  41806. readonly canRescale: boolean;
  41807. private _recreate;
  41808. /**
  41809. * Scales the texture
  41810. * @param ratio the scale factor to apply to both width and height
  41811. */
  41812. scale(ratio: number): void;
  41813. /**
  41814. * Resizes the texture
  41815. * @param width the new width
  41816. * @param height the new height
  41817. */
  41818. scaleTo(width: number, height: number): void;
  41819. /**
  41820. * Gets the context of the canvas used by the texture
  41821. * @returns the canvas context of the dynamic texture
  41822. */
  41823. getContext(): CanvasRenderingContext2D;
  41824. /**
  41825. * Clears the texture
  41826. */
  41827. clear(): void;
  41828. /**
  41829. * Updates the texture
  41830. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41831. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41832. */
  41833. update(invertY?: boolean, premulAlpha?: boolean): void;
  41834. /**
  41835. * Draws text onto the texture
  41836. * @param text defines the text to be drawn
  41837. * @param x defines the placement of the text from the left
  41838. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41839. * @param font defines the font to be used with font-style, font-size, font-name
  41840. * @param color defines the color used for the text
  41841. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41842. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41843. * @param update defines whether texture is immediately update (default is true)
  41844. */
  41845. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41846. /**
  41847. * Clones the texture
  41848. * @returns the clone of the texture.
  41849. */
  41850. clone(): DynamicTexture;
  41851. /**
  41852. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41853. * @returns a serialized dynamic texture object
  41854. */
  41855. serialize(): any;
  41856. /** @hidden */
  41857. _rebuild(): void;
  41858. }
  41859. }
  41860. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41861. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41862. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41863. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41864. /** @hidden */
  41865. export var imageProcessingPixelShader: {
  41866. name: string;
  41867. shader: string;
  41868. };
  41869. }
  41870. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41871. import { Nullable } from "babylonjs/types";
  41872. import { Color4 } from "babylonjs/Maths/math.color";
  41873. import { Camera } from "babylonjs/Cameras/camera";
  41874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41875. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41876. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41878. import { Engine } from "babylonjs/Engines/engine";
  41879. import "babylonjs/Shaders/imageProcessing.fragment";
  41880. import "babylonjs/Shaders/postprocess.vertex";
  41881. /**
  41882. * ImageProcessingPostProcess
  41883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41884. */
  41885. export class ImageProcessingPostProcess extends PostProcess {
  41886. /**
  41887. * Default configuration related to image processing available in the PBR Material.
  41888. */
  41889. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41890. /**
  41891. * Gets the image processing configuration used either in this material.
  41892. */
  41893. /**
  41894. * Sets the Default image processing configuration used either in the this material.
  41895. *
  41896. * If sets to null, the scene one is in use.
  41897. */
  41898. imageProcessingConfiguration: ImageProcessingConfiguration;
  41899. /**
  41900. * Keep track of the image processing observer to allow dispose and replace.
  41901. */
  41902. private _imageProcessingObserver;
  41903. /**
  41904. * Attaches a new image processing configuration to the PBR Material.
  41905. * @param configuration
  41906. */
  41907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41908. /**
  41909. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41910. */
  41911. /**
  41912. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41913. */
  41914. colorCurves: Nullable<ColorCurves>;
  41915. /**
  41916. * Gets wether the color curves effect is enabled.
  41917. */
  41918. /**
  41919. * Sets wether the color curves effect is enabled.
  41920. */
  41921. colorCurvesEnabled: boolean;
  41922. /**
  41923. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41924. */
  41925. /**
  41926. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41927. */
  41928. colorGradingTexture: Nullable<BaseTexture>;
  41929. /**
  41930. * Gets wether the color grading effect is enabled.
  41931. */
  41932. /**
  41933. * Gets wether the color grading effect is enabled.
  41934. */
  41935. colorGradingEnabled: boolean;
  41936. /**
  41937. * Gets exposure used in the effect.
  41938. */
  41939. /**
  41940. * Sets exposure used in the effect.
  41941. */
  41942. exposure: number;
  41943. /**
  41944. * Gets wether tonemapping is enabled or not.
  41945. */
  41946. /**
  41947. * Sets wether tonemapping is enabled or not
  41948. */
  41949. toneMappingEnabled: boolean;
  41950. /**
  41951. * Gets the type of tone mapping effect.
  41952. */
  41953. /**
  41954. * Sets the type of tone mapping effect.
  41955. */
  41956. toneMappingType: number;
  41957. /**
  41958. * Gets contrast used in the effect.
  41959. */
  41960. /**
  41961. * Sets contrast used in the effect.
  41962. */
  41963. contrast: number;
  41964. /**
  41965. * Gets Vignette stretch size.
  41966. */
  41967. /**
  41968. * Sets Vignette stretch size.
  41969. */
  41970. vignetteStretch: number;
  41971. /**
  41972. * Gets Vignette centre X Offset.
  41973. */
  41974. /**
  41975. * Sets Vignette centre X Offset.
  41976. */
  41977. vignetteCentreX: number;
  41978. /**
  41979. * Gets Vignette centre Y Offset.
  41980. */
  41981. /**
  41982. * Sets Vignette centre Y Offset.
  41983. */
  41984. vignetteCentreY: number;
  41985. /**
  41986. * Gets Vignette weight or intensity of the vignette effect.
  41987. */
  41988. /**
  41989. * Sets Vignette weight or intensity of the vignette effect.
  41990. */
  41991. vignetteWeight: number;
  41992. /**
  41993. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41994. * if vignetteEnabled is set to true.
  41995. */
  41996. /**
  41997. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41998. * if vignetteEnabled is set to true.
  41999. */
  42000. vignetteColor: Color4;
  42001. /**
  42002. * Gets Camera field of view used by the Vignette effect.
  42003. */
  42004. /**
  42005. * Sets Camera field of view used by the Vignette effect.
  42006. */
  42007. vignetteCameraFov: number;
  42008. /**
  42009. * Gets the vignette blend mode allowing different kind of effect.
  42010. */
  42011. /**
  42012. * Sets the vignette blend mode allowing different kind of effect.
  42013. */
  42014. vignetteBlendMode: number;
  42015. /**
  42016. * Gets wether the vignette effect is enabled.
  42017. */
  42018. /**
  42019. * Sets wether the vignette effect is enabled.
  42020. */
  42021. vignetteEnabled: boolean;
  42022. private _fromLinearSpace;
  42023. /**
  42024. * Gets wether the input of the processing is in Gamma or Linear Space.
  42025. */
  42026. /**
  42027. * Sets wether the input of the processing is in Gamma or Linear Space.
  42028. */
  42029. fromLinearSpace: boolean;
  42030. /**
  42031. * Defines cache preventing GC.
  42032. */
  42033. private _defines;
  42034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42035. /**
  42036. * "ImageProcessingPostProcess"
  42037. * @returns "ImageProcessingPostProcess"
  42038. */
  42039. getClassName(): string;
  42040. protected _updateParameters(): void;
  42041. dispose(camera?: Camera): void;
  42042. }
  42043. }
  42044. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42045. import { Scene } from "babylonjs/scene";
  42046. import { Color3 } from "babylonjs/Maths/math.color";
  42047. import { Mesh } from "babylonjs/Meshes/mesh";
  42048. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42049. import { Nullable } from "babylonjs/types";
  42050. /**
  42051. * Class containing static functions to help procedurally build meshes
  42052. */
  42053. export class GroundBuilder {
  42054. /**
  42055. * Creates a ground mesh
  42056. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42057. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42059. * @param name defines the name of the mesh
  42060. * @param options defines the options used to create the mesh
  42061. * @param scene defines the hosting scene
  42062. * @returns the ground mesh
  42063. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42064. */
  42065. static CreateGround(name: string, options: {
  42066. width?: number;
  42067. height?: number;
  42068. subdivisions?: number;
  42069. subdivisionsX?: number;
  42070. subdivisionsY?: number;
  42071. updatable?: boolean;
  42072. }, scene: any): Mesh;
  42073. /**
  42074. * Creates a tiled ground mesh
  42075. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42076. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42077. * * 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
  42078. * * 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
  42079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42080. * @param name defines the name of the mesh
  42081. * @param options defines the options used to create the mesh
  42082. * @param scene defines the hosting scene
  42083. * @returns the tiled ground mesh
  42084. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42085. */
  42086. static CreateTiledGround(name: string, options: {
  42087. xmin: number;
  42088. zmin: number;
  42089. xmax: number;
  42090. zmax: number;
  42091. subdivisions?: {
  42092. w: number;
  42093. h: number;
  42094. };
  42095. precision?: {
  42096. w: number;
  42097. h: number;
  42098. };
  42099. updatable?: boolean;
  42100. }, scene?: Nullable<Scene>): Mesh;
  42101. /**
  42102. * Creates a ground mesh from a height map
  42103. * * The parameter `url` sets the URL of the height map image resource.
  42104. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42105. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42106. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42107. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42108. * * 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.
  42109. * * 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).
  42110. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42112. * @param name defines the name of the mesh
  42113. * @param url defines the url to the height map
  42114. * @param options defines the options used to create the mesh
  42115. * @param scene defines the hosting scene
  42116. * @returns the ground mesh
  42117. * @see https://doc.babylonjs.com/babylon101/height_map
  42118. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42119. */
  42120. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42121. width?: number;
  42122. height?: number;
  42123. subdivisions?: number;
  42124. minHeight?: number;
  42125. maxHeight?: number;
  42126. colorFilter?: Color3;
  42127. alphaFilter?: number;
  42128. updatable?: boolean;
  42129. onReady?: (mesh: GroundMesh) => void;
  42130. }, scene?: Nullable<Scene>): GroundMesh;
  42131. }
  42132. }
  42133. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42134. import { Vector4 } from "babylonjs/Maths/math.vector";
  42135. import { Mesh } from "babylonjs/Meshes/mesh";
  42136. /**
  42137. * Class containing static functions to help procedurally build meshes
  42138. */
  42139. export class TorusBuilder {
  42140. /**
  42141. * Creates a torus mesh
  42142. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42143. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42144. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42148. * @param name defines the name of the mesh
  42149. * @param options defines the options used to create the mesh
  42150. * @param scene defines the hosting scene
  42151. * @returns the torus mesh
  42152. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42153. */
  42154. static CreateTorus(name: string, options: {
  42155. diameter?: number;
  42156. thickness?: number;
  42157. tessellation?: number;
  42158. updatable?: boolean;
  42159. sideOrientation?: number;
  42160. frontUVs?: Vector4;
  42161. backUVs?: Vector4;
  42162. }, scene: any): Mesh;
  42163. }
  42164. }
  42165. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42166. import { Vector4 } from "babylonjs/Maths/math.vector";
  42167. import { Color4 } from "babylonjs/Maths/math.color";
  42168. import { Mesh } from "babylonjs/Meshes/mesh";
  42169. /**
  42170. * Class containing static functions to help procedurally build meshes
  42171. */
  42172. export class CylinderBuilder {
  42173. /**
  42174. * Creates a cylinder or a cone mesh
  42175. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42176. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42177. * * 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.
  42178. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42179. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42180. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42181. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42182. * * 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).
  42183. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42184. * * 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).
  42185. * * 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
  42186. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42187. * * 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
  42188. * * 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.
  42189. * * If `enclose` is false, a ring surface is one element.
  42190. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42191. * * 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
  42192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42195. * @param name defines the name of the mesh
  42196. * @param options defines the options used to create the mesh
  42197. * @param scene defines the hosting scene
  42198. * @returns the cylinder mesh
  42199. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42200. */
  42201. static CreateCylinder(name: string, options: {
  42202. height?: number;
  42203. diameterTop?: number;
  42204. diameterBottom?: number;
  42205. diameter?: number;
  42206. tessellation?: number;
  42207. subdivisions?: number;
  42208. arc?: number;
  42209. faceColors?: Color4[];
  42210. faceUV?: Vector4[];
  42211. updatable?: boolean;
  42212. hasRings?: boolean;
  42213. enclose?: boolean;
  42214. cap?: number;
  42215. sideOrientation?: number;
  42216. frontUVs?: Vector4;
  42217. backUVs?: Vector4;
  42218. }, scene: any): Mesh;
  42219. }
  42220. }
  42221. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42222. import { Observable } from "babylonjs/Misc/observable";
  42223. import { Nullable } from "babylonjs/types";
  42224. import { Camera } from "babylonjs/Cameras/camera";
  42225. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42226. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42227. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42228. import { Scene } from "babylonjs/scene";
  42229. import { Vector3 } from "babylonjs/Maths/math.vector";
  42230. import { Color3 } from "babylonjs/Maths/math.color";
  42231. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42233. import { Mesh } from "babylonjs/Meshes/mesh";
  42234. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42235. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42236. import "babylonjs/Meshes/Builders/groundBuilder";
  42237. import "babylonjs/Meshes/Builders/torusBuilder";
  42238. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42239. import "babylonjs/Gamepads/gamepadSceneComponent";
  42240. import "babylonjs/Animations/animatable";
  42241. /**
  42242. * Options to modify the vr teleportation behavior.
  42243. */
  42244. export interface VRTeleportationOptions {
  42245. /**
  42246. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42247. */
  42248. floorMeshName?: string;
  42249. /**
  42250. * A list of meshes to be used as the teleportation floor. (default: empty)
  42251. */
  42252. floorMeshes?: Mesh[];
  42253. }
  42254. /**
  42255. * Options to modify the vr experience helper's behavior.
  42256. */
  42257. export interface VRExperienceHelperOptions extends WebVROptions {
  42258. /**
  42259. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42260. */
  42261. createDeviceOrientationCamera?: boolean;
  42262. /**
  42263. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42264. */
  42265. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42266. /**
  42267. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42268. */
  42269. laserToggle?: boolean;
  42270. /**
  42271. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42272. */
  42273. floorMeshes?: Mesh[];
  42274. /**
  42275. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42276. */
  42277. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42278. }
  42279. /**
  42280. * Event containing information after VR has been entered
  42281. */
  42282. export class OnAfterEnteringVRObservableEvent {
  42283. /**
  42284. * If entering vr was successful
  42285. */
  42286. success: boolean;
  42287. }
  42288. /**
  42289. * Helps to quickly add VR support to an existing scene.
  42290. * See http://doc.babylonjs.com/how_to/webvr_helper
  42291. */
  42292. export class VRExperienceHelper {
  42293. /** Options to modify the vr experience helper's behavior. */
  42294. webVROptions: VRExperienceHelperOptions;
  42295. private _scene;
  42296. private _position;
  42297. private _btnVR;
  42298. private _btnVRDisplayed;
  42299. private _webVRsupported;
  42300. private _webVRready;
  42301. private _webVRrequesting;
  42302. private _webVRpresenting;
  42303. private _hasEnteredVR;
  42304. private _fullscreenVRpresenting;
  42305. private _canvas;
  42306. private _webVRCamera;
  42307. private _vrDeviceOrientationCamera;
  42308. private _deviceOrientationCamera;
  42309. private _existingCamera;
  42310. private _onKeyDown;
  42311. private _onVrDisplayPresentChange;
  42312. private _onVRDisplayChanged;
  42313. private _onVRRequestPresentStart;
  42314. private _onVRRequestPresentComplete;
  42315. /**
  42316. * 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)
  42317. */
  42318. enableGazeEvenWhenNoPointerLock: boolean;
  42319. /**
  42320. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42321. */
  42322. exitVROnDoubleTap: boolean;
  42323. /**
  42324. * Observable raised right before entering VR.
  42325. */
  42326. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42327. /**
  42328. * Observable raised when entering VR has completed.
  42329. */
  42330. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42331. /**
  42332. * Observable raised when exiting VR.
  42333. */
  42334. onExitingVRObservable: Observable<VRExperienceHelper>;
  42335. /**
  42336. * Observable raised when controller mesh is loaded.
  42337. */
  42338. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42339. /** Return this.onEnteringVRObservable
  42340. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42341. */
  42342. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42343. /** Return this.onExitingVRObservable
  42344. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42345. */
  42346. readonly onExitingVR: Observable<VRExperienceHelper>;
  42347. /** Return this.onControllerMeshLoadedObservable
  42348. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42349. */
  42350. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42351. private _rayLength;
  42352. private _useCustomVRButton;
  42353. private _teleportationRequested;
  42354. private _teleportActive;
  42355. private _floorMeshName;
  42356. private _floorMeshesCollection;
  42357. private _rotationAllowed;
  42358. private _teleportBackwardsVector;
  42359. private _teleportationTarget;
  42360. private _isDefaultTeleportationTarget;
  42361. private _postProcessMove;
  42362. private _teleportationFillColor;
  42363. private _teleportationBorderColor;
  42364. private _rotationAngle;
  42365. private _haloCenter;
  42366. private _cameraGazer;
  42367. private _padSensibilityUp;
  42368. private _padSensibilityDown;
  42369. private _leftController;
  42370. private _rightController;
  42371. /**
  42372. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42373. */
  42374. onNewMeshSelected: Observable<AbstractMesh>;
  42375. /**
  42376. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42377. * This observable will provide the mesh and the controller used to select the mesh
  42378. */
  42379. onMeshSelectedWithController: Observable<{
  42380. mesh: AbstractMesh;
  42381. controller: WebVRController;
  42382. }>;
  42383. /**
  42384. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42385. */
  42386. onNewMeshPicked: Observable<PickingInfo>;
  42387. private _circleEase;
  42388. /**
  42389. * Observable raised before camera teleportation
  42390. */
  42391. onBeforeCameraTeleport: Observable<Vector3>;
  42392. /**
  42393. * Observable raised after camera teleportation
  42394. */
  42395. onAfterCameraTeleport: Observable<Vector3>;
  42396. /**
  42397. * Observable raised when current selected mesh gets unselected
  42398. */
  42399. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42400. private _raySelectionPredicate;
  42401. /**
  42402. * To be optionaly changed by user to define custom ray selection
  42403. */
  42404. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42405. /**
  42406. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42407. */
  42408. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42409. /**
  42410. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42411. */
  42412. teleportationEnabled: boolean;
  42413. private _defaultHeight;
  42414. private _teleportationInitialized;
  42415. private _interactionsEnabled;
  42416. private _interactionsRequested;
  42417. private _displayGaze;
  42418. private _displayLaserPointer;
  42419. /**
  42420. * The mesh used to display where the user is going to teleport.
  42421. */
  42422. /**
  42423. * Sets the mesh to be used to display where the user is going to teleport.
  42424. */
  42425. teleportationTarget: Mesh;
  42426. /**
  42427. * 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
  42428. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42429. * See http://doc.babylonjs.com/resources/baking_transformations
  42430. */
  42431. gazeTrackerMesh: Mesh;
  42432. /**
  42433. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42434. */
  42435. updateGazeTrackerScale: boolean;
  42436. /**
  42437. * If the gaze trackers color should be updated when selecting meshes
  42438. */
  42439. updateGazeTrackerColor: boolean;
  42440. /**
  42441. * The gaze tracking mesh corresponding to the left controller
  42442. */
  42443. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42444. /**
  42445. * The gaze tracking mesh corresponding to the right controller
  42446. */
  42447. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42448. /**
  42449. * If the ray of the gaze should be displayed.
  42450. */
  42451. /**
  42452. * Sets if the ray of the gaze should be displayed.
  42453. */
  42454. displayGaze: boolean;
  42455. /**
  42456. * If the ray of the LaserPointer should be displayed.
  42457. */
  42458. /**
  42459. * Sets if the ray of the LaserPointer should be displayed.
  42460. */
  42461. displayLaserPointer: boolean;
  42462. /**
  42463. * The deviceOrientationCamera used as the camera when not in VR.
  42464. */
  42465. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42466. /**
  42467. * Based on the current WebVR support, returns the current VR camera used.
  42468. */
  42469. readonly currentVRCamera: Nullable<Camera>;
  42470. /**
  42471. * The webVRCamera which is used when in VR.
  42472. */
  42473. readonly webVRCamera: WebVRFreeCamera;
  42474. /**
  42475. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42476. */
  42477. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42478. /**
  42479. * The html button that is used to trigger entering into VR.
  42480. */
  42481. readonly vrButton: Nullable<HTMLButtonElement>;
  42482. private readonly _teleportationRequestInitiated;
  42483. /**
  42484. * Defines wether or not Pointer lock should be requested when switching to
  42485. * full screen.
  42486. */
  42487. requestPointerLockOnFullScreen: boolean;
  42488. /**
  42489. * Instantiates a VRExperienceHelper.
  42490. * Helps to quickly add VR support to an existing scene.
  42491. * @param scene The scene the VRExperienceHelper belongs to.
  42492. * @param webVROptions Options to modify the vr experience helper's behavior.
  42493. */
  42494. constructor(scene: Scene,
  42495. /** Options to modify the vr experience helper's behavior. */
  42496. webVROptions?: VRExperienceHelperOptions);
  42497. private _onDefaultMeshLoaded;
  42498. private _onResize;
  42499. private _onFullscreenChange;
  42500. /**
  42501. * Gets a value indicating if we are currently in VR mode.
  42502. */
  42503. readonly isInVRMode: boolean;
  42504. private onVrDisplayPresentChange;
  42505. private onVRDisplayChanged;
  42506. private moveButtonToBottomRight;
  42507. private displayVRButton;
  42508. private updateButtonVisibility;
  42509. private _cachedAngularSensibility;
  42510. /**
  42511. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42512. * Otherwise, will use the fullscreen API.
  42513. */
  42514. enterVR(): void;
  42515. /**
  42516. * Attempt to exit VR, or fullscreen.
  42517. */
  42518. exitVR(): void;
  42519. /**
  42520. * The position of the vr experience helper.
  42521. */
  42522. /**
  42523. * Sets the position of the vr experience helper.
  42524. */
  42525. position: Vector3;
  42526. /**
  42527. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42528. */
  42529. enableInteractions(): void;
  42530. private readonly _noControllerIsActive;
  42531. private beforeRender;
  42532. private _isTeleportationFloor;
  42533. /**
  42534. * Adds a floor mesh to be used for teleportation.
  42535. * @param floorMesh the mesh to be used for teleportation.
  42536. */
  42537. addFloorMesh(floorMesh: Mesh): void;
  42538. /**
  42539. * Removes a floor mesh from being used for teleportation.
  42540. * @param floorMesh the mesh to be removed.
  42541. */
  42542. removeFloorMesh(floorMesh: Mesh): void;
  42543. /**
  42544. * Enables interactions and teleportation using the VR controllers and gaze.
  42545. * @param vrTeleportationOptions options to modify teleportation behavior.
  42546. */
  42547. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42548. private _onNewGamepadConnected;
  42549. private _tryEnableInteractionOnController;
  42550. private _onNewGamepadDisconnected;
  42551. private _enableInteractionOnController;
  42552. private _checkTeleportWithRay;
  42553. private _checkRotate;
  42554. private _checkTeleportBackwards;
  42555. private _enableTeleportationOnController;
  42556. private _createTeleportationCircles;
  42557. private _displayTeleportationTarget;
  42558. private _hideTeleportationTarget;
  42559. private _rotateCamera;
  42560. private _moveTeleportationSelectorTo;
  42561. private _workingVector;
  42562. private _workingQuaternion;
  42563. private _workingMatrix;
  42564. /**
  42565. * Teleports the users feet to the desired location
  42566. * @param location The location where the user's feet should be placed
  42567. */
  42568. teleportCamera(location: Vector3): void;
  42569. private _convertNormalToDirectionOfRay;
  42570. private _castRayAndSelectObject;
  42571. private _notifySelectedMeshUnselected;
  42572. /**
  42573. * Sets the color of the laser ray from the vr controllers.
  42574. * @param color new color for the ray.
  42575. */
  42576. changeLaserColor(color: Color3): void;
  42577. /**
  42578. * Sets the color of the ray from the vr headsets gaze.
  42579. * @param color new color for the ray.
  42580. */
  42581. changeGazeColor(color: Color3): void;
  42582. /**
  42583. * Exits VR and disposes of the vr experience helper
  42584. */
  42585. dispose(): void;
  42586. /**
  42587. * Gets the name of the VRExperienceHelper class
  42588. * @returns "VRExperienceHelper"
  42589. */
  42590. getClassName(): string;
  42591. }
  42592. }
  42593. declare module "babylonjs/Cameras/VR/index" {
  42594. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42595. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42596. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42597. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42598. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42599. export * from "babylonjs/Cameras/VR/webVRCamera";
  42600. }
  42601. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42602. import { Observable } from "babylonjs/Misc/observable";
  42603. import { Nullable } from "babylonjs/types";
  42604. import { IDisposable, Scene } from "babylonjs/scene";
  42605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42606. /**
  42607. * Manages an XRSession to work with Babylon's engine
  42608. * @see https://doc.babylonjs.com/how_to/webxr
  42609. */
  42610. export class WebXRSessionManager implements IDisposable {
  42611. private scene;
  42612. /**
  42613. * Fires every time a new xrFrame arrives which can be used to update the camera
  42614. */
  42615. onXRFrameObservable: Observable<any>;
  42616. /**
  42617. * Fires when the xr session is ended either by the device or manually done
  42618. */
  42619. onXRSessionEnded: Observable<any>;
  42620. /**
  42621. * Underlying xr session
  42622. */
  42623. session: XRSession;
  42624. /**
  42625. * Type of reference space used when creating the session
  42626. */
  42627. referenceSpace: XRReferenceSpace;
  42628. /** @hidden */
  42629. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42630. /**
  42631. * Current XR frame
  42632. */
  42633. currentFrame: Nullable<XRFrame>;
  42634. private _xrNavigator;
  42635. private baseLayer;
  42636. /**
  42637. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42638. * @param scene The scene which the session should be created for
  42639. */
  42640. constructor(scene: Scene);
  42641. /**
  42642. * Initializes the manager
  42643. * After initialization enterXR can be called to start an XR session
  42644. * @returns Promise which resolves after it is initialized
  42645. */
  42646. initializeAsync(): Promise<void>;
  42647. /**
  42648. * Initializes an xr session
  42649. * @param xrSessionMode mode to initialize
  42650. * @returns a promise which will resolve once the session has been initialized
  42651. */
  42652. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42653. /**
  42654. * Sets the reference space on the xr session
  42655. * @param referenceSpace space to set
  42656. * @returns a promise that will resolve once the reference space has been set
  42657. */
  42658. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42659. /**
  42660. * Updates the render state of the session
  42661. * @param state state to set
  42662. * @returns a promise that resolves once the render state has been updated
  42663. */
  42664. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42665. /**
  42666. * Starts rendering to the xr layer
  42667. * @returns a promise that will resolve once rendering has started
  42668. */
  42669. startRenderingToXRAsync(): Promise<void>;
  42670. /**
  42671. * Stops the xrSession and restores the renderloop
  42672. * @returns Promise which resolves after it exits XR
  42673. */
  42674. exitXRAsync(): Promise<unknown>;
  42675. /**
  42676. * Checks if a session would be supported for the creation options specified
  42677. * @param sessionMode session mode to check if supported eg. immersive-vr
  42678. * @returns true if supported
  42679. */
  42680. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42681. /**
  42682. * @hidden
  42683. * Converts the render layer of xrSession to a render target
  42684. * @param session session to create render target for
  42685. * @param scene scene the new render target should be created for
  42686. */
  42687. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42688. /**
  42689. * Disposes of the session manager
  42690. */
  42691. dispose(): void;
  42692. }
  42693. }
  42694. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42695. import { Scene } from "babylonjs/scene";
  42696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42697. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42698. /**
  42699. * WebXR Camera which holds the views for the xrSession
  42700. * @see https://doc.babylonjs.com/how_to/webxr
  42701. */
  42702. export class WebXRCamera extends FreeCamera {
  42703. private static _TmpMatrix;
  42704. /**
  42705. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42706. * @param name the name of the camera
  42707. * @param scene the scene to add the camera to
  42708. */
  42709. constructor(name: string, scene: Scene);
  42710. private _updateNumberOfRigCameras;
  42711. /** @hidden */
  42712. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42713. /**
  42714. * Updates the cameras position from the current pose information of the XR session
  42715. * @param xrSessionManager the session containing pose information
  42716. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42717. */
  42718. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42719. }
  42720. }
  42721. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42722. import { Nullable } from "babylonjs/types";
  42723. import { IDisposable } from "babylonjs/scene";
  42724. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42725. /**
  42726. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42727. */
  42728. export class WebXRManagedOutputCanvas implements IDisposable {
  42729. private helper;
  42730. private _canvas;
  42731. /**
  42732. * xrpresent context of the canvas which can be used to display/mirror xr content
  42733. */
  42734. canvasContext: WebGLRenderingContext;
  42735. /**
  42736. * xr layer for the canvas
  42737. */
  42738. xrLayer: Nullable<XRWebGLLayer>;
  42739. /**
  42740. * Initializes the xr layer for the session
  42741. * @param xrSession xr session
  42742. * @returns a promise that will resolve once the XR Layer has been created
  42743. */
  42744. initializeXRLayerAsync(xrSession: any): any;
  42745. /**
  42746. * Initializes the canvas to be added/removed upon entering/exiting xr
  42747. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42748. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42749. */
  42750. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42751. /**
  42752. * Disposes of the object
  42753. */
  42754. dispose(): void;
  42755. private _setManagedOutputCanvas;
  42756. private _addCanvas;
  42757. private _removeCanvas;
  42758. }
  42759. }
  42760. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { IDisposable, Scene } from "babylonjs/scene";
  42763. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42765. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42766. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42767. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42768. /**
  42769. * States of the webXR experience
  42770. */
  42771. export enum WebXRState {
  42772. /**
  42773. * Transitioning to being in XR mode
  42774. */
  42775. ENTERING_XR = 0,
  42776. /**
  42777. * Transitioning to non XR mode
  42778. */
  42779. EXITING_XR = 1,
  42780. /**
  42781. * In XR mode and presenting
  42782. */
  42783. IN_XR = 2,
  42784. /**
  42785. * Not entered XR mode
  42786. */
  42787. NOT_IN_XR = 3
  42788. }
  42789. /**
  42790. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42791. * @see https://doc.babylonjs.com/how_to/webxr
  42792. */
  42793. export class WebXRExperienceHelper implements IDisposable {
  42794. private scene;
  42795. /**
  42796. * 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
  42797. */
  42798. container: AbstractMesh;
  42799. /**
  42800. * Camera used to render xr content
  42801. */
  42802. camera: WebXRCamera;
  42803. /**
  42804. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42805. */
  42806. state: WebXRState;
  42807. private _setState;
  42808. private static _TmpVector;
  42809. /**
  42810. * Fires when the state of the experience helper has changed
  42811. */
  42812. onStateChangedObservable: Observable<WebXRState>;
  42813. /** Session manager used to keep track of xr session */
  42814. sessionManager: WebXRSessionManager;
  42815. private _nonVRCamera;
  42816. private _originalSceneAutoClear;
  42817. private _supported;
  42818. /**
  42819. * Creates the experience helper
  42820. * @param scene the scene to attach the experience helper to
  42821. * @returns a promise for the experience helper
  42822. */
  42823. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42824. /**
  42825. * Creates a WebXRExperienceHelper
  42826. * @param scene The scene the helper should be created in
  42827. */
  42828. private constructor();
  42829. /**
  42830. * Exits XR mode and returns the scene to its original state
  42831. * @returns promise that resolves after xr mode has exited
  42832. */
  42833. exitXRAsync(): Promise<unknown>;
  42834. /**
  42835. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42836. * @param sessionCreationOptions options for the XR session
  42837. * @param referenceSpaceType frame of reference of the XR session
  42838. * @param outputCanvas the output canvas that will be used to enter XR mode
  42839. * @returns promise that resolves after xr mode has entered
  42840. */
  42841. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42842. /**
  42843. * Updates the global position of the camera by moving the camera's container
  42844. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42845. * @param position The desired global position of the camera
  42846. */
  42847. setPositionOfCameraUsingContainer(position: Vector3): void;
  42848. /**
  42849. * Rotates the xr camera by rotating the camera's container around the camera's position
  42850. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42851. * @param rotation the desired quaternion rotation to apply to the camera
  42852. */
  42853. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42854. /**
  42855. * Disposes of the experience helper
  42856. */
  42857. dispose(): void;
  42858. }
  42859. }
  42860. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42861. import { Nullable } from "babylonjs/types";
  42862. import { Observable } from "babylonjs/Misc/observable";
  42863. import { IDisposable, Scene } from "babylonjs/scene";
  42864. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42865. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42866. /**
  42867. * Button which can be used to enter a different mode of XR
  42868. */
  42869. export class WebXREnterExitUIButton {
  42870. /** button element */
  42871. element: HTMLElement;
  42872. /** XR initialization options for the button */
  42873. sessionMode: XRSessionMode;
  42874. /** Reference space type */
  42875. referenceSpaceType: XRReferenceSpaceType;
  42876. /**
  42877. * Creates a WebXREnterExitUIButton
  42878. * @param element button element
  42879. * @param sessionMode XR initialization session mode
  42880. * @param referenceSpaceType the type of reference space to be used
  42881. */
  42882. constructor(
  42883. /** button element */
  42884. element: HTMLElement,
  42885. /** XR initialization options for the button */
  42886. sessionMode: XRSessionMode,
  42887. /** Reference space type */
  42888. referenceSpaceType: XRReferenceSpaceType);
  42889. /**
  42890. * Overwritable function which can be used to update the button's visuals when the state changes
  42891. * @param activeButton the current active button in the UI
  42892. */
  42893. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42894. }
  42895. /**
  42896. * Options to create the webXR UI
  42897. */
  42898. export class WebXREnterExitUIOptions {
  42899. /**
  42900. * Context to enter xr with
  42901. */
  42902. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42903. /**
  42904. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42905. */
  42906. customButtons?: Array<WebXREnterExitUIButton>;
  42907. }
  42908. /**
  42909. * UI to allow the user to enter/exit XR mode
  42910. */
  42911. export class WebXREnterExitUI implements IDisposable {
  42912. private scene;
  42913. private _overlay;
  42914. private _buttons;
  42915. private _activeButton;
  42916. /**
  42917. * Fired every time the active button is changed.
  42918. *
  42919. * When xr is entered via a button that launches xr that button will be the callback parameter
  42920. *
  42921. * When exiting xr the callback parameter will be null)
  42922. */
  42923. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42924. /**
  42925. * Creates UI to allow the user to enter/exit XR mode
  42926. * @param scene the scene to add the ui to
  42927. * @param helper the xr experience helper to enter/exit xr with
  42928. * @param options options to configure the UI
  42929. * @returns the created ui
  42930. */
  42931. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42932. private constructor();
  42933. private _updateButtons;
  42934. /**
  42935. * Disposes of the object
  42936. */
  42937. dispose(): void;
  42938. }
  42939. }
  42940. declare module "babylonjs/Cameras/XR/webXRController" {
  42941. import { Nullable } from "babylonjs/types";
  42942. import { Observable } from "babylonjs/Misc/observable";
  42943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42944. import { Ray } from "babylonjs/Culling/ray";
  42945. import { Scene } from "babylonjs/scene";
  42946. /**
  42947. * Represents an XR input
  42948. */
  42949. export class WebXRController {
  42950. private scene;
  42951. /** The underlying input source for the controller */
  42952. inputSource: XRInputSource;
  42953. private parentContainer;
  42954. /**
  42955. * 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
  42956. */
  42957. grip?: AbstractMesh;
  42958. /**
  42959. * Pointer which can be used to select objects or attach a visible laser to
  42960. */
  42961. pointer: AbstractMesh;
  42962. /**
  42963. * Event that fires when the controller is removed/disposed
  42964. */
  42965. onDisposeObservable: Observable<{}>;
  42966. private _tmpMatrix;
  42967. private _tmpQuaternion;
  42968. private _tmpVector;
  42969. /**
  42970. * Creates the controller
  42971. * @see https://doc.babylonjs.com/how_to/webxr
  42972. * @param scene the scene which the controller should be associated to
  42973. * @param inputSource the underlying input source for the controller
  42974. * @param parentContainer parent that the controller meshes should be children of
  42975. */
  42976. constructor(scene: Scene,
  42977. /** The underlying input source for the controller */
  42978. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42979. /**
  42980. * Updates the controller pose based on the given XRFrame
  42981. * @param xrFrame xr frame to update the pose with
  42982. * @param referenceSpace reference space to use
  42983. */
  42984. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42985. /**
  42986. * Gets a world space ray coming from the controller
  42987. * @param result the resulting ray
  42988. */
  42989. getWorldPointerRayToRef(result: Ray): void;
  42990. /**
  42991. * Disposes of the object
  42992. */
  42993. dispose(): void;
  42994. }
  42995. }
  42996. declare module "babylonjs/Cameras/XR/webXRInput" {
  42997. import { Observable } from "babylonjs/Misc/observable";
  42998. import { IDisposable } from "babylonjs/scene";
  42999. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43000. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43001. /**
  43002. * XR input used to track XR inputs such as controllers/rays
  43003. */
  43004. export class WebXRInput implements IDisposable {
  43005. /**
  43006. * Base experience the input listens to
  43007. */
  43008. baseExperience: WebXRExperienceHelper;
  43009. /**
  43010. * XR controllers being tracked
  43011. */
  43012. controllers: Array<WebXRController>;
  43013. private _frameObserver;
  43014. private _stateObserver;
  43015. /**
  43016. * Event when a controller has been connected/added
  43017. */
  43018. onControllerAddedObservable: Observable<WebXRController>;
  43019. /**
  43020. * Event when a controller has been removed/disconnected
  43021. */
  43022. onControllerRemovedObservable: Observable<WebXRController>;
  43023. /**
  43024. * Initializes the WebXRInput
  43025. * @param baseExperience experience helper which the input should be created for
  43026. */
  43027. constructor(
  43028. /**
  43029. * Base experience the input listens to
  43030. */
  43031. baseExperience: WebXRExperienceHelper);
  43032. private _onInputSourcesChange;
  43033. private _addAndRemoveControllers;
  43034. /**
  43035. * Disposes of the object
  43036. */
  43037. dispose(): void;
  43038. }
  43039. }
  43040. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43042. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43043. /**
  43044. * Enables teleportation
  43045. */
  43046. export class WebXRControllerTeleportation {
  43047. private _teleportationFillColor;
  43048. private _teleportationBorderColor;
  43049. private _tmpRay;
  43050. private _tmpVector;
  43051. /**
  43052. * Creates a WebXRControllerTeleportation
  43053. * @param input input manager to add teleportation to
  43054. * @param floorMeshes floormeshes which can be teleported to
  43055. */
  43056. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43057. }
  43058. }
  43059. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43060. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43061. /**
  43062. * Handles pointer input automatically for the pointer of XR controllers
  43063. */
  43064. export class WebXRControllerPointerSelection {
  43065. private static _idCounter;
  43066. private _tmpRay;
  43067. /**
  43068. * Creates a WebXRControllerPointerSelection
  43069. * @param input input manager to setup pointer selection
  43070. */
  43071. constructor(input: WebXRInput);
  43072. private _convertNormalToDirectionOfRay;
  43073. private _updatePointerDistance;
  43074. }
  43075. }
  43076. declare module "babylonjs/Loading/sceneLoader" {
  43077. import { Observable } from "babylonjs/Misc/observable";
  43078. import { Nullable } from "babylonjs/types";
  43079. import { Scene } from "babylonjs/scene";
  43080. import { Engine } from "babylonjs/Engines/engine";
  43081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43082. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43083. import { AssetContainer } from "babylonjs/assetContainer";
  43084. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43085. import { Skeleton } from "babylonjs/Bones/skeleton";
  43086. /**
  43087. * Class used to represent data loading progression
  43088. */
  43089. export class SceneLoaderProgressEvent {
  43090. /** defines if data length to load can be evaluated */
  43091. readonly lengthComputable: boolean;
  43092. /** defines the loaded data length */
  43093. readonly loaded: number;
  43094. /** defines the data length to load */
  43095. readonly total: number;
  43096. /**
  43097. * Create a new progress event
  43098. * @param lengthComputable defines if data length to load can be evaluated
  43099. * @param loaded defines the loaded data length
  43100. * @param total defines the data length to load
  43101. */
  43102. constructor(
  43103. /** defines if data length to load can be evaluated */
  43104. lengthComputable: boolean,
  43105. /** defines the loaded data length */
  43106. loaded: number,
  43107. /** defines the data length to load */
  43108. total: number);
  43109. /**
  43110. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43111. * @param event defines the source event
  43112. * @returns a new SceneLoaderProgressEvent
  43113. */
  43114. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43115. }
  43116. /**
  43117. * Interface used by SceneLoader plugins to define supported file extensions
  43118. */
  43119. export interface ISceneLoaderPluginExtensions {
  43120. /**
  43121. * Defines the list of supported extensions
  43122. */
  43123. [extension: string]: {
  43124. isBinary: boolean;
  43125. };
  43126. }
  43127. /**
  43128. * Interface used by SceneLoader plugin factory
  43129. */
  43130. export interface ISceneLoaderPluginFactory {
  43131. /**
  43132. * Defines the name of the factory
  43133. */
  43134. name: string;
  43135. /**
  43136. * Function called to create a new plugin
  43137. * @return the new plugin
  43138. */
  43139. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43140. /**
  43141. * Boolean indicating if the plugin can direct load specific data
  43142. */
  43143. canDirectLoad?: (data: string) => boolean;
  43144. }
  43145. /**
  43146. * Interface used to define a SceneLoader plugin
  43147. */
  43148. export interface ISceneLoaderPlugin {
  43149. /**
  43150. * The friendly name of this plugin.
  43151. */
  43152. name: string;
  43153. /**
  43154. * The file extensions supported by this plugin.
  43155. */
  43156. extensions: string | ISceneLoaderPluginExtensions;
  43157. /**
  43158. * Import meshes into a scene.
  43159. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43160. * @param scene The scene to import into
  43161. * @param data The data to import
  43162. * @param rootUrl The root url for scene and resources
  43163. * @param meshes The meshes array to import into
  43164. * @param particleSystems The particle systems array to import into
  43165. * @param skeletons The skeletons array to import into
  43166. * @param onError The callback when import fails
  43167. * @returns True if successful or false otherwise
  43168. */
  43169. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43170. /**
  43171. * Load into a scene.
  43172. * @param scene The scene to load into
  43173. * @param data The data to import
  43174. * @param rootUrl The root url for scene and resources
  43175. * @param onError The callback when import fails
  43176. * @returns true if successful or false otherwise
  43177. */
  43178. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43179. /**
  43180. * The callback that returns true if the data can be directly loaded.
  43181. */
  43182. canDirectLoad?: (data: string) => boolean;
  43183. /**
  43184. * The callback that allows custom handling of the root url based on the response url.
  43185. */
  43186. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43187. /**
  43188. * Load into an asset container.
  43189. * @param scene The scene to load into
  43190. * @param data The data to import
  43191. * @param rootUrl The root url for scene and resources
  43192. * @param onError The callback when import fails
  43193. * @returns The loaded asset container
  43194. */
  43195. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43196. }
  43197. /**
  43198. * Interface used to define an async SceneLoader plugin
  43199. */
  43200. export interface ISceneLoaderPluginAsync {
  43201. /**
  43202. * The friendly name of this plugin.
  43203. */
  43204. name: string;
  43205. /**
  43206. * The file extensions supported by this plugin.
  43207. */
  43208. extensions: string | ISceneLoaderPluginExtensions;
  43209. /**
  43210. * Import meshes into a scene.
  43211. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43212. * @param scene The scene to import into
  43213. * @param data The data to import
  43214. * @param rootUrl The root url for scene and resources
  43215. * @param onProgress The callback when the load progresses
  43216. * @param fileName Defines the name of the file to load
  43217. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43218. */
  43219. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43220. meshes: AbstractMesh[];
  43221. particleSystems: IParticleSystem[];
  43222. skeletons: Skeleton[];
  43223. animationGroups: AnimationGroup[];
  43224. }>;
  43225. /**
  43226. * Load into a scene.
  43227. * @param scene The scene to load into
  43228. * @param data The data to import
  43229. * @param rootUrl The root url for scene and resources
  43230. * @param onProgress The callback when the load progresses
  43231. * @param fileName Defines the name of the file to load
  43232. * @returns Nothing
  43233. */
  43234. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43235. /**
  43236. * The callback that returns true if the data can be directly loaded.
  43237. */
  43238. canDirectLoad?: (data: string) => boolean;
  43239. /**
  43240. * The callback that allows custom handling of the root url based on the response url.
  43241. */
  43242. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43243. /**
  43244. * Load into an asset container.
  43245. * @param scene The scene to load into
  43246. * @param data The data to import
  43247. * @param rootUrl The root url for scene and resources
  43248. * @param onProgress The callback when the load progresses
  43249. * @param fileName Defines the name of the file to load
  43250. * @returns The loaded asset container
  43251. */
  43252. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43253. }
  43254. /**
  43255. * Class used to load scene from various file formats using registered plugins
  43256. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43257. */
  43258. export class SceneLoader {
  43259. /**
  43260. * No logging while loading
  43261. */
  43262. static readonly NO_LOGGING: number;
  43263. /**
  43264. * Minimal logging while loading
  43265. */
  43266. static readonly MINIMAL_LOGGING: number;
  43267. /**
  43268. * Summary logging while loading
  43269. */
  43270. static readonly SUMMARY_LOGGING: number;
  43271. /**
  43272. * Detailled logging while loading
  43273. */
  43274. static readonly DETAILED_LOGGING: number;
  43275. /**
  43276. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43277. */
  43278. static ForceFullSceneLoadingForIncremental: boolean;
  43279. /**
  43280. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43281. */
  43282. static ShowLoadingScreen: boolean;
  43283. /**
  43284. * Defines the current logging level (while loading the scene)
  43285. * @ignorenaming
  43286. */
  43287. static loggingLevel: number;
  43288. /**
  43289. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43290. */
  43291. static CleanBoneMatrixWeights: boolean;
  43292. /**
  43293. * Event raised when a plugin is used to load a scene
  43294. */
  43295. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43296. private static _registeredPlugins;
  43297. private static _getDefaultPlugin;
  43298. private static _getPluginForExtension;
  43299. private static _getPluginForDirectLoad;
  43300. private static _getPluginForFilename;
  43301. private static _getDirectLoad;
  43302. private static _loadData;
  43303. private static _getFileInfo;
  43304. /**
  43305. * Gets a plugin that can load the given extension
  43306. * @param extension defines the extension to load
  43307. * @returns a plugin or null if none works
  43308. */
  43309. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43310. /**
  43311. * Gets a boolean indicating that the given extension can be loaded
  43312. * @param extension defines the extension to load
  43313. * @returns true if the extension is supported
  43314. */
  43315. static IsPluginForExtensionAvailable(extension: string): boolean;
  43316. /**
  43317. * Adds a new plugin to the list of registered plugins
  43318. * @param plugin defines the plugin to add
  43319. */
  43320. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43321. /**
  43322. * Import meshes into a scene
  43323. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43324. * @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)
  43325. * @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)
  43326. * @param scene the instance of BABYLON.Scene to append to
  43327. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43328. * @param onProgress a callback with a progress event for each file being loaded
  43329. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43330. * @param pluginExtension the extension used to determine the plugin
  43331. * @returns The loaded plugin
  43332. */
  43333. 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>;
  43334. /**
  43335. * Import meshes into a scene
  43336. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43337. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43338. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43339. * @param scene the instance of BABYLON.Scene to append to
  43340. * @param onProgress a callback with a progress event for each file being loaded
  43341. * @param pluginExtension the extension used to determine the plugin
  43342. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43343. */
  43344. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43345. meshes: AbstractMesh[];
  43346. particleSystems: IParticleSystem[];
  43347. skeletons: Skeleton[];
  43348. animationGroups: AnimationGroup[];
  43349. }>;
  43350. /**
  43351. * Load a scene
  43352. * @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)
  43353. * @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)
  43354. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43355. * @param onSuccess a callback with the scene when import succeeds
  43356. * @param onProgress a callback with a progress event for each file being loaded
  43357. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43358. * @param pluginExtension the extension used to determine the plugin
  43359. * @returns The loaded plugin
  43360. */
  43361. 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>;
  43362. /**
  43363. * Load a scene
  43364. * @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)
  43365. * @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)
  43366. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43367. * @param onProgress a callback with a progress event for each file being loaded
  43368. * @param pluginExtension the extension used to determine the plugin
  43369. * @returns The loaded scene
  43370. */
  43371. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43372. /**
  43373. * Append a scene
  43374. * @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)
  43375. * @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)
  43376. * @param scene is the instance of BABYLON.Scene to append to
  43377. * @param onSuccess a callback with the scene when import succeeds
  43378. * @param onProgress a callback with a progress event for each file being loaded
  43379. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43380. * @param pluginExtension the extension used to determine the plugin
  43381. * @returns The loaded plugin
  43382. */
  43383. 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>;
  43384. /**
  43385. * Append a scene
  43386. * @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)
  43387. * @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)
  43388. * @param scene is the instance of BABYLON.Scene to append to
  43389. * @param onProgress a callback with a progress event for each file being loaded
  43390. * @param pluginExtension the extension used to determine the plugin
  43391. * @returns The given scene
  43392. */
  43393. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43394. /**
  43395. * Load a scene into an asset container
  43396. * @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)
  43397. * @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)
  43398. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43399. * @param onSuccess a callback with the scene when import succeeds
  43400. * @param onProgress a callback with a progress event for each file being loaded
  43401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43402. * @param pluginExtension the extension used to determine the plugin
  43403. * @returns The loaded plugin
  43404. */
  43405. 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>;
  43406. /**
  43407. * Load a scene into an asset container
  43408. * @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)
  43409. * @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)
  43410. * @param scene is the instance of Scene to append to
  43411. * @param onProgress a callback with a progress event for each file being loaded
  43412. * @param pluginExtension the extension used to determine the plugin
  43413. * @returns The loaded asset container
  43414. */
  43415. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43416. }
  43417. }
  43418. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43419. import { Scene } from "babylonjs/scene";
  43420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43421. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43422. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43423. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43424. /**
  43425. * Generic Controller
  43426. */
  43427. export class GenericController extends WebVRController {
  43428. /**
  43429. * Base Url for the controller model.
  43430. */
  43431. static readonly MODEL_BASE_URL: string;
  43432. /**
  43433. * File name for the controller model.
  43434. */
  43435. static readonly MODEL_FILENAME: string;
  43436. /**
  43437. * Creates a new GenericController from a gamepad
  43438. * @param vrGamepad the gamepad that the controller should be created from
  43439. */
  43440. constructor(vrGamepad: any);
  43441. /**
  43442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43443. * @param scene scene in which to add meshes
  43444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43445. */
  43446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43447. /**
  43448. * Called once for each button that changed state since the last frame
  43449. * @param buttonIdx Which button index changed
  43450. * @param state New state of the button
  43451. * @param changes Which properties on the state changed since last frame
  43452. */
  43453. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43454. }
  43455. }
  43456. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43457. import { Observable } from "babylonjs/Misc/observable";
  43458. import { Scene } from "babylonjs/scene";
  43459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43460. import { Ray } from "babylonjs/Culling/ray";
  43461. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43462. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43463. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43464. /**
  43465. * Defines the WindowsMotionController object that the state of the windows motion controller
  43466. */
  43467. export class WindowsMotionController extends WebVRController {
  43468. /**
  43469. * The base url used to load the left and right controller models
  43470. */
  43471. static MODEL_BASE_URL: string;
  43472. /**
  43473. * The name of the left controller model file
  43474. */
  43475. static MODEL_LEFT_FILENAME: string;
  43476. /**
  43477. * The name of the right controller model file
  43478. */
  43479. static MODEL_RIGHT_FILENAME: string;
  43480. /**
  43481. * The controller name prefix for this controller type
  43482. */
  43483. static readonly GAMEPAD_ID_PREFIX: string;
  43484. /**
  43485. * The controller id pattern for this controller type
  43486. */
  43487. private static readonly GAMEPAD_ID_PATTERN;
  43488. private _loadedMeshInfo;
  43489. private readonly _mapping;
  43490. /**
  43491. * Fired when the trackpad on this controller is clicked
  43492. */
  43493. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43494. /**
  43495. * Fired when the trackpad on this controller is modified
  43496. */
  43497. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43498. /**
  43499. * The current x and y values of this controller's trackpad
  43500. */
  43501. trackpad: StickValues;
  43502. /**
  43503. * Creates a new WindowsMotionController from a gamepad
  43504. * @param vrGamepad the gamepad that the controller should be created from
  43505. */
  43506. constructor(vrGamepad: any);
  43507. /**
  43508. * Fired when the trigger on this controller is modified
  43509. */
  43510. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43511. /**
  43512. * Fired when the menu button on this controller is modified
  43513. */
  43514. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the grip button on this controller is modified
  43517. */
  43518. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43519. /**
  43520. * Fired when the thumbstick button on this controller is modified
  43521. */
  43522. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43523. /**
  43524. * Fired when the touchpad button on this controller is modified
  43525. */
  43526. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43527. /**
  43528. * Fired when the touchpad values on this controller are modified
  43529. */
  43530. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43531. private _updateTrackpad;
  43532. /**
  43533. * Called once per frame by the engine.
  43534. */
  43535. update(): void;
  43536. /**
  43537. * Called once for each button that changed state since the last frame
  43538. * @param buttonIdx Which button index changed
  43539. * @param state New state of the button
  43540. * @param changes Which properties on the state changed since last frame
  43541. */
  43542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43543. /**
  43544. * Moves the buttons on the controller mesh based on their current state
  43545. * @param buttonName the name of the button to move
  43546. * @param buttonValue the value of the button which determines the buttons new position
  43547. */
  43548. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43549. /**
  43550. * Moves the axis on the controller mesh based on its current state
  43551. * @param axis the index of the axis
  43552. * @param axisValue the value of the axis which determines the meshes new position
  43553. * @hidden
  43554. */
  43555. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43556. /**
  43557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43558. * @param scene scene in which to add meshes
  43559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43560. */
  43561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43562. /**
  43563. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43564. * can be transformed by button presses and axes values, based on this._mapping.
  43565. *
  43566. * @param scene scene in which the meshes exist
  43567. * @param meshes list of meshes that make up the controller model to process
  43568. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43569. */
  43570. private processModel;
  43571. private createMeshInfo;
  43572. /**
  43573. * Gets the ray of the controller in the direction the controller is pointing
  43574. * @param length the length the resulting ray should be
  43575. * @returns a ray in the direction the controller is pointing
  43576. */
  43577. getForwardRay(length?: number): Ray;
  43578. /**
  43579. * Disposes of the controller
  43580. */
  43581. dispose(): void;
  43582. }
  43583. }
  43584. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43585. import { Observable } from "babylonjs/Misc/observable";
  43586. import { Scene } from "babylonjs/scene";
  43587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43588. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43589. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43590. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43591. /**
  43592. * Oculus Touch Controller
  43593. */
  43594. export class OculusTouchController extends WebVRController {
  43595. /**
  43596. * Base Url for the controller model.
  43597. */
  43598. static MODEL_BASE_URL: string;
  43599. /**
  43600. * File name for the left controller model.
  43601. */
  43602. static MODEL_LEFT_FILENAME: string;
  43603. /**
  43604. * File name for the right controller model.
  43605. */
  43606. static MODEL_RIGHT_FILENAME: string;
  43607. /**
  43608. * Base Url for the Quest controller model.
  43609. */
  43610. static QUEST_MODEL_BASE_URL: string;
  43611. /**
  43612. * @hidden
  43613. * If the controllers are running on a device that needs the updated Quest controller models
  43614. */
  43615. static _IsQuest: boolean;
  43616. /**
  43617. * Fired when the secondary trigger on this controller is modified
  43618. */
  43619. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43620. /**
  43621. * Fired when the thumb rest on this controller is modified
  43622. */
  43623. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43624. /**
  43625. * Creates a new OculusTouchController from a gamepad
  43626. * @param vrGamepad the gamepad that the controller should be created from
  43627. */
  43628. constructor(vrGamepad: any);
  43629. /**
  43630. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43631. * @param scene scene in which to add meshes
  43632. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43633. */
  43634. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43635. /**
  43636. * Fired when the A button on this controller is modified
  43637. */
  43638. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43639. /**
  43640. * Fired when the B button on this controller is modified
  43641. */
  43642. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43643. /**
  43644. * Fired when the X button on this controller is modified
  43645. */
  43646. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43647. /**
  43648. * Fired when the Y button on this controller is modified
  43649. */
  43650. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43651. /**
  43652. * Called once for each button that changed state since the last frame
  43653. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43654. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43655. * 2) secondary trigger (same)
  43656. * 3) A (right) X (left), touch, pressed = value
  43657. * 4) B / Y
  43658. * 5) thumb rest
  43659. * @param buttonIdx Which button index changed
  43660. * @param state New state of the button
  43661. * @param changes Which properties on the state changed since last frame
  43662. */
  43663. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43664. }
  43665. }
  43666. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43667. import { Scene } from "babylonjs/scene";
  43668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43669. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43670. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43671. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43672. import { Observable } from "babylonjs/Misc/observable";
  43673. /**
  43674. * Vive Controller
  43675. */
  43676. export class ViveController extends WebVRController {
  43677. /**
  43678. * Base Url for the controller model.
  43679. */
  43680. static MODEL_BASE_URL: string;
  43681. /**
  43682. * File name for the controller model.
  43683. */
  43684. static MODEL_FILENAME: string;
  43685. /**
  43686. * Creates a new ViveController from a gamepad
  43687. * @param vrGamepad the gamepad that the controller should be created from
  43688. */
  43689. constructor(vrGamepad: any);
  43690. /**
  43691. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43692. * @param scene scene in which to add meshes
  43693. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43694. */
  43695. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43696. /**
  43697. * Fired when the left button on this controller is modified
  43698. */
  43699. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43700. /**
  43701. * Fired when the right button on this controller is modified
  43702. */
  43703. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43704. /**
  43705. * Fired when the menu button on this controller is modified
  43706. */
  43707. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43708. /**
  43709. * Called once for each button that changed state since the last frame
  43710. * Vive mapping:
  43711. * 0: touchpad
  43712. * 1: trigger
  43713. * 2: left AND right buttons
  43714. * 3: menu button
  43715. * @param buttonIdx Which button index changed
  43716. * @param state New state of the button
  43717. * @param changes Which properties on the state changed since last frame
  43718. */
  43719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43720. }
  43721. }
  43722. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43723. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43724. /**
  43725. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43726. */
  43727. export class WebXRControllerModelLoader {
  43728. /**
  43729. * Creates the WebXRControllerModelLoader
  43730. * @param input xr input that creates the controllers
  43731. */
  43732. constructor(input: WebXRInput);
  43733. }
  43734. }
  43735. declare module "babylonjs/Cameras/XR/index" {
  43736. export * from "babylonjs/Cameras/XR/webXRCamera";
  43737. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43738. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43739. export * from "babylonjs/Cameras/XR/webXRInput";
  43740. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43741. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43742. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43743. export * from "babylonjs/Cameras/XR/webXRController";
  43744. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43745. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43746. }
  43747. declare module "babylonjs/Cameras/RigModes/index" {
  43748. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43749. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43750. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43751. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43752. }
  43753. declare module "babylonjs/Cameras/index" {
  43754. export * from "babylonjs/Cameras/Inputs/index";
  43755. export * from "babylonjs/Cameras/cameraInputsManager";
  43756. export * from "babylonjs/Cameras/camera";
  43757. export * from "babylonjs/Cameras/targetCamera";
  43758. export * from "babylonjs/Cameras/freeCamera";
  43759. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43760. export * from "babylonjs/Cameras/touchCamera";
  43761. export * from "babylonjs/Cameras/arcRotateCamera";
  43762. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43763. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43764. export * from "babylonjs/Cameras/flyCamera";
  43765. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43766. export * from "babylonjs/Cameras/followCamera";
  43767. export * from "babylonjs/Cameras/followCameraInputsManager";
  43768. export * from "babylonjs/Cameras/gamepadCamera";
  43769. export * from "babylonjs/Cameras/Stereoscopic/index";
  43770. export * from "babylonjs/Cameras/universalCamera";
  43771. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43772. export * from "babylonjs/Cameras/VR/index";
  43773. export * from "babylonjs/Cameras/XR/index";
  43774. export * from "babylonjs/Cameras/RigModes/index";
  43775. }
  43776. declare module "babylonjs/Collisions/index" {
  43777. export * from "babylonjs/Collisions/collider";
  43778. export * from "babylonjs/Collisions/collisionCoordinator";
  43779. export * from "babylonjs/Collisions/pickingInfo";
  43780. export * from "babylonjs/Collisions/intersectionInfo";
  43781. export * from "babylonjs/Collisions/meshCollisionData";
  43782. }
  43783. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43784. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43785. import { Vector3 } from "babylonjs/Maths/math.vector";
  43786. import { Ray } from "babylonjs/Culling/ray";
  43787. import { Plane } from "babylonjs/Maths/math.plane";
  43788. /**
  43789. * Contains an array of blocks representing the octree
  43790. */
  43791. export interface IOctreeContainer<T> {
  43792. /**
  43793. * Blocks within the octree
  43794. */
  43795. blocks: Array<OctreeBlock<T>>;
  43796. }
  43797. /**
  43798. * Class used to store a cell in an octree
  43799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43800. */
  43801. export class OctreeBlock<T> {
  43802. /**
  43803. * Gets the content of the current block
  43804. */
  43805. entries: T[];
  43806. /**
  43807. * Gets the list of block children
  43808. */
  43809. blocks: Array<OctreeBlock<T>>;
  43810. private _depth;
  43811. private _maxDepth;
  43812. private _capacity;
  43813. private _minPoint;
  43814. private _maxPoint;
  43815. private _boundingVectors;
  43816. private _creationFunc;
  43817. /**
  43818. * Creates a new block
  43819. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43820. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43821. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43822. * @param depth defines the current depth of this block in the octree
  43823. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43824. * @param creationFunc defines a callback to call when an element is added to the block
  43825. */
  43826. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43827. /**
  43828. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43829. */
  43830. readonly capacity: number;
  43831. /**
  43832. * Gets the minimum vector (in world space) of the block's bounding box
  43833. */
  43834. readonly minPoint: Vector3;
  43835. /**
  43836. * Gets the maximum vector (in world space) of the block's bounding box
  43837. */
  43838. readonly maxPoint: Vector3;
  43839. /**
  43840. * Add a new element to this block
  43841. * @param entry defines the element to add
  43842. */
  43843. addEntry(entry: T): void;
  43844. /**
  43845. * Remove an element from this block
  43846. * @param entry defines the element to remove
  43847. */
  43848. removeEntry(entry: T): void;
  43849. /**
  43850. * Add an array of elements to this block
  43851. * @param entries defines the array of elements to add
  43852. */
  43853. addEntries(entries: T[]): void;
  43854. /**
  43855. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43856. * @param frustumPlanes defines the frustum planes to test
  43857. * @param selection defines the array to store current content if selection is positive
  43858. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43859. */
  43860. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43861. /**
  43862. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43863. * @param sphereCenter defines the bounding sphere center
  43864. * @param sphereRadius defines the bounding sphere radius
  43865. * @param selection defines the array to store current content if selection is positive
  43866. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43867. */
  43868. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43869. /**
  43870. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43871. * @param ray defines the ray to test with
  43872. * @param selection defines the array to store current content if selection is positive
  43873. */
  43874. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43875. /**
  43876. * Subdivide the content into child blocks (this block will then be empty)
  43877. */
  43878. createInnerBlocks(): void;
  43879. /**
  43880. * @hidden
  43881. */
  43882. 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;
  43883. }
  43884. }
  43885. declare module "babylonjs/Culling/Octrees/octree" {
  43886. import { SmartArray } from "babylonjs/Misc/smartArray";
  43887. import { Vector3 } from "babylonjs/Maths/math.vector";
  43888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43890. import { Ray } from "babylonjs/Culling/ray";
  43891. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43892. import { Plane } from "babylonjs/Maths/math.plane";
  43893. /**
  43894. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43896. */
  43897. export class Octree<T> {
  43898. /** 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.) */
  43899. maxDepth: number;
  43900. /**
  43901. * Blocks within the octree containing objects
  43902. */
  43903. blocks: Array<OctreeBlock<T>>;
  43904. /**
  43905. * Content stored in the octree
  43906. */
  43907. dynamicContent: T[];
  43908. private _maxBlockCapacity;
  43909. private _selectionContent;
  43910. private _creationFunc;
  43911. /**
  43912. * Creates a octree
  43913. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43914. * @param creationFunc function to be used to instatiate the octree
  43915. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43916. * @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.)
  43917. */
  43918. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43919. /** 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.) */
  43920. maxDepth?: number);
  43921. /**
  43922. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43923. * @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);
  43924. * @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);
  43925. * @param entries meshes to be added to the octree blocks
  43926. */
  43927. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43928. /**
  43929. * Adds a mesh to the octree
  43930. * @param entry Mesh to add to the octree
  43931. */
  43932. addMesh(entry: T): void;
  43933. /**
  43934. * Remove an element from the octree
  43935. * @param entry defines the element to remove
  43936. */
  43937. removeMesh(entry: T): void;
  43938. /**
  43939. * Selects an array of meshes within the frustum
  43940. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43941. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43942. * @returns array of meshes within the frustum
  43943. */
  43944. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43945. /**
  43946. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43947. * @param sphereCenter defines the bounding sphere center
  43948. * @param sphereRadius defines the bounding sphere radius
  43949. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43950. * @returns an array of objects that intersect the sphere
  43951. */
  43952. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43953. /**
  43954. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43955. * @param ray defines the ray to test with
  43956. * @returns array of intersected objects
  43957. */
  43958. intersectsRay(ray: Ray): SmartArray<T>;
  43959. /**
  43960. * Adds a mesh into the octree block if it intersects the block
  43961. */
  43962. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43963. /**
  43964. * Adds a submesh into the octree block if it intersects the block
  43965. */
  43966. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43967. }
  43968. }
  43969. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43970. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43971. import { Scene } from "babylonjs/scene";
  43972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43974. import { Ray } from "babylonjs/Culling/ray";
  43975. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43976. import { Collider } from "babylonjs/Collisions/collider";
  43977. module "babylonjs/scene" {
  43978. interface Scene {
  43979. /**
  43980. * @hidden
  43981. * Backing Filed
  43982. */
  43983. _selectionOctree: Octree<AbstractMesh>;
  43984. /**
  43985. * Gets the octree used to boost mesh selection (picking)
  43986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43987. */
  43988. selectionOctree: Octree<AbstractMesh>;
  43989. /**
  43990. * Creates or updates the octree used to boost selection (picking)
  43991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43992. * @param maxCapacity defines the maximum capacity per leaf
  43993. * @param maxDepth defines the maximum depth of the octree
  43994. * @returns an octree of AbstractMesh
  43995. */
  43996. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43997. }
  43998. }
  43999. module "babylonjs/Meshes/abstractMesh" {
  44000. interface AbstractMesh {
  44001. /**
  44002. * @hidden
  44003. * Backing Field
  44004. */
  44005. _submeshesOctree: Octree<SubMesh>;
  44006. /**
  44007. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44008. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44009. * @param maxCapacity defines the maximum size of each block (64 by default)
  44010. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44011. * @returns the new octree
  44012. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44013. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44014. */
  44015. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44016. }
  44017. }
  44018. /**
  44019. * Defines the octree scene component responsible to manage any octrees
  44020. * in a given scene.
  44021. */
  44022. export class OctreeSceneComponent {
  44023. /**
  44024. * The component name help to identify the component in the list of scene components.
  44025. */
  44026. readonly name: string;
  44027. /**
  44028. * The scene the component belongs to.
  44029. */
  44030. scene: Scene;
  44031. /**
  44032. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44033. */
  44034. readonly checksIsEnabled: boolean;
  44035. /**
  44036. * Creates a new instance of the component for the given scene
  44037. * @param scene Defines the scene to register the component in
  44038. */
  44039. constructor(scene: Scene);
  44040. /**
  44041. * Registers the component in a given scene
  44042. */
  44043. register(): void;
  44044. /**
  44045. * Return the list of active meshes
  44046. * @returns the list of active meshes
  44047. */
  44048. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44049. /**
  44050. * Return the list of active sub meshes
  44051. * @param mesh The mesh to get the candidates sub meshes from
  44052. * @returns the list of active sub meshes
  44053. */
  44054. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44055. private _tempRay;
  44056. /**
  44057. * Return the list of sub meshes intersecting with a given local ray
  44058. * @param mesh defines the mesh to find the submesh for
  44059. * @param localRay defines the ray in local space
  44060. * @returns the list of intersecting sub meshes
  44061. */
  44062. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44063. /**
  44064. * Return the list of sub meshes colliding with a collider
  44065. * @param mesh defines the mesh to find the submesh for
  44066. * @param collider defines the collider to evaluate the collision against
  44067. * @returns the list of colliding sub meshes
  44068. */
  44069. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44070. /**
  44071. * Rebuilds the elements related to this component in case of
  44072. * context lost for instance.
  44073. */
  44074. rebuild(): void;
  44075. /**
  44076. * Disposes the component and the associated ressources.
  44077. */
  44078. dispose(): void;
  44079. }
  44080. }
  44081. declare module "babylonjs/Culling/Octrees/index" {
  44082. export * from "babylonjs/Culling/Octrees/octree";
  44083. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44084. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44085. }
  44086. declare module "babylonjs/Culling/index" {
  44087. export * from "babylonjs/Culling/boundingBox";
  44088. export * from "babylonjs/Culling/boundingInfo";
  44089. export * from "babylonjs/Culling/boundingSphere";
  44090. export * from "babylonjs/Culling/Octrees/index";
  44091. export * from "babylonjs/Culling/ray";
  44092. }
  44093. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44094. import { IDisposable, Scene } from "babylonjs/scene";
  44095. import { Nullable } from "babylonjs/types";
  44096. import { Observable } from "babylonjs/Misc/observable";
  44097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44098. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44099. import { Camera } from "babylonjs/Cameras/camera";
  44100. /**
  44101. * Renders a layer on top of an existing scene
  44102. */
  44103. export class UtilityLayerRenderer implements IDisposable {
  44104. /** the original scene that will be rendered on top of */
  44105. originalScene: Scene;
  44106. private _pointerCaptures;
  44107. private _lastPointerEvents;
  44108. private static _DefaultUtilityLayer;
  44109. private static _DefaultKeepDepthUtilityLayer;
  44110. private _sharedGizmoLight;
  44111. private _renderCamera;
  44112. /**
  44113. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44114. * @returns the camera that is used when rendering the utility layer
  44115. */
  44116. getRenderCamera(): Nullable<Camera>;
  44117. /**
  44118. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44119. * @param cam the camera that should be used when rendering the utility layer
  44120. */
  44121. setRenderCamera(cam: Nullable<Camera>): void;
  44122. /**
  44123. * @hidden
  44124. * Light which used by gizmos to get light shading
  44125. */
  44126. _getSharedGizmoLight(): HemisphericLight;
  44127. /**
  44128. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44129. */
  44130. pickUtilitySceneFirst: boolean;
  44131. /**
  44132. * 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)
  44133. */
  44134. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44135. /**
  44136. * 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)
  44137. */
  44138. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44139. /**
  44140. * The scene that is rendered on top of the original scene
  44141. */
  44142. utilityLayerScene: Scene;
  44143. /**
  44144. * If the utility layer should automatically be rendered on top of existing scene
  44145. */
  44146. shouldRender: boolean;
  44147. /**
  44148. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44149. */
  44150. onlyCheckPointerDownEvents: boolean;
  44151. /**
  44152. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44153. */
  44154. processAllEvents: boolean;
  44155. /**
  44156. * Observable raised when the pointer move from the utility layer scene to the main scene
  44157. */
  44158. onPointerOutObservable: Observable<number>;
  44159. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44160. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44161. private _afterRenderObserver;
  44162. private _sceneDisposeObserver;
  44163. private _originalPointerObserver;
  44164. /**
  44165. * Instantiates a UtilityLayerRenderer
  44166. * @param originalScene the original scene that will be rendered on top of
  44167. * @param handleEvents boolean indicating if the utility layer should handle events
  44168. */
  44169. constructor(
  44170. /** the original scene that will be rendered on top of */
  44171. originalScene: Scene, handleEvents?: boolean);
  44172. private _notifyObservers;
  44173. /**
  44174. * Renders the utility layers scene on top of the original scene
  44175. */
  44176. render(): void;
  44177. /**
  44178. * Disposes of the renderer
  44179. */
  44180. dispose(): void;
  44181. private _updateCamera;
  44182. }
  44183. }
  44184. declare module "babylonjs/Gizmos/gizmo" {
  44185. import { Nullable } from "babylonjs/types";
  44186. import { IDisposable } from "babylonjs/scene";
  44187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44188. import { Mesh } from "babylonjs/Meshes/mesh";
  44189. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44190. /**
  44191. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44192. */
  44193. export class Gizmo implements IDisposable {
  44194. /** The utility layer the gizmo will be added to */
  44195. gizmoLayer: UtilityLayerRenderer;
  44196. /**
  44197. * The root mesh of the gizmo
  44198. */
  44199. _rootMesh: Mesh;
  44200. private _attachedMesh;
  44201. /**
  44202. * Ratio for the scale of the gizmo (Default: 1)
  44203. */
  44204. scaleRatio: number;
  44205. /**
  44206. * If a custom mesh has been set (Default: false)
  44207. */
  44208. protected _customMeshSet: boolean;
  44209. /**
  44210. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44211. * * When set, interactions will be enabled
  44212. */
  44213. attachedMesh: Nullable<AbstractMesh>;
  44214. /**
  44215. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44216. * @param mesh The mesh to replace the default mesh of the gizmo
  44217. */
  44218. setCustomMesh(mesh: Mesh): void;
  44219. /**
  44220. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44221. */
  44222. updateGizmoRotationToMatchAttachedMesh: boolean;
  44223. /**
  44224. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44225. */
  44226. updateGizmoPositionToMatchAttachedMesh: boolean;
  44227. /**
  44228. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44229. */
  44230. updateScale: boolean;
  44231. protected _interactionsEnabled: boolean;
  44232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44233. private _beforeRenderObserver;
  44234. private _tempVector;
  44235. /**
  44236. * Creates a gizmo
  44237. * @param gizmoLayer The utility layer the gizmo will be added to
  44238. */
  44239. constructor(
  44240. /** The utility layer the gizmo will be added to */
  44241. gizmoLayer?: UtilityLayerRenderer);
  44242. /**
  44243. * Updates the gizmo to match the attached mesh's position/rotation
  44244. */
  44245. protected _update(): void;
  44246. /**
  44247. * Disposes of the gizmo
  44248. */
  44249. dispose(): void;
  44250. }
  44251. }
  44252. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44253. import { Observable } from "babylonjs/Misc/observable";
  44254. import { Nullable } from "babylonjs/types";
  44255. import { Vector3 } from "babylonjs/Maths/math.vector";
  44256. import { Color3 } from "babylonjs/Maths/math.color";
  44257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44259. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44260. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44261. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44262. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44263. import { Scene } from "babylonjs/scene";
  44264. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44265. /**
  44266. * Single plane drag gizmo
  44267. */
  44268. export class PlaneDragGizmo extends Gizmo {
  44269. /**
  44270. * Drag behavior responsible for the gizmos dragging interactions
  44271. */
  44272. dragBehavior: PointerDragBehavior;
  44273. private _pointerObserver;
  44274. /**
  44275. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44276. */
  44277. snapDistance: number;
  44278. /**
  44279. * Event that fires each time the gizmo snaps to a new location.
  44280. * * snapDistance is the the change in distance
  44281. */
  44282. onSnapObservable: Observable<{
  44283. snapDistance: number;
  44284. }>;
  44285. private _plane;
  44286. private _coloredMaterial;
  44287. private _hoverMaterial;
  44288. private _isEnabled;
  44289. private _parent;
  44290. /** @hidden */
  44291. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44292. /** @hidden */
  44293. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44294. /**
  44295. * Creates a PlaneDragGizmo
  44296. * @param gizmoLayer The utility layer the gizmo will be added to
  44297. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44298. * @param color The color of the gizmo
  44299. */
  44300. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44301. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44302. /**
  44303. * If the gizmo is enabled
  44304. */
  44305. isEnabled: boolean;
  44306. /**
  44307. * Disposes of the gizmo
  44308. */
  44309. dispose(): void;
  44310. }
  44311. }
  44312. declare module "babylonjs/Gizmos/positionGizmo" {
  44313. import { Observable } from "babylonjs/Misc/observable";
  44314. import { Nullable } from "babylonjs/types";
  44315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44316. import { Mesh } from "babylonjs/Meshes/mesh";
  44317. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44318. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44319. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44321. /**
  44322. * Gizmo that enables dragging a mesh along 3 axis
  44323. */
  44324. export class PositionGizmo extends Gizmo {
  44325. /**
  44326. * Internal gizmo used for interactions on the x axis
  44327. */
  44328. xGizmo: AxisDragGizmo;
  44329. /**
  44330. * Internal gizmo used for interactions on the y axis
  44331. */
  44332. yGizmo: AxisDragGizmo;
  44333. /**
  44334. * Internal gizmo used for interactions on the z axis
  44335. */
  44336. zGizmo: AxisDragGizmo;
  44337. /**
  44338. * Internal gizmo used for interactions on the yz plane
  44339. */
  44340. xPlaneGizmo: PlaneDragGizmo;
  44341. /**
  44342. * Internal gizmo used for interactions on the xz plane
  44343. */
  44344. yPlaneGizmo: PlaneDragGizmo;
  44345. /**
  44346. * Internal gizmo used for interactions on the xy plane
  44347. */
  44348. zPlaneGizmo: PlaneDragGizmo;
  44349. /**
  44350. * private variables
  44351. */
  44352. private _meshAttached;
  44353. private _updateGizmoRotationToMatchAttachedMesh;
  44354. private _snapDistance;
  44355. private _scaleRatio;
  44356. /** Fires an event when any of it's sub gizmos are dragged */
  44357. onDragStartObservable: Observable<unknown>;
  44358. /** Fires an event when any of it's sub gizmos are released from dragging */
  44359. onDragEndObservable: Observable<unknown>;
  44360. /**
  44361. * If set to true, planar drag is enabled
  44362. */
  44363. private _planarGizmoEnabled;
  44364. attachedMesh: Nullable<AbstractMesh>;
  44365. /**
  44366. * Creates a PositionGizmo
  44367. * @param gizmoLayer The utility layer the gizmo will be added to
  44368. */
  44369. constructor(gizmoLayer?: UtilityLayerRenderer);
  44370. /**
  44371. * If the planar drag gizmo is enabled
  44372. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44373. */
  44374. planarGizmoEnabled: boolean;
  44375. updateGizmoRotationToMatchAttachedMesh: boolean;
  44376. /**
  44377. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44378. */
  44379. snapDistance: number;
  44380. /**
  44381. * Ratio for the scale of the gizmo (Default: 1)
  44382. */
  44383. scaleRatio: number;
  44384. /**
  44385. * Disposes of the gizmo
  44386. */
  44387. dispose(): void;
  44388. /**
  44389. * CustomMeshes are not supported by this gizmo
  44390. * @param mesh The mesh to replace the default mesh of the gizmo
  44391. */
  44392. setCustomMesh(mesh: Mesh): void;
  44393. }
  44394. }
  44395. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44396. import { Observable } from "babylonjs/Misc/observable";
  44397. import { Nullable } from "babylonjs/types";
  44398. import { Vector3 } from "babylonjs/Maths/math.vector";
  44399. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44401. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44402. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44403. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44404. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44405. import { Scene } from "babylonjs/scene";
  44406. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44407. import { Color3 } from "babylonjs/Maths/math.color";
  44408. /**
  44409. * Single axis drag gizmo
  44410. */
  44411. export class AxisDragGizmo extends Gizmo {
  44412. /**
  44413. * Drag behavior responsible for the gizmos dragging interactions
  44414. */
  44415. dragBehavior: PointerDragBehavior;
  44416. private _pointerObserver;
  44417. /**
  44418. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44419. */
  44420. snapDistance: number;
  44421. /**
  44422. * Event that fires each time the gizmo snaps to a new location.
  44423. * * snapDistance is the the change in distance
  44424. */
  44425. onSnapObservable: Observable<{
  44426. snapDistance: number;
  44427. }>;
  44428. private _isEnabled;
  44429. private _parent;
  44430. private _arrow;
  44431. private _coloredMaterial;
  44432. private _hoverMaterial;
  44433. /** @hidden */
  44434. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44435. /** @hidden */
  44436. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44437. /**
  44438. * Creates an AxisDragGizmo
  44439. * @param gizmoLayer The utility layer the gizmo will be added to
  44440. * @param dragAxis The axis which the gizmo will be able to drag on
  44441. * @param color The color of the gizmo
  44442. */
  44443. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44444. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44445. /**
  44446. * If the gizmo is enabled
  44447. */
  44448. isEnabled: boolean;
  44449. /**
  44450. * Disposes of the gizmo
  44451. */
  44452. dispose(): void;
  44453. }
  44454. }
  44455. declare module "babylonjs/Debug/axesViewer" {
  44456. import { Vector3 } from "babylonjs/Maths/math.vector";
  44457. import { Nullable } from "babylonjs/types";
  44458. import { Scene } from "babylonjs/scene";
  44459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44460. /**
  44461. * The Axes viewer will show 3 axes in a specific point in space
  44462. */
  44463. export class AxesViewer {
  44464. private _xAxis;
  44465. private _yAxis;
  44466. private _zAxis;
  44467. private _scaleLinesFactor;
  44468. private _instanced;
  44469. /**
  44470. * Gets the hosting scene
  44471. */
  44472. scene: Scene;
  44473. /**
  44474. * Gets or sets a number used to scale line length
  44475. */
  44476. scaleLines: number;
  44477. /** Gets the node hierarchy used to render x-axis */
  44478. readonly xAxis: TransformNode;
  44479. /** Gets the node hierarchy used to render y-axis */
  44480. readonly yAxis: TransformNode;
  44481. /** Gets the node hierarchy used to render z-axis */
  44482. readonly zAxis: TransformNode;
  44483. /**
  44484. * Creates a new AxesViewer
  44485. * @param scene defines the hosting scene
  44486. * @param scaleLines defines a number used to scale line length (1 by default)
  44487. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44488. * @param xAxis defines the node hierarchy used to render the x-axis
  44489. * @param yAxis defines the node hierarchy used to render the y-axis
  44490. * @param zAxis defines the node hierarchy used to render the z-axis
  44491. */
  44492. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44493. /**
  44494. * Force the viewer to update
  44495. * @param position defines the position of the viewer
  44496. * @param xaxis defines the x axis of the viewer
  44497. * @param yaxis defines the y axis of the viewer
  44498. * @param zaxis defines the z axis of the viewer
  44499. */
  44500. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44501. /**
  44502. * Creates an instance of this axes viewer.
  44503. * @returns a new axes viewer with instanced meshes
  44504. */
  44505. createInstance(): AxesViewer;
  44506. /** Releases resources */
  44507. dispose(): void;
  44508. private static _SetRenderingGroupId;
  44509. }
  44510. }
  44511. declare module "babylonjs/Debug/boneAxesViewer" {
  44512. import { Nullable } from "babylonjs/types";
  44513. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44514. import { Vector3 } from "babylonjs/Maths/math.vector";
  44515. import { Mesh } from "babylonjs/Meshes/mesh";
  44516. import { Bone } from "babylonjs/Bones/bone";
  44517. import { Scene } from "babylonjs/scene";
  44518. /**
  44519. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44520. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44521. */
  44522. export class BoneAxesViewer extends AxesViewer {
  44523. /**
  44524. * Gets or sets the target mesh where to display the axes viewer
  44525. */
  44526. mesh: Nullable<Mesh>;
  44527. /**
  44528. * Gets or sets the target bone where to display the axes viewer
  44529. */
  44530. bone: Nullable<Bone>;
  44531. /** Gets current position */
  44532. pos: Vector3;
  44533. /** Gets direction of X axis */
  44534. xaxis: Vector3;
  44535. /** Gets direction of Y axis */
  44536. yaxis: Vector3;
  44537. /** Gets direction of Z axis */
  44538. zaxis: Vector3;
  44539. /**
  44540. * Creates a new BoneAxesViewer
  44541. * @param scene defines the hosting scene
  44542. * @param bone defines the target bone
  44543. * @param mesh defines the target mesh
  44544. * @param scaleLines defines a scaling factor for line length (1 by default)
  44545. */
  44546. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44547. /**
  44548. * Force the viewer to update
  44549. */
  44550. update(): void;
  44551. /** Releases resources */
  44552. dispose(): void;
  44553. }
  44554. }
  44555. declare module "babylonjs/Debug/debugLayer" {
  44556. import { Scene } from "babylonjs/scene";
  44557. /**
  44558. * Interface used to define scene explorer extensibility option
  44559. */
  44560. export interface IExplorerExtensibilityOption {
  44561. /**
  44562. * Define the option label
  44563. */
  44564. label: string;
  44565. /**
  44566. * Defines the action to execute on click
  44567. */
  44568. action: (entity: any) => void;
  44569. }
  44570. /**
  44571. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44572. */
  44573. export interface IExplorerExtensibilityGroup {
  44574. /**
  44575. * Defines a predicate to test if a given type mut be extended
  44576. */
  44577. predicate: (entity: any) => boolean;
  44578. /**
  44579. * Gets the list of options added to a type
  44580. */
  44581. entries: IExplorerExtensibilityOption[];
  44582. }
  44583. /**
  44584. * Interface used to define the options to use to create the Inspector
  44585. */
  44586. export interface IInspectorOptions {
  44587. /**
  44588. * Display in overlay mode (default: false)
  44589. */
  44590. overlay?: boolean;
  44591. /**
  44592. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44593. */
  44594. globalRoot?: HTMLElement;
  44595. /**
  44596. * Display the Scene explorer
  44597. */
  44598. showExplorer?: boolean;
  44599. /**
  44600. * Display the property inspector
  44601. */
  44602. showInspector?: boolean;
  44603. /**
  44604. * Display in embed mode (both panes on the right)
  44605. */
  44606. embedMode?: boolean;
  44607. /**
  44608. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44609. */
  44610. handleResize?: boolean;
  44611. /**
  44612. * Allow the panes to popup (default: true)
  44613. */
  44614. enablePopup?: boolean;
  44615. /**
  44616. * Allow the panes to be closed by users (default: true)
  44617. */
  44618. enableClose?: boolean;
  44619. /**
  44620. * Optional list of extensibility entries
  44621. */
  44622. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44623. /**
  44624. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44625. */
  44626. inspectorURL?: string;
  44627. }
  44628. module "babylonjs/scene" {
  44629. interface Scene {
  44630. /**
  44631. * @hidden
  44632. * Backing field
  44633. */
  44634. _debugLayer: DebugLayer;
  44635. /**
  44636. * Gets the debug layer (aka Inspector) associated with the scene
  44637. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44638. */
  44639. debugLayer: DebugLayer;
  44640. }
  44641. }
  44642. /**
  44643. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44644. * what is happening in your scene
  44645. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44646. */
  44647. export class DebugLayer {
  44648. /**
  44649. * Define the url to get the inspector script from.
  44650. * By default it uses the babylonjs CDN.
  44651. * @ignoreNaming
  44652. */
  44653. static InspectorURL: string;
  44654. private _scene;
  44655. private BJSINSPECTOR;
  44656. private _onPropertyChangedObservable?;
  44657. /**
  44658. * Observable triggered when a property is changed through the inspector.
  44659. */
  44660. readonly onPropertyChangedObservable: any;
  44661. /**
  44662. * Instantiates a new debug layer.
  44663. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44664. * what is happening in your scene
  44665. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44666. * @param scene Defines the scene to inspect
  44667. */
  44668. constructor(scene: Scene);
  44669. /** Creates the inspector window. */
  44670. private _createInspector;
  44671. /**
  44672. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44673. * @param entity defines the entity to select
  44674. * @param lineContainerTitle defines the specific block to highlight
  44675. */
  44676. select(entity: any, lineContainerTitle?: string): void;
  44677. /** Get the inspector from bundle or global */
  44678. private _getGlobalInspector;
  44679. /**
  44680. * Get if the inspector is visible or not.
  44681. * @returns true if visible otherwise, false
  44682. */
  44683. isVisible(): boolean;
  44684. /**
  44685. * Hide the inspector and close its window.
  44686. */
  44687. hide(): void;
  44688. /**
  44689. * Launch the debugLayer.
  44690. * @param config Define the configuration of the inspector
  44691. * @return a promise fulfilled when the debug layer is visible
  44692. */
  44693. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44694. }
  44695. }
  44696. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44697. import { Nullable } from "babylonjs/types";
  44698. import { Scene } from "babylonjs/scene";
  44699. import { Vector4 } from "babylonjs/Maths/math.vector";
  44700. import { Color4 } from "babylonjs/Maths/math.color";
  44701. import { Mesh } from "babylonjs/Meshes/mesh";
  44702. /**
  44703. * Class containing static functions to help procedurally build meshes
  44704. */
  44705. export class BoxBuilder {
  44706. /**
  44707. * Creates a box mesh
  44708. * * The parameter `size` sets the size (float) of each box side (default 1)
  44709. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44710. * * 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)
  44711. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44715. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44716. * @param name defines the name of the mesh
  44717. * @param options defines the options used to create the mesh
  44718. * @param scene defines the hosting scene
  44719. * @returns the box mesh
  44720. */
  44721. static CreateBox(name: string, options: {
  44722. size?: number;
  44723. width?: number;
  44724. height?: number;
  44725. depth?: number;
  44726. faceUV?: Vector4[];
  44727. faceColors?: Color4[];
  44728. sideOrientation?: number;
  44729. frontUVs?: Vector4;
  44730. backUVs?: Vector4;
  44731. wrap?: boolean;
  44732. topBaseAt?: number;
  44733. bottomBaseAt?: number;
  44734. updatable?: boolean;
  44735. }, scene?: Nullable<Scene>): Mesh;
  44736. }
  44737. }
  44738. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44739. import { Vector4 } from "babylonjs/Maths/math.vector";
  44740. import { Mesh } from "babylonjs/Meshes/mesh";
  44741. import { Scene } from "babylonjs/scene";
  44742. import { Nullable } from "babylonjs/types";
  44743. /**
  44744. * Class containing static functions to help procedurally build meshes
  44745. */
  44746. export class SphereBuilder {
  44747. /**
  44748. * Creates a sphere mesh
  44749. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44750. * * 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`)
  44751. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44752. * * 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
  44753. * * 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)
  44754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44757. * @param name defines the name of the mesh
  44758. * @param options defines the options used to create the mesh
  44759. * @param scene defines the hosting scene
  44760. * @returns the sphere mesh
  44761. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44762. */
  44763. static CreateSphere(name: string, options: {
  44764. segments?: number;
  44765. diameter?: number;
  44766. diameterX?: number;
  44767. diameterY?: number;
  44768. diameterZ?: number;
  44769. arc?: number;
  44770. slice?: number;
  44771. sideOrientation?: number;
  44772. frontUVs?: Vector4;
  44773. backUVs?: Vector4;
  44774. updatable?: boolean;
  44775. }, scene?: Nullable<Scene>): Mesh;
  44776. }
  44777. }
  44778. declare module "babylonjs/Debug/physicsViewer" {
  44779. import { Nullable } from "babylonjs/types";
  44780. import { Scene } from "babylonjs/scene";
  44781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44782. import { Mesh } from "babylonjs/Meshes/mesh";
  44783. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44784. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44785. /**
  44786. * Used to show the physics impostor around the specific mesh
  44787. */
  44788. export class PhysicsViewer {
  44789. /** @hidden */
  44790. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44791. /** @hidden */
  44792. protected _meshes: Array<Nullable<AbstractMesh>>;
  44793. /** @hidden */
  44794. protected _scene: Nullable<Scene>;
  44795. /** @hidden */
  44796. protected _numMeshes: number;
  44797. /** @hidden */
  44798. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44799. private _renderFunction;
  44800. private _utilityLayer;
  44801. private _debugBoxMesh;
  44802. private _debugSphereMesh;
  44803. private _debugCylinderMesh;
  44804. private _debugMaterial;
  44805. private _debugMeshMeshes;
  44806. /**
  44807. * Creates a new PhysicsViewer
  44808. * @param scene defines the hosting scene
  44809. */
  44810. constructor(scene: Scene);
  44811. /** @hidden */
  44812. protected _updateDebugMeshes(): void;
  44813. /**
  44814. * Renders a specified physic impostor
  44815. * @param impostor defines the impostor to render
  44816. * @param targetMesh defines the mesh represented by the impostor
  44817. * @returns the new debug mesh used to render the impostor
  44818. */
  44819. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44820. /**
  44821. * Hides a specified physic impostor
  44822. * @param impostor defines the impostor to hide
  44823. */
  44824. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44825. private _getDebugMaterial;
  44826. private _getDebugBoxMesh;
  44827. private _getDebugSphereMesh;
  44828. private _getDebugCylinderMesh;
  44829. private _getDebugMeshMesh;
  44830. private _getDebugMesh;
  44831. /** Releases all resources */
  44832. dispose(): void;
  44833. }
  44834. }
  44835. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44836. import { Vector3 } from "babylonjs/Maths/math.vector";
  44837. import { Color4 } from "babylonjs/Maths/math.color";
  44838. import { Nullable } from "babylonjs/types";
  44839. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44840. import { Scene } from "babylonjs/scene";
  44841. /**
  44842. * Class containing static functions to help procedurally build meshes
  44843. */
  44844. export class LinesBuilder {
  44845. /**
  44846. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44847. * * 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
  44848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44849. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44850. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44851. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44852. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44853. * * 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
  44854. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44857. * @param name defines the name of the new line system
  44858. * @param options defines the options used to create the line system
  44859. * @param scene defines the hosting scene
  44860. * @returns a new line system mesh
  44861. */
  44862. static CreateLineSystem(name: string, options: {
  44863. lines: Vector3[][];
  44864. updatable?: boolean;
  44865. instance?: Nullable<LinesMesh>;
  44866. colors?: Nullable<Color4[][]>;
  44867. useVertexAlpha?: boolean;
  44868. }, scene: Nullable<Scene>): LinesMesh;
  44869. /**
  44870. * Creates a line mesh
  44871. * 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
  44872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44873. * * The parameter `points` is an array successive Vector3
  44874. * * 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
  44875. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44877. * * When updating an instance, remember that only point positions can change, not the number of points
  44878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44880. * @param name defines the name of the new line system
  44881. * @param options defines the options used to create the line system
  44882. * @param scene defines the hosting scene
  44883. * @returns a new line mesh
  44884. */
  44885. static CreateLines(name: string, options: {
  44886. points: Vector3[];
  44887. updatable?: boolean;
  44888. instance?: Nullable<LinesMesh>;
  44889. colors?: Color4[];
  44890. useVertexAlpha?: boolean;
  44891. }, scene?: Nullable<Scene>): LinesMesh;
  44892. /**
  44893. * Creates a dashed line mesh
  44894. * * 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
  44895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44896. * * The parameter `points` is an array successive Vector3
  44897. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44898. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44899. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44900. * * 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
  44901. * * When updating an instance, remember that only point positions can change, not the number of points
  44902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44903. * @param name defines the name of the mesh
  44904. * @param options defines the options used to create the mesh
  44905. * @param scene defines the hosting scene
  44906. * @returns the dashed line mesh
  44907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44908. */
  44909. static CreateDashedLines(name: string, options: {
  44910. points: Vector3[];
  44911. dashSize?: number;
  44912. gapSize?: number;
  44913. dashNb?: number;
  44914. updatable?: boolean;
  44915. instance?: LinesMesh;
  44916. }, scene?: Nullable<Scene>): LinesMesh;
  44917. }
  44918. }
  44919. declare module "babylonjs/Debug/rayHelper" {
  44920. import { Nullable } from "babylonjs/types";
  44921. import { Ray } from "babylonjs/Culling/ray";
  44922. import { Vector3 } from "babylonjs/Maths/math.vector";
  44923. import { Color3 } from "babylonjs/Maths/math.color";
  44924. import { Scene } from "babylonjs/scene";
  44925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44926. import "babylonjs/Meshes/Builders/linesBuilder";
  44927. /**
  44928. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44929. * in order to better appreciate the issue one might have.
  44930. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44931. */
  44932. export class RayHelper {
  44933. /**
  44934. * Defines the ray we are currently tryin to visualize.
  44935. */
  44936. ray: Nullable<Ray>;
  44937. private _renderPoints;
  44938. private _renderLine;
  44939. private _renderFunction;
  44940. private _scene;
  44941. private _updateToMeshFunction;
  44942. private _attachedToMesh;
  44943. private _meshSpaceDirection;
  44944. private _meshSpaceOrigin;
  44945. /**
  44946. * Helper function to create a colored helper in a scene in one line.
  44947. * @param ray Defines the ray we are currently tryin to visualize
  44948. * @param scene Defines the scene the ray is used in
  44949. * @param color Defines the color we want to see the ray in
  44950. * @returns The newly created ray helper.
  44951. */
  44952. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44953. /**
  44954. * Instantiate a new ray helper.
  44955. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44956. * in order to better appreciate the issue one might have.
  44957. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44958. * @param ray Defines the ray we are currently tryin to visualize
  44959. */
  44960. constructor(ray: Ray);
  44961. /**
  44962. * Shows the ray we are willing to debug.
  44963. * @param scene Defines the scene the ray needs to be rendered in
  44964. * @param color Defines the color the ray needs to be rendered in
  44965. */
  44966. show(scene: Scene, color?: Color3): void;
  44967. /**
  44968. * Hides the ray we are debugging.
  44969. */
  44970. hide(): void;
  44971. private _render;
  44972. /**
  44973. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44974. * @param mesh Defines the mesh we want the helper attached to
  44975. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44976. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44977. * @param length Defines the length of the ray
  44978. */
  44979. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44980. /**
  44981. * Detach the ray helper from the mesh it has previously been attached to.
  44982. */
  44983. detachFromMesh(): void;
  44984. private _updateToMesh;
  44985. /**
  44986. * Dispose the helper and release its associated resources.
  44987. */
  44988. dispose(): void;
  44989. }
  44990. }
  44991. declare module "babylonjs/Debug/skeletonViewer" {
  44992. import { Color3 } from "babylonjs/Maths/math.color";
  44993. import { Scene } from "babylonjs/scene";
  44994. import { Nullable } from "babylonjs/types";
  44995. import { Skeleton } from "babylonjs/Bones/skeleton";
  44996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44997. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44998. /**
  44999. * Class used to render a debug view of a given skeleton
  45000. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45001. */
  45002. export class SkeletonViewer {
  45003. /** defines the skeleton to render */
  45004. skeleton: Skeleton;
  45005. /** defines the mesh attached to the skeleton */
  45006. mesh: AbstractMesh;
  45007. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45008. autoUpdateBonesMatrices: boolean;
  45009. /** defines the rendering group id to use with the viewer */
  45010. renderingGroupId: number;
  45011. /** Gets or sets the color used to render the skeleton */
  45012. color: Color3;
  45013. private _scene;
  45014. private _debugLines;
  45015. private _debugMesh;
  45016. private _isEnabled;
  45017. private _renderFunction;
  45018. private _utilityLayer;
  45019. /**
  45020. * Returns the mesh used to render the bones
  45021. */
  45022. readonly debugMesh: Nullable<LinesMesh>;
  45023. /**
  45024. * Creates a new SkeletonViewer
  45025. * @param skeleton defines the skeleton to render
  45026. * @param mesh defines the mesh attached to the skeleton
  45027. * @param scene defines the hosting scene
  45028. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45029. * @param renderingGroupId defines the rendering group id to use with the viewer
  45030. */
  45031. constructor(
  45032. /** defines the skeleton to render */
  45033. skeleton: Skeleton,
  45034. /** defines the mesh attached to the skeleton */
  45035. mesh: AbstractMesh, scene: Scene,
  45036. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45037. autoUpdateBonesMatrices?: boolean,
  45038. /** defines the rendering group id to use with the viewer */
  45039. renderingGroupId?: number);
  45040. /** Gets or sets a boolean indicating if the viewer is enabled */
  45041. isEnabled: boolean;
  45042. private _getBonePosition;
  45043. private _getLinesForBonesWithLength;
  45044. private _getLinesForBonesNoLength;
  45045. /** Update the viewer to sync with current skeleton state */
  45046. update(): void;
  45047. /** Release associated resources */
  45048. dispose(): void;
  45049. }
  45050. }
  45051. declare module "babylonjs/Debug/index" {
  45052. export * from "babylonjs/Debug/axesViewer";
  45053. export * from "babylonjs/Debug/boneAxesViewer";
  45054. export * from "babylonjs/Debug/debugLayer";
  45055. export * from "babylonjs/Debug/physicsViewer";
  45056. export * from "babylonjs/Debug/rayHelper";
  45057. export * from "babylonjs/Debug/skeletonViewer";
  45058. }
  45059. declare module "babylonjs/Engines/nullEngine" {
  45060. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45061. import { Scene } from "babylonjs/scene";
  45062. import { Engine } from "babylonjs/Engines/engine";
  45063. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45064. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45066. import { Effect } from "babylonjs/Materials/effect";
  45067. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45068. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45069. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45070. /**
  45071. * Options to create the null engine
  45072. */
  45073. export class NullEngineOptions {
  45074. /**
  45075. * Render width (Default: 512)
  45076. */
  45077. renderWidth: number;
  45078. /**
  45079. * Render height (Default: 256)
  45080. */
  45081. renderHeight: number;
  45082. /**
  45083. * Texture size (Default: 512)
  45084. */
  45085. textureSize: number;
  45086. /**
  45087. * If delta time between frames should be constant
  45088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45089. */
  45090. deterministicLockstep: boolean;
  45091. /**
  45092. * Maximum about of steps between frames (Default: 4)
  45093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45094. */
  45095. lockstepMaxSteps: number;
  45096. }
  45097. /**
  45098. * The null engine class provides support for headless version of babylon.js.
  45099. * This can be used in server side scenario or for testing purposes
  45100. */
  45101. export class NullEngine extends Engine {
  45102. private _options;
  45103. /**
  45104. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45105. */
  45106. isDeterministicLockStep(): boolean;
  45107. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45108. getLockstepMaxSteps(): number;
  45109. /**
  45110. * Sets hardware scaling, used to save performance if needed
  45111. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45112. */
  45113. getHardwareScalingLevel(): number;
  45114. constructor(options?: NullEngineOptions);
  45115. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45116. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45117. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45118. getRenderWidth(useScreen?: boolean): number;
  45119. getRenderHeight(useScreen?: boolean): number;
  45120. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45121. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45122. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45124. bindSamplers(effect: Effect): void;
  45125. enableEffect(effect: Effect): void;
  45126. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45127. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45128. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45129. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45130. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45131. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45132. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45133. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45134. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45135. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45136. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45137. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45138. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45139. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45140. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45141. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45142. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45143. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45144. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45145. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45146. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45147. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45148. bindBuffers(vertexBuffers: {
  45149. [key: string]: VertexBuffer;
  45150. }, indexBuffer: DataBuffer, effect: Effect): void;
  45151. wipeCaches(bruteForce?: boolean): void;
  45152. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45153. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45154. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45155. /** @hidden */
  45156. _createTexture(): WebGLTexture;
  45157. /** @hidden */
  45158. _releaseTexture(texture: InternalTexture): void;
  45159. 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;
  45160. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45161. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45162. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45163. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45164. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45165. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45166. areAllEffectsReady(): boolean;
  45167. /**
  45168. * @hidden
  45169. * Get the current error code of the webGL context
  45170. * @returns the error code
  45171. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45172. */
  45173. getError(): number;
  45174. /** @hidden */
  45175. _getUnpackAlignement(): number;
  45176. /** @hidden */
  45177. _unpackFlipY(value: boolean): void;
  45178. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45179. /**
  45180. * Updates a dynamic vertex buffer.
  45181. * @param vertexBuffer the vertex buffer to update
  45182. * @param data the data used to update the vertex buffer
  45183. * @param byteOffset the byte offset of the data (optional)
  45184. * @param byteLength the byte length of the data (optional)
  45185. */
  45186. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45187. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45188. /** @hidden */
  45189. _bindTexture(channel: number, texture: InternalTexture): void;
  45190. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45191. releaseEffects(): void;
  45192. displayLoadingUI(): void;
  45193. hideLoadingUI(): void;
  45194. /** @hidden */
  45195. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45196. /** @hidden */
  45197. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45198. /** @hidden */
  45199. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45200. /** @hidden */
  45201. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45202. }
  45203. }
  45204. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45205. import { Nullable, int } from "babylonjs/types";
  45206. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45207. /** @hidden */
  45208. export class _OcclusionDataStorage {
  45209. /** @hidden */
  45210. occlusionInternalRetryCounter: number;
  45211. /** @hidden */
  45212. isOcclusionQueryInProgress: boolean;
  45213. /** @hidden */
  45214. isOccluded: boolean;
  45215. /** @hidden */
  45216. occlusionRetryCount: number;
  45217. /** @hidden */
  45218. occlusionType: number;
  45219. /** @hidden */
  45220. occlusionQueryAlgorithmType: number;
  45221. }
  45222. module "babylonjs/Engines/engine" {
  45223. interface Engine {
  45224. /**
  45225. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45226. * @return the new query
  45227. */
  45228. createQuery(): WebGLQuery;
  45229. /**
  45230. * Delete and release a webGL query
  45231. * @param query defines the query to delete
  45232. * @return the current engine
  45233. */
  45234. deleteQuery(query: WebGLQuery): Engine;
  45235. /**
  45236. * Check if a given query has resolved and got its value
  45237. * @param query defines the query to check
  45238. * @returns true if the query got its value
  45239. */
  45240. isQueryResultAvailable(query: WebGLQuery): boolean;
  45241. /**
  45242. * Gets the value of a given query
  45243. * @param query defines the query to check
  45244. * @returns the value of the query
  45245. */
  45246. getQueryResult(query: WebGLQuery): number;
  45247. /**
  45248. * Initiates an occlusion query
  45249. * @param algorithmType defines the algorithm to use
  45250. * @param query defines the query to use
  45251. * @returns the current engine
  45252. * @see http://doc.babylonjs.com/features/occlusionquery
  45253. */
  45254. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45255. /**
  45256. * Ends an occlusion query
  45257. * @see http://doc.babylonjs.com/features/occlusionquery
  45258. * @param algorithmType defines the algorithm to use
  45259. * @returns the current engine
  45260. */
  45261. endOcclusionQuery(algorithmType: number): Engine;
  45262. /**
  45263. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45264. * Please note that only one query can be issued at a time
  45265. * @returns a time token used to track the time span
  45266. */
  45267. startTimeQuery(): Nullable<_TimeToken>;
  45268. /**
  45269. * Ends a time query
  45270. * @param token defines the token used to measure the time span
  45271. * @returns the time spent (in ns)
  45272. */
  45273. endTimeQuery(token: _TimeToken): int;
  45274. /** @hidden */
  45275. _currentNonTimestampToken: Nullable<_TimeToken>;
  45276. /** @hidden */
  45277. _createTimeQuery(): WebGLQuery;
  45278. /** @hidden */
  45279. _deleteTimeQuery(query: WebGLQuery): void;
  45280. /** @hidden */
  45281. _getGlAlgorithmType(algorithmType: number): number;
  45282. /** @hidden */
  45283. _getTimeQueryResult(query: WebGLQuery): any;
  45284. /** @hidden */
  45285. _getTimeQueryAvailability(query: WebGLQuery): any;
  45286. }
  45287. }
  45288. module "babylonjs/Meshes/abstractMesh" {
  45289. interface AbstractMesh {
  45290. /**
  45291. * Backing filed
  45292. * @hidden
  45293. */
  45294. __occlusionDataStorage: _OcclusionDataStorage;
  45295. /**
  45296. * Access property
  45297. * @hidden
  45298. */
  45299. _occlusionDataStorage: _OcclusionDataStorage;
  45300. /**
  45301. * 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.
  45302. * The default value is -1 which means don't break the query and wait till the result
  45303. * @see http://doc.babylonjs.com/features/occlusionquery
  45304. */
  45305. occlusionRetryCount: number;
  45306. /**
  45307. * 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:
  45308. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45309. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45310. * * 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.
  45311. * @see http://doc.babylonjs.com/features/occlusionquery
  45312. */
  45313. occlusionType: number;
  45314. /**
  45315. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45316. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45317. * * 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.
  45318. * @see http://doc.babylonjs.com/features/occlusionquery
  45319. */
  45320. occlusionQueryAlgorithmType: number;
  45321. /**
  45322. * 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
  45323. * @see http://doc.babylonjs.com/features/occlusionquery
  45324. */
  45325. isOccluded: boolean;
  45326. /**
  45327. * Flag to check the progress status of the query
  45328. * @see http://doc.babylonjs.com/features/occlusionquery
  45329. */
  45330. isOcclusionQueryInProgress: boolean;
  45331. }
  45332. }
  45333. }
  45334. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45335. import { Nullable } from "babylonjs/types";
  45336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45337. /** @hidden */
  45338. export var _forceTransformFeedbackToBundle: boolean;
  45339. module "babylonjs/Engines/engine" {
  45340. interface Engine {
  45341. /**
  45342. * Creates a webGL transform feedback object
  45343. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45344. * @returns the webGL transform feedback object
  45345. */
  45346. createTransformFeedback(): WebGLTransformFeedback;
  45347. /**
  45348. * Delete a webGL transform feedback object
  45349. * @param value defines the webGL transform feedback object to delete
  45350. */
  45351. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45352. /**
  45353. * Bind a webGL transform feedback object to the webgl context
  45354. * @param value defines the webGL transform feedback object to bind
  45355. */
  45356. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45357. /**
  45358. * Begins a transform feedback operation
  45359. * @param usePoints defines if points or triangles must be used
  45360. */
  45361. beginTransformFeedback(usePoints: boolean): void;
  45362. /**
  45363. * Ends a transform feedback operation
  45364. */
  45365. endTransformFeedback(): void;
  45366. /**
  45367. * Specify the varyings to use with transform feedback
  45368. * @param program defines the associated webGL program
  45369. * @param value defines the list of strings representing the varying names
  45370. */
  45371. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45372. /**
  45373. * Bind a webGL buffer for a transform feedback operation
  45374. * @param value defines the webGL buffer to bind
  45375. */
  45376. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45377. }
  45378. }
  45379. }
  45380. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45381. import { Scene } from "babylonjs/scene";
  45382. import { Engine } from "babylonjs/Engines/engine";
  45383. import { Texture } from "babylonjs/Materials/Textures/texture";
  45384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45385. import "babylonjs/Engines/Extensions/engine.multiRender";
  45386. /**
  45387. * Creation options of the multi render target texture.
  45388. */
  45389. export interface IMultiRenderTargetOptions {
  45390. /**
  45391. * Define if the texture needs to create mip maps after render.
  45392. */
  45393. generateMipMaps?: boolean;
  45394. /**
  45395. * Define the types of all the draw buffers we want to create
  45396. */
  45397. types?: number[];
  45398. /**
  45399. * Define the sampling modes of all the draw buffers we want to create
  45400. */
  45401. samplingModes?: number[];
  45402. /**
  45403. * Define if a depth buffer is required
  45404. */
  45405. generateDepthBuffer?: boolean;
  45406. /**
  45407. * Define if a stencil buffer is required
  45408. */
  45409. generateStencilBuffer?: boolean;
  45410. /**
  45411. * Define if a depth texture is required instead of a depth buffer
  45412. */
  45413. generateDepthTexture?: boolean;
  45414. /**
  45415. * Define the number of desired draw buffers
  45416. */
  45417. textureCount?: number;
  45418. /**
  45419. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45420. */
  45421. doNotChangeAspectRatio?: boolean;
  45422. /**
  45423. * Define the default type of the buffers we are creating
  45424. */
  45425. defaultType?: number;
  45426. }
  45427. /**
  45428. * A multi render target, like a render target provides the ability to render to a texture.
  45429. * Unlike the render target, it can render to several draw buffers in one draw.
  45430. * This is specially interesting in deferred rendering or for any effects requiring more than
  45431. * just one color from a single pass.
  45432. */
  45433. export class MultiRenderTarget extends RenderTargetTexture {
  45434. private _internalTextures;
  45435. private _textures;
  45436. private _multiRenderTargetOptions;
  45437. /**
  45438. * Get if draw buffers are currently supported by the used hardware and browser.
  45439. */
  45440. readonly isSupported: boolean;
  45441. /**
  45442. * Get the list of textures generated by the multi render target.
  45443. */
  45444. readonly textures: Texture[];
  45445. /**
  45446. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45447. */
  45448. readonly depthTexture: Texture;
  45449. /**
  45450. * Set the wrapping mode on U of all the textures we are rendering to.
  45451. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45452. */
  45453. wrapU: number;
  45454. /**
  45455. * Set the wrapping mode on V of all the textures we are rendering to.
  45456. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45457. */
  45458. wrapV: number;
  45459. /**
  45460. * Instantiate a new multi render target texture.
  45461. * A multi render target, like a render target provides the ability to render to a texture.
  45462. * Unlike the render target, it can render to several draw buffers in one draw.
  45463. * This is specially interesting in deferred rendering or for any effects requiring more than
  45464. * just one color from a single pass.
  45465. * @param name Define the name of the texture
  45466. * @param size Define the size of the buffers to render to
  45467. * @param count Define the number of target we are rendering into
  45468. * @param scene Define the scene the texture belongs to
  45469. * @param options Define the options used to create the multi render target
  45470. */
  45471. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45472. /** @hidden */
  45473. _rebuild(): void;
  45474. private _createInternalTextures;
  45475. private _createTextures;
  45476. /**
  45477. * Define the number of samples used if MSAA is enabled.
  45478. */
  45479. samples: number;
  45480. /**
  45481. * Resize all the textures in the multi render target.
  45482. * Be carrefull as it will recreate all the data in the new texture.
  45483. * @param size Define the new size
  45484. */
  45485. resize(size: any): void;
  45486. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45487. /**
  45488. * Dispose the render targets and their associated resources
  45489. */
  45490. dispose(): void;
  45491. /**
  45492. * Release all the underlying texture used as draw buffers.
  45493. */
  45494. releaseInternalTextures(): void;
  45495. }
  45496. }
  45497. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45499. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45500. import { Nullable } from "babylonjs/types";
  45501. module "babylonjs/Engines/engine" {
  45502. interface Engine {
  45503. /**
  45504. * Unbind a list of render target textures from the webGL context
  45505. * This is used only when drawBuffer extension or webGL2 are active
  45506. * @param textures defines the render target textures to unbind
  45507. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45508. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45509. */
  45510. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45511. /**
  45512. * Create a multi render target texture
  45513. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45514. * @param size defines the size of the texture
  45515. * @param options defines the creation options
  45516. * @returns the cube texture as an InternalTexture
  45517. */
  45518. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45519. /**
  45520. * Update the sample count for a given multiple render target texture
  45521. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45522. * @param textures defines the textures to update
  45523. * @param samples defines the sample count to set
  45524. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45525. */
  45526. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45527. }
  45528. }
  45529. }
  45530. declare module "babylonjs/Engines/Extensions/index" {
  45531. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45532. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45533. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45534. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45535. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45536. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45537. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45538. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45539. }
  45540. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45541. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45542. /** @hidden */
  45543. export var rgbdEncodePixelShader: {
  45544. name: string;
  45545. shader: string;
  45546. };
  45547. }
  45548. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45550. /** @hidden */
  45551. export var rgbdDecodePixelShader: {
  45552. name: string;
  45553. shader: string;
  45554. };
  45555. }
  45556. declare module "babylonjs/Misc/environmentTextureTools" {
  45557. import { Nullable } from "babylonjs/types";
  45558. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45560. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45561. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45562. import "babylonjs/Shaders/rgbdEncode.fragment";
  45563. import "babylonjs/Shaders/rgbdDecode.fragment";
  45564. /**
  45565. * Raw texture data and descriptor sufficient for WebGL texture upload
  45566. */
  45567. export interface EnvironmentTextureInfo {
  45568. /**
  45569. * Version of the environment map
  45570. */
  45571. version: number;
  45572. /**
  45573. * Width of image
  45574. */
  45575. width: number;
  45576. /**
  45577. * Irradiance information stored in the file.
  45578. */
  45579. irradiance: any;
  45580. /**
  45581. * Specular information stored in the file.
  45582. */
  45583. specular: any;
  45584. }
  45585. /**
  45586. * Defines One Image in the file. It requires only the position in the file
  45587. * as well as the length.
  45588. */
  45589. interface BufferImageData {
  45590. /**
  45591. * Length of the image data.
  45592. */
  45593. length: number;
  45594. /**
  45595. * Position of the data from the null terminator delimiting the end of the JSON.
  45596. */
  45597. position: number;
  45598. }
  45599. /**
  45600. * Defines the specular data enclosed in the file.
  45601. * This corresponds to the version 1 of the data.
  45602. */
  45603. export interface EnvironmentTextureSpecularInfoV1 {
  45604. /**
  45605. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45606. */
  45607. specularDataPosition?: number;
  45608. /**
  45609. * This contains all the images data needed to reconstruct the cubemap.
  45610. */
  45611. mipmaps: Array<BufferImageData>;
  45612. /**
  45613. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45614. */
  45615. lodGenerationScale: number;
  45616. }
  45617. /**
  45618. * Sets of helpers addressing the serialization and deserialization of environment texture
  45619. * stored in a BabylonJS env file.
  45620. * Those files are usually stored as .env files.
  45621. */
  45622. export class EnvironmentTextureTools {
  45623. /**
  45624. * Magic number identifying the env file.
  45625. */
  45626. private static _MagicBytes;
  45627. /**
  45628. * Gets the environment info from an env file.
  45629. * @param data The array buffer containing the .env bytes.
  45630. * @returns the environment file info (the json header) if successfully parsed.
  45631. */
  45632. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45633. /**
  45634. * Creates an environment texture from a loaded cube texture.
  45635. * @param texture defines the cube texture to convert in env file
  45636. * @return a promise containing the environment data if succesfull.
  45637. */
  45638. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45639. /**
  45640. * Creates a JSON representation of the spherical data.
  45641. * @param texture defines the texture containing the polynomials
  45642. * @return the JSON representation of the spherical info
  45643. */
  45644. private static _CreateEnvTextureIrradiance;
  45645. /**
  45646. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45647. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45648. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45649. * @return the views described by info providing access to the underlying buffer
  45650. */
  45651. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45652. /**
  45653. * Uploads the texture info contained in the env file to the GPU.
  45654. * @param texture defines the internal texture to upload to
  45655. * @param arrayBuffer defines the buffer cotaining the data to load
  45656. * @param info defines the texture info retrieved through the GetEnvInfo method
  45657. * @returns a promise
  45658. */
  45659. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45660. /**
  45661. * Uploads the levels of image data to the GPU.
  45662. * @param texture defines the internal texture to upload to
  45663. * @param imageData defines the array buffer views of image data [mipmap][face]
  45664. * @returns a promise
  45665. */
  45666. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45667. /**
  45668. * Uploads spherical polynomials information to the texture.
  45669. * @param texture defines the texture we are trying to upload the information to
  45670. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45671. */
  45672. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45673. /** @hidden */
  45674. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45675. }
  45676. }
  45677. declare module "babylonjs/Maths/math.vertexFormat" {
  45678. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45679. /**
  45680. * Contains position and normal vectors for a vertex
  45681. */
  45682. export class PositionNormalVertex {
  45683. /** the position of the vertex (defaut: 0,0,0) */
  45684. position: Vector3;
  45685. /** the normal of the vertex (defaut: 0,1,0) */
  45686. normal: Vector3;
  45687. /**
  45688. * Creates a PositionNormalVertex
  45689. * @param position the position of the vertex (defaut: 0,0,0)
  45690. * @param normal the normal of the vertex (defaut: 0,1,0)
  45691. */
  45692. constructor(
  45693. /** the position of the vertex (defaut: 0,0,0) */
  45694. position?: Vector3,
  45695. /** the normal of the vertex (defaut: 0,1,0) */
  45696. normal?: Vector3);
  45697. /**
  45698. * Clones the PositionNormalVertex
  45699. * @returns the cloned PositionNormalVertex
  45700. */
  45701. clone(): PositionNormalVertex;
  45702. }
  45703. /**
  45704. * Contains position, normal and uv vectors for a vertex
  45705. */
  45706. export class PositionNormalTextureVertex {
  45707. /** the position of the vertex (defaut: 0,0,0) */
  45708. position: Vector3;
  45709. /** the normal of the vertex (defaut: 0,1,0) */
  45710. normal: Vector3;
  45711. /** the uv of the vertex (default: 0,0) */
  45712. uv: Vector2;
  45713. /**
  45714. * Creates a PositionNormalTextureVertex
  45715. * @param position the position of the vertex (defaut: 0,0,0)
  45716. * @param normal the normal of the vertex (defaut: 0,1,0)
  45717. * @param uv the uv of the vertex (default: 0,0)
  45718. */
  45719. constructor(
  45720. /** the position of the vertex (defaut: 0,0,0) */
  45721. position?: Vector3,
  45722. /** the normal of the vertex (defaut: 0,1,0) */
  45723. normal?: Vector3,
  45724. /** the uv of the vertex (default: 0,0) */
  45725. uv?: Vector2);
  45726. /**
  45727. * Clones the PositionNormalTextureVertex
  45728. * @returns the cloned PositionNormalTextureVertex
  45729. */
  45730. clone(): PositionNormalTextureVertex;
  45731. }
  45732. }
  45733. declare module "babylonjs/Maths/math" {
  45734. export * from "babylonjs/Maths/math.axis";
  45735. export * from "babylonjs/Maths/math.color";
  45736. export * from "babylonjs/Maths/math.constants";
  45737. export * from "babylonjs/Maths/math.frustum";
  45738. export * from "babylonjs/Maths/math.path";
  45739. export * from "babylonjs/Maths/math.plane";
  45740. export * from "babylonjs/Maths/math.size";
  45741. export * from "babylonjs/Maths/math.vector";
  45742. export * from "babylonjs/Maths/math.vertexFormat";
  45743. export * from "babylonjs/Maths/math.viewport";
  45744. }
  45745. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45746. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45747. /** @hidden */
  45748. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45749. private _genericAttributeLocation;
  45750. private _varyingLocationCount;
  45751. private _varyingLocationMap;
  45752. private _replacements;
  45753. private _textureCount;
  45754. private _uniforms;
  45755. lineProcessor(line: string): string;
  45756. attributeProcessor(attribute: string): string;
  45757. varyingProcessor(varying: string, isFragment: boolean): string;
  45758. uniformProcessor(uniform: string): string;
  45759. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45760. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45761. }
  45762. }
  45763. declare module "babylonjs/Engines/nativeEngine" {
  45764. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45765. import { Engine } from "babylonjs/Engines/engine";
  45766. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45767. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45769. import { Effect } from "babylonjs/Materials/effect";
  45770. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45771. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45772. import { Scene } from "babylonjs/scene";
  45773. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45774. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45775. /**
  45776. * Container for accessors for natively-stored mesh data buffers.
  45777. */
  45778. class NativeDataBuffer extends DataBuffer {
  45779. /**
  45780. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45781. */
  45782. nativeIndexBuffer?: any;
  45783. /**
  45784. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45785. */
  45786. nativeVertexBuffer?: any;
  45787. }
  45788. /** @hidden */
  45789. export class NativeEngine extends Engine {
  45790. private readonly _native;
  45791. getHardwareScalingLevel(): number;
  45792. constructor();
  45793. /**
  45794. * Can be used to override the current requestAnimationFrame requester.
  45795. * @hidden
  45796. */
  45797. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45798. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45799. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45800. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45801. recordVertexArrayObject(vertexBuffers: {
  45802. [key: string]: VertexBuffer;
  45803. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45804. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45805. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45806. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45807. /**
  45808. * Draw a list of indexed primitives
  45809. * @param fillMode defines the primitive to use
  45810. * @param indexStart defines the starting index
  45811. * @param indexCount defines the number of index to draw
  45812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45813. */
  45814. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45815. /**
  45816. * Draw a list of unindexed primitives
  45817. * @param fillMode defines the primitive to use
  45818. * @param verticesStart defines the index of first vertex to draw
  45819. * @param verticesCount defines the count of vertices to draw
  45820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45821. */
  45822. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45823. createPipelineContext(): IPipelineContext;
  45824. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45825. /** @hidden */
  45826. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45827. /** @hidden */
  45828. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45829. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45830. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45831. protected _setProgram(program: WebGLProgram): void;
  45832. _releaseEffect(effect: Effect): void;
  45833. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45834. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45835. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45836. bindSamplers(effect: Effect): void;
  45837. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45838. getRenderWidth(useScreen?: boolean): number;
  45839. getRenderHeight(useScreen?: boolean): number;
  45840. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45841. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45842. /**
  45843. * Set the z offset to apply to current rendering
  45844. * @param value defines the offset to apply
  45845. */
  45846. setZOffset(value: number): void;
  45847. /**
  45848. * Gets the current value of the zOffset
  45849. * @returns the current zOffset state
  45850. */
  45851. getZOffset(): number;
  45852. /**
  45853. * Enable or disable depth buffering
  45854. * @param enable defines the state to set
  45855. */
  45856. setDepthBuffer(enable: boolean): void;
  45857. /**
  45858. * Gets a boolean indicating if depth writing is enabled
  45859. * @returns the current depth writing state
  45860. */
  45861. getDepthWrite(): boolean;
  45862. /**
  45863. * Enable or disable depth writing
  45864. * @param enable defines the state to set
  45865. */
  45866. setDepthWrite(enable: boolean): void;
  45867. /**
  45868. * Enable or disable color writing
  45869. * @param enable defines the state to set
  45870. */
  45871. setColorWrite(enable: boolean): void;
  45872. /**
  45873. * Gets a boolean indicating if color writing is enabled
  45874. * @returns the current color writing state
  45875. */
  45876. getColorWrite(): boolean;
  45877. /**
  45878. * Sets alpha constants used by some alpha blending modes
  45879. * @param r defines the red component
  45880. * @param g defines the green component
  45881. * @param b defines the blue component
  45882. * @param a defines the alpha component
  45883. */
  45884. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45885. /**
  45886. * Sets the current alpha mode
  45887. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45890. */
  45891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45892. /**
  45893. * Gets the current alpha mode
  45894. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45895. * @returns the current alpha mode
  45896. */
  45897. getAlphaMode(): number;
  45898. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45899. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45900. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45901. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45902. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45903. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45904. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45905. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45906. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45907. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45908. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45909. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45910. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45911. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45912. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45913. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45914. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45915. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45916. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45917. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45918. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45919. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45920. wipeCaches(bruteForce?: boolean): void;
  45921. _createTexture(): WebGLTexture;
  45922. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45923. /**
  45924. * Usually called from BABYLON.Texture.ts.
  45925. * Passed information to create a WebGLTexture
  45926. * @param urlArg defines a value which contains one of the following:
  45927. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45928. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45929. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45931. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45932. * @param scene needed for loading to the correct scene
  45933. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45934. * @param onLoad optional callback to be called upon successful completion
  45935. * @param onError optional callback to be called upon failure
  45936. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45937. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45938. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45939. * @param forcedExtension defines the extension to use to pick the right loader
  45940. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45941. */
  45942. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45943. /**
  45944. * Creates a cube texture
  45945. * @param rootUrl defines the url where the files to load is located
  45946. * @param scene defines the current scene
  45947. * @param files defines the list of files to load (1 per face)
  45948. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45949. * @param onLoad defines an optional callback raised when the texture is loaded
  45950. * @param onError defines an optional callback raised if there is an issue to load the texture
  45951. * @param format defines the format of the data
  45952. * @param forcedExtension defines the extension to use to pick the right loader
  45953. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45954. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45955. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45956. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45957. * @returns the cube texture as an InternalTexture
  45958. */
  45959. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45960. private _getSamplingFilter;
  45961. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45962. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45963. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45964. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45965. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45966. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45967. /**
  45968. * Updates a dynamic vertex buffer.
  45969. * @param vertexBuffer the vertex buffer to update
  45970. * @param data the data used to update the vertex buffer
  45971. * @param byteOffset the byte offset of the data (optional)
  45972. * @param byteLength the byte length of the data (optional)
  45973. */
  45974. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45975. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45976. private _updateAnisotropicLevel;
  45977. private _getAddressMode;
  45978. /** @hidden */
  45979. _bindTexture(channel: number, texture: InternalTexture): void;
  45980. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45981. releaseEffects(): void;
  45982. /** @hidden */
  45983. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45984. /** @hidden */
  45985. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45986. /** @hidden */
  45987. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45988. /** @hidden */
  45989. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45990. }
  45991. }
  45992. declare module "babylonjs/Engines/index" {
  45993. export * from "babylonjs/Engines/constants";
  45994. export * from "babylonjs/Engines/engine";
  45995. export * from "babylonjs/Engines/engineStore";
  45996. export * from "babylonjs/Engines/nullEngine";
  45997. export * from "babylonjs/Engines/Extensions/index";
  45998. export * from "babylonjs/Engines/IPipelineContext";
  45999. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46000. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46001. export * from "babylonjs/Engines/nativeEngine";
  46002. }
  46003. declare module "babylonjs/Events/clipboardEvents" {
  46004. /**
  46005. * Gather the list of clipboard event types as constants.
  46006. */
  46007. export class ClipboardEventTypes {
  46008. /**
  46009. * The clipboard event is fired when a copy command is active (pressed).
  46010. */
  46011. static readonly COPY: number;
  46012. /**
  46013. * The clipboard event is fired when a cut command is active (pressed).
  46014. */
  46015. static readonly CUT: number;
  46016. /**
  46017. * The clipboard event is fired when a paste command is active (pressed).
  46018. */
  46019. static readonly PASTE: number;
  46020. }
  46021. /**
  46022. * This class is used to store clipboard related info for the onClipboardObservable event.
  46023. */
  46024. export class ClipboardInfo {
  46025. /**
  46026. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46027. */
  46028. type: number;
  46029. /**
  46030. * Defines the related dom event
  46031. */
  46032. event: ClipboardEvent;
  46033. /**
  46034. *Creates an instance of ClipboardInfo.
  46035. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46036. * @param event Defines the related dom event
  46037. */
  46038. constructor(
  46039. /**
  46040. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46041. */
  46042. type: number,
  46043. /**
  46044. * Defines the related dom event
  46045. */
  46046. event: ClipboardEvent);
  46047. /**
  46048. * Get the clipboard event's type from the keycode.
  46049. * @param keyCode Defines the keyCode for the current keyboard event.
  46050. * @return {number}
  46051. */
  46052. static GetTypeFromCharacter(keyCode: number): number;
  46053. }
  46054. }
  46055. declare module "babylonjs/Events/index" {
  46056. export * from "babylonjs/Events/keyboardEvents";
  46057. export * from "babylonjs/Events/pointerEvents";
  46058. export * from "babylonjs/Events/clipboardEvents";
  46059. }
  46060. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46061. import { Scene } from "babylonjs/scene";
  46062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46063. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46064. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46065. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46066. /**
  46067. * Google Daydream controller
  46068. */
  46069. export class DaydreamController extends WebVRController {
  46070. /**
  46071. * Base Url for the controller model.
  46072. */
  46073. static MODEL_BASE_URL: string;
  46074. /**
  46075. * File name for the controller model.
  46076. */
  46077. static MODEL_FILENAME: string;
  46078. /**
  46079. * Gamepad Id prefix used to identify Daydream Controller.
  46080. */
  46081. static readonly GAMEPAD_ID_PREFIX: string;
  46082. /**
  46083. * Creates a new DaydreamController from a gamepad
  46084. * @param vrGamepad the gamepad that the controller should be created from
  46085. */
  46086. constructor(vrGamepad: any);
  46087. /**
  46088. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46089. * @param scene scene in which to add meshes
  46090. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46091. */
  46092. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46093. /**
  46094. * Called once for each button that changed state since the last frame
  46095. * @param buttonIdx Which button index changed
  46096. * @param state New state of the button
  46097. * @param changes Which properties on the state changed since last frame
  46098. */
  46099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46100. }
  46101. }
  46102. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46103. import { Scene } from "babylonjs/scene";
  46104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46105. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46106. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46107. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46108. /**
  46109. * Gear VR Controller
  46110. */
  46111. export class GearVRController extends WebVRController {
  46112. /**
  46113. * Base Url for the controller model.
  46114. */
  46115. static MODEL_BASE_URL: string;
  46116. /**
  46117. * File name for the controller model.
  46118. */
  46119. static MODEL_FILENAME: string;
  46120. /**
  46121. * Gamepad Id prefix used to identify this controller.
  46122. */
  46123. static readonly GAMEPAD_ID_PREFIX: string;
  46124. private readonly _buttonIndexToObservableNameMap;
  46125. /**
  46126. * Creates a new GearVRController from a gamepad
  46127. * @param vrGamepad the gamepad that the controller should be created from
  46128. */
  46129. constructor(vrGamepad: any);
  46130. /**
  46131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46132. * @param scene scene in which to add meshes
  46133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46134. */
  46135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46136. /**
  46137. * Called once for each button that changed state since the last frame
  46138. * @param buttonIdx Which button index changed
  46139. * @param state New state of the button
  46140. * @param changes Which properties on the state changed since last frame
  46141. */
  46142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46143. }
  46144. }
  46145. declare module "babylonjs/Gamepads/Controllers/index" {
  46146. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46147. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46148. export * from "babylonjs/Gamepads/Controllers/genericController";
  46149. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46150. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46151. export * from "babylonjs/Gamepads/Controllers/viveController";
  46152. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46153. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46154. }
  46155. declare module "babylonjs/Gamepads/index" {
  46156. export * from "babylonjs/Gamepads/Controllers/index";
  46157. export * from "babylonjs/Gamepads/gamepad";
  46158. export * from "babylonjs/Gamepads/gamepadManager";
  46159. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46160. export * from "babylonjs/Gamepads/xboxGamepad";
  46161. export * from "babylonjs/Gamepads/dualShockGamepad";
  46162. }
  46163. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46164. import { Scene } from "babylonjs/scene";
  46165. import { Vector4 } from "babylonjs/Maths/math.vector";
  46166. import { Color4 } from "babylonjs/Maths/math.color";
  46167. import { Mesh } from "babylonjs/Meshes/mesh";
  46168. import { Nullable } from "babylonjs/types";
  46169. /**
  46170. * Class containing static functions to help procedurally build meshes
  46171. */
  46172. export class PolyhedronBuilder {
  46173. /**
  46174. * Creates a polyhedron mesh
  46175. * * 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
  46176. * * The parameter `size` (positive float, default 1) sets the polygon size
  46177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46178. * * 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`
  46179. * * 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
  46180. * * 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)`)
  46181. * * 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
  46182. * * 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
  46183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46186. * @param name defines the name of the mesh
  46187. * @param options defines the options used to create the mesh
  46188. * @param scene defines the hosting scene
  46189. * @returns the polyhedron mesh
  46190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46191. */
  46192. static CreatePolyhedron(name: string, options: {
  46193. type?: number;
  46194. size?: number;
  46195. sizeX?: number;
  46196. sizeY?: number;
  46197. sizeZ?: number;
  46198. custom?: any;
  46199. faceUV?: Vector4[];
  46200. faceColors?: Color4[];
  46201. flat?: boolean;
  46202. updatable?: boolean;
  46203. sideOrientation?: number;
  46204. frontUVs?: Vector4;
  46205. backUVs?: Vector4;
  46206. }, scene?: Nullable<Scene>): Mesh;
  46207. }
  46208. }
  46209. declare module "babylonjs/Gizmos/scaleGizmo" {
  46210. import { Observable } from "babylonjs/Misc/observable";
  46211. import { Nullable } from "babylonjs/types";
  46212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46214. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46215. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46216. /**
  46217. * Gizmo that enables scaling a mesh along 3 axis
  46218. */
  46219. export class ScaleGizmo extends Gizmo {
  46220. /**
  46221. * Internal gizmo used for interactions on the x axis
  46222. */
  46223. xGizmo: AxisScaleGizmo;
  46224. /**
  46225. * Internal gizmo used for interactions on the y axis
  46226. */
  46227. yGizmo: AxisScaleGizmo;
  46228. /**
  46229. * Internal gizmo used for interactions on the z axis
  46230. */
  46231. zGizmo: AxisScaleGizmo;
  46232. /**
  46233. * Internal gizmo used to scale all axis equally
  46234. */
  46235. uniformScaleGizmo: AxisScaleGizmo;
  46236. private _meshAttached;
  46237. private _updateGizmoRotationToMatchAttachedMesh;
  46238. private _snapDistance;
  46239. private _scaleRatio;
  46240. private _uniformScalingMesh;
  46241. private _octahedron;
  46242. /** Fires an event when any of it's sub gizmos are dragged */
  46243. onDragStartObservable: Observable<unknown>;
  46244. /** Fires an event when any of it's sub gizmos are released from dragging */
  46245. onDragEndObservable: Observable<unknown>;
  46246. attachedMesh: Nullable<AbstractMesh>;
  46247. /**
  46248. * Creates a ScaleGizmo
  46249. * @param gizmoLayer The utility layer the gizmo will be added to
  46250. */
  46251. constructor(gizmoLayer?: UtilityLayerRenderer);
  46252. updateGizmoRotationToMatchAttachedMesh: boolean;
  46253. /**
  46254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46255. */
  46256. snapDistance: number;
  46257. /**
  46258. * Ratio for the scale of the gizmo (Default: 1)
  46259. */
  46260. scaleRatio: number;
  46261. /**
  46262. * Disposes of the gizmo
  46263. */
  46264. dispose(): void;
  46265. }
  46266. }
  46267. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46268. import { Observable } from "babylonjs/Misc/observable";
  46269. import { Nullable } from "babylonjs/types";
  46270. import { Vector3 } from "babylonjs/Maths/math.vector";
  46271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46272. import { Mesh } from "babylonjs/Meshes/mesh";
  46273. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46274. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46275. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46276. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46277. import { Color3 } from "babylonjs/Maths/math.color";
  46278. /**
  46279. * Single axis scale gizmo
  46280. */
  46281. export class AxisScaleGizmo extends Gizmo {
  46282. /**
  46283. * Drag behavior responsible for the gizmos dragging interactions
  46284. */
  46285. dragBehavior: PointerDragBehavior;
  46286. private _pointerObserver;
  46287. /**
  46288. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46289. */
  46290. snapDistance: number;
  46291. /**
  46292. * Event that fires each time the gizmo snaps to a new location.
  46293. * * snapDistance is the the change in distance
  46294. */
  46295. onSnapObservable: Observable<{
  46296. snapDistance: number;
  46297. }>;
  46298. /**
  46299. * If the scaling operation should be done on all axis (default: false)
  46300. */
  46301. uniformScaling: boolean;
  46302. private _isEnabled;
  46303. private _parent;
  46304. private _arrow;
  46305. private _coloredMaterial;
  46306. private _hoverMaterial;
  46307. /**
  46308. * Creates an AxisScaleGizmo
  46309. * @param gizmoLayer The utility layer the gizmo will be added to
  46310. * @param dragAxis The axis which the gizmo will be able to scale on
  46311. * @param color The color of the gizmo
  46312. */
  46313. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46315. /**
  46316. * If the gizmo is enabled
  46317. */
  46318. isEnabled: boolean;
  46319. /**
  46320. * Disposes of the gizmo
  46321. */
  46322. dispose(): void;
  46323. /**
  46324. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46325. * @param mesh The mesh to replace the default mesh of the gizmo
  46326. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46327. */
  46328. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46329. }
  46330. }
  46331. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46332. import { Observable } from "babylonjs/Misc/observable";
  46333. import { Nullable } from "babylonjs/types";
  46334. import { Vector3 } from "babylonjs/Maths/math.vector";
  46335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46336. import { Mesh } from "babylonjs/Meshes/mesh";
  46337. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46339. import { Color3 } from "babylonjs/Maths/math.color";
  46340. import "babylonjs/Meshes/Builders/boxBuilder";
  46341. /**
  46342. * Bounding box gizmo
  46343. */
  46344. export class BoundingBoxGizmo extends Gizmo {
  46345. private _lineBoundingBox;
  46346. private _rotateSpheresParent;
  46347. private _scaleBoxesParent;
  46348. private _boundingDimensions;
  46349. private _renderObserver;
  46350. private _pointerObserver;
  46351. private _scaleDragSpeed;
  46352. private _tmpQuaternion;
  46353. private _tmpVector;
  46354. private _tmpRotationMatrix;
  46355. /**
  46356. * 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)
  46357. */
  46358. ignoreChildren: boolean;
  46359. /**
  46360. * 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)
  46361. */
  46362. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46363. /**
  46364. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46365. */
  46366. rotationSphereSize: number;
  46367. /**
  46368. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46369. */
  46370. scaleBoxSize: number;
  46371. /**
  46372. * 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)
  46373. */
  46374. fixedDragMeshScreenSize: boolean;
  46375. /**
  46376. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46377. */
  46378. fixedDragMeshScreenSizeDistanceFactor: number;
  46379. /**
  46380. * Fired when a rotation sphere or scale box is dragged
  46381. */
  46382. onDragStartObservable: Observable<{}>;
  46383. /**
  46384. * Fired when a scale box is dragged
  46385. */
  46386. onScaleBoxDragObservable: Observable<{}>;
  46387. /**
  46388. * Fired when a scale box drag is ended
  46389. */
  46390. onScaleBoxDragEndObservable: Observable<{}>;
  46391. /**
  46392. * Fired when a rotation sphere is dragged
  46393. */
  46394. onRotationSphereDragObservable: Observable<{}>;
  46395. /**
  46396. * Fired when a rotation sphere drag is ended
  46397. */
  46398. onRotationSphereDragEndObservable: Observable<{}>;
  46399. /**
  46400. * 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)
  46401. */
  46402. scalePivot: Nullable<Vector3>;
  46403. /**
  46404. * Mesh used as a pivot to rotate the attached mesh
  46405. */
  46406. private _anchorMesh;
  46407. private _existingMeshScale;
  46408. private _dragMesh;
  46409. private pointerDragBehavior;
  46410. private coloredMaterial;
  46411. private hoverColoredMaterial;
  46412. /**
  46413. * Sets the color of the bounding box gizmo
  46414. * @param color the color to set
  46415. */
  46416. setColor(color: Color3): void;
  46417. /**
  46418. * Creates an BoundingBoxGizmo
  46419. * @param gizmoLayer The utility layer the gizmo will be added to
  46420. * @param color The color of the gizmo
  46421. */
  46422. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46423. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46424. private _selectNode;
  46425. /**
  46426. * Updates the bounding box information for the Gizmo
  46427. */
  46428. updateBoundingBox(): void;
  46429. private _updateRotationSpheres;
  46430. private _updateScaleBoxes;
  46431. /**
  46432. * Enables rotation on the specified axis and disables rotation on the others
  46433. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46434. */
  46435. setEnabledRotationAxis(axis: string): void;
  46436. /**
  46437. * Enables/disables scaling
  46438. * @param enable if scaling should be enabled
  46439. */
  46440. setEnabledScaling(enable: boolean): void;
  46441. private _updateDummy;
  46442. /**
  46443. * Enables a pointer drag behavior on the bounding box of the gizmo
  46444. */
  46445. enableDragBehavior(): void;
  46446. /**
  46447. * Disposes of the gizmo
  46448. */
  46449. dispose(): void;
  46450. /**
  46451. * 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)
  46452. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46453. * @returns the bounding box mesh with the passed in mesh as a child
  46454. */
  46455. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46456. /**
  46457. * CustomMeshes are not supported by this gizmo
  46458. * @param mesh The mesh to replace the default mesh of the gizmo
  46459. */
  46460. setCustomMesh(mesh: Mesh): void;
  46461. }
  46462. }
  46463. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46464. import { Observable } from "babylonjs/Misc/observable";
  46465. import { Nullable } from "babylonjs/types";
  46466. import { Vector3 } from "babylonjs/Maths/math.vector";
  46467. import { Color3 } from "babylonjs/Maths/math.color";
  46468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46469. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46470. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46471. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46472. import "babylonjs/Meshes/Builders/linesBuilder";
  46473. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46474. /**
  46475. * Single plane rotation gizmo
  46476. */
  46477. export class PlaneRotationGizmo extends Gizmo {
  46478. /**
  46479. * Drag behavior responsible for the gizmos dragging interactions
  46480. */
  46481. dragBehavior: PointerDragBehavior;
  46482. private _pointerObserver;
  46483. /**
  46484. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46485. */
  46486. snapDistance: number;
  46487. /**
  46488. * Event that fires each time the gizmo snaps to a new location.
  46489. * * snapDistance is the the change in distance
  46490. */
  46491. onSnapObservable: Observable<{
  46492. snapDistance: number;
  46493. }>;
  46494. private _isEnabled;
  46495. private _parent;
  46496. /**
  46497. * Creates a PlaneRotationGizmo
  46498. * @param gizmoLayer The utility layer the gizmo will be added to
  46499. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46500. * @param color The color of the gizmo
  46501. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46502. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46503. */
  46504. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46505. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46506. /**
  46507. * If the gizmo is enabled
  46508. */
  46509. isEnabled: boolean;
  46510. /**
  46511. * Disposes of the gizmo
  46512. */
  46513. dispose(): void;
  46514. }
  46515. }
  46516. declare module "babylonjs/Gizmos/rotationGizmo" {
  46517. import { Observable } from "babylonjs/Misc/observable";
  46518. import { Nullable } from "babylonjs/types";
  46519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46520. import { Mesh } from "babylonjs/Meshes/mesh";
  46521. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46522. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46523. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46524. /**
  46525. * Gizmo that enables rotating a mesh along 3 axis
  46526. */
  46527. export class RotationGizmo extends Gizmo {
  46528. /**
  46529. * Internal gizmo used for interactions on the x axis
  46530. */
  46531. xGizmo: PlaneRotationGizmo;
  46532. /**
  46533. * Internal gizmo used for interactions on the y axis
  46534. */
  46535. yGizmo: PlaneRotationGizmo;
  46536. /**
  46537. * Internal gizmo used for interactions on the z axis
  46538. */
  46539. zGizmo: PlaneRotationGizmo;
  46540. /** Fires an event when any of it's sub gizmos are dragged */
  46541. onDragStartObservable: Observable<unknown>;
  46542. /** Fires an event when any of it's sub gizmos are released from dragging */
  46543. onDragEndObservable: Observable<unknown>;
  46544. private _meshAttached;
  46545. attachedMesh: Nullable<AbstractMesh>;
  46546. /**
  46547. * Creates a RotationGizmo
  46548. * @param gizmoLayer The utility layer the gizmo will be added to
  46549. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46550. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46551. */
  46552. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46553. updateGizmoRotationToMatchAttachedMesh: boolean;
  46554. /**
  46555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46556. */
  46557. snapDistance: number;
  46558. /**
  46559. * Ratio for the scale of the gizmo (Default: 1)
  46560. */
  46561. scaleRatio: number;
  46562. /**
  46563. * Disposes of the gizmo
  46564. */
  46565. dispose(): void;
  46566. /**
  46567. * CustomMeshes are not supported by this gizmo
  46568. * @param mesh The mesh to replace the default mesh of the gizmo
  46569. */
  46570. setCustomMesh(mesh: Mesh): void;
  46571. }
  46572. }
  46573. declare module "babylonjs/Gizmos/gizmoManager" {
  46574. import { Observable } from "babylonjs/Misc/observable";
  46575. import { Nullable } from "babylonjs/types";
  46576. import { Scene, IDisposable } from "babylonjs/scene";
  46577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46579. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46580. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46581. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46582. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46583. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46584. /**
  46585. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46586. */
  46587. export class GizmoManager implements IDisposable {
  46588. private scene;
  46589. /**
  46590. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46591. */
  46592. gizmos: {
  46593. positionGizmo: Nullable<PositionGizmo>;
  46594. rotationGizmo: Nullable<RotationGizmo>;
  46595. scaleGizmo: Nullable<ScaleGizmo>;
  46596. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46597. };
  46598. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46599. clearGizmoOnEmptyPointerEvent: boolean;
  46600. /** Fires an event when the manager is attached to a mesh */
  46601. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46602. private _gizmosEnabled;
  46603. private _pointerObserver;
  46604. private _attachedMesh;
  46605. private _boundingBoxColor;
  46606. private _defaultUtilityLayer;
  46607. private _defaultKeepDepthUtilityLayer;
  46608. /**
  46609. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46610. */
  46611. boundingBoxDragBehavior: SixDofDragBehavior;
  46612. /**
  46613. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46614. */
  46615. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46616. /**
  46617. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46618. */
  46619. usePointerToAttachGizmos: boolean;
  46620. /**
  46621. * Utility layer that the bounding box gizmo belongs to
  46622. */
  46623. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46624. /**
  46625. * Utility layer that all gizmos besides bounding box belong to
  46626. */
  46627. readonly utilityLayer: UtilityLayerRenderer;
  46628. /**
  46629. * Instatiates a gizmo manager
  46630. * @param scene the scene to overlay the gizmos on top of
  46631. */
  46632. constructor(scene: Scene);
  46633. /**
  46634. * Attaches a set of gizmos to the specified mesh
  46635. * @param mesh The mesh the gizmo's should be attached to
  46636. */
  46637. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46638. /**
  46639. * If the position gizmo is enabled
  46640. */
  46641. positionGizmoEnabled: boolean;
  46642. /**
  46643. * If the rotation gizmo is enabled
  46644. */
  46645. rotationGizmoEnabled: boolean;
  46646. /**
  46647. * If the scale gizmo is enabled
  46648. */
  46649. scaleGizmoEnabled: boolean;
  46650. /**
  46651. * If the boundingBox gizmo is enabled
  46652. */
  46653. boundingBoxGizmoEnabled: boolean;
  46654. /**
  46655. * Disposes of the gizmo manager
  46656. */
  46657. dispose(): void;
  46658. }
  46659. }
  46660. declare module "babylonjs/Lights/directionalLight" {
  46661. import { Camera } from "babylonjs/Cameras/camera";
  46662. import { Scene } from "babylonjs/scene";
  46663. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46665. import { Light } from "babylonjs/Lights/light";
  46666. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46667. import { Effect } from "babylonjs/Materials/effect";
  46668. /**
  46669. * A directional light is defined by a direction (what a surprise!).
  46670. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46671. * 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.
  46672. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46673. */
  46674. export class DirectionalLight extends ShadowLight {
  46675. private _shadowFrustumSize;
  46676. /**
  46677. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46678. */
  46679. /**
  46680. * Specifies a fix frustum size for the shadow generation.
  46681. */
  46682. shadowFrustumSize: number;
  46683. private _shadowOrthoScale;
  46684. /**
  46685. * Gets the shadow projection scale against the optimal computed one.
  46686. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46687. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46688. */
  46689. /**
  46690. * Sets the shadow projection scale against the optimal computed one.
  46691. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46692. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46693. */
  46694. shadowOrthoScale: number;
  46695. /**
  46696. * Automatically compute the projection matrix to best fit (including all the casters)
  46697. * on each frame.
  46698. */
  46699. autoUpdateExtends: boolean;
  46700. private _orthoLeft;
  46701. private _orthoRight;
  46702. private _orthoTop;
  46703. private _orthoBottom;
  46704. /**
  46705. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46706. * The directional light is emitted from everywhere in the given direction.
  46707. * It can cast shadows.
  46708. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46709. * @param name The friendly name of the light
  46710. * @param direction The direction of the light
  46711. * @param scene The scene the light belongs to
  46712. */
  46713. constructor(name: string, direction: Vector3, scene: Scene);
  46714. /**
  46715. * Returns the string "DirectionalLight".
  46716. * @return The class name
  46717. */
  46718. getClassName(): string;
  46719. /**
  46720. * Returns the integer 1.
  46721. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46722. */
  46723. getTypeID(): number;
  46724. /**
  46725. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46726. * Returns the DirectionalLight Shadow projection matrix.
  46727. */
  46728. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46729. /**
  46730. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46731. * Returns the DirectionalLight Shadow projection matrix.
  46732. */
  46733. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46734. /**
  46735. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46736. * Returns the DirectionalLight Shadow projection matrix.
  46737. */
  46738. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46739. protected _buildUniformLayout(): void;
  46740. /**
  46741. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46742. * @param effect The effect to update
  46743. * @param lightIndex The index of the light in the effect to update
  46744. * @returns The directional light
  46745. */
  46746. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46747. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46748. /**
  46749. * Gets the minZ used for shadow according to both the scene and the light.
  46750. *
  46751. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46752. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46753. * @param activeCamera The camera we are returning the min for
  46754. * @returns the depth min z
  46755. */
  46756. getDepthMinZ(activeCamera: Camera): number;
  46757. /**
  46758. * Gets the maxZ used for shadow according to both the scene and the light.
  46759. *
  46760. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46761. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46762. * @param activeCamera The camera we are returning the max for
  46763. * @returns the depth max z
  46764. */
  46765. getDepthMaxZ(activeCamera: Camera): number;
  46766. /**
  46767. * Prepares the list of defines specific to the light type.
  46768. * @param defines the list of defines
  46769. * @param lightIndex defines the index of the light for the effect
  46770. */
  46771. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46772. }
  46773. }
  46774. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46775. import { Mesh } from "babylonjs/Meshes/mesh";
  46776. /**
  46777. * Class containing static functions to help procedurally build meshes
  46778. */
  46779. export class HemisphereBuilder {
  46780. /**
  46781. * Creates a hemisphere mesh
  46782. * @param name defines the name of the mesh
  46783. * @param options defines the options used to create the mesh
  46784. * @param scene defines the hosting scene
  46785. * @returns the hemisphere mesh
  46786. */
  46787. static CreateHemisphere(name: string, options: {
  46788. segments?: number;
  46789. diameter?: number;
  46790. sideOrientation?: number;
  46791. }, scene: any): Mesh;
  46792. }
  46793. }
  46794. declare module "babylonjs/Lights/spotLight" {
  46795. import { Nullable } from "babylonjs/types";
  46796. import { Scene } from "babylonjs/scene";
  46797. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46799. import { Effect } from "babylonjs/Materials/effect";
  46800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46801. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46802. /**
  46803. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46804. * These values define a cone of light starting from the position, emitting toward the direction.
  46805. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46806. * and the exponent defines the speed of the decay of the light with distance (reach).
  46807. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46808. */
  46809. export class SpotLight extends ShadowLight {
  46810. private _angle;
  46811. private _innerAngle;
  46812. private _cosHalfAngle;
  46813. private _lightAngleScale;
  46814. private _lightAngleOffset;
  46815. /**
  46816. * Gets the cone angle of the spot light in Radians.
  46817. */
  46818. /**
  46819. * Sets the cone angle of the spot light in Radians.
  46820. */
  46821. angle: number;
  46822. /**
  46823. * Only used in gltf falloff mode, this defines the angle where
  46824. * the directional falloff will start before cutting at angle which could be seen
  46825. * as outer angle.
  46826. */
  46827. /**
  46828. * Only used in gltf falloff mode, this defines the angle where
  46829. * the directional falloff will start before cutting at angle which could be seen
  46830. * as outer angle.
  46831. */
  46832. innerAngle: number;
  46833. private _shadowAngleScale;
  46834. /**
  46835. * Allows scaling the angle of the light for shadow generation only.
  46836. */
  46837. /**
  46838. * Allows scaling the angle of the light for shadow generation only.
  46839. */
  46840. shadowAngleScale: number;
  46841. /**
  46842. * The light decay speed with the distance from the emission spot.
  46843. */
  46844. exponent: number;
  46845. private _projectionTextureMatrix;
  46846. /**
  46847. * Allows reading the projecton texture
  46848. */
  46849. readonly projectionTextureMatrix: Matrix;
  46850. protected _projectionTextureLightNear: number;
  46851. /**
  46852. * Gets the near clip of the Spotlight for texture projection.
  46853. */
  46854. /**
  46855. * Sets the near clip of the Spotlight for texture projection.
  46856. */
  46857. projectionTextureLightNear: number;
  46858. protected _projectionTextureLightFar: number;
  46859. /**
  46860. * Gets the far clip of the Spotlight for texture projection.
  46861. */
  46862. /**
  46863. * Sets the far clip of the Spotlight for texture projection.
  46864. */
  46865. projectionTextureLightFar: number;
  46866. protected _projectionTextureUpDirection: Vector3;
  46867. /**
  46868. * Gets the Up vector of the Spotlight for texture projection.
  46869. */
  46870. /**
  46871. * Sets the Up vector of the Spotlight for texture projection.
  46872. */
  46873. projectionTextureUpDirection: Vector3;
  46874. private _projectionTexture;
  46875. /**
  46876. * Gets the projection texture of the light.
  46877. */
  46878. /**
  46879. * Sets the projection texture of the light.
  46880. */
  46881. projectionTexture: Nullable<BaseTexture>;
  46882. private _projectionTextureViewLightDirty;
  46883. private _projectionTextureProjectionLightDirty;
  46884. private _projectionTextureDirty;
  46885. private _projectionTextureViewTargetVector;
  46886. private _projectionTextureViewLightMatrix;
  46887. private _projectionTextureProjectionLightMatrix;
  46888. private _projectionTextureScalingMatrix;
  46889. /**
  46890. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46891. * It can cast shadows.
  46892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46893. * @param name The light friendly name
  46894. * @param position The position of the spot light in the scene
  46895. * @param direction The direction of the light in the scene
  46896. * @param angle The cone angle of the light in Radians
  46897. * @param exponent The light decay speed with the distance from the emission spot
  46898. * @param scene The scene the lights belongs to
  46899. */
  46900. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46901. /**
  46902. * Returns the string "SpotLight".
  46903. * @returns the class name
  46904. */
  46905. getClassName(): string;
  46906. /**
  46907. * Returns the integer 2.
  46908. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46909. */
  46910. getTypeID(): number;
  46911. /**
  46912. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46913. */
  46914. protected _setDirection(value: Vector3): void;
  46915. /**
  46916. * Overrides the position setter to recompute the projection texture view light Matrix.
  46917. */
  46918. protected _setPosition(value: Vector3): void;
  46919. /**
  46920. * 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.
  46921. * Returns the SpotLight.
  46922. */
  46923. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46924. protected _computeProjectionTextureViewLightMatrix(): void;
  46925. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46926. /**
  46927. * Main function for light texture projection matrix computing.
  46928. */
  46929. protected _computeProjectionTextureMatrix(): void;
  46930. protected _buildUniformLayout(): void;
  46931. private _computeAngleValues;
  46932. /**
  46933. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46934. * @param effect The effect to update
  46935. * @param lightIndex The index of the light in the effect to update
  46936. * @returns The spot light
  46937. */
  46938. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46939. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46940. /**
  46941. * Disposes the light and the associated resources.
  46942. */
  46943. dispose(): void;
  46944. /**
  46945. * Prepares the list of defines specific to the light type.
  46946. * @param defines the list of defines
  46947. * @param lightIndex defines the index of the light for the effect
  46948. */
  46949. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46950. }
  46951. }
  46952. declare module "babylonjs/Gizmos/lightGizmo" {
  46953. import { Nullable } from "babylonjs/types";
  46954. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46955. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46956. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46957. import { Light } from "babylonjs/Lights/light";
  46958. /**
  46959. * Gizmo that enables viewing a light
  46960. */
  46961. export class LightGizmo extends Gizmo {
  46962. private _lightMesh;
  46963. private _material;
  46964. private cachedPosition;
  46965. private cachedForward;
  46966. /**
  46967. * Creates a LightGizmo
  46968. * @param gizmoLayer The utility layer the gizmo will be added to
  46969. */
  46970. constructor(gizmoLayer?: UtilityLayerRenderer);
  46971. private _light;
  46972. /**
  46973. * The light that the gizmo is attached to
  46974. */
  46975. light: Nullable<Light>;
  46976. /**
  46977. * Gets the material used to render the light gizmo
  46978. */
  46979. readonly material: StandardMaterial;
  46980. /**
  46981. * @hidden
  46982. * Updates the gizmo to match the attached mesh's position/rotation
  46983. */
  46984. protected _update(): void;
  46985. private static _Scale;
  46986. /**
  46987. * Creates the lines for a light mesh
  46988. */
  46989. private static _createLightLines;
  46990. /**
  46991. * Disposes of the light gizmo
  46992. */
  46993. dispose(): void;
  46994. private static _CreateHemisphericLightMesh;
  46995. private static _CreatePointLightMesh;
  46996. private static _CreateSpotLightMesh;
  46997. private static _CreateDirectionalLightMesh;
  46998. }
  46999. }
  47000. declare module "babylonjs/Gizmos/index" {
  47001. export * from "babylonjs/Gizmos/axisDragGizmo";
  47002. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47003. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47004. export * from "babylonjs/Gizmos/gizmo";
  47005. export * from "babylonjs/Gizmos/gizmoManager";
  47006. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47007. export * from "babylonjs/Gizmos/positionGizmo";
  47008. export * from "babylonjs/Gizmos/rotationGizmo";
  47009. export * from "babylonjs/Gizmos/scaleGizmo";
  47010. export * from "babylonjs/Gizmos/lightGizmo";
  47011. export * from "babylonjs/Gizmos/planeDragGizmo";
  47012. }
  47013. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47014. /** @hidden */
  47015. export var backgroundFragmentDeclaration: {
  47016. name: string;
  47017. shader: string;
  47018. };
  47019. }
  47020. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47021. /** @hidden */
  47022. export var backgroundUboDeclaration: {
  47023. name: string;
  47024. shader: string;
  47025. };
  47026. }
  47027. declare module "babylonjs/Shaders/background.fragment" {
  47028. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47029. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47030. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47031. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47032. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47033. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47035. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47036. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47037. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47038. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47039. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47041. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47042. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47043. /** @hidden */
  47044. export var backgroundPixelShader: {
  47045. name: string;
  47046. shader: string;
  47047. };
  47048. }
  47049. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47050. /** @hidden */
  47051. export var backgroundVertexDeclaration: {
  47052. name: string;
  47053. shader: string;
  47054. };
  47055. }
  47056. declare module "babylonjs/Shaders/background.vertex" {
  47057. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47061. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47062. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47063. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47066. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47067. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47068. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47069. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47070. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47071. /** @hidden */
  47072. export var backgroundVertexShader: {
  47073. name: string;
  47074. shader: string;
  47075. };
  47076. }
  47077. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47078. import { Nullable, int, float } from "babylonjs/types";
  47079. import { Scene } from "babylonjs/scene";
  47080. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47081. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47083. import { Mesh } from "babylonjs/Meshes/mesh";
  47084. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47086. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47088. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47089. import { Color3 } from "babylonjs/Maths/math.color";
  47090. import "babylonjs/Shaders/background.fragment";
  47091. import "babylonjs/Shaders/background.vertex";
  47092. /**
  47093. * Background material used to create an efficient environement around your scene.
  47094. */
  47095. export class BackgroundMaterial extends PushMaterial {
  47096. /**
  47097. * Standard reflectance value at parallel view angle.
  47098. */
  47099. static StandardReflectance0: number;
  47100. /**
  47101. * Standard reflectance value at grazing angle.
  47102. */
  47103. static StandardReflectance90: number;
  47104. protected _primaryColor: Color3;
  47105. /**
  47106. * Key light Color (multiply against the environement texture)
  47107. */
  47108. primaryColor: Color3;
  47109. protected __perceptualColor: Nullable<Color3>;
  47110. /**
  47111. * Experimental Internal Use Only.
  47112. *
  47113. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47114. * This acts as a helper to set the primary color to a more "human friendly" value.
  47115. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47116. * output color as close as possible from the chosen value.
  47117. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47118. * part of lighting setup.)
  47119. */
  47120. _perceptualColor: Nullable<Color3>;
  47121. protected _primaryColorShadowLevel: float;
  47122. /**
  47123. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47124. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47125. */
  47126. primaryColorShadowLevel: float;
  47127. protected _primaryColorHighlightLevel: float;
  47128. /**
  47129. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47130. * The primary color is used at the level chosen to define what the white area would look.
  47131. */
  47132. primaryColorHighlightLevel: float;
  47133. protected _reflectionTexture: Nullable<BaseTexture>;
  47134. /**
  47135. * Reflection Texture used in the material.
  47136. * Should be author in a specific way for the best result (refer to the documentation).
  47137. */
  47138. reflectionTexture: Nullable<BaseTexture>;
  47139. protected _reflectionBlur: float;
  47140. /**
  47141. * Reflection Texture level of blur.
  47142. *
  47143. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47144. * texture twice.
  47145. */
  47146. reflectionBlur: float;
  47147. protected _diffuseTexture: Nullable<BaseTexture>;
  47148. /**
  47149. * Diffuse Texture used in the material.
  47150. * Should be author in a specific way for the best result (refer to the documentation).
  47151. */
  47152. diffuseTexture: Nullable<BaseTexture>;
  47153. protected _shadowLights: Nullable<IShadowLight[]>;
  47154. /**
  47155. * Specify the list of lights casting shadow on the material.
  47156. * All scene shadow lights will be included if null.
  47157. */
  47158. shadowLights: Nullable<IShadowLight[]>;
  47159. protected _shadowLevel: float;
  47160. /**
  47161. * Helps adjusting the shadow to a softer level if required.
  47162. * 0 means black shadows and 1 means no shadows.
  47163. */
  47164. shadowLevel: float;
  47165. protected _sceneCenter: Vector3;
  47166. /**
  47167. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47168. * It is usually zero but might be interesting to modify according to your setup.
  47169. */
  47170. sceneCenter: Vector3;
  47171. protected _opacityFresnel: boolean;
  47172. /**
  47173. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47174. * This helps ensuring a nice transition when the camera goes under the ground.
  47175. */
  47176. opacityFresnel: boolean;
  47177. protected _reflectionFresnel: boolean;
  47178. /**
  47179. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47180. * This helps adding a mirror texture on the ground.
  47181. */
  47182. reflectionFresnel: boolean;
  47183. protected _reflectionFalloffDistance: number;
  47184. /**
  47185. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47186. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47187. */
  47188. reflectionFalloffDistance: number;
  47189. protected _reflectionAmount: number;
  47190. /**
  47191. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47192. */
  47193. reflectionAmount: number;
  47194. protected _reflectionReflectance0: number;
  47195. /**
  47196. * This specifies the weight of the reflection at grazing angle.
  47197. */
  47198. reflectionReflectance0: number;
  47199. protected _reflectionReflectance90: number;
  47200. /**
  47201. * This specifies the weight of the reflection at a perpendicular point of view.
  47202. */
  47203. reflectionReflectance90: number;
  47204. /**
  47205. * Sets the reflection reflectance fresnel values according to the default standard
  47206. * empirically know to work well :-)
  47207. */
  47208. reflectionStandardFresnelWeight: number;
  47209. protected _useRGBColor: boolean;
  47210. /**
  47211. * Helps to directly use the maps channels instead of their level.
  47212. */
  47213. useRGBColor: boolean;
  47214. protected _enableNoise: boolean;
  47215. /**
  47216. * This helps reducing the banding effect that could occur on the background.
  47217. */
  47218. enableNoise: boolean;
  47219. /**
  47220. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47221. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47222. * Recommended to be keep at 1.0 except for special cases.
  47223. */
  47224. fovMultiplier: number;
  47225. private _fovMultiplier;
  47226. /**
  47227. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47228. */
  47229. useEquirectangularFOV: boolean;
  47230. private _maxSimultaneousLights;
  47231. /**
  47232. * Number of Simultaneous lights allowed on the material.
  47233. */
  47234. maxSimultaneousLights: int;
  47235. /**
  47236. * Default configuration related to image processing available in the Background Material.
  47237. */
  47238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47239. /**
  47240. * Keep track of the image processing observer to allow dispose and replace.
  47241. */
  47242. private _imageProcessingObserver;
  47243. /**
  47244. * Attaches a new image processing configuration to the PBR Material.
  47245. * @param configuration (if null the scene configuration will be use)
  47246. */
  47247. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47248. /**
  47249. * Gets the image processing configuration used either in this material.
  47250. */
  47251. /**
  47252. * Sets the Default image processing configuration used either in the this material.
  47253. *
  47254. * If sets to null, the scene one is in use.
  47255. */
  47256. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47257. /**
  47258. * Gets wether the color curves effect is enabled.
  47259. */
  47260. /**
  47261. * Sets wether the color curves effect is enabled.
  47262. */
  47263. cameraColorCurvesEnabled: boolean;
  47264. /**
  47265. * Gets wether the color grading effect is enabled.
  47266. */
  47267. /**
  47268. * Gets wether the color grading effect is enabled.
  47269. */
  47270. cameraColorGradingEnabled: boolean;
  47271. /**
  47272. * Gets wether tonemapping is enabled or not.
  47273. */
  47274. /**
  47275. * Sets wether tonemapping is enabled or not
  47276. */
  47277. cameraToneMappingEnabled: boolean;
  47278. /**
  47279. * The camera exposure used on this material.
  47280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47281. * This corresponds to a photographic exposure.
  47282. */
  47283. /**
  47284. * The camera exposure used on this material.
  47285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47286. * This corresponds to a photographic exposure.
  47287. */
  47288. cameraExposure: float;
  47289. /**
  47290. * Gets The camera contrast used on this material.
  47291. */
  47292. /**
  47293. * Sets The camera contrast used on this material.
  47294. */
  47295. cameraContrast: float;
  47296. /**
  47297. * Gets the Color Grading 2D Lookup Texture.
  47298. */
  47299. /**
  47300. * Sets the Color Grading 2D Lookup Texture.
  47301. */
  47302. cameraColorGradingTexture: Nullable<BaseTexture>;
  47303. /**
  47304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47306. * 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;
  47307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47308. */
  47309. /**
  47310. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47311. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47312. * 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;
  47313. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47314. */
  47315. cameraColorCurves: Nullable<ColorCurves>;
  47316. /**
  47317. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47318. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47319. */
  47320. switchToBGR: boolean;
  47321. private _renderTargets;
  47322. private _reflectionControls;
  47323. private _white;
  47324. private _primaryShadowColor;
  47325. private _primaryHighlightColor;
  47326. /**
  47327. * Instantiates a Background Material in the given scene
  47328. * @param name The friendly name of the material
  47329. * @param scene The scene to add the material to
  47330. */
  47331. constructor(name: string, scene: Scene);
  47332. /**
  47333. * Gets a boolean indicating that current material needs to register RTT
  47334. */
  47335. readonly hasRenderTargetTextures: boolean;
  47336. /**
  47337. * The entire material has been created in order to prevent overdraw.
  47338. * @returns false
  47339. */
  47340. needAlphaTesting(): boolean;
  47341. /**
  47342. * The entire material has been created in order to prevent overdraw.
  47343. * @returns true if blending is enable
  47344. */
  47345. needAlphaBlending(): boolean;
  47346. /**
  47347. * Checks wether the material is ready to be rendered for a given mesh.
  47348. * @param mesh The mesh to render
  47349. * @param subMesh The submesh to check against
  47350. * @param useInstances Specify wether or not the material is used with instances
  47351. * @returns true if all the dependencies are ready (Textures, Effects...)
  47352. */
  47353. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47354. /**
  47355. * Compute the primary color according to the chosen perceptual color.
  47356. */
  47357. private _computePrimaryColorFromPerceptualColor;
  47358. /**
  47359. * Compute the highlights and shadow colors according to their chosen levels.
  47360. */
  47361. private _computePrimaryColors;
  47362. /**
  47363. * Build the uniform buffer used in the material.
  47364. */
  47365. buildUniformLayout(): void;
  47366. /**
  47367. * Unbind the material.
  47368. */
  47369. unbind(): void;
  47370. /**
  47371. * Bind only the world matrix to the material.
  47372. * @param world The world matrix to bind.
  47373. */
  47374. bindOnlyWorldMatrix(world: Matrix): void;
  47375. /**
  47376. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47377. * @param world The world matrix to bind.
  47378. * @param subMesh The submesh to bind for.
  47379. */
  47380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47381. /**
  47382. * Checks to see if a texture is used in the material.
  47383. * @param texture - Base texture to use.
  47384. * @returns - Boolean specifying if a texture is used in the material.
  47385. */
  47386. hasTexture(texture: BaseTexture): boolean;
  47387. /**
  47388. * Dispose the material.
  47389. * @param forceDisposeEffect Force disposal of the associated effect.
  47390. * @param forceDisposeTextures Force disposal of the associated textures.
  47391. */
  47392. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47393. /**
  47394. * Clones the material.
  47395. * @param name The cloned name.
  47396. * @returns The cloned material.
  47397. */
  47398. clone(name: string): BackgroundMaterial;
  47399. /**
  47400. * Serializes the current material to its JSON representation.
  47401. * @returns The JSON representation.
  47402. */
  47403. serialize(): any;
  47404. /**
  47405. * Gets the class name of the material
  47406. * @returns "BackgroundMaterial"
  47407. */
  47408. getClassName(): string;
  47409. /**
  47410. * Parse a JSON input to create back a background material.
  47411. * @param source The JSON data to parse
  47412. * @param scene The scene to create the parsed material in
  47413. * @param rootUrl The root url of the assets the material depends upon
  47414. * @returns the instantiated BackgroundMaterial.
  47415. */
  47416. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47417. }
  47418. }
  47419. declare module "babylonjs/Helpers/environmentHelper" {
  47420. import { Observable } from "babylonjs/Misc/observable";
  47421. import { Nullable } from "babylonjs/types";
  47422. import { Scene } from "babylonjs/scene";
  47423. import { Vector3 } from "babylonjs/Maths/math.vector";
  47424. import { Color3 } from "babylonjs/Maths/math.color";
  47425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47426. import { Mesh } from "babylonjs/Meshes/mesh";
  47427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47428. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47429. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47430. import "babylonjs/Meshes/Builders/planeBuilder";
  47431. import "babylonjs/Meshes/Builders/boxBuilder";
  47432. /**
  47433. * Represents the different options available during the creation of
  47434. * a Environment helper.
  47435. *
  47436. * This can control the default ground, skybox and image processing setup of your scene.
  47437. */
  47438. export interface IEnvironmentHelperOptions {
  47439. /**
  47440. * Specifies wether or not to create a ground.
  47441. * True by default.
  47442. */
  47443. createGround: boolean;
  47444. /**
  47445. * Specifies the ground size.
  47446. * 15 by default.
  47447. */
  47448. groundSize: number;
  47449. /**
  47450. * The texture used on the ground for the main color.
  47451. * Comes from the BabylonJS CDN by default.
  47452. *
  47453. * Remarks: Can be either a texture or a url.
  47454. */
  47455. groundTexture: string | BaseTexture;
  47456. /**
  47457. * The color mixed in the ground texture by default.
  47458. * BabylonJS clearColor by default.
  47459. */
  47460. groundColor: Color3;
  47461. /**
  47462. * Specifies the ground opacity.
  47463. * 1 by default.
  47464. */
  47465. groundOpacity: number;
  47466. /**
  47467. * Enables the ground to receive shadows.
  47468. * True by default.
  47469. */
  47470. enableGroundShadow: boolean;
  47471. /**
  47472. * Helps preventing the shadow to be fully black on the ground.
  47473. * 0.5 by default.
  47474. */
  47475. groundShadowLevel: number;
  47476. /**
  47477. * Creates a mirror texture attach to the ground.
  47478. * false by default.
  47479. */
  47480. enableGroundMirror: boolean;
  47481. /**
  47482. * Specifies the ground mirror size ratio.
  47483. * 0.3 by default as the default kernel is 64.
  47484. */
  47485. groundMirrorSizeRatio: number;
  47486. /**
  47487. * Specifies the ground mirror blur kernel size.
  47488. * 64 by default.
  47489. */
  47490. groundMirrorBlurKernel: number;
  47491. /**
  47492. * Specifies the ground mirror visibility amount.
  47493. * 1 by default
  47494. */
  47495. groundMirrorAmount: number;
  47496. /**
  47497. * Specifies the ground mirror reflectance weight.
  47498. * This uses the standard weight of the background material to setup the fresnel effect
  47499. * of the mirror.
  47500. * 1 by default.
  47501. */
  47502. groundMirrorFresnelWeight: number;
  47503. /**
  47504. * Specifies the ground mirror Falloff distance.
  47505. * This can helps reducing the size of the reflection.
  47506. * 0 by Default.
  47507. */
  47508. groundMirrorFallOffDistance: number;
  47509. /**
  47510. * Specifies the ground mirror texture type.
  47511. * Unsigned Int by Default.
  47512. */
  47513. groundMirrorTextureType: number;
  47514. /**
  47515. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47516. * the shown objects.
  47517. */
  47518. groundYBias: number;
  47519. /**
  47520. * Specifies wether or not to create a skybox.
  47521. * True by default.
  47522. */
  47523. createSkybox: boolean;
  47524. /**
  47525. * Specifies the skybox size.
  47526. * 20 by default.
  47527. */
  47528. skyboxSize: number;
  47529. /**
  47530. * The texture used on the skybox for the main color.
  47531. * Comes from the BabylonJS CDN by default.
  47532. *
  47533. * Remarks: Can be either a texture or a url.
  47534. */
  47535. skyboxTexture: string | BaseTexture;
  47536. /**
  47537. * The color mixed in the skybox texture by default.
  47538. * BabylonJS clearColor by default.
  47539. */
  47540. skyboxColor: Color3;
  47541. /**
  47542. * The background rotation around the Y axis of the scene.
  47543. * This helps aligning the key lights of your scene with the background.
  47544. * 0 by default.
  47545. */
  47546. backgroundYRotation: number;
  47547. /**
  47548. * Compute automatically the size of the elements to best fit with the scene.
  47549. */
  47550. sizeAuto: boolean;
  47551. /**
  47552. * Default position of the rootMesh if autoSize is not true.
  47553. */
  47554. rootPosition: Vector3;
  47555. /**
  47556. * Sets up the image processing in the scene.
  47557. * true by default.
  47558. */
  47559. setupImageProcessing: boolean;
  47560. /**
  47561. * The texture used as your environment texture in the scene.
  47562. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47563. *
  47564. * Remarks: Can be either a texture or a url.
  47565. */
  47566. environmentTexture: string | BaseTexture;
  47567. /**
  47568. * The value of the exposure to apply to the scene.
  47569. * 0.6 by default if setupImageProcessing is true.
  47570. */
  47571. cameraExposure: number;
  47572. /**
  47573. * The value of the contrast to apply to the scene.
  47574. * 1.6 by default if setupImageProcessing is true.
  47575. */
  47576. cameraContrast: number;
  47577. /**
  47578. * Specifies wether or not tonemapping should be enabled in the scene.
  47579. * true by default if setupImageProcessing is true.
  47580. */
  47581. toneMappingEnabled: boolean;
  47582. }
  47583. /**
  47584. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47585. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47586. * It also helps with the default setup of your imageProcessing configuration.
  47587. */
  47588. export class EnvironmentHelper {
  47589. /**
  47590. * Default ground texture URL.
  47591. */
  47592. private static _groundTextureCDNUrl;
  47593. /**
  47594. * Default skybox texture URL.
  47595. */
  47596. private static _skyboxTextureCDNUrl;
  47597. /**
  47598. * Default environment texture URL.
  47599. */
  47600. private static _environmentTextureCDNUrl;
  47601. /**
  47602. * Creates the default options for the helper.
  47603. */
  47604. private static _getDefaultOptions;
  47605. private _rootMesh;
  47606. /**
  47607. * Gets the root mesh created by the helper.
  47608. */
  47609. readonly rootMesh: Mesh;
  47610. private _skybox;
  47611. /**
  47612. * Gets the skybox created by the helper.
  47613. */
  47614. readonly skybox: Nullable<Mesh>;
  47615. private _skyboxTexture;
  47616. /**
  47617. * Gets the skybox texture created by the helper.
  47618. */
  47619. readonly skyboxTexture: Nullable<BaseTexture>;
  47620. private _skyboxMaterial;
  47621. /**
  47622. * Gets the skybox material created by the helper.
  47623. */
  47624. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47625. private _ground;
  47626. /**
  47627. * Gets the ground mesh created by the helper.
  47628. */
  47629. readonly ground: Nullable<Mesh>;
  47630. private _groundTexture;
  47631. /**
  47632. * Gets the ground texture created by the helper.
  47633. */
  47634. readonly groundTexture: Nullable<BaseTexture>;
  47635. private _groundMirror;
  47636. /**
  47637. * Gets the ground mirror created by the helper.
  47638. */
  47639. readonly groundMirror: Nullable<MirrorTexture>;
  47640. /**
  47641. * Gets the ground mirror render list to helps pushing the meshes
  47642. * you wish in the ground reflection.
  47643. */
  47644. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47645. private _groundMaterial;
  47646. /**
  47647. * Gets the ground material created by the helper.
  47648. */
  47649. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47650. /**
  47651. * Stores the creation options.
  47652. */
  47653. private readonly _scene;
  47654. private _options;
  47655. /**
  47656. * This observable will be notified with any error during the creation of the environment,
  47657. * mainly texture creation errors.
  47658. */
  47659. onErrorObservable: Observable<{
  47660. message?: string;
  47661. exception?: any;
  47662. }>;
  47663. /**
  47664. * constructor
  47665. * @param options Defines the options we want to customize the helper
  47666. * @param scene The scene to add the material to
  47667. */
  47668. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47669. /**
  47670. * Updates the background according to the new options
  47671. * @param options
  47672. */
  47673. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47674. /**
  47675. * Sets the primary color of all the available elements.
  47676. * @param color the main color to affect to the ground and the background
  47677. */
  47678. setMainColor(color: Color3): void;
  47679. /**
  47680. * Setup the image processing according to the specified options.
  47681. */
  47682. private _setupImageProcessing;
  47683. /**
  47684. * Setup the environment texture according to the specified options.
  47685. */
  47686. private _setupEnvironmentTexture;
  47687. /**
  47688. * Setup the background according to the specified options.
  47689. */
  47690. private _setupBackground;
  47691. /**
  47692. * Get the scene sizes according to the setup.
  47693. */
  47694. private _getSceneSize;
  47695. /**
  47696. * Setup the ground according to the specified options.
  47697. */
  47698. private _setupGround;
  47699. /**
  47700. * Setup the ground material according to the specified options.
  47701. */
  47702. private _setupGroundMaterial;
  47703. /**
  47704. * Setup the ground diffuse texture according to the specified options.
  47705. */
  47706. private _setupGroundDiffuseTexture;
  47707. /**
  47708. * Setup the ground mirror texture according to the specified options.
  47709. */
  47710. private _setupGroundMirrorTexture;
  47711. /**
  47712. * Setup the ground to receive the mirror texture.
  47713. */
  47714. private _setupMirrorInGroundMaterial;
  47715. /**
  47716. * Setup the skybox according to the specified options.
  47717. */
  47718. private _setupSkybox;
  47719. /**
  47720. * Setup the skybox material according to the specified options.
  47721. */
  47722. private _setupSkyboxMaterial;
  47723. /**
  47724. * Setup the skybox reflection texture according to the specified options.
  47725. */
  47726. private _setupSkyboxReflectionTexture;
  47727. private _errorHandler;
  47728. /**
  47729. * Dispose all the elements created by the Helper.
  47730. */
  47731. dispose(): void;
  47732. }
  47733. }
  47734. declare module "babylonjs/Helpers/photoDome" {
  47735. import { Observable } from "babylonjs/Misc/observable";
  47736. import { Nullable } from "babylonjs/types";
  47737. import { Scene } from "babylonjs/scene";
  47738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47739. import { Mesh } from "babylonjs/Meshes/mesh";
  47740. import { Texture } from "babylonjs/Materials/Textures/texture";
  47741. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47742. import "babylonjs/Meshes/Builders/sphereBuilder";
  47743. /**
  47744. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47745. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47746. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47747. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47748. */
  47749. export class PhotoDome extends TransformNode {
  47750. /**
  47751. * Define the image as a Monoscopic panoramic 360 image.
  47752. */
  47753. static readonly MODE_MONOSCOPIC: number;
  47754. /**
  47755. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47756. */
  47757. static readonly MODE_TOPBOTTOM: number;
  47758. /**
  47759. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47760. */
  47761. static readonly MODE_SIDEBYSIDE: number;
  47762. private _useDirectMapping;
  47763. /**
  47764. * The texture being displayed on the sphere
  47765. */
  47766. protected _photoTexture: Texture;
  47767. /**
  47768. * Gets or sets the texture being displayed on the sphere
  47769. */
  47770. photoTexture: Texture;
  47771. /**
  47772. * Observable raised when an error occured while loading the 360 image
  47773. */
  47774. onLoadErrorObservable: Observable<string>;
  47775. /**
  47776. * The skybox material
  47777. */
  47778. protected _material: BackgroundMaterial;
  47779. /**
  47780. * The surface used for the skybox
  47781. */
  47782. protected _mesh: Mesh;
  47783. /**
  47784. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47785. * Also see the options.resolution property.
  47786. */
  47787. fovMultiplier: number;
  47788. private _imageMode;
  47789. /**
  47790. * Gets or set the current video mode for the video. It can be:
  47791. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47792. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47793. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47794. */
  47795. imageMode: number;
  47796. /**
  47797. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47798. * @param name Element's name, child elements will append suffixes for their own names.
  47799. * @param urlsOfPhoto defines the url of the photo to display
  47800. * @param options defines an object containing optional or exposed sub element properties
  47801. * @param onError defines a callback called when an error occured while loading the texture
  47802. */
  47803. constructor(name: string, urlOfPhoto: string, options: {
  47804. resolution?: number;
  47805. size?: number;
  47806. useDirectMapping?: boolean;
  47807. faceForward?: boolean;
  47808. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47809. private _onBeforeCameraRenderObserver;
  47810. private _changeImageMode;
  47811. /**
  47812. * Releases resources associated with this node.
  47813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47815. */
  47816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47817. }
  47818. }
  47819. declare module "babylonjs/Misc/brdfTextureTools" {
  47820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47821. import { Scene } from "babylonjs/scene";
  47822. import "babylonjs/Shaders/rgbdDecode.fragment";
  47823. /**
  47824. * Class used to host texture specific utilities
  47825. */
  47826. export class BRDFTextureTools {
  47827. /**
  47828. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47829. * @param texture the texture to expand.
  47830. */
  47831. private static _ExpandDefaultBRDFTexture;
  47832. /**
  47833. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47834. * @param scene defines the hosting scene
  47835. * @returns the environment BRDF texture
  47836. */
  47837. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47838. private static _environmentBRDFBase64Texture;
  47839. }
  47840. }
  47841. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47842. import { Nullable } from "babylonjs/types";
  47843. import { Color3 } from "babylonjs/Maths/math.color";
  47844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47845. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47848. import { Engine } from "babylonjs/Engines/engine";
  47849. import { Scene } from "babylonjs/scene";
  47850. /**
  47851. * @hidden
  47852. */
  47853. export interface IMaterialClearCoatDefines {
  47854. CLEARCOAT: boolean;
  47855. CLEARCOAT_DEFAULTIOR: boolean;
  47856. CLEARCOAT_TEXTURE: boolean;
  47857. CLEARCOAT_TEXTUREDIRECTUV: number;
  47858. CLEARCOAT_BUMP: boolean;
  47859. CLEARCOAT_BUMPDIRECTUV: number;
  47860. CLEARCOAT_TINT: boolean;
  47861. CLEARCOAT_TINT_TEXTURE: boolean;
  47862. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47863. /** @hidden */
  47864. _areTexturesDirty: boolean;
  47865. }
  47866. /**
  47867. * Define the code related to the clear coat parameters of the pbr material.
  47868. */
  47869. export class PBRClearCoatConfiguration {
  47870. /**
  47871. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47872. * The default fits with a polyurethane material.
  47873. */
  47874. private static readonly _DefaultIndexOfRefraction;
  47875. private _isEnabled;
  47876. /**
  47877. * Defines if the clear coat is enabled in the material.
  47878. */
  47879. isEnabled: boolean;
  47880. /**
  47881. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47882. */
  47883. intensity: number;
  47884. /**
  47885. * Defines the clear coat layer roughness.
  47886. */
  47887. roughness: number;
  47888. private _indexOfRefraction;
  47889. /**
  47890. * Defines the index of refraction of the clear coat.
  47891. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47892. * The default fits with a polyurethane material.
  47893. * Changing the default value is more performance intensive.
  47894. */
  47895. indexOfRefraction: number;
  47896. private _texture;
  47897. /**
  47898. * Stores the clear coat values in a texture.
  47899. */
  47900. texture: Nullable<BaseTexture>;
  47901. private _bumpTexture;
  47902. /**
  47903. * Define the clear coat specific bump texture.
  47904. */
  47905. bumpTexture: Nullable<BaseTexture>;
  47906. private _isTintEnabled;
  47907. /**
  47908. * Defines if the clear coat tint is enabled in the material.
  47909. */
  47910. isTintEnabled: boolean;
  47911. /**
  47912. * Defines the clear coat tint of the material.
  47913. * This is only use if tint is enabled
  47914. */
  47915. tintColor: Color3;
  47916. /**
  47917. * Defines the distance at which the tint color should be found in the
  47918. * clear coat media.
  47919. * This is only use if tint is enabled
  47920. */
  47921. tintColorAtDistance: number;
  47922. /**
  47923. * Defines the clear coat layer thickness.
  47924. * This is only use if tint is enabled
  47925. */
  47926. tintThickness: number;
  47927. private _tintTexture;
  47928. /**
  47929. * Stores the clear tint values in a texture.
  47930. * rgb is tint
  47931. * a is a thickness factor
  47932. */
  47933. tintTexture: Nullable<BaseTexture>;
  47934. /** @hidden */
  47935. private _internalMarkAllSubMeshesAsTexturesDirty;
  47936. /** @hidden */
  47937. _markAllSubMeshesAsTexturesDirty(): void;
  47938. /**
  47939. * Instantiate a new istance of clear coat configuration.
  47940. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47941. */
  47942. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47943. /**
  47944. * Gets wehter the submesh is ready to be used or not.
  47945. * @param defines the list of "defines" to update.
  47946. * @param scene defines the scene the material belongs to.
  47947. * @param engine defines the engine the material belongs to.
  47948. * @param disableBumpMap defines wether the material disables bump or not.
  47949. * @returns - boolean indicating that the submesh is ready or not.
  47950. */
  47951. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47952. /**
  47953. * Checks to see if a texture is used in the material.
  47954. * @param defines the list of "defines" to update.
  47955. * @param scene defines the scene to the material belongs to.
  47956. */
  47957. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47958. /**
  47959. * Binds the material data.
  47960. * @param uniformBuffer defines the Uniform buffer to fill in.
  47961. * @param scene defines the scene the material belongs to.
  47962. * @param engine defines the engine the material belongs to.
  47963. * @param disableBumpMap defines wether the material disables bump or not.
  47964. * @param isFrozen defines wether the material is frozen or not.
  47965. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47966. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47967. */
  47968. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47969. /**
  47970. * Checks to see if a texture is used in the material.
  47971. * @param texture - Base texture to use.
  47972. * @returns - Boolean specifying if a texture is used in the material.
  47973. */
  47974. hasTexture(texture: BaseTexture): boolean;
  47975. /**
  47976. * Returns an array of the actively used textures.
  47977. * @param activeTextures Array of BaseTextures
  47978. */
  47979. getActiveTextures(activeTextures: BaseTexture[]): void;
  47980. /**
  47981. * Returns the animatable textures.
  47982. * @param animatables Array of animatable textures.
  47983. */
  47984. getAnimatables(animatables: IAnimatable[]): void;
  47985. /**
  47986. * Disposes the resources of the material.
  47987. * @param forceDisposeTextures - Forces the disposal of all textures.
  47988. */
  47989. dispose(forceDisposeTextures?: boolean): void;
  47990. /**
  47991. * Get the current class name of the texture useful for serialization or dynamic coding.
  47992. * @returns "PBRClearCoatConfiguration"
  47993. */
  47994. getClassName(): string;
  47995. /**
  47996. * Add fallbacks to the effect fallbacks list.
  47997. * @param defines defines the Base texture to use.
  47998. * @param fallbacks defines the current fallback list.
  47999. * @param currentRank defines the current fallback rank.
  48000. * @returns the new fallback rank.
  48001. */
  48002. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48003. /**
  48004. * Add the required uniforms to the current list.
  48005. * @param uniforms defines the current uniform list.
  48006. */
  48007. static AddUniforms(uniforms: string[]): void;
  48008. /**
  48009. * Add the required samplers to the current list.
  48010. * @param samplers defines the current sampler list.
  48011. */
  48012. static AddSamplers(samplers: string[]): void;
  48013. /**
  48014. * Add the required uniforms to the current buffer.
  48015. * @param uniformBuffer defines the current uniform buffer.
  48016. */
  48017. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48018. /**
  48019. * Makes a duplicate of the current configuration into another one.
  48020. * @param clearCoatConfiguration define the config where to copy the info
  48021. */
  48022. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48023. /**
  48024. * Serializes this clear coat configuration.
  48025. * @returns - An object with the serialized config.
  48026. */
  48027. serialize(): any;
  48028. /**
  48029. * Parses a anisotropy Configuration from a serialized object.
  48030. * @param source - Serialized object.
  48031. * @param scene Defines the scene we are parsing for
  48032. * @param rootUrl Defines the rootUrl to load from
  48033. */
  48034. parse(source: any, scene: Scene, rootUrl: string): void;
  48035. }
  48036. }
  48037. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48038. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48039. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48041. import { Vector2 } from "babylonjs/Maths/math.vector";
  48042. import { Scene } from "babylonjs/scene";
  48043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48044. import { Nullable } from "babylonjs/types";
  48045. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48046. /**
  48047. * @hidden
  48048. */
  48049. export interface IMaterialAnisotropicDefines {
  48050. ANISOTROPIC: boolean;
  48051. ANISOTROPIC_TEXTURE: boolean;
  48052. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48053. MAINUV1: boolean;
  48054. _areTexturesDirty: boolean;
  48055. _needUVs: boolean;
  48056. }
  48057. /**
  48058. * Define the code related to the anisotropic parameters of the pbr material.
  48059. */
  48060. export class PBRAnisotropicConfiguration {
  48061. private _isEnabled;
  48062. /**
  48063. * Defines if the anisotropy is enabled in the material.
  48064. */
  48065. isEnabled: boolean;
  48066. /**
  48067. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48068. */
  48069. intensity: number;
  48070. /**
  48071. * Defines if the effect is along the tangents, bitangents or in between.
  48072. * By default, the effect is "strectching" the highlights along the tangents.
  48073. */
  48074. direction: Vector2;
  48075. private _texture;
  48076. /**
  48077. * Stores the anisotropy values in a texture.
  48078. * rg is direction (like normal from -1 to 1)
  48079. * b is a intensity
  48080. */
  48081. texture: Nullable<BaseTexture>;
  48082. /** @hidden */
  48083. private _internalMarkAllSubMeshesAsTexturesDirty;
  48084. /** @hidden */
  48085. _markAllSubMeshesAsTexturesDirty(): void;
  48086. /**
  48087. * Instantiate a new istance of anisotropy configuration.
  48088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48089. */
  48090. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48091. /**
  48092. * Specifies that the submesh is ready to be used.
  48093. * @param defines the list of "defines" to update.
  48094. * @param scene defines the scene the material belongs to.
  48095. * @returns - boolean indicating that the submesh is ready or not.
  48096. */
  48097. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48098. /**
  48099. * Checks to see if a texture is used in the material.
  48100. * @param defines the list of "defines" to update.
  48101. * @param mesh the mesh we are preparing the defines for.
  48102. * @param scene defines the scene the material belongs to.
  48103. */
  48104. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48105. /**
  48106. * Binds the material data.
  48107. * @param uniformBuffer defines the Uniform buffer to fill in.
  48108. * @param scene defines the scene the material belongs to.
  48109. * @param isFrozen defines wether the material is frozen or not.
  48110. */
  48111. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48112. /**
  48113. * Checks to see if a texture is used in the material.
  48114. * @param texture - Base texture to use.
  48115. * @returns - Boolean specifying if a texture is used in the material.
  48116. */
  48117. hasTexture(texture: BaseTexture): boolean;
  48118. /**
  48119. * Returns an array of the actively used textures.
  48120. * @param activeTextures Array of BaseTextures
  48121. */
  48122. getActiveTextures(activeTextures: BaseTexture[]): void;
  48123. /**
  48124. * Returns the animatable textures.
  48125. * @param animatables Array of animatable textures.
  48126. */
  48127. getAnimatables(animatables: IAnimatable[]): void;
  48128. /**
  48129. * Disposes the resources of the material.
  48130. * @param forceDisposeTextures - Forces the disposal of all textures.
  48131. */
  48132. dispose(forceDisposeTextures?: boolean): void;
  48133. /**
  48134. * Get the current class name of the texture useful for serialization or dynamic coding.
  48135. * @returns "PBRAnisotropicConfiguration"
  48136. */
  48137. getClassName(): string;
  48138. /**
  48139. * Add fallbacks to the effect fallbacks list.
  48140. * @param defines defines the Base texture to use.
  48141. * @param fallbacks defines the current fallback list.
  48142. * @param currentRank defines the current fallback rank.
  48143. * @returns the new fallback rank.
  48144. */
  48145. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48146. /**
  48147. * Add the required uniforms to the current list.
  48148. * @param uniforms defines the current uniform list.
  48149. */
  48150. static AddUniforms(uniforms: string[]): void;
  48151. /**
  48152. * Add the required uniforms to the current buffer.
  48153. * @param uniformBuffer defines the current uniform buffer.
  48154. */
  48155. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48156. /**
  48157. * Add the required samplers to the current list.
  48158. * @param samplers defines the current sampler list.
  48159. */
  48160. static AddSamplers(samplers: string[]): void;
  48161. /**
  48162. * Makes a duplicate of the current configuration into another one.
  48163. * @param anisotropicConfiguration define the config where to copy the info
  48164. */
  48165. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48166. /**
  48167. * Serializes this anisotropy configuration.
  48168. * @returns - An object with the serialized config.
  48169. */
  48170. serialize(): any;
  48171. /**
  48172. * Parses a anisotropy Configuration from a serialized object.
  48173. * @param source - Serialized object.
  48174. * @param scene Defines the scene we are parsing for
  48175. * @param rootUrl Defines the rootUrl to load from
  48176. */
  48177. parse(source: any, scene: Scene, rootUrl: string): void;
  48178. }
  48179. }
  48180. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48181. import { Scene } from "babylonjs/scene";
  48182. /**
  48183. * @hidden
  48184. */
  48185. export interface IMaterialBRDFDefines {
  48186. BRDF_V_HEIGHT_CORRELATED: boolean;
  48187. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48188. SPHERICAL_HARMONICS: boolean;
  48189. /** @hidden */
  48190. _areMiscDirty: boolean;
  48191. }
  48192. /**
  48193. * Define the code related to the BRDF parameters of the pbr material.
  48194. */
  48195. export class PBRBRDFConfiguration {
  48196. /**
  48197. * Default value used for the energy conservation.
  48198. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48199. */
  48200. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48201. /**
  48202. * Default value used for the Smith Visibility Height Correlated mode.
  48203. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48204. */
  48205. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48206. /**
  48207. * Default value used for the IBL diffuse part.
  48208. * This can help switching back to the polynomials mode globally which is a tiny bit
  48209. * less GPU intensive at the drawback of a lower quality.
  48210. */
  48211. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48212. private _useEnergyConservation;
  48213. /**
  48214. * Defines if the material uses energy conservation.
  48215. */
  48216. useEnergyConservation: boolean;
  48217. private _useSmithVisibilityHeightCorrelated;
  48218. /**
  48219. * LEGACY Mode set to false
  48220. * Defines if the material uses height smith correlated visibility term.
  48221. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48222. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48223. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48224. * Not relying on height correlated will also disable energy conservation.
  48225. */
  48226. useSmithVisibilityHeightCorrelated: boolean;
  48227. private _useSphericalHarmonics;
  48228. /**
  48229. * LEGACY Mode set to false
  48230. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48231. * diffuse part of the IBL.
  48232. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48233. * to the ground truth.
  48234. */
  48235. useSphericalHarmonics: boolean;
  48236. /** @hidden */
  48237. private _internalMarkAllSubMeshesAsMiscDirty;
  48238. /** @hidden */
  48239. _markAllSubMeshesAsMiscDirty(): void;
  48240. /**
  48241. * Instantiate a new istance of clear coat configuration.
  48242. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48243. */
  48244. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48245. /**
  48246. * Checks to see if a texture is used in the material.
  48247. * @param defines the list of "defines" to update.
  48248. */
  48249. prepareDefines(defines: IMaterialBRDFDefines): void;
  48250. /**
  48251. * Get the current class name of the texture useful for serialization or dynamic coding.
  48252. * @returns "PBRClearCoatConfiguration"
  48253. */
  48254. getClassName(): string;
  48255. /**
  48256. * Makes a duplicate of the current configuration into another one.
  48257. * @param brdfConfiguration define the config where to copy the info
  48258. */
  48259. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48260. /**
  48261. * Serializes this BRDF configuration.
  48262. * @returns - An object with the serialized config.
  48263. */
  48264. serialize(): any;
  48265. /**
  48266. * Parses a anisotropy Configuration from a serialized object.
  48267. * @param source - Serialized object.
  48268. * @param scene Defines the scene we are parsing for
  48269. * @param rootUrl Defines the rootUrl to load from
  48270. */
  48271. parse(source: any, scene: Scene, rootUrl: string): void;
  48272. }
  48273. }
  48274. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48275. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48276. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48277. import { Color3 } from "babylonjs/Maths/math.color";
  48278. import { Scene } from "babylonjs/scene";
  48279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48280. import { Nullable } from "babylonjs/types";
  48281. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48282. /**
  48283. * @hidden
  48284. */
  48285. export interface IMaterialSheenDefines {
  48286. SHEEN: boolean;
  48287. SHEEN_TEXTURE: boolean;
  48288. SHEEN_TEXTUREDIRECTUV: number;
  48289. SHEEN_LINKWITHALBEDO: boolean;
  48290. /** @hidden */
  48291. _areTexturesDirty: boolean;
  48292. }
  48293. /**
  48294. * Define the code related to the Sheen parameters of the pbr material.
  48295. */
  48296. export class PBRSheenConfiguration {
  48297. private _isEnabled;
  48298. /**
  48299. * Defines if the material uses sheen.
  48300. */
  48301. isEnabled: boolean;
  48302. private _linkSheenWithAlbedo;
  48303. /**
  48304. * Defines if the sheen is linked to the sheen color.
  48305. */
  48306. linkSheenWithAlbedo: boolean;
  48307. /**
  48308. * Defines the sheen intensity.
  48309. */
  48310. intensity: number;
  48311. /**
  48312. * Defines the sheen color.
  48313. */
  48314. color: Color3;
  48315. private _texture;
  48316. /**
  48317. * Stores the sheen tint values in a texture.
  48318. * rgb is tint
  48319. * a is a intensity
  48320. */
  48321. texture: Nullable<BaseTexture>;
  48322. /** @hidden */
  48323. private _internalMarkAllSubMeshesAsTexturesDirty;
  48324. /** @hidden */
  48325. _markAllSubMeshesAsTexturesDirty(): void;
  48326. /**
  48327. * Instantiate a new istance of clear coat configuration.
  48328. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48329. */
  48330. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48331. /**
  48332. * Specifies that the submesh is ready to be used.
  48333. * @param defines the list of "defines" to update.
  48334. * @param scene defines the scene the material belongs to.
  48335. * @returns - boolean indicating that the submesh is ready or not.
  48336. */
  48337. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48338. /**
  48339. * Checks to see if a texture is used in the material.
  48340. * @param defines the list of "defines" to update.
  48341. * @param scene defines the scene the material belongs to.
  48342. */
  48343. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48344. /**
  48345. * Binds the material data.
  48346. * @param uniformBuffer defines the Uniform buffer to fill in.
  48347. * @param scene defines the scene the material belongs to.
  48348. * @param isFrozen defines wether the material is frozen or not.
  48349. */
  48350. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48351. /**
  48352. * Checks to see if a texture is used in the material.
  48353. * @param texture - Base texture to use.
  48354. * @returns - Boolean specifying if a texture is used in the material.
  48355. */
  48356. hasTexture(texture: BaseTexture): boolean;
  48357. /**
  48358. * Returns an array of the actively used textures.
  48359. * @param activeTextures Array of BaseTextures
  48360. */
  48361. getActiveTextures(activeTextures: BaseTexture[]): void;
  48362. /**
  48363. * Returns the animatable textures.
  48364. * @param animatables Array of animatable textures.
  48365. */
  48366. getAnimatables(animatables: IAnimatable[]): void;
  48367. /**
  48368. * Disposes the resources of the material.
  48369. * @param forceDisposeTextures - Forces the disposal of all textures.
  48370. */
  48371. dispose(forceDisposeTextures?: boolean): void;
  48372. /**
  48373. * Get the current class name of the texture useful for serialization or dynamic coding.
  48374. * @returns "PBRSheenConfiguration"
  48375. */
  48376. getClassName(): string;
  48377. /**
  48378. * Add fallbacks to the effect fallbacks list.
  48379. * @param defines defines the Base texture to use.
  48380. * @param fallbacks defines the current fallback list.
  48381. * @param currentRank defines the current fallback rank.
  48382. * @returns the new fallback rank.
  48383. */
  48384. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48385. /**
  48386. * Add the required uniforms to the current list.
  48387. * @param uniforms defines the current uniform list.
  48388. */
  48389. static AddUniforms(uniforms: string[]): void;
  48390. /**
  48391. * Add the required uniforms to the current buffer.
  48392. * @param uniformBuffer defines the current uniform buffer.
  48393. */
  48394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48395. /**
  48396. * Add the required samplers to the current list.
  48397. * @param samplers defines the current sampler list.
  48398. */
  48399. static AddSamplers(samplers: string[]): void;
  48400. /**
  48401. * Makes a duplicate of the current configuration into another one.
  48402. * @param sheenConfiguration define the config where to copy the info
  48403. */
  48404. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48405. /**
  48406. * Serializes this BRDF configuration.
  48407. * @returns - An object with the serialized config.
  48408. */
  48409. serialize(): any;
  48410. /**
  48411. * Parses a anisotropy Configuration from a serialized object.
  48412. * @param source - Serialized object.
  48413. * @param scene Defines the scene we are parsing for
  48414. * @param rootUrl Defines the rootUrl to load from
  48415. */
  48416. parse(source: any, scene: Scene, rootUrl: string): void;
  48417. }
  48418. }
  48419. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48420. import { Nullable } from "babylonjs/types";
  48421. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48422. import { Color3 } from "babylonjs/Maths/math.color";
  48423. import { SmartArray } from "babylonjs/Misc/smartArray";
  48424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48426. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48427. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48428. import { Engine } from "babylonjs/Engines/engine";
  48429. import { Scene } from "babylonjs/scene";
  48430. /**
  48431. * @hidden
  48432. */
  48433. export interface IMaterialSubSurfaceDefines {
  48434. SUBSURFACE: boolean;
  48435. SS_REFRACTION: boolean;
  48436. SS_TRANSLUCENCY: boolean;
  48437. SS_SCATERRING: boolean;
  48438. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48439. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48440. SS_REFRACTIONMAP_3D: boolean;
  48441. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48442. SS_LODINREFRACTIONALPHA: boolean;
  48443. SS_GAMMAREFRACTION: boolean;
  48444. SS_RGBDREFRACTION: boolean;
  48445. SS_LINEARSPECULARREFRACTION: boolean;
  48446. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48447. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48448. /** @hidden */
  48449. _areTexturesDirty: boolean;
  48450. }
  48451. /**
  48452. * Define the code related to the sub surface parameters of the pbr material.
  48453. */
  48454. export class PBRSubSurfaceConfiguration {
  48455. private _isRefractionEnabled;
  48456. /**
  48457. * Defines if the refraction is enabled in the material.
  48458. */
  48459. isRefractionEnabled: boolean;
  48460. private _isTranslucencyEnabled;
  48461. /**
  48462. * Defines if the translucency is enabled in the material.
  48463. */
  48464. isTranslucencyEnabled: boolean;
  48465. private _isScatteringEnabled;
  48466. /**
  48467. * Defines the refraction intensity of the material.
  48468. * The refraction when enabled replaces the Diffuse part of the material.
  48469. * The intensity helps transitionning between diffuse and refraction.
  48470. */
  48471. refractionIntensity: number;
  48472. /**
  48473. * Defines the translucency intensity of the material.
  48474. * When translucency has been enabled, this defines how much of the "translucency"
  48475. * is addded to the diffuse part of the material.
  48476. */
  48477. translucencyIntensity: number;
  48478. /**
  48479. * Defines the scattering intensity of the material.
  48480. * When scattering has been enabled, this defines how much of the "scattered light"
  48481. * is addded to the diffuse part of the material.
  48482. */
  48483. scatteringIntensity: number;
  48484. private _thicknessTexture;
  48485. /**
  48486. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48487. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48488. * 0 would mean minimumThickness
  48489. * 1 would mean maximumThickness
  48490. * The other channels might be use as a mask to vary the different effects intensity.
  48491. */
  48492. thicknessTexture: Nullable<BaseTexture>;
  48493. private _refractionTexture;
  48494. /**
  48495. * Defines the texture to use for refraction.
  48496. */
  48497. refractionTexture: Nullable<BaseTexture>;
  48498. private _indexOfRefraction;
  48499. /**
  48500. * Defines the index of refraction used in the material.
  48501. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48502. */
  48503. indexOfRefraction: number;
  48504. private _invertRefractionY;
  48505. /**
  48506. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48507. */
  48508. invertRefractionY: boolean;
  48509. private _linkRefractionWithTransparency;
  48510. /**
  48511. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48512. * Materials half opaque for instance using refraction could benefit from this control.
  48513. */
  48514. linkRefractionWithTransparency: boolean;
  48515. /**
  48516. * Defines the minimum thickness stored in the thickness map.
  48517. * If no thickness map is defined, this value will be used to simulate thickness.
  48518. */
  48519. minimumThickness: number;
  48520. /**
  48521. * Defines the maximum thickness stored in the thickness map.
  48522. */
  48523. maximumThickness: number;
  48524. /**
  48525. * Defines the volume tint of the material.
  48526. * This is used for both translucency and scattering.
  48527. */
  48528. tintColor: Color3;
  48529. /**
  48530. * Defines the distance at which the tint color should be found in the media.
  48531. * This is used for refraction only.
  48532. */
  48533. tintColorAtDistance: number;
  48534. /**
  48535. * Defines how far each channel transmit through the media.
  48536. * It is defined as a color to simplify it selection.
  48537. */
  48538. diffusionDistance: Color3;
  48539. private _useMaskFromThicknessTexture;
  48540. /**
  48541. * Stores the intensity of the different subsurface effects in the thickness texture.
  48542. * * the green channel is the translucency intensity.
  48543. * * the blue channel is the scattering intensity.
  48544. * * the alpha channel is the refraction intensity.
  48545. */
  48546. useMaskFromThicknessTexture: boolean;
  48547. /** @hidden */
  48548. private _internalMarkAllSubMeshesAsTexturesDirty;
  48549. /** @hidden */
  48550. _markAllSubMeshesAsTexturesDirty(): void;
  48551. /**
  48552. * Instantiate a new istance of sub surface configuration.
  48553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48554. */
  48555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48556. /**
  48557. * Gets wehter the submesh is ready to be used or not.
  48558. * @param defines the list of "defines" to update.
  48559. * @param scene defines the scene the material belongs to.
  48560. * @returns - boolean indicating that the submesh is ready or not.
  48561. */
  48562. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48563. /**
  48564. * Checks to see if a texture is used in the material.
  48565. * @param defines the list of "defines" to update.
  48566. * @param scene defines the scene to the material belongs to.
  48567. */
  48568. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48569. /**
  48570. * Binds the material data.
  48571. * @param uniformBuffer defines the Uniform buffer to fill in.
  48572. * @param scene defines the scene the material belongs to.
  48573. * @param engine defines the engine the material belongs to.
  48574. * @param isFrozen defines wether the material is frozen or not.
  48575. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48576. */
  48577. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48578. /**
  48579. * Unbinds the material from the mesh.
  48580. * @param activeEffect defines the effect that should be unbound from.
  48581. * @returns true if unbound, otherwise false
  48582. */
  48583. unbind(activeEffect: Effect): boolean;
  48584. /**
  48585. * Returns the texture used for refraction or null if none is used.
  48586. * @param scene defines the scene the material belongs to.
  48587. * @returns - Refraction texture if present. If no refraction texture and refraction
  48588. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48589. */
  48590. private _getRefractionTexture;
  48591. /**
  48592. * Returns true if alpha blending should be disabled.
  48593. */
  48594. readonly disableAlphaBlending: boolean;
  48595. /**
  48596. * Fills the list of render target textures.
  48597. * @param renderTargets the list of render targets to update
  48598. */
  48599. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48600. /**
  48601. * Checks to see if a texture is used in the material.
  48602. * @param texture - Base texture to use.
  48603. * @returns - Boolean specifying if a texture is used in the material.
  48604. */
  48605. hasTexture(texture: BaseTexture): boolean;
  48606. /**
  48607. * Gets a boolean indicating that current material needs to register RTT
  48608. * @returns true if this uses a render target otherwise false.
  48609. */
  48610. hasRenderTargetTextures(): boolean;
  48611. /**
  48612. * Returns an array of the actively used textures.
  48613. * @param activeTextures Array of BaseTextures
  48614. */
  48615. getActiveTextures(activeTextures: BaseTexture[]): void;
  48616. /**
  48617. * Returns the animatable textures.
  48618. * @param animatables Array of animatable textures.
  48619. */
  48620. getAnimatables(animatables: IAnimatable[]): void;
  48621. /**
  48622. * Disposes the resources of the material.
  48623. * @param forceDisposeTextures - Forces the disposal of all textures.
  48624. */
  48625. dispose(forceDisposeTextures?: boolean): void;
  48626. /**
  48627. * Get the current class name of the texture useful for serialization or dynamic coding.
  48628. * @returns "PBRSubSurfaceConfiguration"
  48629. */
  48630. getClassName(): string;
  48631. /**
  48632. * Add fallbacks to the effect fallbacks list.
  48633. * @param defines defines the Base texture to use.
  48634. * @param fallbacks defines the current fallback list.
  48635. * @param currentRank defines the current fallback rank.
  48636. * @returns the new fallback rank.
  48637. */
  48638. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48639. /**
  48640. * Add the required uniforms to the current list.
  48641. * @param uniforms defines the current uniform list.
  48642. */
  48643. static AddUniforms(uniforms: string[]): void;
  48644. /**
  48645. * Add the required samplers to the current list.
  48646. * @param samplers defines the current sampler list.
  48647. */
  48648. static AddSamplers(samplers: string[]): void;
  48649. /**
  48650. * Add the required uniforms to the current buffer.
  48651. * @param uniformBuffer defines the current uniform buffer.
  48652. */
  48653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48654. /**
  48655. * Makes a duplicate of the current configuration into another one.
  48656. * @param configuration define the config where to copy the info
  48657. */
  48658. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48659. /**
  48660. * Serializes this Sub Surface configuration.
  48661. * @returns - An object with the serialized config.
  48662. */
  48663. serialize(): any;
  48664. /**
  48665. * Parses a anisotropy Configuration from a serialized object.
  48666. * @param source - Serialized object.
  48667. * @param scene Defines the scene we are parsing for
  48668. * @param rootUrl Defines the rootUrl to load from
  48669. */
  48670. parse(source: any, scene: Scene, rootUrl: string): void;
  48671. }
  48672. }
  48673. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48674. /** @hidden */
  48675. export var pbrFragmentDeclaration: {
  48676. name: string;
  48677. shader: string;
  48678. };
  48679. }
  48680. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48681. /** @hidden */
  48682. export var pbrUboDeclaration: {
  48683. name: string;
  48684. shader: string;
  48685. };
  48686. }
  48687. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48688. /** @hidden */
  48689. export var pbrFragmentExtraDeclaration: {
  48690. name: string;
  48691. shader: string;
  48692. };
  48693. }
  48694. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48695. /** @hidden */
  48696. export var pbrFragmentSamplersDeclaration: {
  48697. name: string;
  48698. shader: string;
  48699. };
  48700. }
  48701. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48702. /** @hidden */
  48703. export var pbrHelperFunctions: {
  48704. name: string;
  48705. shader: string;
  48706. };
  48707. }
  48708. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48709. /** @hidden */
  48710. export var harmonicsFunctions: {
  48711. name: string;
  48712. shader: string;
  48713. };
  48714. }
  48715. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48716. /** @hidden */
  48717. export var pbrDirectLightingSetupFunctions: {
  48718. name: string;
  48719. shader: string;
  48720. };
  48721. }
  48722. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48723. /** @hidden */
  48724. export var pbrDirectLightingFalloffFunctions: {
  48725. name: string;
  48726. shader: string;
  48727. };
  48728. }
  48729. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48730. /** @hidden */
  48731. export var pbrBRDFFunctions: {
  48732. name: string;
  48733. shader: string;
  48734. };
  48735. }
  48736. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48737. /** @hidden */
  48738. export var pbrDirectLightingFunctions: {
  48739. name: string;
  48740. shader: string;
  48741. };
  48742. }
  48743. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48744. /** @hidden */
  48745. export var pbrIBLFunctions: {
  48746. name: string;
  48747. shader: string;
  48748. };
  48749. }
  48750. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48751. /** @hidden */
  48752. export var pbrDebug: {
  48753. name: string;
  48754. shader: string;
  48755. };
  48756. }
  48757. declare module "babylonjs/Shaders/pbr.fragment" {
  48758. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48759. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48760. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48761. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48762. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48763. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48764. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48765. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48766. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48767. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48769. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48770. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48771. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48772. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48773. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48774. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48775. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48776. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48777. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48778. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48779. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48780. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48781. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48782. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48783. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48784. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48785. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48786. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48787. /** @hidden */
  48788. export var pbrPixelShader: {
  48789. name: string;
  48790. shader: string;
  48791. };
  48792. }
  48793. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48794. /** @hidden */
  48795. export var pbrVertexDeclaration: {
  48796. name: string;
  48797. shader: string;
  48798. };
  48799. }
  48800. declare module "babylonjs/Shaders/pbr.vertex" {
  48801. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48802. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48803. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48804. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48805. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48806. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48807. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48808. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48809. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48810. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48816. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48817. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48818. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48819. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48820. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48821. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48822. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48823. /** @hidden */
  48824. export var pbrVertexShader: {
  48825. name: string;
  48826. shader: string;
  48827. };
  48828. }
  48829. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48830. import { Nullable } from "babylonjs/types";
  48831. import { Scene } from "babylonjs/scene";
  48832. import { Matrix } from "babylonjs/Maths/math.vector";
  48833. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48835. import { Mesh } from "babylonjs/Meshes/mesh";
  48836. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48837. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48838. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48839. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48840. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48841. import { Color3 } from "babylonjs/Maths/math.color";
  48842. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48843. import { Material } from "babylonjs/Materials/material";
  48844. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48845. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48848. import "babylonjs/Shaders/pbr.fragment";
  48849. import "babylonjs/Shaders/pbr.vertex";
  48850. /**
  48851. * Manages the defines for the PBR Material.
  48852. * @hidden
  48853. */
  48854. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48855. PBR: boolean;
  48856. MAINUV1: boolean;
  48857. MAINUV2: boolean;
  48858. UV1: boolean;
  48859. UV2: boolean;
  48860. ALBEDO: boolean;
  48861. ALBEDODIRECTUV: number;
  48862. VERTEXCOLOR: boolean;
  48863. AMBIENT: boolean;
  48864. AMBIENTDIRECTUV: number;
  48865. AMBIENTINGRAYSCALE: boolean;
  48866. OPACITY: boolean;
  48867. VERTEXALPHA: boolean;
  48868. OPACITYDIRECTUV: number;
  48869. OPACITYRGB: boolean;
  48870. ALPHATEST: boolean;
  48871. DEPTHPREPASS: boolean;
  48872. ALPHABLEND: boolean;
  48873. ALPHAFROMALBEDO: boolean;
  48874. ALPHATESTVALUE: string;
  48875. SPECULAROVERALPHA: boolean;
  48876. RADIANCEOVERALPHA: boolean;
  48877. ALPHAFRESNEL: boolean;
  48878. LINEARALPHAFRESNEL: boolean;
  48879. PREMULTIPLYALPHA: boolean;
  48880. EMISSIVE: boolean;
  48881. EMISSIVEDIRECTUV: number;
  48882. REFLECTIVITY: boolean;
  48883. REFLECTIVITYDIRECTUV: number;
  48884. SPECULARTERM: boolean;
  48885. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48886. MICROSURFACEAUTOMATIC: boolean;
  48887. LODBASEDMICROSFURACE: boolean;
  48888. MICROSURFACEMAP: boolean;
  48889. MICROSURFACEMAPDIRECTUV: number;
  48890. METALLICWORKFLOW: boolean;
  48891. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48892. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48893. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48894. AOSTOREINMETALMAPRED: boolean;
  48895. ENVIRONMENTBRDF: boolean;
  48896. ENVIRONMENTBRDF_RGBD: boolean;
  48897. NORMAL: boolean;
  48898. TANGENT: boolean;
  48899. BUMP: boolean;
  48900. BUMPDIRECTUV: number;
  48901. OBJECTSPACE_NORMALMAP: boolean;
  48902. PARALLAX: boolean;
  48903. PARALLAXOCCLUSION: boolean;
  48904. NORMALXYSCALE: boolean;
  48905. LIGHTMAP: boolean;
  48906. LIGHTMAPDIRECTUV: number;
  48907. USELIGHTMAPASSHADOWMAP: boolean;
  48908. GAMMALIGHTMAP: boolean;
  48909. REFLECTION: boolean;
  48910. REFLECTIONMAP_3D: boolean;
  48911. REFLECTIONMAP_SPHERICAL: boolean;
  48912. REFLECTIONMAP_PLANAR: boolean;
  48913. REFLECTIONMAP_CUBIC: boolean;
  48914. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48915. REFLECTIONMAP_PROJECTION: boolean;
  48916. REFLECTIONMAP_SKYBOX: boolean;
  48917. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48918. REFLECTIONMAP_EXPLICIT: boolean;
  48919. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48920. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48921. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48922. INVERTCUBICMAP: boolean;
  48923. USESPHERICALFROMREFLECTIONMAP: boolean;
  48924. USEIRRADIANCEMAP: boolean;
  48925. SPHERICAL_HARMONICS: boolean;
  48926. USESPHERICALINVERTEX: boolean;
  48927. REFLECTIONMAP_OPPOSITEZ: boolean;
  48928. LODINREFLECTIONALPHA: boolean;
  48929. GAMMAREFLECTION: boolean;
  48930. RGBDREFLECTION: boolean;
  48931. LINEARSPECULARREFLECTION: boolean;
  48932. RADIANCEOCCLUSION: boolean;
  48933. HORIZONOCCLUSION: boolean;
  48934. INSTANCES: boolean;
  48935. NUM_BONE_INFLUENCERS: number;
  48936. BonesPerMesh: number;
  48937. BONETEXTURE: boolean;
  48938. NONUNIFORMSCALING: boolean;
  48939. MORPHTARGETS: boolean;
  48940. MORPHTARGETS_NORMAL: boolean;
  48941. MORPHTARGETS_TANGENT: boolean;
  48942. MORPHTARGETS_UV: boolean;
  48943. NUM_MORPH_INFLUENCERS: number;
  48944. IMAGEPROCESSING: boolean;
  48945. VIGNETTE: boolean;
  48946. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48947. VIGNETTEBLENDMODEOPAQUE: boolean;
  48948. TONEMAPPING: boolean;
  48949. TONEMAPPING_ACES: boolean;
  48950. CONTRAST: boolean;
  48951. COLORCURVES: boolean;
  48952. COLORGRADING: boolean;
  48953. COLORGRADING3D: boolean;
  48954. SAMPLER3DGREENDEPTH: boolean;
  48955. SAMPLER3DBGRMAP: boolean;
  48956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48957. EXPOSURE: boolean;
  48958. MULTIVIEW: boolean;
  48959. USEPHYSICALLIGHTFALLOFF: boolean;
  48960. USEGLTFLIGHTFALLOFF: boolean;
  48961. TWOSIDEDLIGHTING: boolean;
  48962. SHADOWFLOAT: boolean;
  48963. CLIPPLANE: boolean;
  48964. CLIPPLANE2: boolean;
  48965. CLIPPLANE3: boolean;
  48966. CLIPPLANE4: boolean;
  48967. POINTSIZE: boolean;
  48968. FOG: boolean;
  48969. LOGARITHMICDEPTH: boolean;
  48970. FORCENORMALFORWARD: boolean;
  48971. SPECULARAA: boolean;
  48972. CLEARCOAT: boolean;
  48973. CLEARCOAT_DEFAULTIOR: boolean;
  48974. CLEARCOAT_TEXTURE: boolean;
  48975. CLEARCOAT_TEXTUREDIRECTUV: number;
  48976. CLEARCOAT_BUMP: boolean;
  48977. CLEARCOAT_BUMPDIRECTUV: number;
  48978. CLEARCOAT_TINT: boolean;
  48979. CLEARCOAT_TINT_TEXTURE: boolean;
  48980. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48981. ANISOTROPIC: boolean;
  48982. ANISOTROPIC_TEXTURE: boolean;
  48983. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48984. BRDF_V_HEIGHT_CORRELATED: boolean;
  48985. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48986. SHEEN: boolean;
  48987. SHEEN_TEXTURE: boolean;
  48988. SHEEN_TEXTUREDIRECTUV: number;
  48989. SHEEN_LINKWITHALBEDO: boolean;
  48990. SUBSURFACE: boolean;
  48991. SS_REFRACTION: boolean;
  48992. SS_TRANSLUCENCY: boolean;
  48993. SS_SCATERRING: boolean;
  48994. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48995. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48996. SS_REFRACTIONMAP_3D: boolean;
  48997. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48998. SS_LODINREFRACTIONALPHA: boolean;
  48999. SS_GAMMAREFRACTION: boolean;
  49000. SS_RGBDREFRACTION: boolean;
  49001. SS_LINEARSPECULARREFRACTION: boolean;
  49002. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49003. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49004. UNLIT: boolean;
  49005. DEBUGMODE: number;
  49006. /**
  49007. * Initializes the PBR Material defines.
  49008. */
  49009. constructor();
  49010. /**
  49011. * Resets the PBR Material defines.
  49012. */
  49013. reset(): void;
  49014. }
  49015. /**
  49016. * The Physically based material base class of BJS.
  49017. *
  49018. * This offers the main features of a standard PBR material.
  49019. * For more information, please refer to the documentation :
  49020. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49021. */
  49022. export abstract class PBRBaseMaterial extends PushMaterial {
  49023. /**
  49024. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49025. */
  49026. static readonly PBRMATERIAL_OPAQUE: number;
  49027. /**
  49028. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49029. */
  49030. static readonly PBRMATERIAL_ALPHATEST: number;
  49031. /**
  49032. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49033. */
  49034. static readonly PBRMATERIAL_ALPHABLEND: number;
  49035. /**
  49036. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49037. * They are also discarded below the alpha cutoff threshold to improve performances.
  49038. */
  49039. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49040. /**
  49041. * Defines the default value of how much AO map is occluding the analytical lights
  49042. * (point spot...).
  49043. */
  49044. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49045. /**
  49046. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49047. */
  49048. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49049. /**
  49050. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49051. * to enhance interoperability with other engines.
  49052. */
  49053. static readonly LIGHTFALLOFF_GLTF: number;
  49054. /**
  49055. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49056. * to enhance interoperability with other materials.
  49057. */
  49058. static readonly LIGHTFALLOFF_STANDARD: number;
  49059. /**
  49060. * Intensity of the direct lights e.g. the four lights available in your scene.
  49061. * This impacts both the direct diffuse and specular highlights.
  49062. */
  49063. protected _directIntensity: number;
  49064. /**
  49065. * Intensity of the emissive part of the material.
  49066. * This helps controlling the emissive effect without modifying the emissive color.
  49067. */
  49068. protected _emissiveIntensity: number;
  49069. /**
  49070. * Intensity of the environment e.g. how much the environment will light the object
  49071. * either through harmonics for rough material or through the refelction for shiny ones.
  49072. */
  49073. protected _environmentIntensity: number;
  49074. /**
  49075. * This is a special control allowing the reduction of the specular highlights coming from the
  49076. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49077. */
  49078. protected _specularIntensity: number;
  49079. /**
  49080. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49081. */
  49082. private _lightingInfos;
  49083. /**
  49084. * Debug Control allowing disabling the bump map on this material.
  49085. */
  49086. protected _disableBumpMap: boolean;
  49087. /**
  49088. * AKA Diffuse Texture in standard nomenclature.
  49089. */
  49090. protected _albedoTexture: Nullable<BaseTexture>;
  49091. /**
  49092. * AKA Occlusion Texture in other nomenclature.
  49093. */
  49094. protected _ambientTexture: Nullable<BaseTexture>;
  49095. /**
  49096. * AKA Occlusion Texture Intensity in other nomenclature.
  49097. */
  49098. protected _ambientTextureStrength: number;
  49099. /**
  49100. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49101. * 1 means it completely occludes it
  49102. * 0 mean it has no impact
  49103. */
  49104. protected _ambientTextureImpactOnAnalyticalLights: number;
  49105. /**
  49106. * Stores the alpha values in a texture.
  49107. */
  49108. protected _opacityTexture: Nullable<BaseTexture>;
  49109. /**
  49110. * Stores the reflection values in a texture.
  49111. */
  49112. protected _reflectionTexture: Nullable<BaseTexture>;
  49113. /**
  49114. * Stores the emissive values in a texture.
  49115. */
  49116. protected _emissiveTexture: Nullable<BaseTexture>;
  49117. /**
  49118. * AKA Specular texture in other nomenclature.
  49119. */
  49120. protected _reflectivityTexture: Nullable<BaseTexture>;
  49121. /**
  49122. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49123. */
  49124. protected _metallicTexture: Nullable<BaseTexture>;
  49125. /**
  49126. * Specifies the metallic scalar of the metallic/roughness workflow.
  49127. * Can also be used to scale the metalness values of the metallic texture.
  49128. */
  49129. protected _metallic: Nullable<number>;
  49130. /**
  49131. * Specifies the roughness scalar of the metallic/roughness workflow.
  49132. * Can also be used to scale the roughness values of the metallic texture.
  49133. */
  49134. protected _roughness: Nullable<number>;
  49135. /**
  49136. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49137. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49138. */
  49139. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49140. /**
  49141. * Stores surface normal data used to displace a mesh in a texture.
  49142. */
  49143. protected _bumpTexture: Nullable<BaseTexture>;
  49144. /**
  49145. * Stores the pre-calculated light information of a mesh in a texture.
  49146. */
  49147. protected _lightmapTexture: Nullable<BaseTexture>;
  49148. /**
  49149. * The color of a material in ambient lighting.
  49150. */
  49151. protected _ambientColor: Color3;
  49152. /**
  49153. * AKA Diffuse Color in other nomenclature.
  49154. */
  49155. protected _albedoColor: Color3;
  49156. /**
  49157. * AKA Specular Color in other nomenclature.
  49158. */
  49159. protected _reflectivityColor: Color3;
  49160. /**
  49161. * The color applied when light is reflected from a material.
  49162. */
  49163. protected _reflectionColor: Color3;
  49164. /**
  49165. * The color applied when light is emitted from a material.
  49166. */
  49167. protected _emissiveColor: Color3;
  49168. /**
  49169. * AKA Glossiness in other nomenclature.
  49170. */
  49171. protected _microSurface: number;
  49172. /**
  49173. * Specifies that the material will use the light map as a show map.
  49174. */
  49175. protected _useLightmapAsShadowmap: boolean;
  49176. /**
  49177. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49178. * makes the reflect vector face the model (under horizon).
  49179. */
  49180. protected _useHorizonOcclusion: boolean;
  49181. /**
  49182. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49183. * too much the area relying on ambient texture to define their ambient occlusion.
  49184. */
  49185. protected _useRadianceOcclusion: boolean;
  49186. /**
  49187. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49188. */
  49189. protected _useAlphaFromAlbedoTexture: boolean;
  49190. /**
  49191. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49192. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49193. */
  49194. protected _useSpecularOverAlpha: boolean;
  49195. /**
  49196. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49197. */
  49198. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49199. /**
  49200. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49201. */
  49202. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49203. /**
  49204. * Specifies if the metallic texture contains the roughness information in its green channel.
  49205. */
  49206. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49207. /**
  49208. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49209. */
  49210. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49211. /**
  49212. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49213. */
  49214. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49215. /**
  49216. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49217. */
  49218. protected _useAmbientInGrayScale: boolean;
  49219. /**
  49220. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49221. * The material will try to infer what glossiness each pixel should be.
  49222. */
  49223. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49224. /**
  49225. * Defines the falloff type used in this material.
  49226. * It by default is Physical.
  49227. */
  49228. protected _lightFalloff: number;
  49229. /**
  49230. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49231. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49232. */
  49233. protected _useRadianceOverAlpha: boolean;
  49234. /**
  49235. * Allows using an object space normal map (instead of tangent space).
  49236. */
  49237. protected _useObjectSpaceNormalMap: boolean;
  49238. /**
  49239. * Allows using the bump map in parallax mode.
  49240. */
  49241. protected _useParallax: boolean;
  49242. /**
  49243. * Allows using the bump map in parallax occlusion mode.
  49244. */
  49245. protected _useParallaxOcclusion: boolean;
  49246. /**
  49247. * Controls the scale bias of the parallax mode.
  49248. */
  49249. protected _parallaxScaleBias: number;
  49250. /**
  49251. * If sets to true, disables all the lights affecting the material.
  49252. */
  49253. protected _disableLighting: boolean;
  49254. /**
  49255. * Number of Simultaneous lights allowed on the material.
  49256. */
  49257. protected _maxSimultaneousLights: number;
  49258. /**
  49259. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49260. */
  49261. protected _invertNormalMapX: boolean;
  49262. /**
  49263. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49264. */
  49265. protected _invertNormalMapY: boolean;
  49266. /**
  49267. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49268. */
  49269. protected _twoSidedLighting: boolean;
  49270. /**
  49271. * Defines the alpha limits in alpha test mode.
  49272. */
  49273. protected _alphaCutOff: number;
  49274. /**
  49275. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49276. */
  49277. protected _forceAlphaTest: boolean;
  49278. /**
  49279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49280. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49281. */
  49282. protected _useAlphaFresnel: boolean;
  49283. /**
  49284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49285. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49286. */
  49287. protected _useLinearAlphaFresnel: boolean;
  49288. /**
  49289. * The transparency mode of the material.
  49290. */
  49291. protected _transparencyMode: Nullable<number>;
  49292. /**
  49293. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49294. * from cos thetav and roughness:
  49295. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49296. */
  49297. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49298. /**
  49299. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49300. */
  49301. protected _forceIrradianceInFragment: boolean;
  49302. /**
  49303. * Force normal to face away from face.
  49304. */
  49305. protected _forceNormalForward: boolean;
  49306. /**
  49307. * Enables specular anti aliasing in the PBR shader.
  49308. * It will both interacts on the Geometry for analytical and IBL lighting.
  49309. * It also prefilter the roughness map based on the bump values.
  49310. */
  49311. protected _enableSpecularAntiAliasing: boolean;
  49312. /**
  49313. * Default configuration related to image processing available in the PBR Material.
  49314. */
  49315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49316. /**
  49317. * Keep track of the image processing observer to allow dispose and replace.
  49318. */
  49319. private _imageProcessingObserver;
  49320. /**
  49321. * Attaches a new image processing configuration to the PBR Material.
  49322. * @param configuration
  49323. */
  49324. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49325. /**
  49326. * Stores the available render targets.
  49327. */
  49328. private _renderTargets;
  49329. /**
  49330. * Sets the global ambient color for the material used in lighting calculations.
  49331. */
  49332. private _globalAmbientColor;
  49333. /**
  49334. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49335. */
  49336. private _useLogarithmicDepth;
  49337. /**
  49338. * If set to true, no lighting calculations will be applied.
  49339. */
  49340. private _unlit;
  49341. private _debugMode;
  49342. /**
  49343. * @hidden
  49344. * This is reserved for the inspector.
  49345. * Defines the material debug mode.
  49346. * It helps seeing only some components of the material while troubleshooting.
  49347. */
  49348. debugMode: number;
  49349. /**
  49350. * @hidden
  49351. * This is reserved for the inspector.
  49352. * Specify from where on screen the debug mode should start.
  49353. * The value goes from -1 (full screen) to 1 (not visible)
  49354. * It helps with side by side comparison against the final render
  49355. * This defaults to -1
  49356. */
  49357. private debugLimit;
  49358. /**
  49359. * @hidden
  49360. * This is reserved for the inspector.
  49361. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49362. * You can use the factor to better multiply the final value.
  49363. */
  49364. private debugFactor;
  49365. /**
  49366. * Defines the clear coat layer parameters for the material.
  49367. */
  49368. readonly clearCoat: PBRClearCoatConfiguration;
  49369. /**
  49370. * Defines the anisotropic parameters for the material.
  49371. */
  49372. readonly anisotropy: PBRAnisotropicConfiguration;
  49373. /**
  49374. * Defines the BRDF parameters for the material.
  49375. */
  49376. readonly brdf: PBRBRDFConfiguration;
  49377. /**
  49378. * Defines the Sheen parameters for the material.
  49379. */
  49380. readonly sheen: PBRSheenConfiguration;
  49381. /**
  49382. * Defines the SubSurface parameters for the material.
  49383. */
  49384. readonly subSurface: PBRSubSurfaceConfiguration;
  49385. /**
  49386. * Custom callback helping to override the default shader used in the material.
  49387. */
  49388. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49389. protected _rebuildInParallel: boolean;
  49390. /**
  49391. * Instantiates a new PBRMaterial instance.
  49392. *
  49393. * @param name The material name
  49394. * @param scene The scene the material will be use in.
  49395. */
  49396. constructor(name: string, scene: Scene);
  49397. /**
  49398. * Gets a boolean indicating that current material needs to register RTT
  49399. */
  49400. readonly hasRenderTargetTextures: boolean;
  49401. /**
  49402. * Gets the name of the material class.
  49403. */
  49404. getClassName(): string;
  49405. /**
  49406. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49407. */
  49408. /**
  49409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49410. */
  49411. useLogarithmicDepth: boolean;
  49412. /**
  49413. * Gets the current transparency mode.
  49414. */
  49415. /**
  49416. * Sets the transparency mode of the material.
  49417. *
  49418. * | Value | Type | Description |
  49419. * | ----- | ----------------------------------- | ----------- |
  49420. * | 0 | OPAQUE | |
  49421. * | 1 | ALPHATEST | |
  49422. * | 2 | ALPHABLEND | |
  49423. * | 3 | ALPHATESTANDBLEND | |
  49424. *
  49425. */
  49426. transparencyMode: Nullable<number>;
  49427. /**
  49428. * Returns true if alpha blending should be disabled.
  49429. */
  49430. private readonly _disableAlphaBlending;
  49431. /**
  49432. * Specifies whether or not this material should be rendered in alpha blend mode.
  49433. */
  49434. needAlphaBlending(): boolean;
  49435. /**
  49436. * Specifies if the mesh will require alpha blending.
  49437. * @param mesh - BJS mesh.
  49438. */
  49439. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49440. /**
  49441. * Specifies whether or not this material should be rendered in alpha test mode.
  49442. */
  49443. needAlphaTesting(): boolean;
  49444. /**
  49445. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49446. */
  49447. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49448. /**
  49449. * Gets the texture used for the alpha test.
  49450. */
  49451. getAlphaTestTexture(): Nullable<BaseTexture>;
  49452. /**
  49453. * Specifies that the submesh is ready to be used.
  49454. * @param mesh - BJS mesh.
  49455. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49456. * @param useInstances - Specifies that instances should be used.
  49457. * @returns - boolean indicating that the submesh is ready or not.
  49458. */
  49459. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49460. /**
  49461. * Specifies if the material uses metallic roughness workflow.
  49462. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49463. */
  49464. isMetallicWorkflow(): boolean;
  49465. private _prepareEffect;
  49466. private _prepareDefines;
  49467. /**
  49468. * Force shader compilation
  49469. */
  49470. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49471. clipPlane: boolean;
  49472. }>): void;
  49473. /**
  49474. * Initializes the uniform buffer layout for the shader.
  49475. */
  49476. buildUniformLayout(): void;
  49477. /**
  49478. * Unbinds the material from the mesh
  49479. */
  49480. unbind(): void;
  49481. /**
  49482. * Binds the submesh data.
  49483. * @param world - The world matrix.
  49484. * @param mesh - The BJS mesh.
  49485. * @param subMesh - A submesh of the BJS mesh.
  49486. */
  49487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49488. /**
  49489. * Returns the animatable textures.
  49490. * @returns - Array of animatable textures.
  49491. */
  49492. getAnimatables(): IAnimatable[];
  49493. /**
  49494. * Returns the texture used for reflections.
  49495. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49496. */
  49497. private _getReflectionTexture;
  49498. /**
  49499. * Returns an array of the actively used textures.
  49500. * @returns - Array of BaseTextures
  49501. */
  49502. getActiveTextures(): BaseTexture[];
  49503. /**
  49504. * Checks to see if a texture is used in the material.
  49505. * @param texture - Base texture to use.
  49506. * @returns - Boolean specifying if a texture is used in the material.
  49507. */
  49508. hasTexture(texture: BaseTexture): boolean;
  49509. /**
  49510. * Disposes the resources of the material.
  49511. * @param forceDisposeEffect - Forces the disposal of effects.
  49512. * @param forceDisposeTextures - Forces the disposal of all textures.
  49513. */
  49514. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49515. }
  49516. }
  49517. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49518. import { Nullable } from "babylonjs/types";
  49519. import { Scene } from "babylonjs/scene";
  49520. import { Color3 } from "babylonjs/Maths/math.color";
  49521. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49522. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49523. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49524. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49525. /**
  49526. * The Physically based material of BJS.
  49527. *
  49528. * This offers the main features of a standard PBR material.
  49529. * For more information, please refer to the documentation :
  49530. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49531. */
  49532. export class PBRMaterial extends PBRBaseMaterial {
  49533. /**
  49534. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49535. */
  49536. static readonly PBRMATERIAL_OPAQUE: number;
  49537. /**
  49538. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49539. */
  49540. static readonly PBRMATERIAL_ALPHATEST: number;
  49541. /**
  49542. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49543. */
  49544. static readonly PBRMATERIAL_ALPHABLEND: number;
  49545. /**
  49546. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49547. * They are also discarded below the alpha cutoff threshold to improve performances.
  49548. */
  49549. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49550. /**
  49551. * Defines the default value of how much AO map is occluding the analytical lights
  49552. * (point spot...).
  49553. */
  49554. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49555. /**
  49556. * Intensity of the direct lights e.g. the four lights available in your scene.
  49557. * This impacts both the direct diffuse and specular highlights.
  49558. */
  49559. directIntensity: number;
  49560. /**
  49561. * Intensity of the emissive part of the material.
  49562. * This helps controlling the emissive effect without modifying the emissive color.
  49563. */
  49564. emissiveIntensity: number;
  49565. /**
  49566. * Intensity of the environment e.g. how much the environment will light the object
  49567. * either through harmonics for rough material or through the refelction for shiny ones.
  49568. */
  49569. environmentIntensity: number;
  49570. /**
  49571. * This is a special control allowing the reduction of the specular highlights coming from the
  49572. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49573. */
  49574. specularIntensity: number;
  49575. /**
  49576. * Debug Control allowing disabling the bump map on this material.
  49577. */
  49578. disableBumpMap: boolean;
  49579. /**
  49580. * AKA Diffuse Texture in standard nomenclature.
  49581. */
  49582. albedoTexture: BaseTexture;
  49583. /**
  49584. * AKA Occlusion Texture in other nomenclature.
  49585. */
  49586. ambientTexture: BaseTexture;
  49587. /**
  49588. * AKA Occlusion Texture Intensity in other nomenclature.
  49589. */
  49590. ambientTextureStrength: number;
  49591. /**
  49592. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49593. * 1 means it completely occludes it
  49594. * 0 mean it has no impact
  49595. */
  49596. ambientTextureImpactOnAnalyticalLights: number;
  49597. /**
  49598. * Stores the alpha values in a texture.
  49599. */
  49600. opacityTexture: BaseTexture;
  49601. /**
  49602. * Stores the reflection values in a texture.
  49603. */
  49604. reflectionTexture: Nullable<BaseTexture>;
  49605. /**
  49606. * Stores the emissive values in a texture.
  49607. */
  49608. emissiveTexture: BaseTexture;
  49609. /**
  49610. * AKA Specular texture in other nomenclature.
  49611. */
  49612. reflectivityTexture: BaseTexture;
  49613. /**
  49614. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49615. */
  49616. metallicTexture: BaseTexture;
  49617. /**
  49618. * Specifies the metallic scalar of the metallic/roughness workflow.
  49619. * Can also be used to scale the metalness values of the metallic texture.
  49620. */
  49621. metallic: Nullable<number>;
  49622. /**
  49623. * Specifies the roughness scalar of the metallic/roughness workflow.
  49624. * Can also be used to scale the roughness values of the metallic texture.
  49625. */
  49626. roughness: Nullable<number>;
  49627. /**
  49628. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49629. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49630. */
  49631. microSurfaceTexture: BaseTexture;
  49632. /**
  49633. * Stores surface normal data used to displace a mesh in a texture.
  49634. */
  49635. bumpTexture: BaseTexture;
  49636. /**
  49637. * Stores the pre-calculated light information of a mesh in a texture.
  49638. */
  49639. lightmapTexture: BaseTexture;
  49640. /**
  49641. * Stores the refracted light information in a texture.
  49642. */
  49643. refractionTexture: Nullable<BaseTexture>;
  49644. /**
  49645. * The color of a material in ambient lighting.
  49646. */
  49647. ambientColor: Color3;
  49648. /**
  49649. * AKA Diffuse Color in other nomenclature.
  49650. */
  49651. albedoColor: Color3;
  49652. /**
  49653. * AKA Specular Color in other nomenclature.
  49654. */
  49655. reflectivityColor: Color3;
  49656. /**
  49657. * The color reflected from the material.
  49658. */
  49659. reflectionColor: Color3;
  49660. /**
  49661. * The color emitted from the material.
  49662. */
  49663. emissiveColor: Color3;
  49664. /**
  49665. * AKA Glossiness in other nomenclature.
  49666. */
  49667. microSurface: number;
  49668. /**
  49669. * source material index of refraction (IOR)' / 'destination material IOR.
  49670. */
  49671. indexOfRefraction: number;
  49672. /**
  49673. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49674. */
  49675. invertRefractionY: boolean;
  49676. /**
  49677. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49678. * Materials half opaque for instance using refraction could benefit from this control.
  49679. */
  49680. linkRefractionWithTransparency: boolean;
  49681. /**
  49682. * If true, the light map contains occlusion information instead of lighting info.
  49683. */
  49684. useLightmapAsShadowmap: boolean;
  49685. /**
  49686. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49687. */
  49688. useAlphaFromAlbedoTexture: boolean;
  49689. /**
  49690. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49691. */
  49692. forceAlphaTest: boolean;
  49693. /**
  49694. * Defines the alpha limits in alpha test mode.
  49695. */
  49696. alphaCutOff: number;
  49697. /**
  49698. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49699. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49700. */
  49701. useSpecularOverAlpha: boolean;
  49702. /**
  49703. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49704. */
  49705. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49706. /**
  49707. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49708. */
  49709. useRoughnessFromMetallicTextureAlpha: boolean;
  49710. /**
  49711. * Specifies if the metallic texture contains the roughness information in its green channel.
  49712. */
  49713. useRoughnessFromMetallicTextureGreen: boolean;
  49714. /**
  49715. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49716. */
  49717. useMetallnessFromMetallicTextureBlue: boolean;
  49718. /**
  49719. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49720. */
  49721. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49722. /**
  49723. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49724. */
  49725. useAmbientInGrayScale: boolean;
  49726. /**
  49727. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49728. * The material will try to infer what glossiness each pixel should be.
  49729. */
  49730. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49731. /**
  49732. * BJS is using an harcoded light falloff based on a manually sets up range.
  49733. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49734. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49735. */
  49736. /**
  49737. * BJS is using an harcoded light falloff based on a manually sets up range.
  49738. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49739. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49740. */
  49741. usePhysicalLightFalloff: boolean;
  49742. /**
  49743. * In order to support the falloff compatibility with gltf, a special mode has been added
  49744. * to reproduce the gltf light falloff.
  49745. */
  49746. /**
  49747. * In order to support the falloff compatibility with gltf, a special mode has been added
  49748. * to reproduce the gltf light falloff.
  49749. */
  49750. useGLTFLightFalloff: boolean;
  49751. /**
  49752. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49754. */
  49755. useRadianceOverAlpha: boolean;
  49756. /**
  49757. * Allows using an object space normal map (instead of tangent space).
  49758. */
  49759. useObjectSpaceNormalMap: boolean;
  49760. /**
  49761. * Allows using the bump map in parallax mode.
  49762. */
  49763. useParallax: boolean;
  49764. /**
  49765. * Allows using the bump map in parallax occlusion mode.
  49766. */
  49767. useParallaxOcclusion: boolean;
  49768. /**
  49769. * Controls the scale bias of the parallax mode.
  49770. */
  49771. parallaxScaleBias: number;
  49772. /**
  49773. * If sets to true, disables all the lights affecting the material.
  49774. */
  49775. disableLighting: boolean;
  49776. /**
  49777. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49778. */
  49779. forceIrradianceInFragment: boolean;
  49780. /**
  49781. * Number of Simultaneous lights allowed on the material.
  49782. */
  49783. maxSimultaneousLights: number;
  49784. /**
  49785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49786. */
  49787. invertNormalMapX: boolean;
  49788. /**
  49789. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49790. */
  49791. invertNormalMapY: boolean;
  49792. /**
  49793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49794. */
  49795. twoSidedLighting: boolean;
  49796. /**
  49797. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49798. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49799. */
  49800. useAlphaFresnel: boolean;
  49801. /**
  49802. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49803. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49804. */
  49805. useLinearAlphaFresnel: boolean;
  49806. /**
  49807. * Let user defines the brdf lookup texture used for IBL.
  49808. * A default 8bit version is embedded but you could point at :
  49809. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49810. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49811. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49812. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49813. */
  49814. environmentBRDFTexture: Nullable<BaseTexture>;
  49815. /**
  49816. * Force normal to face away from face.
  49817. */
  49818. forceNormalForward: boolean;
  49819. /**
  49820. * Enables specular anti aliasing in the PBR shader.
  49821. * It will both interacts on the Geometry for analytical and IBL lighting.
  49822. * It also prefilter the roughness map based on the bump values.
  49823. */
  49824. enableSpecularAntiAliasing: boolean;
  49825. /**
  49826. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49827. * makes the reflect vector face the model (under horizon).
  49828. */
  49829. useHorizonOcclusion: boolean;
  49830. /**
  49831. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49832. * too much the area relying on ambient texture to define their ambient occlusion.
  49833. */
  49834. useRadianceOcclusion: boolean;
  49835. /**
  49836. * If set to true, no lighting calculations will be applied.
  49837. */
  49838. unlit: boolean;
  49839. /**
  49840. * Gets the image processing configuration used either in this material.
  49841. */
  49842. /**
  49843. * Sets the Default image processing configuration used either in the this material.
  49844. *
  49845. * If sets to null, the scene one is in use.
  49846. */
  49847. imageProcessingConfiguration: ImageProcessingConfiguration;
  49848. /**
  49849. * Gets wether the color curves effect is enabled.
  49850. */
  49851. /**
  49852. * Sets wether the color curves effect is enabled.
  49853. */
  49854. cameraColorCurvesEnabled: boolean;
  49855. /**
  49856. * Gets wether the color grading effect is enabled.
  49857. */
  49858. /**
  49859. * Gets wether the color grading effect is enabled.
  49860. */
  49861. cameraColorGradingEnabled: boolean;
  49862. /**
  49863. * Gets wether tonemapping is enabled or not.
  49864. */
  49865. /**
  49866. * Sets wether tonemapping is enabled or not
  49867. */
  49868. cameraToneMappingEnabled: boolean;
  49869. /**
  49870. * The camera exposure used on this material.
  49871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49872. * This corresponds to a photographic exposure.
  49873. */
  49874. /**
  49875. * The camera exposure used on this material.
  49876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49877. * This corresponds to a photographic exposure.
  49878. */
  49879. cameraExposure: number;
  49880. /**
  49881. * Gets The camera contrast used on this material.
  49882. */
  49883. /**
  49884. * Sets The camera contrast used on this material.
  49885. */
  49886. cameraContrast: number;
  49887. /**
  49888. * Gets the Color Grading 2D Lookup Texture.
  49889. */
  49890. /**
  49891. * Sets the Color Grading 2D Lookup Texture.
  49892. */
  49893. cameraColorGradingTexture: Nullable<BaseTexture>;
  49894. /**
  49895. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49896. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49897. * 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;
  49898. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49899. */
  49900. /**
  49901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49903. * 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;
  49904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49905. */
  49906. cameraColorCurves: Nullable<ColorCurves>;
  49907. /**
  49908. * Instantiates a new PBRMaterial instance.
  49909. *
  49910. * @param name The material name
  49911. * @param scene The scene the material will be use in.
  49912. */
  49913. constructor(name: string, scene: Scene);
  49914. /**
  49915. * Returns the name of this material class.
  49916. */
  49917. getClassName(): string;
  49918. /**
  49919. * Makes a duplicate of the current material.
  49920. * @param name - name to use for the new material.
  49921. */
  49922. clone(name: string): PBRMaterial;
  49923. /**
  49924. * Serializes this PBR Material.
  49925. * @returns - An object with the serialized material.
  49926. */
  49927. serialize(): any;
  49928. /**
  49929. * Parses a PBR Material from a serialized object.
  49930. * @param source - Serialized object.
  49931. * @param scene - BJS scene instance.
  49932. * @param rootUrl - url for the scene object
  49933. * @returns - PBRMaterial
  49934. */
  49935. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49936. }
  49937. }
  49938. declare module "babylonjs/Misc/dds" {
  49939. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49940. import { Engine } from "babylonjs/Engines/engine";
  49941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49942. import { Nullable } from "babylonjs/types";
  49943. import { Scene } from "babylonjs/scene";
  49944. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49945. /**
  49946. * Direct draw surface info
  49947. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49948. */
  49949. export interface DDSInfo {
  49950. /**
  49951. * Width of the texture
  49952. */
  49953. width: number;
  49954. /**
  49955. * Width of the texture
  49956. */
  49957. height: number;
  49958. /**
  49959. * Number of Mipmaps for the texture
  49960. * @see https://en.wikipedia.org/wiki/Mipmap
  49961. */
  49962. mipmapCount: number;
  49963. /**
  49964. * If the textures format is a known fourCC format
  49965. * @see https://www.fourcc.org/
  49966. */
  49967. isFourCC: boolean;
  49968. /**
  49969. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49970. */
  49971. isRGB: boolean;
  49972. /**
  49973. * If the texture is a lumincance format
  49974. */
  49975. isLuminance: boolean;
  49976. /**
  49977. * If this is a cube texture
  49978. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49979. */
  49980. isCube: boolean;
  49981. /**
  49982. * If the texture is a compressed format eg. FOURCC_DXT1
  49983. */
  49984. isCompressed: boolean;
  49985. /**
  49986. * The dxgiFormat of the texture
  49987. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49988. */
  49989. dxgiFormat: number;
  49990. /**
  49991. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49992. */
  49993. textureType: number;
  49994. /**
  49995. * Sphericle polynomial created for the dds texture
  49996. */
  49997. sphericalPolynomial?: SphericalPolynomial;
  49998. }
  49999. /**
  50000. * Class used to provide DDS decompression tools
  50001. */
  50002. export class DDSTools {
  50003. /**
  50004. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50005. */
  50006. static StoreLODInAlphaChannel: boolean;
  50007. /**
  50008. * Gets DDS information from an array buffer
  50009. * @param arrayBuffer defines the array buffer to read data from
  50010. * @returns the DDS information
  50011. */
  50012. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50013. private static _FloatView;
  50014. private static _Int32View;
  50015. private static _ToHalfFloat;
  50016. private static _FromHalfFloat;
  50017. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50018. private static _GetHalfFloatRGBAArrayBuffer;
  50019. private static _GetFloatRGBAArrayBuffer;
  50020. private static _GetFloatAsUIntRGBAArrayBuffer;
  50021. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50022. private static _GetRGBAArrayBuffer;
  50023. private static _ExtractLongWordOrder;
  50024. private static _GetRGBArrayBuffer;
  50025. private static _GetLuminanceArrayBuffer;
  50026. /**
  50027. * Uploads DDS Levels to a Babylon Texture
  50028. * @hidden
  50029. */
  50030. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50031. }
  50032. module "babylonjs/Engines/engine" {
  50033. interface Engine {
  50034. /**
  50035. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50036. * @param rootUrl defines the url where the file to load is located
  50037. * @param scene defines the current scene
  50038. * @param lodScale defines scale to apply to the mip map selection
  50039. * @param lodOffset defines offset to apply to the mip map selection
  50040. * @param onLoad defines an optional callback raised when the texture is loaded
  50041. * @param onError defines an optional callback raised if there is an issue to load the texture
  50042. * @param format defines the format of the data
  50043. * @param forcedExtension defines the extension to use to pick the right loader
  50044. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50045. * @returns the cube texture as an InternalTexture
  50046. */
  50047. 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;
  50048. }
  50049. }
  50050. }
  50051. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50052. import { Nullable } from "babylonjs/types";
  50053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50054. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50055. /**
  50056. * Implementation of the DDS Texture Loader.
  50057. * @hidden
  50058. */
  50059. export class _DDSTextureLoader implements IInternalTextureLoader {
  50060. /**
  50061. * Defines wether the loader supports cascade loading the different faces.
  50062. */
  50063. readonly supportCascades: boolean;
  50064. /**
  50065. * This returns if the loader support the current file information.
  50066. * @param extension defines the file extension of the file being loaded
  50067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50068. * @param fallback defines the fallback internal texture if any
  50069. * @param isBase64 defines whether the texture is encoded as a base64
  50070. * @param isBuffer defines whether the texture data are stored as a buffer
  50071. * @returns true if the loader can load the specified file
  50072. */
  50073. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50074. /**
  50075. * Transform the url before loading if required.
  50076. * @param rootUrl the url of the texture
  50077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50078. * @returns the transformed texture
  50079. */
  50080. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50081. /**
  50082. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50083. * @param rootUrl the url of the texture
  50084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50085. * @returns the fallback texture
  50086. */
  50087. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50088. /**
  50089. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50090. * @param data contains the texture data
  50091. * @param texture defines the BabylonJS internal texture
  50092. * @param createPolynomials will be true if polynomials have been requested
  50093. * @param onLoad defines the callback to trigger once the texture is ready
  50094. * @param onError defines the callback to trigger in case of error
  50095. */
  50096. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50097. /**
  50098. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50099. * @param data contains the texture data
  50100. * @param texture defines the BabylonJS internal texture
  50101. * @param callback defines the method to call once ready to upload
  50102. */
  50103. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50104. }
  50105. }
  50106. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50107. import { Nullable } from "babylonjs/types";
  50108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50109. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50110. /**
  50111. * Implementation of the ENV Texture Loader.
  50112. * @hidden
  50113. */
  50114. export class _ENVTextureLoader implements IInternalTextureLoader {
  50115. /**
  50116. * Defines wether the loader supports cascade loading the different faces.
  50117. */
  50118. readonly supportCascades: boolean;
  50119. /**
  50120. * This returns if the loader support the current file information.
  50121. * @param extension defines the file extension of the file being loaded
  50122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50123. * @param fallback defines the fallback internal texture if any
  50124. * @param isBase64 defines whether the texture is encoded as a base64
  50125. * @param isBuffer defines whether the texture data are stored as a buffer
  50126. * @returns true if the loader can load the specified file
  50127. */
  50128. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50129. /**
  50130. * Transform the url before loading if required.
  50131. * @param rootUrl the url of the texture
  50132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50133. * @returns the transformed texture
  50134. */
  50135. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50136. /**
  50137. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50138. * @param rootUrl the url of the texture
  50139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50140. * @returns the fallback texture
  50141. */
  50142. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50143. /**
  50144. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50145. * @param data contains the texture data
  50146. * @param texture defines the BabylonJS internal texture
  50147. * @param createPolynomials will be true if polynomials have been requested
  50148. * @param onLoad defines the callback to trigger once the texture is ready
  50149. * @param onError defines the callback to trigger in case of error
  50150. */
  50151. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50152. /**
  50153. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50154. * @param data contains the texture data
  50155. * @param texture defines the BabylonJS internal texture
  50156. * @param callback defines the method to call once ready to upload
  50157. */
  50158. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50159. }
  50160. }
  50161. declare module "babylonjs/Misc/khronosTextureContainer" {
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. /**
  50164. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50165. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50166. */
  50167. export class KhronosTextureContainer {
  50168. /** contents of the KTX container file */
  50169. arrayBuffer: any;
  50170. private static HEADER_LEN;
  50171. private static COMPRESSED_2D;
  50172. private static COMPRESSED_3D;
  50173. private static TEX_2D;
  50174. private static TEX_3D;
  50175. /**
  50176. * Gets the openGL type
  50177. */
  50178. glType: number;
  50179. /**
  50180. * Gets the openGL type size
  50181. */
  50182. glTypeSize: number;
  50183. /**
  50184. * Gets the openGL format
  50185. */
  50186. glFormat: number;
  50187. /**
  50188. * Gets the openGL internal format
  50189. */
  50190. glInternalFormat: number;
  50191. /**
  50192. * Gets the base internal format
  50193. */
  50194. glBaseInternalFormat: number;
  50195. /**
  50196. * Gets image width in pixel
  50197. */
  50198. pixelWidth: number;
  50199. /**
  50200. * Gets image height in pixel
  50201. */
  50202. pixelHeight: number;
  50203. /**
  50204. * Gets image depth in pixels
  50205. */
  50206. pixelDepth: number;
  50207. /**
  50208. * Gets the number of array elements
  50209. */
  50210. numberOfArrayElements: number;
  50211. /**
  50212. * Gets the number of faces
  50213. */
  50214. numberOfFaces: number;
  50215. /**
  50216. * Gets the number of mipmap levels
  50217. */
  50218. numberOfMipmapLevels: number;
  50219. /**
  50220. * Gets the bytes of key value data
  50221. */
  50222. bytesOfKeyValueData: number;
  50223. /**
  50224. * Gets the load type
  50225. */
  50226. loadType: number;
  50227. /**
  50228. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50229. */
  50230. isInvalid: boolean;
  50231. /**
  50232. * Creates a new KhronosTextureContainer
  50233. * @param arrayBuffer contents of the KTX container file
  50234. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50235. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50236. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50237. */
  50238. constructor(
  50239. /** contents of the KTX container file */
  50240. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50241. /**
  50242. * Uploads KTX content to a Babylon Texture.
  50243. * It is assumed that the texture has already been created & is currently bound
  50244. * @hidden
  50245. */
  50246. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50247. private _upload2DCompressedLevels;
  50248. }
  50249. }
  50250. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50251. import { Nullable } from "babylonjs/types";
  50252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50253. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50254. /**
  50255. * Implementation of the KTX Texture Loader.
  50256. * @hidden
  50257. */
  50258. export class _KTXTextureLoader implements IInternalTextureLoader {
  50259. /**
  50260. * Defines wether the loader supports cascade loading the different faces.
  50261. */
  50262. readonly supportCascades: boolean;
  50263. /**
  50264. * This returns if the loader support the current file information.
  50265. * @param extension defines the file extension of the file being loaded
  50266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50267. * @param fallback defines the fallback internal texture if any
  50268. * @param isBase64 defines whether the texture is encoded as a base64
  50269. * @param isBuffer defines whether the texture data are stored as a buffer
  50270. * @returns true if the loader can load the specified file
  50271. */
  50272. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50273. /**
  50274. * Transform the url before loading if required.
  50275. * @param rootUrl the url of the texture
  50276. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50277. * @returns the transformed texture
  50278. */
  50279. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50280. /**
  50281. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50282. * @param rootUrl the url of the texture
  50283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50284. * @returns the fallback texture
  50285. */
  50286. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50287. /**
  50288. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50289. * @param data contains the texture data
  50290. * @param texture defines the BabylonJS internal texture
  50291. * @param createPolynomials will be true if polynomials have been requested
  50292. * @param onLoad defines the callback to trigger once the texture is ready
  50293. * @param onError defines the callback to trigger in case of error
  50294. */
  50295. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50296. /**
  50297. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50298. * @param data contains the texture data
  50299. * @param texture defines the BabylonJS internal texture
  50300. * @param callback defines the method to call once ready to upload
  50301. */
  50302. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50303. }
  50304. }
  50305. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50306. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50307. import { Scene } from "babylonjs/scene";
  50308. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50309. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50310. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50311. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50312. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50313. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50315. /**
  50316. * Options for the default xr helper
  50317. */
  50318. export class WebXRDefaultExperienceOptions {
  50319. /**
  50320. * Floor meshes that should be used for teleporting
  50321. */
  50322. floorMeshes: Array<AbstractMesh>;
  50323. }
  50324. /**
  50325. * Default experience which provides a similar setup to the previous webVRExperience
  50326. */
  50327. export class WebXRDefaultExperience {
  50328. /**
  50329. * Base experience
  50330. */
  50331. baseExperience: WebXRExperienceHelper;
  50332. /**
  50333. * Input experience extension
  50334. */
  50335. input: WebXRInput;
  50336. /**
  50337. * Loads the controller models
  50338. */
  50339. controllerModelLoader: WebXRControllerModelLoader;
  50340. /**
  50341. * Enables laser pointer and selection
  50342. */
  50343. pointerSelection: WebXRControllerPointerSelection;
  50344. /**
  50345. * Enables teleportation
  50346. */
  50347. teleportation: WebXRControllerTeleportation;
  50348. /**
  50349. * Enables ui for enetering/exiting xr
  50350. */
  50351. enterExitUI: WebXREnterExitUI;
  50352. /**
  50353. * Default output canvas xr should render to
  50354. */
  50355. outputCanvas: WebXRManagedOutputCanvas;
  50356. /**
  50357. * Creates the default xr experience
  50358. * @param scene scene
  50359. * @param options options for basic configuration
  50360. * @returns resulting WebXRDefaultExperience
  50361. */
  50362. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50363. private constructor();
  50364. /**
  50365. * DIsposes of the experience helper
  50366. */
  50367. dispose(): void;
  50368. }
  50369. }
  50370. declare module "babylonjs/Helpers/sceneHelpers" {
  50371. import { Nullable } from "babylonjs/types";
  50372. import { Mesh } from "babylonjs/Meshes/mesh";
  50373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50374. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50375. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50376. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50377. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50378. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50379. import "babylonjs/Meshes/Builders/boxBuilder";
  50380. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50381. /** @hidden */
  50382. export var _forceSceneHelpersToBundle: boolean;
  50383. module "babylonjs/scene" {
  50384. interface Scene {
  50385. /**
  50386. * Creates a default light for the scene.
  50387. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50388. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50389. */
  50390. createDefaultLight(replace?: boolean): void;
  50391. /**
  50392. * Creates a default camera for the scene.
  50393. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50394. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50395. * @param replace has default false, when true replaces the active camera in the scene
  50396. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50397. */
  50398. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50399. /**
  50400. * Creates a default camera and a default light.
  50401. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50402. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50403. * @param replace has the default false, when true replaces the active camera/light in the scene
  50404. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50405. */
  50406. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50407. /**
  50408. * Creates a new sky box
  50409. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50410. * @param environmentTexture defines the texture to use as environment texture
  50411. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50412. * @param scale defines the overall scale of the skybox
  50413. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50414. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50415. * @returns a new mesh holding the sky box
  50416. */
  50417. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50418. /**
  50419. * Creates a new environment
  50420. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50421. * @param options defines the options you can use to configure the environment
  50422. * @returns the new EnvironmentHelper
  50423. */
  50424. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50425. /**
  50426. * Creates a new VREXperienceHelper
  50427. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50428. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50429. * @returns a new VREXperienceHelper
  50430. */
  50431. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50432. /**
  50433. * Creates a new WebXRDefaultExperience
  50434. * @see http://doc.babylonjs.com/how_to/webxr
  50435. * @param options experience options
  50436. * @returns a promise for a new WebXRDefaultExperience
  50437. */
  50438. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50439. }
  50440. }
  50441. }
  50442. declare module "babylonjs/Helpers/videoDome" {
  50443. import { Scene } from "babylonjs/scene";
  50444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50445. import { Mesh } from "babylonjs/Meshes/mesh";
  50446. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50447. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50448. import "babylonjs/Meshes/Builders/sphereBuilder";
  50449. /**
  50450. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50451. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50452. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50453. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50454. */
  50455. export class VideoDome extends TransformNode {
  50456. /**
  50457. * Define the video source as a Monoscopic panoramic 360 video.
  50458. */
  50459. static readonly MODE_MONOSCOPIC: number;
  50460. /**
  50461. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50462. */
  50463. static readonly MODE_TOPBOTTOM: number;
  50464. /**
  50465. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50466. */
  50467. static readonly MODE_SIDEBYSIDE: number;
  50468. private _halfDome;
  50469. private _useDirectMapping;
  50470. /**
  50471. * The video texture being displayed on the sphere
  50472. */
  50473. protected _videoTexture: VideoTexture;
  50474. /**
  50475. * Gets the video texture being displayed on the sphere
  50476. */
  50477. readonly videoTexture: VideoTexture;
  50478. /**
  50479. * The skybox material
  50480. */
  50481. protected _material: BackgroundMaterial;
  50482. /**
  50483. * The surface used for the skybox
  50484. */
  50485. protected _mesh: Mesh;
  50486. /**
  50487. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50488. */
  50489. private _halfDomeMask;
  50490. /**
  50491. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50492. * Also see the options.resolution property.
  50493. */
  50494. fovMultiplier: number;
  50495. private _videoMode;
  50496. /**
  50497. * Gets or set the current video mode for the video. It can be:
  50498. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50499. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50500. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50501. */
  50502. videoMode: number;
  50503. /**
  50504. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50505. *
  50506. */
  50507. /**
  50508. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50509. */
  50510. halfDome: boolean;
  50511. /**
  50512. * Oberserver used in Stereoscopic VR Mode.
  50513. */
  50514. private _onBeforeCameraRenderObserver;
  50515. /**
  50516. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50517. * @param name Element's name, child elements will append suffixes for their own names.
  50518. * @param urlsOrVideo defines the url(s) or the video element to use
  50519. * @param options An object containing optional or exposed sub element properties
  50520. */
  50521. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50522. resolution?: number;
  50523. clickToPlay?: boolean;
  50524. autoPlay?: boolean;
  50525. loop?: boolean;
  50526. size?: number;
  50527. poster?: string;
  50528. faceForward?: boolean;
  50529. useDirectMapping?: boolean;
  50530. halfDomeMode?: boolean;
  50531. }, scene: Scene);
  50532. private _changeVideoMode;
  50533. /**
  50534. * Releases resources associated with this node.
  50535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50537. */
  50538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50539. }
  50540. }
  50541. declare module "babylonjs/Helpers/index" {
  50542. export * from "babylonjs/Helpers/environmentHelper";
  50543. export * from "babylonjs/Helpers/photoDome";
  50544. export * from "babylonjs/Helpers/sceneHelpers";
  50545. export * from "babylonjs/Helpers/videoDome";
  50546. }
  50547. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50548. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50549. import { IDisposable } from "babylonjs/scene";
  50550. import { Engine } from "babylonjs/Engines/engine";
  50551. /**
  50552. * This class can be used to get instrumentation data from a Babylon engine
  50553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50554. */
  50555. export class EngineInstrumentation implements IDisposable {
  50556. /**
  50557. * Define the instrumented engine.
  50558. */
  50559. engine: Engine;
  50560. private _captureGPUFrameTime;
  50561. private _gpuFrameTimeToken;
  50562. private _gpuFrameTime;
  50563. private _captureShaderCompilationTime;
  50564. private _shaderCompilationTime;
  50565. private _onBeginFrameObserver;
  50566. private _onEndFrameObserver;
  50567. private _onBeforeShaderCompilationObserver;
  50568. private _onAfterShaderCompilationObserver;
  50569. /**
  50570. * Gets the perf counter used for GPU frame time
  50571. */
  50572. readonly gpuFrameTimeCounter: PerfCounter;
  50573. /**
  50574. * Gets the GPU frame time capture status
  50575. */
  50576. /**
  50577. * Enable or disable the GPU frame time capture
  50578. */
  50579. captureGPUFrameTime: boolean;
  50580. /**
  50581. * Gets the perf counter used for shader compilation time
  50582. */
  50583. readonly shaderCompilationTimeCounter: PerfCounter;
  50584. /**
  50585. * Gets the shader compilation time capture status
  50586. */
  50587. /**
  50588. * Enable or disable the shader compilation time capture
  50589. */
  50590. captureShaderCompilationTime: boolean;
  50591. /**
  50592. * Instantiates a new engine instrumentation.
  50593. * This class can be used to get instrumentation data from a Babylon engine
  50594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50595. * @param engine Defines the engine to instrument
  50596. */
  50597. constructor(
  50598. /**
  50599. * Define the instrumented engine.
  50600. */
  50601. engine: Engine);
  50602. /**
  50603. * Dispose and release associated resources.
  50604. */
  50605. dispose(): void;
  50606. }
  50607. }
  50608. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50609. import { Scene, IDisposable } from "babylonjs/scene";
  50610. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50611. /**
  50612. * This class can be used to get instrumentation data from a Babylon engine
  50613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50614. */
  50615. export class SceneInstrumentation implements IDisposable {
  50616. /**
  50617. * Defines the scene to instrument
  50618. */
  50619. scene: Scene;
  50620. private _captureActiveMeshesEvaluationTime;
  50621. private _activeMeshesEvaluationTime;
  50622. private _captureRenderTargetsRenderTime;
  50623. private _renderTargetsRenderTime;
  50624. private _captureFrameTime;
  50625. private _frameTime;
  50626. private _captureRenderTime;
  50627. private _renderTime;
  50628. private _captureInterFrameTime;
  50629. private _interFrameTime;
  50630. private _captureParticlesRenderTime;
  50631. private _particlesRenderTime;
  50632. private _captureSpritesRenderTime;
  50633. private _spritesRenderTime;
  50634. private _capturePhysicsTime;
  50635. private _physicsTime;
  50636. private _captureAnimationsTime;
  50637. private _animationsTime;
  50638. private _captureCameraRenderTime;
  50639. private _cameraRenderTime;
  50640. private _onBeforeActiveMeshesEvaluationObserver;
  50641. private _onAfterActiveMeshesEvaluationObserver;
  50642. private _onBeforeRenderTargetsRenderObserver;
  50643. private _onAfterRenderTargetsRenderObserver;
  50644. private _onAfterRenderObserver;
  50645. private _onBeforeDrawPhaseObserver;
  50646. private _onAfterDrawPhaseObserver;
  50647. private _onBeforeAnimationsObserver;
  50648. private _onBeforeParticlesRenderingObserver;
  50649. private _onAfterParticlesRenderingObserver;
  50650. private _onBeforeSpritesRenderingObserver;
  50651. private _onAfterSpritesRenderingObserver;
  50652. private _onBeforePhysicsObserver;
  50653. private _onAfterPhysicsObserver;
  50654. private _onAfterAnimationsObserver;
  50655. private _onBeforeCameraRenderObserver;
  50656. private _onAfterCameraRenderObserver;
  50657. /**
  50658. * Gets the perf counter used for active meshes evaluation time
  50659. */
  50660. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50661. /**
  50662. * Gets the active meshes evaluation time capture status
  50663. */
  50664. /**
  50665. * Enable or disable the active meshes evaluation time capture
  50666. */
  50667. captureActiveMeshesEvaluationTime: boolean;
  50668. /**
  50669. * Gets the perf counter used for render targets render time
  50670. */
  50671. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50672. /**
  50673. * Gets the render targets render time capture status
  50674. */
  50675. /**
  50676. * Enable or disable the render targets render time capture
  50677. */
  50678. captureRenderTargetsRenderTime: boolean;
  50679. /**
  50680. * Gets the perf counter used for particles render time
  50681. */
  50682. readonly particlesRenderTimeCounter: PerfCounter;
  50683. /**
  50684. * Gets the particles render time capture status
  50685. */
  50686. /**
  50687. * Enable or disable the particles render time capture
  50688. */
  50689. captureParticlesRenderTime: boolean;
  50690. /**
  50691. * Gets the perf counter used for sprites render time
  50692. */
  50693. readonly spritesRenderTimeCounter: PerfCounter;
  50694. /**
  50695. * Gets the sprites render time capture status
  50696. */
  50697. /**
  50698. * Enable or disable the sprites render time capture
  50699. */
  50700. captureSpritesRenderTime: boolean;
  50701. /**
  50702. * Gets the perf counter used for physics time
  50703. */
  50704. readonly physicsTimeCounter: PerfCounter;
  50705. /**
  50706. * Gets the physics time capture status
  50707. */
  50708. /**
  50709. * Enable or disable the physics time capture
  50710. */
  50711. capturePhysicsTime: boolean;
  50712. /**
  50713. * Gets the perf counter used for animations time
  50714. */
  50715. readonly animationsTimeCounter: PerfCounter;
  50716. /**
  50717. * Gets the animations time capture status
  50718. */
  50719. /**
  50720. * Enable or disable the animations time capture
  50721. */
  50722. captureAnimationsTime: boolean;
  50723. /**
  50724. * Gets the perf counter used for frame time capture
  50725. */
  50726. readonly frameTimeCounter: PerfCounter;
  50727. /**
  50728. * Gets the frame time capture status
  50729. */
  50730. /**
  50731. * Enable or disable the frame time capture
  50732. */
  50733. captureFrameTime: boolean;
  50734. /**
  50735. * Gets the perf counter used for inter-frames time capture
  50736. */
  50737. readonly interFrameTimeCounter: PerfCounter;
  50738. /**
  50739. * Gets the inter-frames time capture status
  50740. */
  50741. /**
  50742. * Enable or disable the inter-frames time capture
  50743. */
  50744. captureInterFrameTime: boolean;
  50745. /**
  50746. * Gets the perf counter used for render time capture
  50747. */
  50748. readonly renderTimeCounter: PerfCounter;
  50749. /**
  50750. * Gets the render time capture status
  50751. */
  50752. /**
  50753. * Enable or disable the render time capture
  50754. */
  50755. captureRenderTime: boolean;
  50756. /**
  50757. * Gets the perf counter used for camera render time capture
  50758. */
  50759. readonly cameraRenderTimeCounter: PerfCounter;
  50760. /**
  50761. * Gets the camera render time capture status
  50762. */
  50763. /**
  50764. * Enable or disable the camera render time capture
  50765. */
  50766. captureCameraRenderTime: boolean;
  50767. /**
  50768. * Gets the perf counter used for draw calls
  50769. */
  50770. readonly drawCallsCounter: PerfCounter;
  50771. /**
  50772. * Instantiates a new scene instrumentation.
  50773. * This class can be used to get instrumentation data from a Babylon engine
  50774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50775. * @param scene Defines the scene to instrument
  50776. */
  50777. constructor(
  50778. /**
  50779. * Defines the scene to instrument
  50780. */
  50781. scene: Scene);
  50782. /**
  50783. * Dispose and release associated resources.
  50784. */
  50785. dispose(): void;
  50786. }
  50787. }
  50788. declare module "babylonjs/Instrumentation/index" {
  50789. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50790. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50791. export * from "babylonjs/Instrumentation/timeToken";
  50792. }
  50793. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50794. /** @hidden */
  50795. export var glowMapGenerationPixelShader: {
  50796. name: string;
  50797. shader: string;
  50798. };
  50799. }
  50800. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50801. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50802. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50803. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50804. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50805. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50806. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50807. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50808. /** @hidden */
  50809. export var glowMapGenerationVertexShader: {
  50810. name: string;
  50811. shader: string;
  50812. };
  50813. }
  50814. declare module "babylonjs/Layers/effectLayer" {
  50815. import { Observable } from "babylonjs/Misc/observable";
  50816. import { Nullable } from "babylonjs/types";
  50817. import { Camera } from "babylonjs/Cameras/camera";
  50818. import { Scene } from "babylonjs/scene";
  50819. import { ISize } from "babylonjs/Maths/math.size";
  50820. import { Color4 } from "babylonjs/Maths/math.color";
  50821. import { Engine } from "babylonjs/Engines/engine";
  50822. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50824. import { Mesh } from "babylonjs/Meshes/mesh";
  50825. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50827. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50828. import { Effect } from "babylonjs/Materials/effect";
  50829. import { Material } from "babylonjs/Materials/material";
  50830. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50831. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50832. /**
  50833. * Effect layer options. This helps customizing the behaviour
  50834. * of the effect layer.
  50835. */
  50836. export interface IEffectLayerOptions {
  50837. /**
  50838. * Multiplication factor apply to the canvas size to compute the render target size
  50839. * used to generated the objects (the smaller the faster).
  50840. */
  50841. mainTextureRatio: number;
  50842. /**
  50843. * Enforces a fixed size texture to ensure effect stability across devices.
  50844. */
  50845. mainTextureFixedSize?: number;
  50846. /**
  50847. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50848. */
  50849. alphaBlendingMode: number;
  50850. /**
  50851. * The camera attached to the layer.
  50852. */
  50853. camera: Nullable<Camera>;
  50854. /**
  50855. * The rendering group to draw the layer in.
  50856. */
  50857. renderingGroupId: number;
  50858. }
  50859. /**
  50860. * The effect layer Helps adding post process effect blended with the main pass.
  50861. *
  50862. * This can be for instance use to generate glow or higlight effects on the scene.
  50863. *
  50864. * The effect layer class can not be used directly and is intented to inherited from to be
  50865. * customized per effects.
  50866. */
  50867. export abstract class EffectLayer {
  50868. private _vertexBuffers;
  50869. private _indexBuffer;
  50870. private _cachedDefines;
  50871. private _effectLayerMapGenerationEffect;
  50872. private _effectLayerOptions;
  50873. private _mergeEffect;
  50874. protected _scene: Scene;
  50875. protected _engine: Engine;
  50876. protected _maxSize: number;
  50877. protected _mainTextureDesiredSize: ISize;
  50878. protected _mainTexture: RenderTargetTexture;
  50879. protected _shouldRender: boolean;
  50880. protected _postProcesses: PostProcess[];
  50881. protected _textures: BaseTexture[];
  50882. protected _emissiveTextureAndColor: {
  50883. texture: Nullable<BaseTexture>;
  50884. color: Color4;
  50885. };
  50886. /**
  50887. * The name of the layer
  50888. */
  50889. name: string;
  50890. /**
  50891. * The clear color of the texture used to generate the glow map.
  50892. */
  50893. neutralColor: Color4;
  50894. /**
  50895. * Specifies wether the highlight layer is enabled or not.
  50896. */
  50897. isEnabled: boolean;
  50898. /**
  50899. * Gets the camera attached to the layer.
  50900. */
  50901. readonly camera: Nullable<Camera>;
  50902. /**
  50903. * Gets the rendering group id the layer should render in.
  50904. */
  50905. renderingGroupId: number;
  50906. /**
  50907. * An event triggered when the effect layer has been disposed.
  50908. */
  50909. onDisposeObservable: Observable<EffectLayer>;
  50910. /**
  50911. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50912. */
  50913. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50914. /**
  50915. * An event triggered when the generated texture is being merged in the scene.
  50916. */
  50917. onBeforeComposeObservable: Observable<EffectLayer>;
  50918. /**
  50919. * An event triggered when the generated texture has been merged in the scene.
  50920. */
  50921. onAfterComposeObservable: Observable<EffectLayer>;
  50922. /**
  50923. * An event triggered when the efffect layer changes its size.
  50924. */
  50925. onSizeChangedObservable: Observable<EffectLayer>;
  50926. /** @hidden */
  50927. static _SceneComponentInitialization: (scene: Scene) => void;
  50928. /**
  50929. * Instantiates a new effect Layer and references it in the scene.
  50930. * @param name The name of the layer
  50931. * @param scene The scene to use the layer in
  50932. */
  50933. constructor(
  50934. /** The Friendly of the effect in the scene */
  50935. name: string, scene: Scene);
  50936. /**
  50937. * Get the effect name of the layer.
  50938. * @return The effect name
  50939. */
  50940. abstract getEffectName(): string;
  50941. /**
  50942. * Checks for the readiness of the element composing the layer.
  50943. * @param subMesh the mesh to check for
  50944. * @param useInstances specify wether or not to use instances to render the mesh
  50945. * @return true if ready otherwise, false
  50946. */
  50947. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50948. /**
  50949. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50950. * @returns true if the effect requires stencil during the main canvas render pass.
  50951. */
  50952. abstract needStencil(): boolean;
  50953. /**
  50954. * Create the merge effect. This is the shader use to blit the information back
  50955. * to the main canvas at the end of the scene rendering.
  50956. * @returns The effect containing the shader used to merge the effect on the main canvas
  50957. */
  50958. protected abstract _createMergeEffect(): Effect;
  50959. /**
  50960. * Creates the render target textures and post processes used in the effect layer.
  50961. */
  50962. protected abstract _createTextureAndPostProcesses(): void;
  50963. /**
  50964. * Implementation specific of rendering the generating effect on the main canvas.
  50965. * @param effect The effect used to render through
  50966. */
  50967. protected abstract _internalRender(effect: Effect): void;
  50968. /**
  50969. * Sets the required values for both the emissive texture and and the main color.
  50970. */
  50971. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50972. /**
  50973. * Free any resources and references associated to a mesh.
  50974. * Internal use
  50975. * @param mesh The mesh to free.
  50976. */
  50977. abstract _disposeMesh(mesh: Mesh): void;
  50978. /**
  50979. * Serializes this layer (Glow or Highlight for example)
  50980. * @returns a serialized layer object
  50981. */
  50982. abstract serialize?(): any;
  50983. /**
  50984. * Initializes the effect layer with the required options.
  50985. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50986. */
  50987. protected _init(options: Partial<IEffectLayerOptions>): void;
  50988. /**
  50989. * Generates the index buffer of the full screen quad blending to the main canvas.
  50990. */
  50991. private _generateIndexBuffer;
  50992. /**
  50993. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50994. */
  50995. private _generateVertexBuffer;
  50996. /**
  50997. * Sets the main texture desired size which is the closest power of two
  50998. * of the engine canvas size.
  50999. */
  51000. private _setMainTextureSize;
  51001. /**
  51002. * Creates the main texture for the effect layer.
  51003. */
  51004. protected _createMainTexture(): void;
  51005. /**
  51006. * Adds specific effects defines.
  51007. * @param defines The defines to add specifics to.
  51008. */
  51009. protected _addCustomEffectDefines(defines: string[]): void;
  51010. /**
  51011. * Checks for the readiness of the element composing the layer.
  51012. * @param subMesh the mesh to check for
  51013. * @param useInstances specify wether or not to use instances to render the mesh
  51014. * @param emissiveTexture the associated emissive texture used to generate the glow
  51015. * @return true if ready otherwise, false
  51016. */
  51017. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51018. /**
  51019. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51020. */
  51021. render(): void;
  51022. /**
  51023. * Determine if a given mesh will be used in the current effect.
  51024. * @param mesh mesh to test
  51025. * @returns true if the mesh will be used
  51026. */
  51027. hasMesh(mesh: AbstractMesh): boolean;
  51028. /**
  51029. * Returns true if the layer contains information to display, otherwise false.
  51030. * @returns true if the glow layer should be rendered
  51031. */
  51032. shouldRender(): boolean;
  51033. /**
  51034. * Returns true if the mesh should render, otherwise false.
  51035. * @param mesh The mesh to render
  51036. * @returns true if it should render otherwise false
  51037. */
  51038. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51039. /**
  51040. * Returns true if the mesh can be rendered, otherwise false.
  51041. * @param mesh The mesh to render
  51042. * @param material The material used on the mesh
  51043. * @returns true if it can be rendered otherwise false
  51044. */
  51045. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51046. /**
  51047. * Returns true if the mesh should render, otherwise false.
  51048. * @param mesh The mesh to render
  51049. * @returns true if it should render otherwise false
  51050. */
  51051. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51052. /**
  51053. * Renders the submesh passed in parameter to the generation map.
  51054. */
  51055. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51056. /**
  51057. * Rebuild the required buffers.
  51058. * @hidden Internal use only.
  51059. */
  51060. _rebuild(): void;
  51061. /**
  51062. * Dispose only the render target textures and post process.
  51063. */
  51064. private _disposeTextureAndPostProcesses;
  51065. /**
  51066. * Dispose the highlight layer and free resources.
  51067. */
  51068. dispose(): void;
  51069. /**
  51070. * Gets the class name of the effect layer
  51071. * @returns the string with the class name of the effect layer
  51072. */
  51073. getClassName(): string;
  51074. /**
  51075. * Creates an effect layer from parsed effect layer data
  51076. * @param parsedEffectLayer defines effect layer data
  51077. * @param scene defines the current scene
  51078. * @param rootUrl defines the root URL containing the effect layer information
  51079. * @returns a parsed effect Layer
  51080. */
  51081. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51082. }
  51083. }
  51084. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51085. import { Scene } from "babylonjs/scene";
  51086. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51087. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51088. import { AbstractScene } from "babylonjs/abstractScene";
  51089. module "babylonjs/abstractScene" {
  51090. interface AbstractScene {
  51091. /**
  51092. * The list of effect layers (highlights/glow) added to the scene
  51093. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51094. * @see http://doc.babylonjs.com/how_to/glow_layer
  51095. */
  51096. effectLayers: Array<EffectLayer>;
  51097. /**
  51098. * Removes the given effect layer from this scene.
  51099. * @param toRemove defines the effect layer to remove
  51100. * @returns the index of the removed effect layer
  51101. */
  51102. removeEffectLayer(toRemove: EffectLayer): number;
  51103. /**
  51104. * Adds the given effect layer to this scene
  51105. * @param newEffectLayer defines the effect layer to add
  51106. */
  51107. addEffectLayer(newEffectLayer: EffectLayer): void;
  51108. }
  51109. }
  51110. /**
  51111. * Defines the layer scene component responsible to manage any effect layers
  51112. * in a given scene.
  51113. */
  51114. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51115. /**
  51116. * The component name helpfull to identify the component in the list of scene components.
  51117. */
  51118. readonly name: string;
  51119. /**
  51120. * The scene the component belongs to.
  51121. */
  51122. scene: Scene;
  51123. private _engine;
  51124. private _renderEffects;
  51125. private _needStencil;
  51126. private _previousStencilState;
  51127. /**
  51128. * Creates a new instance of the component for the given scene
  51129. * @param scene Defines the scene to register the component in
  51130. */
  51131. constructor(scene: Scene);
  51132. /**
  51133. * Registers the component in a given scene
  51134. */
  51135. register(): void;
  51136. /**
  51137. * Rebuilds the elements related to this component in case of
  51138. * context lost for instance.
  51139. */
  51140. rebuild(): void;
  51141. /**
  51142. * Serializes the component data to the specified json object
  51143. * @param serializationObject The object to serialize to
  51144. */
  51145. serialize(serializationObject: any): void;
  51146. /**
  51147. * Adds all the elements from the container to the scene
  51148. * @param container the container holding the elements
  51149. */
  51150. addFromContainer(container: AbstractScene): void;
  51151. /**
  51152. * Removes all the elements in the container from the scene
  51153. * @param container contains the elements to remove
  51154. * @param dispose if the removed element should be disposed (default: false)
  51155. */
  51156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51157. /**
  51158. * Disposes the component and the associated ressources.
  51159. */
  51160. dispose(): void;
  51161. private _isReadyForMesh;
  51162. private _renderMainTexture;
  51163. private _setStencil;
  51164. private _setStencilBack;
  51165. private _draw;
  51166. private _drawCamera;
  51167. private _drawRenderingGroup;
  51168. }
  51169. }
  51170. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51171. /** @hidden */
  51172. export var glowMapMergePixelShader: {
  51173. name: string;
  51174. shader: string;
  51175. };
  51176. }
  51177. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51178. /** @hidden */
  51179. export var glowMapMergeVertexShader: {
  51180. name: string;
  51181. shader: string;
  51182. };
  51183. }
  51184. declare module "babylonjs/Layers/glowLayer" {
  51185. import { Nullable } from "babylonjs/types";
  51186. import { Camera } from "babylonjs/Cameras/camera";
  51187. import { Scene } from "babylonjs/scene";
  51188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51190. import { Mesh } from "babylonjs/Meshes/mesh";
  51191. import { Texture } from "babylonjs/Materials/Textures/texture";
  51192. import { Effect } from "babylonjs/Materials/effect";
  51193. import { Material } from "babylonjs/Materials/material";
  51194. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51195. import { Color4 } from "babylonjs/Maths/math.color";
  51196. import "babylonjs/Shaders/glowMapMerge.fragment";
  51197. import "babylonjs/Shaders/glowMapMerge.vertex";
  51198. import "babylonjs/Layers/effectLayerSceneComponent";
  51199. module "babylonjs/abstractScene" {
  51200. interface AbstractScene {
  51201. /**
  51202. * Return a the first highlight layer of the scene with a given name.
  51203. * @param name The name of the highlight layer to look for.
  51204. * @return The highlight layer if found otherwise null.
  51205. */
  51206. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51207. }
  51208. }
  51209. /**
  51210. * Glow layer options. This helps customizing the behaviour
  51211. * of the glow layer.
  51212. */
  51213. export interface IGlowLayerOptions {
  51214. /**
  51215. * Multiplication factor apply to the canvas size to compute the render target size
  51216. * used to generated the glowing objects (the smaller the faster).
  51217. */
  51218. mainTextureRatio: number;
  51219. /**
  51220. * Enforces a fixed size texture to ensure resize independant blur.
  51221. */
  51222. mainTextureFixedSize?: number;
  51223. /**
  51224. * How big is the kernel of the blur texture.
  51225. */
  51226. blurKernelSize: number;
  51227. /**
  51228. * The camera attached to the layer.
  51229. */
  51230. camera: Nullable<Camera>;
  51231. /**
  51232. * Enable MSAA by chosing the number of samples.
  51233. */
  51234. mainTextureSamples?: number;
  51235. /**
  51236. * The rendering group to draw the layer in.
  51237. */
  51238. renderingGroupId: number;
  51239. }
  51240. /**
  51241. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51242. *
  51243. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51244. * glowy meshes to your scene.
  51245. *
  51246. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51247. */
  51248. export class GlowLayer extends EffectLayer {
  51249. /**
  51250. * Effect Name of the layer.
  51251. */
  51252. static readonly EffectName: string;
  51253. /**
  51254. * The default blur kernel size used for the glow.
  51255. */
  51256. static DefaultBlurKernelSize: number;
  51257. /**
  51258. * The default texture size ratio used for the glow.
  51259. */
  51260. static DefaultTextureRatio: number;
  51261. /**
  51262. * Sets the kernel size of the blur.
  51263. */
  51264. /**
  51265. * Gets the kernel size of the blur.
  51266. */
  51267. blurKernelSize: number;
  51268. /**
  51269. * Sets the glow intensity.
  51270. */
  51271. /**
  51272. * Gets the glow intensity.
  51273. */
  51274. intensity: number;
  51275. private _options;
  51276. private _intensity;
  51277. private _horizontalBlurPostprocess1;
  51278. private _verticalBlurPostprocess1;
  51279. private _horizontalBlurPostprocess2;
  51280. private _verticalBlurPostprocess2;
  51281. private _blurTexture1;
  51282. private _blurTexture2;
  51283. private _postProcesses1;
  51284. private _postProcesses2;
  51285. private _includedOnlyMeshes;
  51286. private _excludedMeshes;
  51287. /**
  51288. * Callback used to let the user override the color selection on a per mesh basis
  51289. */
  51290. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51291. /**
  51292. * Callback used to let the user override the texture selection on a per mesh basis
  51293. */
  51294. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51295. /**
  51296. * Instantiates a new glow Layer and references it to the scene.
  51297. * @param name The name of the layer
  51298. * @param scene The scene to use the layer in
  51299. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51300. */
  51301. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51302. /**
  51303. * Get the effect name of the layer.
  51304. * @return The effect name
  51305. */
  51306. getEffectName(): string;
  51307. /**
  51308. * Create the merge effect. This is the shader use to blit the information back
  51309. * to the main canvas at the end of the scene rendering.
  51310. */
  51311. protected _createMergeEffect(): Effect;
  51312. /**
  51313. * Creates the render target textures and post processes used in the glow layer.
  51314. */
  51315. protected _createTextureAndPostProcesses(): void;
  51316. /**
  51317. * Checks for the readiness of the element composing the layer.
  51318. * @param subMesh the mesh to check for
  51319. * @param useInstances specify wether or not to use instances to render the mesh
  51320. * @param emissiveTexture the associated emissive texture used to generate the glow
  51321. * @return true if ready otherwise, false
  51322. */
  51323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51324. /**
  51325. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51326. */
  51327. needStencil(): boolean;
  51328. /**
  51329. * Returns true if the mesh can be rendered, otherwise false.
  51330. * @param mesh The mesh to render
  51331. * @param material The material used on the mesh
  51332. * @returns true if it can be rendered otherwise false
  51333. */
  51334. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51335. /**
  51336. * Implementation specific of rendering the generating effect on the main canvas.
  51337. * @param effect The effect used to render through
  51338. */
  51339. protected _internalRender(effect: Effect): void;
  51340. /**
  51341. * Sets the required values for both the emissive texture and and the main color.
  51342. */
  51343. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51344. /**
  51345. * Returns true if the mesh should render, otherwise false.
  51346. * @param mesh The mesh to render
  51347. * @returns true if it should render otherwise false
  51348. */
  51349. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51350. /**
  51351. * Adds specific effects defines.
  51352. * @param defines The defines to add specifics to.
  51353. */
  51354. protected _addCustomEffectDefines(defines: string[]): void;
  51355. /**
  51356. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51357. * @param mesh The mesh to exclude from the glow layer
  51358. */
  51359. addExcludedMesh(mesh: Mesh): void;
  51360. /**
  51361. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51362. * @param mesh The mesh to remove
  51363. */
  51364. removeExcludedMesh(mesh: Mesh): void;
  51365. /**
  51366. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51367. * @param mesh The mesh to include in the glow layer
  51368. */
  51369. addIncludedOnlyMesh(mesh: Mesh): void;
  51370. /**
  51371. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51372. * @param mesh The mesh to remove
  51373. */
  51374. removeIncludedOnlyMesh(mesh: Mesh): void;
  51375. /**
  51376. * Determine if a given mesh will be used in the glow layer
  51377. * @param mesh The mesh to test
  51378. * @returns true if the mesh will be highlighted by the current glow layer
  51379. */
  51380. hasMesh(mesh: AbstractMesh): boolean;
  51381. /**
  51382. * Free any resources and references associated to a mesh.
  51383. * Internal use
  51384. * @param mesh The mesh to free.
  51385. * @hidden
  51386. */
  51387. _disposeMesh(mesh: Mesh): void;
  51388. /**
  51389. * Gets the class name of the effect layer
  51390. * @returns the string with the class name of the effect layer
  51391. */
  51392. getClassName(): string;
  51393. /**
  51394. * Serializes this glow layer
  51395. * @returns a serialized glow layer object
  51396. */
  51397. serialize(): any;
  51398. /**
  51399. * Creates a Glow Layer from parsed glow layer data
  51400. * @param parsedGlowLayer defines glow layer data
  51401. * @param scene defines the current scene
  51402. * @param rootUrl defines the root URL containing the glow layer information
  51403. * @returns a parsed Glow Layer
  51404. */
  51405. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51406. }
  51407. }
  51408. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51409. /** @hidden */
  51410. export var glowBlurPostProcessPixelShader: {
  51411. name: string;
  51412. shader: string;
  51413. };
  51414. }
  51415. declare module "babylonjs/Layers/highlightLayer" {
  51416. import { Observable } from "babylonjs/Misc/observable";
  51417. import { Nullable } from "babylonjs/types";
  51418. import { Camera } from "babylonjs/Cameras/camera";
  51419. import { Scene } from "babylonjs/scene";
  51420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51422. import { Mesh } from "babylonjs/Meshes/mesh";
  51423. import { Effect } from "babylonjs/Materials/effect";
  51424. import { Material } from "babylonjs/Materials/material";
  51425. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51426. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51427. import "babylonjs/Shaders/glowMapMerge.fragment";
  51428. import "babylonjs/Shaders/glowMapMerge.vertex";
  51429. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51430. module "babylonjs/abstractScene" {
  51431. interface AbstractScene {
  51432. /**
  51433. * Return a the first highlight layer of the scene with a given name.
  51434. * @param name The name of the highlight layer to look for.
  51435. * @return The highlight layer if found otherwise null.
  51436. */
  51437. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51438. }
  51439. }
  51440. /**
  51441. * Highlight layer options. This helps customizing the behaviour
  51442. * of the highlight layer.
  51443. */
  51444. export interface IHighlightLayerOptions {
  51445. /**
  51446. * Multiplication factor apply to the canvas size to compute the render target size
  51447. * used to generated the glowing objects (the smaller the faster).
  51448. */
  51449. mainTextureRatio: number;
  51450. /**
  51451. * Enforces a fixed size texture to ensure resize independant blur.
  51452. */
  51453. mainTextureFixedSize?: number;
  51454. /**
  51455. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51456. * of the picture to blur (the smaller the faster).
  51457. */
  51458. blurTextureSizeRatio: number;
  51459. /**
  51460. * How big in texel of the blur texture is the vertical blur.
  51461. */
  51462. blurVerticalSize: number;
  51463. /**
  51464. * How big in texel of the blur texture is the horizontal blur.
  51465. */
  51466. blurHorizontalSize: number;
  51467. /**
  51468. * Alpha blending mode used to apply the blur. Default is combine.
  51469. */
  51470. alphaBlendingMode: number;
  51471. /**
  51472. * The camera attached to the layer.
  51473. */
  51474. camera: Nullable<Camera>;
  51475. /**
  51476. * Should we display highlight as a solid stroke?
  51477. */
  51478. isStroke?: boolean;
  51479. /**
  51480. * The rendering group to draw the layer in.
  51481. */
  51482. renderingGroupId: number;
  51483. }
  51484. /**
  51485. * The highlight layer Helps adding a glow effect around a mesh.
  51486. *
  51487. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51488. * glowy meshes to your scene.
  51489. *
  51490. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51491. */
  51492. export class HighlightLayer extends EffectLayer {
  51493. name: string;
  51494. /**
  51495. * Effect Name of the highlight layer.
  51496. */
  51497. static readonly EffectName: string;
  51498. /**
  51499. * The neutral color used during the preparation of the glow effect.
  51500. * This is black by default as the blend operation is a blend operation.
  51501. */
  51502. static NeutralColor: Color4;
  51503. /**
  51504. * Stencil value used for glowing meshes.
  51505. */
  51506. static GlowingMeshStencilReference: number;
  51507. /**
  51508. * Stencil value used for the other meshes in the scene.
  51509. */
  51510. static NormalMeshStencilReference: number;
  51511. /**
  51512. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51513. */
  51514. innerGlow: boolean;
  51515. /**
  51516. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51517. */
  51518. outerGlow: boolean;
  51519. /**
  51520. * Specifies the horizontal size of the blur.
  51521. */
  51522. /**
  51523. * Gets the horizontal size of the blur.
  51524. */
  51525. blurHorizontalSize: number;
  51526. /**
  51527. * Specifies the vertical size of the blur.
  51528. */
  51529. /**
  51530. * Gets the vertical size of the blur.
  51531. */
  51532. blurVerticalSize: number;
  51533. /**
  51534. * An event triggered when the highlight layer is being blurred.
  51535. */
  51536. onBeforeBlurObservable: Observable<HighlightLayer>;
  51537. /**
  51538. * An event triggered when the highlight layer has been blurred.
  51539. */
  51540. onAfterBlurObservable: Observable<HighlightLayer>;
  51541. private _instanceGlowingMeshStencilReference;
  51542. private _options;
  51543. private _downSamplePostprocess;
  51544. private _horizontalBlurPostprocess;
  51545. private _verticalBlurPostprocess;
  51546. private _blurTexture;
  51547. private _meshes;
  51548. private _excludedMeshes;
  51549. /**
  51550. * Instantiates a new highlight Layer and references it to the scene..
  51551. * @param name The name of the layer
  51552. * @param scene The scene to use the layer in
  51553. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51554. */
  51555. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51556. /**
  51557. * Get the effect name of the layer.
  51558. * @return The effect name
  51559. */
  51560. getEffectName(): string;
  51561. /**
  51562. * Create the merge effect. This is the shader use to blit the information back
  51563. * to the main canvas at the end of the scene rendering.
  51564. */
  51565. protected _createMergeEffect(): Effect;
  51566. /**
  51567. * Creates the render target textures and post processes used in the highlight layer.
  51568. */
  51569. protected _createTextureAndPostProcesses(): void;
  51570. /**
  51571. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51572. */
  51573. needStencil(): boolean;
  51574. /**
  51575. * Checks for the readiness of the element composing the layer.
  51576. * @param subMesh the mesh to check for
  51577. * @param useInstances specify wether or not to use instances to render the mesh
  51578. * @param emissiveTexture the associated emissive texture used to generate the glow
  51579. * @return true if ready otherwise, false
  51580. */
  51581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51582. /**
  51583. * Implementation specific of rendering the generating effect on the main canvas.
  51584. * @param effect The effect used to render through
  51585. */
  51586. protected _internalRender(effect: Effect): void;
  51587. /**
  51588. * Returns true if the layer contains information to display, otherwise false.
  51589. */
  51590. shouldRender(): boolean;
  51591. /**
  51592. * Returns true if the mesh should render, otherwise false.
  51593. * @param mesh The mesh to render
  51594. * @returns true if it should render otherwise false
  51595. */
  51596. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51597. /**
  51598. * Sets the required values for both the emissive texture and and the main color.
  51599. */
  51600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51601. /**
  51602. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51603. * @param mesh The mesh to exclude from the highlight layer
  51604. */
  51605. addExcludedMesh(mesh: Mesh): void;
  51606. /**
  51607. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51608. * @param mesh The mesh to highlight
  51609. */
  51610. removeExcludedMesh(mesh: Mesh): void;
  51611. /**
  51612. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51613. * @param mesh mesh to test
  51614. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51615. */
  51616. hasMesh(mesh: AbstractMesh): boolean;
  51617. /**
  51618. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51619. * @param mesh The mesh to highlight
  51620. * @param color The color of the highlight
  51621. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51622. */
  51623. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51624. /**
  51625. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51626. * @param mesh The mesh to highlight
  51627. */
  51628. removeMesh(mesh: Mesh): void;
  51629. /**
  51630. * Force the stencil to the normal expected value for none glowing parts
  51631. */
  51632. private _defaultStencilReference;
  51633. /**
  51634. * Free any resources and references associated to a mesh.
  51635. * Internal use
  51636. * @param mesh The mesh to free.
  51637. * @hidden
  51638. */
  51639. _disposeMesh(mesh: Mesh): void;
  51640. /**
  51641. * Dispose the highlight layer and free resources.
  51642. */
  51643. dispose(): void;
  51644. /**
  51645. * Gets the class name of the effect layer
  51646. * @returns the string with the class name of the effect layer
  51647. */
  51648. getClassName(): string;
  51649. /**
  51650. * Serializes this Highlight layer
  51651. * @returns a serialized Highlight layer object
  51652. */
  51653. serialize(): any;
  51654. /**
  51655. * Creates a Highlight layer from parsed Highlight layer data
  51656. * @param parsedHightlightLayer defines the Highlight layer data
  51657. * @param scene defines the current scene
  51658. * @param rootUrl defines the root URL containing the Highlight layer information
  51659. * @returns a parsed Highlight layer
  51660. */
  51661. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51662. }
  51663. }
  51664. declare module "babylonjs/Layers/layerSceneComponent" {
  51665. import { Scene } from "babylonjs/scene";
  51666. import { ISceneComponent } from "babylonjs/sceneComponent";
  51667. import { Layer } from "babylonjs/Layers/layer";
  51668. import { AbstractScene } from "babylonjs/abstractScene";
  51669. module "babylonjs/abstractScene" {
  51670. interface AbstractScene {
  51671. /**
  51672. * The list of layers (background and foreground) of the scene
  51673. */
  51674. layers: Array<Layer>;
  51675. }
  51676. }
  51677. /**
  51678. * Defines the layer scene component responsible to manage any layers
  51679. * in a given scene.
  51680. */
  51681. export class LayerSceneComponent implements ISceneComponent {
  51682. /**
  51683. * The component name helpfull to identify the component in the list of scene components.
  51684. */
  51685. readonly name: string;
  51686. /**
  51687. * The scene the component belongs to.
  51688. */
  51689. scene: Scene;
  51690. private _engine;
  51691. /**
  51692. * Creates a new instance of the component for the given scene
  51693. * @param scene Defines the scene to register the component in
  51694. */
  51695. constructor(scene: Scene);
  51696. /**
  51697. * Registers the component in a given scene
  51698. */
  51699. register(): void;
  51700. /**
  51701. * Rebuilds the elements related to this component in case of
  51702. * context lost for instance.
  51703. */
  51704. rebuild(): void;
  51705. /**
  51706. * Disposes the component and the associated ressources.
  51707. */
  51708. dispose(): void;
  51709. private _draw;
  51710. private _drawCameraPredicate;
  51711. private _drawCameraBackground;
  51712. private _drawCameraForeground;
  51713. private _drawRenderTargetPredicate;
  51714. private _drawRenderTargetBackground;
  51715. private _drawRenderTargetForeground;
  51716. /**
  51717. * Adds all the elements from the container to the scene
  51718. * @param container the container holding the elements
  51719. */
  51720. addFromContainer(container: AbstractScene): void;
  51721. /**
  51722. * Removes all the elements in the container from the scene
  51723. * @param container contains the elements to remove
  51724. * @param dispose if the removed element should be disposed (default: false)
  51725. */
  51726. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51727. }
  51728. }
  51729. declare module "babylonjs/Shaders/layer.fragment" {
  51730. /** @hidden */
  51731. export var layerPixelShader: {
  51732. name: string;
  51733. shader: string;
  51734. };
  51735. }
  51736. declare module "babylonjs/Shaders/layer.vertex" {
  51737. /** @hidden */
  51738. export var layerVertexShader: {
  51739. name: string;
  51740. shader: string;
  51741. };
  51742. }
  51743. declare module "babylonjs/Layers/layer" {
  51744. import { Observable } from "babylonjs/Misc/observable";
  51745. import { Nullable } from "babylonjs/types";
  51746. import { Scene } from "babylonjs/scene";
  51747. import { Vector2 } from "babylonjs/Maths/math.vector";
  51748. import { Color4 } from "babylonjs/Maths/math.color";
  51749. import { Texture } from "babylonjs/Materials/Textures/texture";
  51750. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51751. import "babylonjs/Shaders/layer.fragment";
  51752. import "babylonjs/Shaders/layer.vertex";
  51753. /**
  51754. * This represents a full screen 2d layer.
  51755. * This can be useful to display a picture in the background of your scene for instance.
  51756. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51757. */
  51758. export class Layer {
  51759. /**
  51760. * Define the name of the layer.
  51761. */
  51762. name: string;
  51763. /**
  51764. * Define the texture the layer should display.
  51765. */
  51766. texture: Nullable<Texture>;
  51767. /**
  51768. * Is the layer in background or foreground.
  51769. */
  51770. isBackground: boolean;
  51771. /**
  51772. * Define the color of the layer (instead of texture).
  51773. */
  51774. color: Color4;
  51775. /**
  51776. * Define the scale of the layer in order to zoom in out of the texture.
  51777. */
  51778. scale: Vector2;
  51779. /**
  51780. * Define an offset for the layer in order to shift the texture.
  51781. */
  51782. offset: Vector2;
  51783. /**
  51784. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51785. */
  51786. alphaBlendingMode: number;
  51787. /**
  51788. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51789. * Alpha test will not mix with the background color in case of transparency.
  51790. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51791. */
  51792. alphaTest: boolean;
  51793. /**
  51794. * Define a mask to restrict the layer to only some of the scene cameras.
  51795. */
  51796. layerMask: number;
  51797. /**
  51798. * Define the list of render target the layer is visible into.
  51799. */
  51800. renderTargetTextures: RenderTargetTexture[];
  51801. /**
  51802. * Define if the layer is only used in renderTarget or if it also
  51803. * renders in the main frame buffer of the canvas.
  51804. */
  51805. renderOnlyInRenderTargetTextures: boolean;
  51806. private _scene;
  51807. private _vertexBuffers;
  51808. private _indexBuffer;
  51809. private _effect;
  51810. private _alphaTestEffect;
  51811. /**
  51812. * An event triggered when the layer is disposed.
  51813. */
  51814. onDisposeObservable: Observable<Layer>;
  51815. private _onDisposeObserver;
  51816. /**
  51817. * Back compatibility with callback before the onDisposeObservable existed.
  51818. * The set callback will be triggered when the layer has been disposed.
  51819. */
  51820. onDispose: () => void;
  51821. /**
  51822. * An event triggered before rendering the scene
  51823. */
  51824. onBeforeRenderObservable: Observable<Layer>;
  51825. private _onBeforeRenderObserver;
  51826. /**
  51827. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51828. * The set callback will be triggered just before rendering the layer.
  51829. */
  51830. onBeforeRender: () => void;
  51831. /**
  51832. * An event triggered after rendering the scene
  51833. */
  51834. onAfterRenderObservable: Observable<Layer>;
  51835. private _onAfterRenderObserver;
  51836. /**
  51837. * Back compatibility with callback before the onAfterRenderObservable existed.
  51838. * The set callback will be triggered just after rendering the layer.
  51839. */
  51840. onAfterRender: () => void;
  51841. /**
  51842. * Instantiates a new layer.
  51843. * This represents a full screen 2d layer.
  51844. * This can be useful to display a picture in the background of your scene for instance.
  51845. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51846. * @param name Define the name of the layer in the scene
  51847. * @param imgUrl Define the url of the texture to display in the layer
  51848. * @param scene Define the scene the layer belongs to
  51849. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51850. * @param color Defines a color for the layer
  51851. */
  51852. constructor(
  51853. /**
  51854. * Define the name of the layer.
  51855. */
  51856. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51857. private _createIndexBuffer;
  51858. /** @hidden */
  51859. _rebuild(): void;
  51860. /**
  51861. * Renders the layer in the scene.
  51862. */
  51863. render(): void;
  51864. /**
  51865. * Disposes and releases the associated ressources.
  51866. */
  51867. dispose(): void;
  51868. }
  51869. }
  51870. declare module "babylonjs/Layers/index" {
  51871. export * from "babylonjs/Layers/effectLayer";
  51872. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51873. export * from "babylonjs/Layers/glowLayer";
  51874. export * from "babylonjs/Layers/highlightLayer";
  51875. export * from "babylonjs/Layers/layer";
  51876. export * from "babylonjs/Layers/layerSceneComponent";
  51877. }
  51878. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51879. /** @hidden */
  51880. export var lensFlarePixelShader: {
  51881. name: string;
  51882. shader: string;
  51883. };
  51884. }
  51885. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51886. /** @hidden */
  51887. export var lensFlareVertexShader: {
  51888. name: string;
  51889. shader: string;
  51890. };
  51891. }
  51892. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51893. import { Scene } from "babylonjs/scene";
  51894. import { Vector3 } from "babylonjs/Maths/math.vector";
  51895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51896. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51897. import "babylonjs/Shaders/lensFlare.fragment";
  51898. import "babylonjs/Shaders/lensFlare.vertex";
  51899. import { Viewport } from "babylonjs/Maths/math.viewport";
  51900. /**
  51901. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51902. * It is usually composed of several `lensFlare`.
  51903. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51904. */
  51905. export class LensFlareSystem {
  51906. /**
  51907. * Define the name of the lens flare system
  51908. */
  51909. name: string;
  51910. /**
  51911. * List of lens flares used in this system.
  51912. */
  51913. lensFlares: LensFlare[];
  51914. /**
  51915. * Define a limit from the border the lens flare can be visible.
  51916. */
  51917. borderLimit: number;
  51918. /**
  51919. * Define a viewport border we do not want to see the lens flare in.
  51920. */
  51921. viewportBorder: number;
  51922. /**
  51923. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51924. */
  51925. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51926. /**
  51927. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51928. */
  51929. layerMask: number;
  51930. /**
  51931. * Define the id of the lens flare system in the scene.
  51932. * (equal to name by default)
  51933. */
  51934. id: string;
  51935. private _scene;
  51936. private _emitter;
  51937. private _vertexBuffers;
  51938. private _indexBuffer;
  51939. private _effect;
  51940. private _positionX;
  51941. private _positionY;
  51942. private _isEnabled;
  51943. /** @hidden */
  51944. static _SceneComponentInitialization: (scene: Scene) => void;
  51945. /**
  51946. * Instantiates a lens flare system.
  51947. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51948. * It is usually composed of several `lensFlare`.
  51949. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51950. * @param name Define the name of the lens flare system in the scene
  51951. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51952. * @param scene Define the scene the lens flare system belongs to
  51953. */
  51954. constructor(
  51955. /**
  51956. * Define the name of the lens flare system
  51957. */
  51958. name: string, emitter: any, scene: Scene);
  51959. /**
  51960. * Define if the lens flare system is enabled.
  51961. */
  51962. isEnabled: boolean;
  51963. /**
  51964. * Get the scene the effects belongs to.
  51965. * @returns the scene holding the lens flare system
  51966. */
  51967. getScene(): Scene;
  51968. /**
  51969. * Get the emitter of the lens flare system.
  51970. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51971. * @returns the emitter of the lens flare system
  51972. */
  51973. getEmitter(): any;
  51974. /**
  51975. * Set the emitter of the lens flare system.
  51976. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51977. * @param newEmitter Define the new emitter of the system
  51978. */
  51979. setEmitter(newEmitter: any): void;
  51980. /**
  51981. * Get the lens flare system emitter position.
  51982. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51983. * @returns the position
  51984. */
  51985. getEmitterPosition(): Vector3;
  51986. /**
  51987. * @hidden
  51988. */
  51989. computeEffectivePosition(globalViewport: Viewport): boolean;
  51990. /** @hidden */
  51991. _isVisible(): boolean;
  51992. /**
  51993. * @hidden
  51994. */
  51995. render(): boolean;
  51996. /**
  51997. * Dispose and release the lens flare with its associated resources.
  51998. */
  51999. dispose(): void;
  52000. /**
  52001. * Parse a lens flare system from a JSON repressentation
  52002. * @param parsedLensFlareSystem Define the JSON to parse
  52003. * @param scene Define the scene the parsed system should be instantiated in
  52004. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52005. * @returns the parsed system
  52006. */
  52007. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52008. /**
  52009. * Serialize the current Lens Flare System into a JSON representation.
  52010. * @returns the serialized JSON
  52011. */
  52012. serialize(): any;
  52013. }
  52014. }
  52015. declare module "babylonjs/LensFlares/lensFlare" {
  52016. import { Nullable } from "babylonjs/types";
  52017. import { Color3 } from "babylonjs/Maths/math.color";
  52018. import { Texture } from "babylonjs/Materials/Textures/texture";
  52019. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52020. /**
  52021. * This represents one of the lens effect in a `lensFlareSystem`.
  52022. * It controls one of the indiviual texture used in the effect.
  52023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52024. */
  52025. export class LensFlare {
  52026. /**
  52027. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52028. */
  52029. size: number;
  52030. /**
  52031. * 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.
  52032. */
  52033. position: number;
  52034. /**
  52035. * Define the lens color.
  52036. */
  52037. color: Color3;
  52038. /**
  52039. * Define the lens texture.
  52040. */
  52041. texture: Nullable<Texture>;
  52042. /**
  52043. * Define the alpha mode to render this particular lens.
  52044. */
  52045. alphaMode: number;
  52046. private _system;
  52047. /**
  52048. * Creates a new Lens Flare.
  52049. * This represents one of the lens effect in a `lensFlareSystem`.
  52050. * It controls one of the indiviual texture used in the effect.
  52051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52052. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52053. * @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.
  52054. * @param color Define the lens color
  52055. * @param imgUrl Define the lens texture url
  52056. * @param system Define the `lensFlareSystem` this flare is part of
  52057. * @returns The newly created Lens Flare
  52058. */
  52059. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52060. /**
  52061. * Instantiates a new Lens Flare.
  52062. * This represents one of the lens effect in a `lensFlareSystem`.
  52063. * It controls one of the indiviual texture used in the effect.
  52064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52065. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52066. * @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.
  52067. * @param color Define the lens color
  52068. * @param imgUrl Define the lens texture url
  52069. * @param system Define the `lensFlareSystem` this flare is part of
  52070. */
  52071. constructor(
  52072. /**
  52073. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52074. */
  52075. size: number,
  52076. /**
  52077. * 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.
  52078. */
  52079. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52080. /**
  52081. * Dispose and release the lens flare with its associated resources.
  52082. */
  52083. dispose(): void;
  52084. }
  52085. }
  52086. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52087. import { Nullable } from "babylonjs/types";
  52088. import { Scene } from "babylonjs/scene";
  52089. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52090. import { AbstractScene } from "babylonjs/abstractScene";
  52091. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52092. module "babylonjs/abstractScene" {
  52093. interface AbstractScene {
  52094. /**
  52095. * The list of lens flare system added to the scene
  52096. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52097. */
  52098. lensFlareSystems: Array<LensFlareSystem>;
  52099. /**
  52100. * Removes the given lens flare system from this scene.
  52101. * @param toRemove The lens flare system to remove
  52102. * @returns The index of the removed lens flare system
  52103. */
  52104. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52105. /**
  52106. * Adds the given lens flare system to this scene
  52107. * @param newLensFlareSystem The lens flare system to add
  52108. */
  52109. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52110. /**
  52111. * Gets a lens flare system using its name
  52112. * @param name defines the name to look for
  52113. * @returns the lens flare system or null if not found
  52114. */
  52115. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52116. /**
  52117. * Gets a lens flare system using its id
  52118. * @param id defines the id to look for
  52119. * @returns the lens flare system or null if not found
  52120. */
  52121. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52122. }
  52123. }
  52124. /**
  52125. * Defines the lens flare scene component responsible to manage any lens flares
  52126. * in a given scene.
  52127. */
  52128. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52129. /**
  52130. * The component name helpfull to identify the component in the list of scene components.
  52131. */
  52132. readonly name: string;
  52133. /**
  52134. * The scene the component belongs to.
  52135. */
  52136. scene: Scene;
  52137. /**
  52138. * Creates a new instance of the component for the given scene
  52139. * @param scene Defines the scene to register the component in
  52140. */
  52141. constructor(scene: Scene);
  52142. /**
  52143. * Registers the component in a given scene
  52144. */
  52145. register(): void;
  52146. /**
  52147. * Rebuilds the elements related to this component in case of
  52148. * context lost for instance.
  52149. */
  52150. rebuild(): void;
  52151. /**
  52152. * Adds all the elements from the container to the scene
  52153. * @param container the container holding the elements
  52154. */
  52155. addFromContainer(container: AbstractScene): void;
  52156. /**
  52157. * Removes all the elements in the container from the scene
  52158. * @param container contains the elements to remove
  52159. * @param dispose if the removed element should be disposed (default: false)
  52160. */
  52161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52162. /**
  52163. * Serializes the component data to the specified json object
  52164. * @param serializationObject The object to serialize to
  52165. */
  52166. serialize(serializationObject: any): void;
  52167. /**
  52168. * Disposes the component and the associated ressources.
  52169. */
  52170. dispose(): void;
  52171. private _draw;
  52172. }
  52173. }
  52174. declare module "babylonjs/LensFlares/index" {
  52175. export * from "babylonjs/LensFlares/lensFlare";
  52176. export * from "babylonjs/LensFlares/lensFlareSystem";
  52177. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52178. }
  52179. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52180. import { Scene } from "babylonjs/scene";
  52181. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52182. import { AbstractScene } from "babylonjs/abstractScene";
  52183. /**
  52184. * Defines the shadow generator component responsible to manage any shadow generators
  52185. * in a given scene.
  52186. */
  52187. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52188. /**
  52189. * The component name helpfull to identify the component in the list of scene components.
  52190. */
  52191. readonly name: string;
  52192. /**
  52193. * The scene the component belongs to.
  52194. */
  52195. scene: Scene;
  52196. /**
  52197. * Creates a new instance of the component for the given scene
  52198. * @param scene Defines the scene to register the component in
  52199. */
  52200. constructor(scene: Scene);
  52201. /**
  52202. * Registers the component in a given scene
  52203. */
  52204. register(): void;
  52205. /**
  52206. * Rebuilds the elements related to this component in case of
  52207. * context lost for instance.
  52208. */
  52209. rebuild(): void;
  52210. /**
  52211. * Serializes the component data to the specified json object
  52212. * @param serializationObject The object to serialize to
  52213. */
  52214. serialize(serializationObject: any): void;
  52215. /**
  52216. * Adds all the elements from the container to the scene
  52217. * @param container the container holding the elements
  52218. */
  52219. addFromContainer(container: AbstractScene): void;
  52220. /**
  52221. * Removes all the elements in the container from the scene
  52222. * @param container contains the elements to remove
  52223. * @param dispose if the removed element should be disposed (default: false)
  52224. */
  52225. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52226. /**
  52227. * Rebuilds the elements related to this component in case of
  52228. * context lost for instance.
  52229. */
  52230. dispose(): void;
  52231. private _gatherRenderTargets;
  52232. }
  52233. }
  52234. declare module "babylonjs/Lights/Shadows/index" {
  52235. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52236. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52237. }
  52238. declare module "babylonjs/Lights/pointLight" {
  52239. import { Scene } from "babylonjs/scene";
  52240. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52242. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52243. import { Effect } from "babylonjs/Materials/effect";
  52244. /**
  52245. * A point light is a light defined by an unique point in world space.
  52246. * The light is emitted in every direction from this point.
  52247. * A good example of a point light is a standard light bulb.
  52248. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52249. */
  52250. export class PointLight extends ShadowLight {
  52251. private _shadowAngle;
  52252. /**
  52253. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52254. * This specifies what angle the shadow will use to be created.
  52255. *
  52256. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52257. */
  52258. /**
  52259. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52260. * This specifies what angle the shadow will use to be created.
  52261. *
  52262. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52263. */
  52264. shadowAngle: number;
  52265. /**
  52266. * Gets the direction if it has been set.
  52267. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52268. */
  52269. /**
  52270. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52271. */
  52272. direction: Vector3;
  52273. /**
  52274. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52275. * A PointLight emits the light in every direction.
  52276. * It can cast shadows.
  52277. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52278. * ```javascript
  52279. * var pointLight = new PointLight("pl", camera.position, scene);
  52280. * ```
  52281. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52282. * @param name The light friendly name
  52283. * @param position The position of the point light in the scene
  52284. * @param scene The scene the lights belongs to
  52285. */
  52286. constructor(name: string, position: Vector3, scene: Scene);
  52287. /**
  52288. * Returns the string "PointLight"
  52289. * @returns the class name
  52290. */
  52291. getClassName(): string;
  52292. /**
  52293. * Returns the integer 0.
  52294. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52295. */
  52296. getTypeID(): number;
  52297. /**
  52298. * Specifies wether or not the shadowmap should be a cube texture.
  52299. * @returns true if the shadowmap needs to be a cube texture.
  52300. */
  52301. needCube(): boolean;
  52302. /**
  52303. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52304. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52305. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52306. */
  52307. getShadowDirection(faceIndex?: number): Vector3;
  52308. /**
  52309. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52310. * - fov = PI / 2
  52311. * - aspect ratio : 1.0
  52312. * - z-near and far equal to the active camera minZ and maxZ.
  52313. * Returns the PointLight.
  52314. */
  52315. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52316. protected _buildUniformLayout(): void;
  52317. /**
  52318. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52319. * @param effect The effect to update
  52320. * @param lightIndex The index of the light in the effect to update
  52321. * @returns The point light
  52322. */
  52323. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52324. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52325. /**
  52326. * Prepares the list of defines specific to the light type.
  52327. * @param defines the list of defines
  52328. * @param lightIndex defines the index of the light for the effect
  52329. */
  52330. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52331. }
  52332. }
  52333. declare module "babylonjs/Lights/index" {
  52334. export * from "babylonjs/Lights/light";
  52335. export * from "babylonjs/Lights/shadowLight";
  52336. export * from "babylonjs/Lights/Shadows/index";
  52337. export * from "babylonjs/Lights/directionalLight";
  52338. export * from "babylonjs/Lights/hemisphericLight";
  52339. export * from "babylonjs/Lights/pointLight";
  52340. export * from "babylonjs/Lights/spotLight";
  52341. }
  52342. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52343. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52344. /**
  52345. * Header information of HDR texture files.
  52346. */
  52347. export interface HDRInfo {
  52348. /**
  52349. * The height of the texture in pixels.
  52350. */
  52351. height: number;
  52352. /**
  52353. * The width of the texture in pixels.
  52354. */
  52355. width: number;
  52356. /**
  52357. * The index of the beginning of the data in the binary file.
  52358. */
  52359. dataPosition: number;
  52360. }
  52361. /**
  52362. * This groups tools to convert HDR texture to native colors array.
  52363. */
  52364. export class HDRTools {
  52365. private static Ldexp;
  52366. private static Rgbe2float;
  52367. private static readStringLine;
  52368. /**
  52369. * Reads header information from an RGBE texture stored in a native array.
  52370. * More information on this format are available here:
  52371. * https://en.wikipedia.org/wiki/RGBE_image_format
  52372. *
  52373. * @param uint8array The binary file stored in native array.
  52374. * @return The header information.
  52375. */
  52376. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52377. /**
  52378. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52379. * This RGBE texture needs to store the information as a panorama.
  52380. *
  52381. * More information on this format are available here:
  52382. * https://en.wikipedia.org/wiki/RGBE_image_format
  52383. *
  52384. * @param buffer The binary file stored in an array buffer.
  52385. * @param size The expected size of the extracted cubemap.
  52386. * @return The Cube Map information.
  52387. */
  52388. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52389. /**
  52390. * Returns the pixels data extracted from an RGBE texture.
  52391. * This pixels will be stored left to right up to down in the R G B order in one array.
  52392. *
  52393. * More information on this format are available here:
  52394. * https://en.wikipedia.org/wiki/RGBE_image_format
  52395. *
  52396. * @param uint8array The binary file stored in an array buffer.
  52397. * @param hdrInfo The header information of the file.
  52398. * @return The pixels data in RGB right to left up to down order.
  52399. */
  52400. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52401. private static RGBE_ReadPixels_RLE;
  52402. }
  52403. }
  52404. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52405. import { Nullable } from "babylonjs/types";
  52406. import { Scene } from "babylonjs/scene";
  52407. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52409. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52410. /**
  52411. * This represents a texture coming from an HDR input.
  52412. *
  52413. * The only supported format is currently panorama picture stored in RGBE format.
  52414. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52415. */
  52416. export class HDRCubeTexture extends BaseTexture {
  52417. private static _facesMapping;
  52418. private _generateHarmonics;
  52419. private _noMipmap;
  52420. private _textureMatrix;
  52421. private _size;
  52422. private _onLoad;
  52423. private _onError;
  52424. /**
  52425. * The texture URL.
  52426. */
  52427. url: string;
  52428. /**
  52429. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52430. */
  52431. coordinatesMode: number;
  52432. protected _isBlocking: boolean;
  52433. /**
  52434. * Sets wether or not the texture is blocking during loading.
  52435. */
  52436. /**
  52437. * Gets wether or not the texture is blocking during loading.
  52438. */
  52439. isBlocking: boolean;
  52440. protected _rotationY: number;
  52441. /**
  52442. * Sets texture matrix rotation angle around Y axis in radians.
  52443. */
  52444. /**
  52445. * Gets texture matrix rotation angle around Y axis radians.
  52446. */
  52447. rotationY: number;
  52448. /**
  52449. * Gets or sets the center of the bounding box associated with the cube texture
  52450. * It must define where the camera used to render the texture was set
  52451. */
  52452. boundingBoxPosition: Vector3;
  52453. private _boundingBoxSize;
  52454. /**
  52455. * Gets or sets the size of the bounding box associated with the cube texture
  52456. * When defined, the cubemap will switch to local mode
  52457. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52458. * @example https://www.babylonjs-playground.com/#RNASML
  52459. */
  52460. boundingBoxSize: Vector3;
  52461. /**
  52462. * Instantiates an HDRTexture from the following parameters.
  52463. *
  52464. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52465. * @param scene The scene the texture will be used in
  52466. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52467. * @param noMipmap Forces to not generate the mipmap if true
  52468. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52469. * @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)
  52470. * @param reserved Reserved flag for internal use.
  52471. */
  52472. 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>);
  52473. /**
  52474. * Get the current class name of the texture useful for serialization or dynamic coding.
  52475. * @returns "HDRCubeTexture"
  52476. */
  52477. getClassName(): string;
  52478. /**
  52479. * Occurs when the file is raw .hdr file.
  52480. */
  52481. private loadTexture;
  52482. clone(): HDRCubeTexture;
  52483. delayLoad(): void;
  52484. /**
  52485. * Get the texture reflection matrix used to rotate/transform the reflection.
  52486. * @returns the reflection matrix
  52487. */
  52488. getReflectionTextureMatrix(): Matrix;
  52489. /**
  52490. * Set the texture reflection matrix used to rotate/transform the reflection.
  52491. * @param value Define the reflection matrix to set
  52492. */
  52493. setReflectionTextureMatrix(value: Matrix): void;
  52494. /**
  52495. * Parses a JSON representation of an HDR Texture in order to create the texture
  52496. * @param parsedTexture Define the JSON representation
  52497. * @param scene Define the scene the texture should be created in
  52498. * @param rootUrl Define the root url in case we need to load relative dependencies
  52499. * @returns the newly created texture after parsing
  52500. */
  52501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52502. serialize(): any;
  52503. }
  52504. }
  52505. declare module "babylonjs/Physics/physicsEngine" {
  52506. import { Nullable } from "babylonjs/types";
  52507. import { Vector3 } from "babylonjs/Maths/math.vector";
  52508. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52509. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52510. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52511. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52512. /**
  52513. * Class used to control physics engine
  52514. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52515. */
  52516. export class PhysicsEngine implements IPhysicsEngine {
  52517. private _physicsPlugin;
  52518. /**
  52519. * Global value used to control the smallest number supported by the simulation
  52520. */
  52521. static Epsilon: number;
  52522. private _impostors;
  52523. private _joints;
  52524. /**
  52525. * Gets the gravity vector used by the simulation
  52526. */
  52527. gravity: Vector3;
  52528. /**
  52529. * Factory used to create the default physics plugin.
  52530. * @returns The default physics plugin
  52531. */
  52532. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52533. /**
  52534. * Creates a new Physics Engine
  52535. * @param gravity defines the gravity vector used by the simulation
  52536. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52537. */
  52538. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52539. /**
  52540. * Sets the gravity vector used by the simulation
  52541. * @param gravity defines the gravity vector to use
  52542. */
  52543. setGravity(gravity: Vector3): void;
  52544. /**
  52545. * Set the time step of the physics engine.
  52546. * Default is 1/60.
  52547. * To slow it down, enter 1/600 for example.
  52548. * To speed it up, 1/30
  52549. * @param newTimeStep defines the new timestep to apply to this world.
  52550. */
  52551. setTimeStep(newTimeStep?: number): void;
  52552. /**
  52553. * Get the time step of the physics engine.
  52554. * @returns the current time step
  52555. */
  52556. getTimeStep(): number;
  52557. /**
  52558. * Release all resources
  52559. */
  52560. dispose(): void;
  52561. /**
  52562. * Gets the name of the current physics plugin
  52563. * @returns the name of the plugin
  52564. */
  52565. getPhysicsPluginName(): string;
  52566. /**
  52567. * Adding a new impostor for the impostor tracking.
  52568. * This will be done by the impostor itself.
  52569. * @param impostor the impostor to add
  52570. */
  52571. addImpostor(impostor: PhysicsImpostor): void;
  52572. /**
  52573. * Remove an impostor from the engine.
  52574. * This impostor and its mesh will not longer be updated by the physics engine.
  52575. * @param impostor the impostor to remove
  52576. */
  52577. removeImpostor(impostor: PhysicsImpostor): void;
  52578. /**
  52579. * Add a joint to the physics engine
  52580. * @param mainImpostor defines the main impostor to which the joint is added.
  52581. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52582. * @param joint defines the joint that will connect both impostors.
  52583. */
  52584. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52585. /**
  52586. * Removes a joint from the simulation
  52587. * @param mainImpostor defines the impostor used with the joint
  52588. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52589. * @param joint defines the joint to remove
  52590. */
  52591. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52592. /**
  52593. * Called by the scene. No need to call it.
  52594. * @param delta defines the timespam between frames
  52595. */
  52596. _step(delta: number): void;
  52597. /**
  52598. * Gets the current plugin used to run the simulation
  52599. * @returns current plugin
  52600. */
  52601. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52602. /**
  52603. * Gets the list of physic impostors
  52604. * @returns an array of PhysicsImpostor
  52605. */
  52606. getImpostors(): Array<PhysicsImpostor>;
  52607. /**
  52608. * Gets the impostor for a physics enabled object
  52609. * @param object defines the object impersonated by the impostor
  52610. * @returns the PhysicsImpostor or null if not found
  52611. */
  52612. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52613. /**
  52614. * Gets the impostor for a physics body object
  52615. * @param body defines physics body used by the impostor
  52616. * @returns the PhysicsImpostor or null if not found
  52617. */
  52618. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52619. /**
  52620. * Does a raycast in the physics world
  52621. * @param from when should the ray start?
  52622. * @param to when should the ray end?
  52623. * @returns PhysicsRaycastResult
  52624. */
  52625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52626. }
  52627. }
  52628. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52629. import { Nullable } from "babylonjs/types";
  52630. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52632. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52634. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52635. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52636. /** @hidden */
  52637. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52638. private _useDeltaForWorldStep;
  52639. world: any;
  52640. name: string;
  52641. private _physicsMaterials;
  52642. private _fixedTimeStep;
  52643. private _cannonRaycastResult;
  52644. private _raycastResult;
  52645. private _physicsBodysToRemoveAfterStep;
  52646. BJSCANNON: any;
  52647. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52648. setGravity(gravity: Vector3): void;
  52649. setTimeStep(timeStep: number): void;
  52650. getTimeStep(): number;
  52651. executeStep(delta: number): void;
  52652. private _removeMarkedPhysicsBodiesFromWorld;
  52653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52656. private _processChildMeshes;
  52657. removePhysicsBody(impostor: PhysicsImpostor): void;
  52658. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52659. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52660. private _addMaterial;
  52661. private _checkWithEpsilon;
  52662. private _createShape;
  52663. private _createHeightmap;
  52664. private _minus90X;
  52665. private _plus90X;
  52666. private _tmpPosition;
  52667. private _tmpDeltaPosition;
  52668. private _tmpUnityRotation;
  52669. private _updatePhysicsBodyTransformation;
  52670. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52671. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52672. isSupported(): boolean;
  52673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52674. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52675. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52676. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52677. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52678. getBodyMass(impostor: PhysicsImpostor): number;
  52679. getBodyFriction(impostor: PhysicsImpostor): number;
  52680. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52681. getBodyRestitution(impostor: PhysicsImpostor): number;
  52682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52683. sleepBody(impostor: PhysicsImpostor): void;
  52684. wakeUpBody(impostor: PhysicsImpostor): void;
  52685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52686. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52688. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52689. getRadius(impostor: PhysicsImpostor): number;
  52690. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52691. dispose(): void;
  52692. private _extendNamespace;
  52693. /**
  52694. * Does a raycast in the physics world
  52695. * @param from when should the ray start?
  52696. * @param to when should the ray end?
  52697. * @returns PhysicsRaycastResult
  52698. */
  52699. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52700. }
  52701. }
  52702. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52703. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52705. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52707. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52708. import { Nullable } from "babylonjs/types";
  52709. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52710. /** @hidden */
  52711. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52712. world: any;
  52713. name: string;
  52714. BJSOIMO: any;
  52715. private _raycastResult;
  52716. constructor(iterations?: number, oimoInjection?: any);
  52717. setGravity(gravity: Vector3): void;
  52718. setTimeStep(timeStep: number): void;
  52719. getTimeStep(): number;
  52720. private _tmpImpostorsArray;
  52721. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52725. private _tmpPositionVector;
  52726. removePhysicsBody(impostor: PhysicsImpostor): void;
  52727. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52728. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52729. isSupported(): boolean;
  52730. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52731. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52732. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52733. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52734. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52735. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52736. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52737. getBodyMass(impostor: PhysicsImpostor): number;
  52738. getBodyFriction(impostor: PhysicsImpostor): number;
  52739. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52740. getBodyRestitution(impostor: PhysicsImpostor): number;
  52741. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52742. sleepBody(impostor: PhysicsImpostor): void;
  52743. wakeUpBody(impostor: PhysicsImpostor): void;
  52744. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52745. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52746. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52747. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52748. getRadius(impostor: PhysicsImpostor): number;
  52749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52750. dispose(): void;
  52751. /**
  52752. * Does a raycast in the physics world
  52753. * @param from when should the ray start?
  52754. * @param to when should the ray end?
  52755. * @returns PhysicsRaycastResult
  52756. */
  52757. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52758. }
  52759. }
  52760. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52761. import { Nullable } from "babylonjs/types";
  52762. import { Scene } from "babylonjs/scene";
  52763. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52764. import { Color4 } from "babylonjs/Maths/math.color";
  52765. import { Mesh } from "babylonjs/Meshes/mesh";
  52766. /**
  52767. * Class containing static functions to help procedurally build meshes
  52768. */
  52769. export class RibbonBuilder {
  52770. /**
  52771. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52772. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52773. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52774. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52775. * * 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
  52776. * * 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
  52777. * * 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
  52778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52780. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52781. * * 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
  52782. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52783. * * 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
  52784. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52786. * @param name defines the name of the mesh
  52787. * @param options defines the options used to create the mesh
  52788. * @param scene defines the hosting scene
  52789. * @returns the ribbon mesh
  52790. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52791. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52792. */
  52793. static CreateRibbon(name: string, options: {
  52794. pathArray: Vector3[][];
  52795. closeArray?: boolean;
  52796. closePath?: boolean;
  52797. offset?: number;
  52798. updatable?: boolean;
  52799. sideOrientation?: number;
  52800. frontUVs?: Vector4;
  52801. backUVs?: Vector4;
  52802. instance?: Mesh;
  52803. invertUV?: boolean;
  52804. uvs?: Vector2[];
  52805. colors?: Color4[];
  52806. }, scene?: Nullable<Scene>): Mesh;
  52807. }
  52808. }
  52809. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52810. import { Nullable } from "babylonjs/types";
  52811. import { Scene } from "babylonjs/scene";
  52812. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52813. import { Mesh } from "babylonjs/Meshes/mesh";
  52814. /**
  52815. * Class containing static functions to help procedurally build meshes
  52816. */
  52817. export class ShapeBuilder {
  52818. /**
  52819. * 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.
  52820. * * 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.
  52821. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52822. * * 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.
  52823. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52824. * * 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
  52825. * * 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
  52826. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52831. * @param name defines the name of the mesh
  52832. * @param options defines the options used to create the mesh
  52833. * @param scene defines the hosting scene
  52834. * @returns the extruded shape mesh
  52835. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52837. */
  52838. static ExtrudeShape(name: string, options: {
  52839. shape: Vector3[];
  52840. path: Vector3[];
  52841. scale?: number;
  52842. rotation?: number;
  52843. cap?: number;
  52844. updatable?: boolean;
  52845. sideOrientation?: number;
  52846. frontUVs?: Vector4;
  52847. backUVs?: Vector4;
  52848. instance?: Mesh;
  52849. invertUV?: boolean;
  52850. }, scene?: Nullable<Scene>): Mesh;
  52851. /**
  52852. * Creates an custom extruded shape mesh.
  52853. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52854. * * 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.
  52855. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52856. * * 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
  52857. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52858. * * 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
  52859. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52860. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52861. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52862. * * 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
  52863. * * 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
  52864. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52869. * @param name defines the name of the mesh
  52870. * @param options defines the options used to create the mesh
  52871. * @param scene defines the hosting scene
  52872. * @returns the custom extruded shape mesh
  52873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52874. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52876. */
  52877. static ExtrudeShapeCustom(name: string, options: {
  52878. shape: Vector3[];
  52879. path: Vector3[];
  52880. scaleFunction?: any;
  52881. rotationFunction?: any;
  52882. ribbonCloseArray?: boolean;
  52883. ribbonClosePath?: boolean;
  52884. cap?: number;
  52885. updatable?: boolean;
  52886. sideOrientation?: number;
  52887. frontUVs?: Vector4;
  52888. backUVs?: Vector4;
  52889. instance?: Mesh;
  52890. invertUV?: boolean;
  52891. }, scene?: Nullable<Scene>): Mesh;
  52892. private static _ExtrudeShapeGeneric;
  52893. }
  52894. }
  52895. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52896. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52897. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52898. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52899. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52900. import { Nullable } from "babylonjs/types";
  52901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52902. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52903. /**
  52904. * AmmoJS Physics plugin
  52905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52906. * @see https://github.com/kripken/ammo.js/
  52907. */
  52908. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52909. private _useDeltaForWorldStep;
  52910. /**
  52911. * Reference to the Ammo library
  52912. */
  52913. bjsAMMO: any;
  52914. /**
  52915. * Created ammoJS world which physics bodies are added to
  52916. */
  52917. world: any;
  52918. /**
  52919. * Name of the plugin
  52920. */
  52921. name: string;
  52922. private _timeStep;
  52923. private _fixedTimeStep;
  52924. private _maxSteps;
  52925. private _tmpQuaternion;
  52926. private _tmpAmmoTransform;
  52927. private _tmpAmmoQuaternion;
  52928. private _tmpAmmoConcreteContactResultCallback;
  52929. private _collisionConfiguration;
  52930. private _dispatcher;
  52931. private _overlappingPairCache;
  52932. private _solver;
  52933. private _softBodySolver;
  52934. private _tmpAmmoVectorA;
  52935. private _tmpAmmoVectorB;
  52936. private _tmpAmmoVectorC;
  52937. private _tmpAmmoVectorD;
  52938. private _tmpContactCallbackResult;
  52939. private _tmpAmmoVectorRCA;
  52940. private _tmpAmmoVectorRCB;
  52941. private _raycastResult;
  52942. private static readonly DISABLE_COLLISION_FLAG;
  52943. private static readonly KINEMATIC_FLAG;
  52944. private static readonly DISABLE_DEACTIVATION_FLAG;
  52945. /**
  52946. * Initializes the ammoJS plugin
  52947. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52948. * @param ammoInjection can be used to inject your own ammo reference
  52949. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52950. */
  52951. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52952. /**
  52953. * Sets the gravity of the physics world (m/(s^2))
  52954. * @param gravity Gravity to set
  52955. */
  52956. setGravity(gravity: Vector3): void;
  52957. /**
  52958. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52959. * @param timeStep timestep to use in seconds
  52960. */
  52961. setTimeStep(timeStep: number): void;
  52962. /**
  52963. * 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)
  52964. * @param fixedTimeStep fixedTimeStep to use in seconds
  52965. */
  52966. setFixedTimeStep(fixedTimeStep: number): void;
  52967. /**
  52968. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52969. * @param maxSteps the maximum number of steps by the physics engine per frame
  52970. */
  52971. setMaxSteps(maxSteps: number): void;
  52972. /**
  52973. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52974. * @returns the current timestep in seconds
  52975. */
  52976. getTimeStep(): number;
  52977. private _isImpostorInContact;
  52978. private _isImpostorPairInContact;
  52979. private _stepSimulation;
  52980. /**
  52981. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52982. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52983. * After the step the babylon meshes are set to the position of the physics imposters
  52984. * @param delta amount of time to step forward
  52985. * @param impostors array of imposters to update before/after the step
  52986. */
  52987. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52988. /**
  52989. * Update babylon mesh to match physics world object
  52990. * @param impostor imposter to match
  52991. */
  52992. private _afterSoftStep;
  52993. /**
  52994. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52995. * @param impostor imposter to match
  52996. */
  52997. private _ropeStep;
  52998. /**
  52999. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53000. * @param impostor imposter to match
  53001. */
  53002. private _softbodyOrClothStep;
  53003. private _tmpVector;
  53004. private _tmpMatrix;
  53005. /**
  53006. * Applies an impulse on the imposter
  53007. * @param impostor imposter to apply impulse to
  53008. * @param force amount of force to be applied to the imposter
  53009. * @param contactPoint the location to apply the impulse on the imposter
  53010. */
  53011. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53012. /**
  53013. * Applies a force on the imposter
  53014. * @param impostor imposter to apply force
  53015. * @param force amount of force to be applied to the imposter
  53016. * @param contactPoint the location to apply the force on the imposter
  53017. */
  53018. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53019. /**
  53020. * Creates a physics body using the plugin
  53021. * @param impostor the imposter to create the physics body on
  53022. */
  53023. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53024. /**
  53025. * Removes the physics body from the imposter and disposes of the body's memory
  53026. * @param impostor imposter to remove the physics body from
  53027. */
  53028. removePhysicsBody(impostor: PhysicsImpostor): void;
  53029. /**
  53030. * Generates a joint
  53031. * @param impostorJoint the imposter joint to create the joint with
  53032. */
  53033. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53034. /**
  53035. * Removes a joint
  53036. * @param impostorJoint the imposter joint to remove the joint from
  53037. */
  53038. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53039. private _addMeshVerts;
  53040. /**
  53041. * Initialise the soft body vertices to match its object's (mesh) vertices
  53042. * Softbody vertices (nodes) are in world space and to match this
  53043. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53044. * @param impostor to create the softbody for
  53045. */
  53046. private _softVertexData;
  53047. /**
  53048. * Create an impostor's soft body
  53049. * @param impostor to create the softbody for
  53050. */
  53051. private _createSoftbody;
  53052. /**
  53053. * Create cloth for an impostor
  53054. * @param impostor to create the softbody for
  53055. */
  53056. private _createCloth;
  53057. /**
  53058. * Create rope for an impostor
  53059. * @param impostor to create the softbody for
  53060. */
  53061. private _createRope;
  53062. private _addHullVerts;
  53063. private _createShape;
  53064. /**
  53065. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53066. * @param impostor imposter containing the physics body and babylon object
  53067. */
  53068. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53069. /**
  53070. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53071. * @param impostor imposter containing the physics body and babylon object
  53072. * @param newPosition new position
  53073. * @param newRotation new rotation
  53074. */
  53075. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53076. /**
  53077. * If this plugin is supported
  53078. * @returns true if its supported
  53079. */
  53080. isSupported(): boolean;
  53081. /**
  53082. * Sets the linear velocity of the physics body
  53083. * @param impostor imposter to set the velocity on
  53084. * @param velocity velocity to set
  53085. */
  53086. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53087. /**
  53088. * Sets the angular velocity of the physics body
  53089. * @param impostor imposter to set the velocity on
  53090. * @param velocity velocity to set
  53091. */
  53092. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53093. /**
  53094. * gets the linear velocity
  53095. * @param impostor imposter to get linear velocity from
  53096. * @returns linear velocity
  53097. */
  53098. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53099. /**
  53100. * gets the angular velocity
  53101. * @param impostor imposter to get angular velocity from
  53102. * @returns angular velocity
  53103. */
  53104. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53105. /**
  53106. * Sets the mass of physics body
  53107. * @param impostor imposter to set the mass on
  53108. * @param mass mass to set
  53109. */
  53110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53111. /**
  53112. * Gets the mass of the physics body
  53113. * @param impostor imposter to get the mass from
  53114. * @returns mass
  53115. */
  53116. getBodyMass(impostor: PhysicsImpostor): number;
  53117. /**
  53118. * Gets friction of the impostor
  53119. * @param impostor impostor to get friction from
  53120. * @returns friction value
  53121. */
  53122. getBodyFriction(impostor: PhysicsImpostor): number;
  53123. /**
  53124. * Sets friction of the impostor
  53125. * @param impostor impostor to set friction on
  53126. * @param friction friction value
  53127. */
  53128. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53129. /**
  53130. * Gets restitution of the impostor
  53131. * @param impostor impostor to get restitution from
  53132. * @returns restitution value
  53133. */
  53134. getBodyRestitution(impostor: PhysicsImpostor): number;
  53135. /**
  53136. * Sets resitution of the impostor
  53137. * @param impostor impostor to set resitution on
  53138. * @param restitution resitution value
  53139. */
  53140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53141. /**
  53142. * Gets pressure inside the impostor
  53143. * @param impostor impostor to get pressure from
  53144. * @returns pressure value
  53145. */
  53146. getBodyPressure(impostor: PhysicsImpostor): number;
  53147. /**
  53148. * Sets pressure inside a soft body impostor
  53149. * Cloth and rope must remain 0 pressure
  53150. * @param impostor impostor to set pressure on
  53151. * @param pressure pressure value
  53152. */
  53153. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53154. /**
  53155. * Gets stiffness of the impostor
  53156. * @param impostor impostor to get stiffness from
  53157. * @returns pressure value
  53158. */
  53159. getBodyStiffness(impostor: PhysicsImpostor): number;
  53160. /**
  53161. * Sets stiffness of the impostor
  53162. * @param impostor impostor to set stiffness on
  53163. * @param stiffness stiffness value from 0 to 1
  53164. */
  53165. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53166. /**
  53167. * Gets velocityIterations of the impostor
  53168. * @param impostor impostor to get velocity iterations from
  53169. * @returns velocityIterations value
  53170. */
  53171. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53172. /**
  53173. * Sets velocityIterations of the impostor
  53174. * @param impostor impostor to set velocity iterations on
  53175. * @param velocityIterations velocityIterations value
  53176. */
  53177. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53178. /**
  53179. * Gets positionIterations of the impostor
  53180. * @param impostor impostor to get position iterations from
  53181. * @returns positionIterations value
  53182. */
  53183. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53184. /**
  53185. * Sets positionIterations of the impostor
  53186. * @param impostor impostor to set position on
  53187. * @param positionIterations positionIterations value
  53188. */
  53189. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53190. /**
  53191. * Append an anchor to a cloth object
  53192. * @param impostor is the cloth impostor to add anchor to
  53193. * @param otherImpostor is the rigid impostor to anchor to
  53194. * @param width ratio across width from 0 to 1
  53195. * @param height ratio up height from 0 to 1
  53196. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53197. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53198. */
  53199. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53200. /**
  53201. * Append an hook to a rope object
  53202. * @param impostor is the rope impostor to add hook to
  53203. * @param otherImpostor is the rigid impostor to hook to
  53204. * @param length ratio along the rope from 0 to 1
  53205. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53206. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53207. */
  53208. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53209. /**
  53210. * Sleeps the physics body and stops it from being active
  53211. * @param impostor impostor to sleep
  53212. */
  53213. sleepBody(impostor: PhysicsImpostor): void;
  53214. /**
  53215. * Activates the physics body
  53216. * @param impostor impostor to activate
  53217. */
  53218. wakeUpBody(impostor: PhysicsImpostor): void;
  53219. /**
  53220. * Updates the distance parameters of the joint
  53221. * @param joint joint to update
  53222. * @param maxDistance maximum distance of the joint
  53223. * @param minDistance minimum distance of the joint
  53224. */
  53225. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53226. /**
  53227. * Sets a motor on the joint
  53228. * @param joint joint to set motor on
  53229. * @param speed speed of the motor
  53230. * @param maxForce maximum force of the motor
  53231. * @param motorIndex index of the motor
  53232. */
  53233. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53234. /**
  53235. * Sets the motors limit
  53236. * @param joint joint to set limit on
  53237. * @param upperLimit upper limit
  53238. * @param lowerLimit lower limit
  53239. */
  53240. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53241. /**
  53242. * Syncs the position and rotation of a mesh with the impostor
  53243. * @param mesh mesh to sync
  53244. * @param impostor impostor to update the mesh with
  53245. */
  53246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53247. /**
  53248. * Gets the radius of the impostor
  53249. * @param impostor impostor to get radius from
  53250. * @returns the radius
  53251. */
  53252. getRadius(impostor: PhysicsImpostor): number;
  53253. /**
  53254. * Gets the box size of the impostor
  53255. * @param impostor impostor to get box size from
  53256. * @param result the resulting box size
  53257. */
  53258. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53259. /**
  53260. * Disposes of the impostor
  53261. */
  53262. dispose(): void;
  53263. /**
  53264. * Does a raycast in the physics world
  53265. * @param from when should the ray start?
  53266. * @param to when should the ray end?
  53267. * @returns PhysicsRaycastResult
  53268. */
  53269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53270. }
  53271. }
  53272. declare module "babylonjs/Probes/reflectionProbe" {
  53273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53274. import { Vector3 } from "babylonjs/Maths/math.vector";
  53275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53276. import { Nullable } from "babylonjs/types";
  53277. import { Scene } from "babylonjs/scene";
  53278. module "babylonjs/abstractScene" {
  53279. interface AbstractScene {
  53280. /**
  53281. * The list of reflection probes added to the scene
  53282. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53283. */
  53284. reflectionProbes: Array<ReflectionProbe>;
  53285. /**
  53286. * Removes the given reflection probe from this scene.
  53287. * @param toRemove The reflection probe to remove
  53288. * @returns The index of the removed reflection probe
  53289. */
  53290. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53291. /**
  53292. * Adds the given reflection probe to this scene.
  53293. * @param newReflectionProbe The reflection probe to add
  53294. */
  53295. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53296. }
  53297. }
  53298. /**
  53299. * Class used to generate realtime reflection / refraction cube textures
  53300. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53301. */
  53302. export class ReflectionProbe {
  53303. /** defines the name of the probe */
  53304. name: string;
  53305. private _scene;
  53306. private _renderTargetTexture;
  53307. private _projectionMatrix;
  53308. private _viewMatrix;
  53309. private _target;
  53310. private _add;
  53311. private _attachedMesh;
  53312. private _invertYAxis;
  53313. /** Gets or sets probe position (center of the cube map) */
  53314. position: Vector3;
  53315. /**
  53316. * Creates a new reflection probe
  53317. * @param name defines the name of the probe
  53318. * @param size defines the texture resolution (for each face)
  53319. * @param scene defines the hosting scene
  53320. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53321. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53322. */
  53323. constructor(
  53324. /** defines the name of the probe */
  53325. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53326. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53327. samples: number;
  53328. /** Gets or sets the refresh rate to use (on every frame by default) */
  53329. refreshRate: number;
  53330. /**
  53331. * Gets the hosting scene
  53332. * @returns a Scene
  53333. */
  53334. getScene(): Scene;
  53335. /** Gets the internal CubeTexture used to render to */
  53336. readonly cubeTexture: RenderTargetTexture;
  53337. /** Gets the list of meshes to render */
  53338. readonly renderList: Nullable<AbstractMesh[]>;
  53339. /**
  53340. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53341. * @param mesh defines the mesh to attach to
  53342. */
  53343. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53344. /**
  53345. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53346. * @param renderingGroupId The rendering group id corresponding to its index
  53347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53348. */
  53349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53350. /**
  53351. * Clean all associated resources
  53352. */
  53353. dispose(): void;
  53354. /**
  53355. * Converts the reflection probe information to a readable string for debug purpose.
  53356. * @param fullDetails Supports for multiple levels of logging within scene loading
  53357. * @returns the human readable reflection probe info
  53358. */
  53359. toString(fullDetails?: boolean): string;
  53360. /**
  53361. * Get the class name of the relfection probe.
  53362. * @returns "ReflectionProbe"
  53363. */
  53364. getClassName(): string;
  53365. /**
  53366. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53367. * @returns The JSON representation of the texture
  53368. */
  53369. serialize(): any;
  53370. /**
  53371. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53372. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53373. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53374. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53375. * @returns The parsed reflection probe if successful
  53376. */
  53377. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53378. }
  53379. }
  53380. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53381. /** @hidden */
  53382. export var _BabylonLoaderRegistered: boolean;
  53383. }
  53384. declare module "babylonjs/Loading/Plugins/index" {
  53385. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53386. }
  53387. declare module "babylonjs/Loading/index" {
  53388. export * from "babylonjs/Loading/loadingScreen";
  53389. export * from "babylonjs/Loading/Plugins/index";
  53390. export * from "babylonjs/Loading/sceneLoader";
  53391. export * from "babylonjs/Loading/sceneLoaderFlags";
  53392. }
  53393. declare module "babylonjs/Materials/Background/index" {
  53394. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53395. }
  53396. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53397. import { Scene } from "babylonjs/scene";
  53398. import { Color3 } from "babylonjs/Maths/math.color";
  53399. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53401. /**
  53402. * The Physically based simple base material of BJS.
  53403. *
  53404. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53405. * It is used as the base class for both the specGloss and metalRough conventions.
  53406. */
  53407. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53408. /**
  53409. * Number of Simultaneous lights allowed on the material.
  53410. */
  53411. maxSimultaneousLights: number;
  53412. /**
  53413. * If sets to true, disables all the lights affecting the material.
  53414. */
  53415. disableLighting: boolean;
  53416. /**
  53417. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53418. */
  53419. environmentTexture: BaseTexture;
  53420. /**
  53421. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53422. */
  53423. invertNormalMapX: boolean;
  53424. /**
  53425. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53426. */
  53427. invertNormalMapY: boolean;
  53428. /**
  53429. * Normal map used in the model.
  53430. */
  53431. normalTexture: BaseTexture;
  53432. /**
  53433. * Emissivie color used to self-illuminate the model.
  53434. */
  53435. emissiveColor: Color3;
  53436. /**
  53437. * Emissivie texture used to self-illuminate the model.
  53438. */
  53439. emissiveTexture: BaseTexture;
  53440. /**
  53441. * Occlusion Channel Strenght.
  53442. */
  53443. occlusionStrength: number;
  53444. /**
  53445. * Occlusion Texture of the material (adding extra occlusion effects).
  53446. */
  53447. occlusionTexture: BaseTexture;
  53448. /**
  53449. * Defines the alpha limits in alpha test mode.
  53450. */
  53451. alphaCutOff: number;
  53452. /**
  53453. * Gets the current double sided mode.
  53454. */
  53455. /**
  53456. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53457. */
  53458. doubleSided: boolean;
  53459. /**
  53460. * Stores the pre-calculated light information of a mesh in a texture.
  53461. */
  53462. lightmapTexture: BaseTexture;
  53463. /**
  53464. * If true, the light map contains occlusion information instead of lighting info.
  53465. */
  53466. useLightmapAsShadowmap: boolean;
  53467. /**
  53468. * Instantiates a new PBRMaterial instance.
  53469. *
  53470. * @param name The material name
  53471. * @param scene The scene the material will be use in.
  53472. */
  53473. constructor(name: string, scene: Scene);
  53474. getClassName(): string;
  53475. }
  53476. }
  53477. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53478. import { Scene } from "babylonjs/scene";
  53479. import { Color3 } from "babylonjs/Maths/math.color";
  53480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53481. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53482. /**
  53483. * The PBR material of BJS following the metal roughness convention.
  53484. *
  53485. * This fits to the PBR convention in the GLTF definition:
  53486. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53487. */
  53488. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53489. /**
  53490. * The base color has two different interpretations depending on the value of metalness.
  53491. * When the material is a metal, the base color is the specific measured reflectance value
  53492. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53493. * of the material.
  53494. */
  53495. baseColor: Color3;
  53496. /**
  53497. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53498. * well as opacity information in the alpha channel.
  53499. */
  53500. baseTexture: BaseTexture;
  53501. /**
  53502. * Specifies the metallic scalar value of the material.
  53503. * Can also be used to scale the metalness values of the metallic texture.
  53504. */
  53505. metallic: number;
  53506. /**
  53507. * Specifies the roughness scalar value of the material.
  53508. * Can also be used to scale the roughness values of the metallic texture.
  53509. */
  53510. roughness: number;
  53511. /**
  53512. * Texture containing both the metallic value in the B channel and the
  53513. * roughness value in the G channel to keep better precision.
  53514. */
  53515. metallicRoughnessTexture: BaseTexture;
  53516. /**
  53517. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53518. *
  53519. * @param name The material name
  53520. * @param scene The scene the material will be use in.
  53521. */
  53522. constructor(name: string, scene: Scene);
  53523. /**
  53524. * Return the currrent class name of the material.
  53525. */
  53526. getClassName(): string;
  53527. /**
  53528. * Makes a duplicate of the current material.
  53529. * @param name - name to use for the new material.
  53530. */
  53531. clone(name: string): PBRMetallicRoughnessMaterial;
  53532. /**
  53533. * Serialize the material to a parsable JSON object.
  53534. */
  53535. serialize(): any;
  53536. /**
  53537. * Parses a JSON object correponding to the serialize function.
  53538. */
  53539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53540. }
  53541. }
  53542. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53543. import { Scene } from "babylonjs/scene";
  53544. import { Color3 } from "babylonjs/Maths/math.color";
  53545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53546. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53547. /**
  53548. * The PBR material of BJS following the specular glossiness convention.
  53549. *
  53550. * This fits to the PBR convention in the GLTF definition:
  53551. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53552. */
  53553. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53554. /**
  53555. * Specifies the diffuse color of the material.
  53556. */
  53557. diffuseColor: Color3;
  53558. /**
  53559. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53560. * channel.
  53561. */
  53562. diffuseTexture: BaseTexture;
  53563. /**
  53564. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53565. */
  53566. specularColor: Color3;
  53567. /**
  53568. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53569. */
  53570. glossiness: number;
  53571. /**
  53572. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53573. */
  53574. specularGlossinessTexture: BaseTexture;
  53575. /**
  53576. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53577. *
  53578. * @param name The material name
  53579. * @param scene The scene the material will be use in.
  53580. */
  53581. constructor(name: string, scene: Scene);
  53582. /**
  53583. * Return the currrent class name of the material.
  53584. */
  53585. getClassName(): string;
  53586. /**
  53587. * Makes a duplicate of the current material.
  53588. * @param name - name to use for the new material.
  53589. */
  53590. clone(name: string): PBRSpecularGlossinessMaterial;
  53591. /**
  53592. * Serialize the material to a parsable JSON object.
  53593. */
  53594. serialize(): any;
  53595. /**
  53596. * Parses a JSON object correponding to the serialize function.
  53597. */
  53598. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53599. }
  53600. }
  53601. declare module "babylonjs/Materials/PBR/index" {
  53602. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53603. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53604. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53605. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53606. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53607. }
  53608. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53609. import { Nullable } from "babylonjs/types";
  53610. import { Scene } from "babylonjs/scene";
  53611. import { Matrix } from "babylonjs/Maths/math.vector";
  53612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53613. /**
  53614. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53615. * It can help converting any input color in a desired output one. This can then be used to create effects
  53616. * from sepia, black and white to sixties or futuristic rendering...
  53617. *
  53618. * The only supported format is currently 3dl.
  53619. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53620. */
  53621. export class ColorGradingTexture extends BaseTexture {
  53622. /**
  53623. * The current texture matrix. (will always be identity in color grading texture)
  53624. */
  53625. private _textureMatrix;
  53626. /**
  53627. * The texture URL.
  53628. */
  53629. url: string;
  53630. /**
  53631. * Empty line regex stored for GC.
  53632. */
  53633. private static _noneEmptyLineRegex;
  53634. private _engine;
  53635. /**
  53636. * Instantiates a ColorGradingTexture from the following parameters.
  53637. *
  53638. * @param url The location of the color gradind data (currently only supporting 3dl)
  53639. * @param scene The scene the texture will be used in
  53640. */
  53641. constructor(url: string, scene: Scene);
  53642. /**
  53643. * Returns the texture matrix used in most of the material.
  53644. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53645. */
  53646. getTextureMatrix(): Matrix;
  53647. /**
  53648. * Occurs when the file being loaded is a .3dl LUT file.
  53649. */
  53650. private load3dlTexture;
  53651. /**
  53652. * Starts the loading process of the texture.
  53653. */
  53654. private loadTexture;
  53655. /**
  53656. * Clones the color gradind texture.
  53657. */
  53658. clone(): ColorGradingTexture;
  53659. /**
  53660. * Called during delayed load for textures.
  53661. */
  53662. delayLoad(): void;
  53663. /**
  53664. * Parses a color grading texture serialized by Babylon.
  53665. * @param parsedTexture The texture information being parsedTexture
  53666. * @param scene The scene to load the texture in
  53667. * @param rootUrl The root url of the data assets to load
  53668. * @return A color gradind texture
  53669. */
  53670. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53671. /**
  53672. * Serializes the LUT texture to json format.
  53673. */
  53674. serialize(): any;
  53675. }
  53676. }
  53677. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53679. import { Scene } from "babylonjs/scene";
  53680. import { Nullable } from "babylonjs/types";
  53681. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53682. /**
  53683. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53684. */
  53685. export class EquiRectangularCubeTexture extends BaseTexture {
  53686. /** The six faces of the cube. */
  53687. private static _FacesMapping;
  53688. private _noMipmap;
  53689. private _onLoad;
  53690. private _onError;
  53691. /** The size of the cubemap. */
  53692. private _size;
  53693. /** The buffer of the image. */
  53694. private _buffer;
  53695. /** The width of the input image. */
  53696. private _width;
  53697. /** The height of the input image. */
  53698. private _height;
  53699. /** The URL to the image. */
  53700. url: string;
  53701. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53702. coordinatesMode: number;
  53703. /**
  53704. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53705. * @param url The location of the image
  53706. * @param scene The scene the texture will be used in
  53707. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53708. * @param noMipmap Forces to not generate the mipmap if true
  53709. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53710. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53711. * @param onLoad — defines a callback called when texture is loaded
  53712. * @param onError — defines a callback called if there is an error
  53713. */
  53714. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53715. /**
  53716. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53717. */
  53718. private loadImage;
  53719. /**
  53720. * Convert the image buffer into a cubemap and create a CubeTexture.
  53721. */
  53722. private loadTexture;
  53723. /**
  53724. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53725. * @param buffer The ArrayBuffer that should be converted.
  53726. * @returns The buffer as Float32Array.
  53727. */
  53728. private getFloat32ArrayFromArrayBuffer;
  53729. /**
  53730. * Get the current class name of the texture useful for serialization or dynamic coding.
  53731. * @returns "EquiRectangularCubeTexture"
  53732. */
  53733. getClassName(): string;
  53734. /**
  53735. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53736. * @returns A clone of the current EquiRectangularCubeTexture.
  53737. */
  53738. clone(): EquiRectangularCubeTexture;
  53739. }
  53740. }
  53741. declare module "babylonjs/Misc/tga" {
  53742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53743. /**
  53744. * Based on jsTGALoader - Javascript loader for TGA file
  53745. * By Vincent Thibault
  53746. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53747. */
  53748. export class TGATools {
  53749. private static _TYPE_INDEXED;
  53750. private static _TYPE_RGB;
  53751. private static _TYPE_GREY;
  53752. private static _TYPE_RLE_INDEXED;
  53753. private static _TYPE_RLE_RGB;
  53754. private static _TYPE_RLE_GREY;
  53755. private static _ORIGIN_MASK;
  53756. private static _ORIGIN_SHIFT;
  53757. private static _ORIGIN_BL;
  53758. private static _ORIGIN_BR;
  53759. private static _ORIGIN_UL;
  53760. private static _ORIGIN_UR;
  53761. /**
  53762. * Gets the header of a TGA file
  53763. * @param data defines the TGA data
  53764. * @returns the header
  53765. */
  53766. static GetTGAHeader(data: Uint8Array): any;
  53767. /**
  53768. * Uploads TGA content to a Babylon Texture
  53769. * @hidden
  53770. */
  53771. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53772. /** @hidden */
  53773. 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;
  53774. /** @hidden */
  53775. 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;
  53776. /** @hidden */
  53777. 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;
  53778. /** @hidden */
  53779. 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;
  53780. /** @hidden */
  53781. 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;
  53782. /** @hidden */
  53783. 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;
  53784. }
  53785. }
  53786. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53787. import { Nullable } from "babylonjs/types";
  53788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53789. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53790. /**
  53791. * Implementation of the TGA Texture Loader.
  53792. * @hidden
  53793. */
  53794. export class _TGATextureLoader implements IInternalTextureLoader {
  53795. /**
  53796. * Defines wether the loader supports cascade loading the different faces.
  53797. */
  53798. readonly supportCascades: boolean;
  53799. /**
  53800. * This returns if the loader support the current file information.
  53801. * @param extension defines the file extension of the file being loaded
  53802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53803. * @param fallback defines the fallback internal texture if any
  53804. * @param isBase64 defines whether the texture is encoded as a base64
  53805. * @param isBuffer defines whether the texture data are stored as a buffer
  53806. * @returns true if the loader can load the specified file
  53807. */
  53808. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53809. /**
  53810. * Transform the url before loading if required.
  53811. * @param rootUrl the url of the texture
  53812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53813. * @returns the transformed texture
  53814. */
  53815. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53816. /**
  53817. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53818. * @param rootUrl the url of the texture
  53819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53820. * @returns the fallback texture
  53821. */
  53822. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53823. /**
  53824. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53825. * @param data contains the texture data
  53826. * @param texture defines the BabylonJS internal texture
  53827. * @param createPolynomials will be true if polynomials have been requested
  53828. * @param onLoad defines the callback to trigger once the texture is ready
  53829. * @param onError defines the callback to trigger in case of error
  53830. */
  53831. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53832. /**
  53833. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53834. * @param data contains the texture data
  53835. * @param texture defines the BabylonJS internal texture
  53836. * @param callback defines the method to call once ready to upload
  53837. */
  53838. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53839. }
  53840. }
  53841. declare module "babylonjs/Misc/basis" {
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. /**
  53844. * Info about the .basis files
  53845. */
  53846. class BasisFileInfo {
  53847. /**
  53848. * If the file has alpha
  53849. */
  53850. hasAlpha: boolean;
  53851. /**
  53852. * Info about each image of the basis file
  53853. */
  53854. images: Array<{
  53855. levels: Array<{
  53856. width: number;
  53857. height: number;
  53858. transcodedPixels: ArrayBufferView;
  53859. }>;
  53860. }>;
  53861. }
  53862. /**
  53863. * Result of transcoding a basis file
  53864. */
  53865. class TranscodeResult {
  53866. /**
  53867. * Info about the .basis file
  53868. */
  53869. fileInfo: BasisFileInfo;
  53870. /**
  53871. * Format to use when loading the file
  53872. */
  53873. format: number;
  53874. }
  53875. /**
  53876. * Configuration options for the Basis transcoder
  53877. */
  53878. export class BasisTranscodeConfiguration {
  53879. /**
  53880. * Supported compression formats used to determine the supported output format of the transcoder
  53881. */
  53882. supportedCompressionFormats?: {
  53883. /**
  53884. * etc1 compression format
  53885. */
  53886. etc1?: boolean;
  53887. /**
  53888. * s3tc compression format
  53889. */
  53890. s3tc?: boolean;
  53891. /**
  53892. * pvrtc compression format
  53893. */
  53894. pvrtc?: boolean;
  53895. /**
  53896. * etc2 compression format
  53897. */
  53898. etc2?: boolean;
  53899. };
  53900. /**
  53901. * If mipmap levels should be loaded for transcoded images (Default: true)
  53902. */
  53903. loadMipmapLevels?: boolean;
  53904. /**
  53905. * Index of a single image to load (Default: all images)
  53906. */
  53907. loadSingleImage?: number;
  53908. }
  53909. /**
  53910. * Used to load .Basis files
  53911. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53912. */
  53913. export class BasisTools {
  53914. private static _IgnoreSupportedFormats;
  53915. /**
  53916. * URL to use when loading the basis transcoder
  53917. */
  53918. static JSModuleURL: string;
  53919. /**
  53920. * URL to use when loading the wasm module for the transcoder
  53921. */
  53922. static WasmModuleURL: string;
  53923. /**
  53924. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53925. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53926. * @returns internal format corresponding to the Basis format
  53927. */
  53928. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53929. private static _WorkerPromise;
  53930. private static _Worker;
  53931. private static _actionId;
  53932. private static _CreateWorkerAsync;
  53933. /**
  53934. * Transcodes a loaded image file to compressed pixel data
  53935. * @param imageData image data to transcode
  53936. * @param config configuration options for the transcoding
  53937. * @returns a promise resulting in the transcoded image
  53938. */
  53939. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53940. /**
  53941. * Loads a texture from the transcode result
  53942. * @param texture texture load to
  53943. * @param transcodeResult the result of transcoding the basis file to load from
  53944. */
  53945. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53946. }
  53947. }
  53948. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53949. import { Nullable } from "babylonjs/types";
  53950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53951. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53952. /**
  53953. * Loader for .basis file format
  53954. */
  53955. export class _BasisTextureLoader implements IInternalTextureLoader {
  53956. /**
  53957. * Defines whether the loader supports cascade loading the different faces.
  53958. */
  53959. readonly supportCascades: boolean;
  53960. /**
  53961. * This returns if the loader support the current file information.
  53962. * @param extension defines the file extension of the file being loaded
  53963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53964. * @param fallback defines the fallback internal texture if any
  53965. * @param isBase64 defines whether the texture is encoded as a base64
  53966. * @param isBuffer defines whether the texture data are stored as a buffer
  53967. * @returns true if the loader can load the specified file
  53968. */
  53969. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53970. /**
  53971. * Transform the url before loading if required.
  53972. * @param rootUrl the url of the texture
  53973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53974. * @returns the transformed texture
  53975. */
  53976. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53977. /**
  53978. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53979. * @param rootUrl the url of the texture
  53980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53981. * @returns the fallback texture
  53982. */
  53983. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53984. /**
  53985. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53986. * @param data contains the texture data
  53987. * @param texture defines the BabylonJS internal texture
  53988. * @param createPolynomials will be true if polynomials have been requested
  53989. * @param onLoad defines the callback to trigger once the texture is ready
  53990. * @param onError defines the callback to trigger in case of error
  53991. */
  53992. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53993. /**
  53994. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53995. * @param data contains the texture data
  53996. * @param texture defines the BabylonJS internal texture
  53997. * @param callback defines the method to call once ready to upload
  53998. */
  53999. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54003. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54004. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54005. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54006. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54007. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54008. }
  54009. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54010. import { Scene } from "babylonjs/scene";
  54011. import { Texture } from "babylonjs/Materials/Textures/texture";
  54012. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54013. /**
  54014. * 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.
  54015. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54016. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54017. */
  54018. export class CustomProceduralTexture extends ProceduralTexture {
  54019. private _animate;
  54020. private _time;
  54021. private _config;
  54022. private _texturePath;
  54023. /**
  54024. * Instantiates a new Custom Procedural Texture.
  54025. * 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.
  54026. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54027. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54028. * @param name Define the name of the texture
  54029. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54030. * @param size Define the size of the texture to create
  54031. * @param scene Define the scene the texture belongs to
  54032. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54033. * @param generateMipMaps Define if the texture should creates mip maps or not
  54034. */
  54035. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54036. private _loadJson;
  54037. /**
  54038. * Is the texture ready to be used ? (rendered at least once)
  54039. * @returns true if ready, otherwise, false.
  54040. */
  54041. isReady(): boolean;
  54042. /**
  54043. * Render the texture to its associated render target.
  54044. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54045. */
  54046. render(useCameraPostProcess?: boolean): void;
  54047. /**
  54048. * Update the list of dependant textures samplers in the shader.
  54049. */
  54050. updateTextures(): void;
  54051. /**
  54052. * Update the uniform values of the procedural texture in the shader.
  54053. */
  54054. updateShaderUniforms(): void;
  54055. /**
  54056. * Define if the texture animates or not.
  54057. */
  54058. animate: boolean;
  54059. }
  54060. }
  54061. declare module "babylonjs/Shaders/noise.fragment" {
  54062. /** @hidden */
  54063. export var noisePixelShader: {
  54064. name: string;
  54065. shader: string;
  54066. };
  54067. }
  54068. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54069. import { Nullable } from "babylonjs/types";
  54070. import { Scene } from "babylonjs/scene";
  54071. import { Texture } from "babylonjs/Materials/Textures/texture";
  54072. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54073. import "babylonjs/Shaders/noise.fragment";
  54074. /**
  54075. * Class used to generate noise procedural textures
  54076. */
  54077. export class NoiseProceduralTexture extends ProceduralTexture {
  54078. private _time;
  54079. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54080. brightness: number;
  54081. /** Defines the number of octaves to process */
  54082. octaves: number;
  54083. /** Defines the level of persistence (0.8 by default) */
  54084. persistence: number;
  54085. /** Gets or sets animation speed factor (default is 1) */
  54086. animationSpeedFactor: number;
  54087. /**
  54088. * Creates a new NoiseProceduralTexture
  54089. * @param name defines the name fo the texture
  54090. * @param size defines the size of the texture (default is 256)
  54091. * @param scene defines the hosting scene
  54092. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54093. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54094. */
  54095. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54096. private _updateShaderUniforms;
  54097. protected _getDefines(): string;
  54098. /** Generate the current state of the procedural texture */
  54099. render(useCameraPostProcess?: boolean): void;
  54100. /**
  54101. * Serializes this noise procedural texture
  54102. * @returns a serialized noise procedural texture object
  54103. */
  54104. serialize(): any;
  54105. /**
  54106. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54107. * @param parsedTexture defines parsed texture data
  54108. * @param scene defines the current scene
  54109. * @param rootUrl defines the root URL containing noise procedural texture information
  54110. * @returns a parsed NoiseProceduralTexture
  54111. */
  54112. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54113. }
  54114. }
  54115. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54116. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54117. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54118. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54119. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54120. }
  54121. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54122. import { Nullable } from "babylonjs/types";
  54123. import { Scene } from "babylonjs/scene";
  54124. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54126. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54127. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54128. /**
  54129. * Raw cube texture where the raw buffers are passed in
  54130. */
  54131. export class RawCubeTexture extends CubeTexture {
  54132. /**
  54133. * Creates a cube texture where the raw buffers are passed in.
  54134. * @param scene defines the scene the texture is attached to
  54135. * @param data defines the array of data to use to create each face
  54136. * @param size defines the size of the textures
  54137. * @param format defines the format of the data
  54138. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54139. * @param generateMipMaps defines if the engine should generate the mip levels
  54140. * @param invertY defines if data must be stored with Y axis inverted
  54141. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54142. * @param compression defines the compression used (null by default)
  54143. */
  54144. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54145. /**
  54146. * Updates the raw cube texture.
  54147. * @param data defines the data to store
  54148. * @param format defines the data format
  54149. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54150. * @param invertY defines if data must be stored with Y axis inverted
  54151. * @param compression defines the compression used (null by default)
  54152. * @param level defines which level of the texture to update
  54153. */
  54154. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54155. /**
  54156. * Updates a raw cube texture with RGBD encoded data.
  54157. * @param data defines the array of data [mipmap][face] to use to create each face
  54158. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54159. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54160. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54161. * @returns a promsie that resolves when the operation is complete
  54162. */
  54163. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54164. /**
  54165. * Clones the raw cube texture.
  54166. * @return a new cube texture
  54167. */
  54168. clone(): CubeTexture;
  54169. /** @hidden */
  54170. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54171. }
  54172. }
  54173. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54174. import { Scene } from "babylonjs/scene";
  54175. import { Texture } from "babylonjs/Materials/Textures/texture";
  54176. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54177. /**
  54178. * Class used to store 3D textures containing user data
  54179. */
  54180. export class RawTexture3D extends Texture {
  54181. /** Gets or sets the texture format to use */
  54182. format: number;
  54183. private _engine;
  54184. /**
  54185. * Create a new RawTexture3D
  54186. * @param data defines the data of the texture
  54187. * @param width defines the width of the texture
  54188. * @param height defines the height of the texture
  54189. * @param depth defines the depth of the texture
  54190. * @param format defines the texture format to use
  54191. * @param scene defines the hosting scene
  54192. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54193. * @param invertY defines if texture must be stored with Y axis inverted
  54194. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54195. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54196. */
  54197. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54198. /** Gets or sets the texture format to use */
  54199. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54200. /**
  54201. * Update the texture with new data
  54202. * @param data defines the data to store in the texture
  54203. */
  54204. update(data: ArrayBufferView): void;
  54205. }
  54206. }
  54207. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54208. import { Scene } from "babylonjs/scene";
  54209. import { Plane } from "babylonjs/Maths/math.plane";
  54210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54211. /**
  54212. * Creates a refraction texture used by refraction channel of the standard material.
  54213. * It is like a mirror but to see through a material.
  54214. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54215. */
  54216. export class RefractionTexture extends RenderTargetTexture {
  54217. /**
  54218. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54219. * 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.
  54220. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54221. */
  54222. refractionPlane: Plane;
  54223. /**
  54224. * Define how deep under the surface we should see.
  54225. */
  54226. depth: number;
  54227. /**
  54228. * Creates a refraction texture used by refraction channel of the standard material.
  54229. * It is like a mirror but to see through a material.
  54230. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54231. * @param name Define the texture name
  54232. * @param size Define the size of the underlying texture
  54233. * @param scene Define the scene the refraction belongs to
  54234. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54235. */
  54236. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54237. /**
  54238. * Clone the refraction texture.
  54239. * @returns the cloned texture
  54240. */
  54241. clone(): RefractionTexture;
  54242. /**
  54243. * Serialize the texture to a JSON representation you could use in Parse later on
  54244. * @returns the serialized JSON representation
  54245. */
  54246. serialize(): any;
  54247. }
  54248. }
  54249. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54250. import { Nullable } from "babylonjs/types";
  54251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54252. import { Matrix } from "babylonjs/Maths/math.vector";
  54253. import { Engine } from "babylonjs/Engines/engine";
  54254. import { Scene } from "babylonjs/scene";
  54255. /**
  54256. * Defines the options related to the creation of an HtmlElementTexture
  54257. */
  54258. export interface IHtmlElementTextureOptions {
  54259. /**
  54260. * Defines wether mip maps should be created or not.
  54261. */
  54262. generateMipMaps?: boolean;
  54263. /**
  54264. * Defines the sampling mode of the texture.
  54265. */
  54266. samplingMode?: number;
  54267. /**
  54268. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54269. */
  54270. engine: Nullable<Engine>;
  54271. /**
  54272. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54273. */
  54274. scene: Nullable<Scene>;
  54275. }
  54276. /**
  54277. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54278. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54279. * is automatically managed.
  54280. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54281. * in your application.
  54282. *
  54283. * As the update is not automatic, you need to call them manually.
  54284. */
  54285. export class HtmlElementTexture extends BaseTexture {
  54286. /**
  54287. * The texture URL.
  54288. */
  54289. element: HTMLVideoElement | HTMLCanvasElement;
  54290. private static readonly DefaultOptions;
  54291. private _textureMatrix;
  54292. private _engine;
  54293. private _isVideo;
  54294. private _generateMipMaps;
  54295. private _samplingMode;
  54296. /**
  54297. * Instantiates a HtmlElementTexture from the following parameters.
  54298. *
  54299. * @param name Defines the name of the texture
  54300. * @param element Defines the video or canvas the texture is filled with
  54301. * @param options Defines the other none mandatory texture creation options
  54302. */
  54303. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54304. private _createInternalTexture;
  54305. /**
  54306. * Returns the texture matrix used in most of the material.
  54307. */
  54308. getTextureMatrix(): Matrix;
  54309. /**
  54310. * Updates the content of the texture.
  54311. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54312. */
  54313. update(invertY?: Nullable<boolean>): void;
  54314. }
  54315. }
  54316. declare module "babylonjs/Materials/Textures/index" {
  54317. export * from "babylonjs/Materials/Textures/baseTexture";
  54318. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54319. export * from "babylonjs/Materials/Textures/cubeTexture";
  54320. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54321. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54322. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54323. export * from "babylonjs/Materials/Textures/internalTexture";
  54324. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54325. export * from "babylonjs/Materials/Textures/Loaders/index";
  54326. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54327. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54328. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54329. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54330. export * from "babylonjs/Materials/Textures/rawTexture";
  54331. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54332. export * from "babylonjs/Materials/Textures/refractionTexture";
  54333. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54334. export * from "babylonjs/Materials/Textures/texture";
  54335. export * from "babylonjs/Materials/Textures/videoTexture";
  54336. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54337. }
  54338. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54339. /**
  54340. * Enum used to define the target of a block
  54341. */
  54342. export enum NodeMaterialBlockTargets {
  54343. /** Vertex shader */
  54344. Vertex = 1,
  54345. /** Fragment shader */
  54346. Fragment = 2,
  54347. /** Neutral */
  54348. Neutral = 4,
  54349. /** Vertex and Fragment */
  54350. VertexAndFragment = 3
  54351. }
  54352. }
  54353. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54354. /**
  54355. * Defines the kind of connection point for node based material
  54356. */
  54357. export enum NodeMaterialBlockConnectionPointTypes {
  54358. /** Float */
  54359. Float = 1,
  54360. /** Int */
  54361. Int = 2,
  54362. /** Vector2 */
  54363. Vector2 = 4,
  54364. /** Vector3 */
  54365. Vector3 = 8,
  54366. /** Vector4 */
  54367. Vector4 = 16,
  54368. /** Color3 */
  54369. Color3 = 32,
  54370. /** Color4 */
  54371. Color4 = 64,
  54372. /** Matrix */
  54373. Matrix = 128,
  54374. /** Detect type based on connection */
  54375. AutoDetect = 1024,
  54376. /** Output type that will be defined by input type */
  54377. BasedOnInput = 2048
  54378. }
  54379. }
  54380. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54382. /**
  54383. * Root class for all node material optimizers
  54384. */
  54385. export class NodeMaterialOptimizer {
  54386. /**
  54387. * Function used to optimize a NodeMaterial graph
  54388. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54389. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54390. */
  54391. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54392. }
  54393. }
  54394. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54398. import { Scene } from "babylonjs/scene";
  54399. /**
  54400. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54401. */
  54402. export class TransformBlock extends NodeMaterialBlock {
  54403. /**
  54404. * Defines the value to use to complement W value to transform it to a Vector4
  54405. */
  54406. complementW: number;
  54407. /**
  54408. * Defines the value to use to complement z value to transform it to a Vector4
  54409. */
  54410. complementZ: number;
  54411. /**
  54412. * Creates a new TransformBlock
  54413. * @param name defines the block name
  54414. */
  54415. constructor(name: string);
  54416. /**
  54417. * Gets the current class name
  54418. * @returns the class name
  54419. */
  54420. getClassName(): string;
  54421. /**
  54422. * Gets the vector input
  54423. */
  54424. readonly vector: NodeMaterialConnectionPoint;
  54425. /**
  54426. * Gets the output component
  54427. */
  54428. readonly output: NodeMaterialConnectionPoint;
  54429. /**
  54430. * Gets the matrix transform input
  54431. */
  54432. readonly transform: NodeMaterialConnectionPoint;
  54433. protected _buildBlock(state: NodeMaterialBuildState): this;
  54434. serialize(): any;
  54435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54436. protected _dumpPropertiesCode(): string;
  54437. }
  54438. }
  54439. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54443. /**
  54444. * Block used to output the vertex position
  54445. */
  54446. export class VertexOutputBlock extends NodeMaterialBlock {
  54447. /**
  54448. * Creates a new VertexOutputBlock
  54449. * @param name defines the block name
  54450. */
  54451. constructor(name: string);
  54452. /**
  54453. * Gets the current class name
  54454. * @returns the class name
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Gets the vector input component
  54459. */
  54460. readonly vector: NodeMaterialConnectionPoint;
  54461. protected _buildBlock(state: NodeMaterialBuildState): this;
  54462. }
  54463. }
  54464. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54468. /**
  54469. * Block used to output the final color
  54470. */
  54471. export class FragmentOutputBlock extends NodeMaterialBlock {
  54472. /**
  54473. * Create a new FragmentOutputBlock
  54474. * @param name defines the block name
  54475. */
  54476. constructor(name: string);
  54477. /**
  54478. * Gets the current class name
  54479. * @returns the class name
  54480. */
  54481. getClassName(): string;
  54482. /**
  54483. * Gets the rgba input component
  54484. */
  54485. readonly rgba: NodeMaterialConnectionPoint;
  54486. /**
  54487. * Gets the rgb input component
  54488. */
  54489. readonly rgb: NodeMaterialConnectionPoint;
  54490. /**
  54491. * Gets the a input component
  54492. */
  54493. readonly a: NodeMaterialConnectionPoint;
  54494. protected _buildBlock(state: NodeMaterialBuildState): this;
  54495. }
  54496. }
  54497. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54498. /**
  54499. * Enum used to define well known values e.g. values automatically provided by the system
  54500. */
  54501. export enum NodeMaterialWellKnownValues {
  54502. /** World */
  54503. World = 1,
  54504. /** View */
  54505. View = 2,
  54506. /** Projection */
  54507. Projection = 3,
  54508. /** ViewProjection */
  54509. ViewProjection = 4,
  54510. /** WorldView */
  54511. WorldView = 5,
  54512. /** WorldViewProjection */
  54513. WorldViewProjection = 6,
  54514. /** CameraPosition */
  54515. CameraPosition = 7,
  54516. /** Fog Color */
  54517. FogColor = 8
  54518. }
  54519. }
  54520. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54527. import { Effect } from "babylonjs/Materials/effect";
  54528. import { Mesh } from "babylonjs/Meshes/mesh";
  54529. import { Nullable } from "babylonjs/types";
  54530. import { Scene } from "babylonjs/scene";
  54531. /**
  54532. * Block used to read a reflection texture from a sampler
  54533. */
  54534. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54535. private _define3DName;
  54536. private _defineCubicName;
  54537. private _defineExplicitName;
  54538. private _defineProjectionName;
  54539. private _defineLocalCubicName;
  54540. private _defineSphericalName;
  54541. private _definePlanarName;
  54542. private _defineEquirectangularName;
  54543. private _defineMirroredEquirectangularFixedName;
  54544. private _defineEquirectangularFixedName;
  54545. private _defineSkyboxName;
  54546. private _cubeSamplerName;
  54547. private _2DSamplerName;
  54548. private _positionUVWName;
  54549. private _directionWName;
  54550. private _reflectionCoordsName;
  54551. private _reflection2DCoordsName;
  54552. private _reflectionColorName;
  54553. private _reflectionMatrixName;
  54554. /**
  54555. * Gets or sets the texture associated with the node
  54556. */
  54557. texture: Nullable<BaseTexture>;
  54558. /**
  54559. * Create a new TextureBlock
  54560. * @param name defines the block name
  54561. */
  54562. constructor(name: string);
  54563. /**
  54564. * Gets the current class name
  54565. * @returns the class name
  54566. */
  54567. getClassName(): string;
  54568. /**
  54569. * Gets the world position input component
  54570. */
  54571. readonly position: NodeMaterialConnectionPoint;
  54572. /**
  54573. * Gets the world position input component
  54574. */
  54575. readonly worldPosition: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the world normal input component
  54578. */
  54579. readonly worldNormal: NodeMaterialConnectionPoint;
  54580. /**
  54581. * Gets the world input component
  54582. */
  54583. readonly world: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the camera (or eye) position component
  54586. */
  54587. readonly cameraPosition: NodeMaterialConnectionPoint;
  54588. /**
  54589. * Gets the view input component
  54590. */
  54591. readonly view: NodeMaterialConnectionPoint;
  54592. /**
  54593. * Gets the rgb output component
  54594. */
  54595. readonly rgb: NodeMaterialConnectionPoint;
  54596. /**
  54597. * Gets the r output component
  54598. */
  54599. readonly r: NodeMaterialConnectionPoint;
  54600. /**
  54601. * Gets the g output component
  54602. */
  54603. readonly g: NodeMaterialConnectionPoint;
  54604. /**
  54605. * Gets the b output component
  54606. */
  54607. readonly b: NodeMaterialConnectionPoint;
  54608. autoConfigure(material: NodeMaterial): void;
  54609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54610. isReady(): boolean;
  54611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54612. private _injectVertexCode;
  54613. private _writeOutput;
  54614. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54615. serialize(): any;
  54616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54617. }
  54618. }
  54619. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54621. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54622. import { Scene } from "babylonjs/scene";
  54623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54624. import { Matrix } from "babylonjs/Maths/math.vector";
  54625. import { Mesh } from "babylonjs/Meshes/mesh";
  54626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54627. import { Observable } from "babylonjs/Misc/observable";
  54628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54629. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54630. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54631. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54632. import { Nullable } from "babylonjs/types";
  54633. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54634. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54635. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54636. /**
  54637. * Interface used to configure the node material editor
  54638. */
  54639. export interface INodeMaterialEditorOptions {
  54640. /** Define the URl to load node editor script */
  54641. editorURL?: string;
  54642. }
  54643. /** @hidden */
  54644. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54645. /** BONES */
  54646. NUM_BONE_INFLUENCERS: number;
  54647. BonesPerMesh: number;
  54648. BONETEXTURE: boolean;
  54649. /** MORPH TARGETS */
  54650. MORPHTARGETS: boolean;
  54651. MORPHTARGETS_NORMAL: boolean;
  54652. MORPHTARGETS_TANGENT: boolean;
  54653. MORPHTARGETS_UV: boolean;
  54654. NUM_MORPH_INFLUENCERS: number;
  54655. /** IMAGE PROCESSING */
  54656. IMAGEPROCESSING: boolean;
  54657. VIGNETTE: boolean;
  54658. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54659. VIGNETTEBLENDMODEOPAQUE: boolean;
  54660. TONEMAPPING: boolean;
  54661. TONEMAPPING_ACES: boolean;
  54662. CONTRAST: boolean;
  54663. EXPOSURE: boolean;
  54664. COLORCURVES: boolean;
  54665. COLORGRADING: boolean;
  54666. COLORGRADING3D: boolean;
  54667. SAMPLER3DGREENDEPTH: boolean;
  54668. SAMPLER3DBGRMAP: boolean;
  54669. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54670. constructor();
  54671. setValue(name: string, value: boolean): void;
  54672. }
  54673. /**
  54674. * Class used to configure NodeMaterial
  54675. */
  54676. export interface INodeMaterialOptions {
  54677. /**
  54678. * Defines if blocks should emit comments
  54679. */
  54680. emitComments: boolean;
  54681. }
  54682. /**
  54683. * Class used to create a node based material built by assembling shader blocks
  54684. */
  54685. export class NodeMaterial extends PushMaterial {
  54686. private static _BuildIdGenerator;
  54687. private _options;
  54688. private _vertexCompilationState;
  54689. private _fragmentCompilationState;
  54690. private _sharedData;
  54691. private _buildId;
  54692. private _buildWasSuccessful;
  54693. private _cachedWorldViewMatrix;
  54694. private _cachedWorldViewProjectionMatrix;
  54695. private _optimizers;
  54696. private _animationFrame;
  54697. /** Define the URl to load node editor script */
  54698. static EditorURL: string;
  54699. private BJSNODEMATERIALEDITOR;
  54700. /** Get the inspector from bundle or global */
  54701. private _getGlobalNodeMaterialEditor;
  54702. /**
  54703. * 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)
  54704. */
  54705. ignoreAlpha: boolean;
  54706. /**
  54707. * Defines the maximum number of lights that can be used in the material
  54708. */
  54709. maxSimultaneousLights: number;
  54710. /**
  54711. * Observable raised when the material is built
  54712. */
  54713. onBuildObservable: Observable<NodeMaterial>;
  54714. /**
  54715. * Gets or sets the root nodes of the material vertex shader
  54716. */
  54717. _vertexOutputNodes: NodeMaterialBlock[];
  54718. /**
  54719. * Gets or sets the root nodes of the material fragment (pixel) shader
  54720. */
  54721. _fragmentOutputNodes: NodeMaterialBlock[];
  54722. /** Gets or sets options to control the node material overall behavior */
  54723. options: INodeMaterialOptions;
  54724. /**
  54725. * Default configuration related to image processing available in the standard Material.
  54726. */
  54727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54728. /**
  54729. * Gets the image processing configuration used either in this material.
  54730. */
  54731. /**
  54732. * Sets the Default image processing configuration used either in the this material.
  54733. *
  54734. * If sets to null, the scene one is in use.
  54735. */
  54736. imageProcessingConfiguration: ImageProcessingConfiguration;
  54737. /**
  54738. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54739. */
  54740. attachedBlocks: NodeMaterialBlock[];
  54741. /**
  54742. * Create a new node based material
  54743. * @param name defines the material name
  54744. * @param scene defines the hosting scene
  54745. * @param options defines creation option
  54746. */
  54747. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54748. /**
  54749. * Gets the current class name of the material e.g. "NodeMaterial"
  54750. * @returns the class name
  54751. */
  54752. getClassName(): string;
  54753. /**
  54754. * Keep track of the image processing observer to allow dispose and replace.
  54755. */
  54756. private _imageProcessingObserver;
  54757. /**
  54758. * Attaches a new image processing configuration to the Standard Material.
  54759. * @param configuration
  54760. */
  54761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54762. /**
  54763. * Get a block by its name
  54764. * @param name defines the name of the block to retrieve
  54765. * @returns the required block or null if not found
  54766. */
  54767. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54768. /**
  54769. * Get a block by its name
  54770. * @param predicate defines the predicate used to find the good candidate
  54771. * @returns the required block or null if not found
  54772. */
  54773. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54774. /**
  54775. * Get an input block by its name
  54776. * @param predicate defines the predicate used to find the good candidate
  54777. * @returns the required input block or null if not found
  54778. */
  54779. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54780. /**
  54781. * Gets the list of input blocks attached to this material
  54782. * @returns an array of InputBlocks
  54783. */
  54784. getInputBlocks(): InputBlock[];
  54785. /**
  54786. * Adds a new optimizer to the list of optimizers
  54787. * @param optimizer defines the optimizers to add
  54788. * @returns the current material
  54789. */
  54790. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54791. /**
  54792. * Remove an optimizer from the list of optimizers
  54793. * @param optimizer defines the optimizers to remove
  54794. * @returns the current material
  54795. */
  54796. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54797. /**
  54798. * Add a new block to the list of output nodes
  54799. * @param node defines the node to add
  54800. * @returns the current material
  54801. */
  54802. addOutputNode(node: NodeMaterialBlock): this;
  54803. /**
  54804. * Remove a block from the list of root nodes
  54805. * @param node defines the node to remove
  54806. * @returns the current material
  54807. */
  54808. removeOutputNode(node: NodeMaterialBlock): this;
  54809. private _addVertexOutputNode;
  54810. private _removeVertexOutputNode;
  54811. private _addFragmentOutputNode;
  54812. private _removeFragmentOutputNode;
  54813. /**
  54814. * Specifies if the material will require alpha blending
  54815. * @returns a boolean specifying if alpha blending is needed
  54816. */
  54817. needAlphaBlending(): boolean;
  54818. /**
  54819. * Specifies if this material should be rendered in alpha test mode
  54820. * @returns a boolean specifying if an alpha test is needed.
  54821. */
  54822. needAlphaTesting(): boolean;
  54823. private _initializeBlock;
  54824. private _resetDualBlocks;
  54825. /**
  54826. * Build the material and generates the inner effect
  54827. * @param verbose defines if the build should log activity
  54828. */
  54829. build(verbose?: boolean): void;
  54830. /**
  54831. * Runs an otpimization phase to try to improve the shader code
  54832. */
  54833. optimize(): void;
  54834. private _prepareDefinesForAttributes;
  54835. /**
  54836. * Get if the submesh is ready to be used and all its information available.
  54837. * Child classes can use it to update shaders
  54838. * @param mesh defines the mesh to check
  54839. * @param subMesh defines which submesh to check
  54840. * @param useInstances specifies that instances should be used
  54841. * @returns a boolean indicating that the submesh is ready or not
  54842. */
  54843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54844. /**
  54845. * Get a string representing the shaders built by the current node graph
  54846. */
  54847. readonly compiledShaders: string;
  54848. /**
  54849. * Binds the world matrix to the material
  54850. * @param world defines the world transformation matrix
  54851. */
  54852. bindOnlyWorldMatrix(world: Matrix): void;
  54853. /**
  54854. * Binds the submesh to this material by preparing the effect and shader to draw
  54855. * @param world defines the world transformation matrix
  54856. * @param mesh defines the mesh containing the submesh
  54857. * @param subMesh defines the submesh to bind the material to
  54858. */
  54859. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54860. /**
  54861. * Gets the active textures from the material
  54862. * @returns an array of textures
  54863. */
  54864. getActiveTextures(): BaseTexture[];
  54865. /**
  54866. * Gets the list of texture blocks
  54867. * @returns an array of texture blocks
  54868. */
  54869. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54870. /**
  54871. * Specifies if the material uses a texture
  54872. * @param texture defines the texture to check against the material
  54873. * @returns a boolean specifying if the material uses the texture
  54874. */
  54875. hasTexture(texture: BaseTexture): boolean;
  54876. /**
  54877. * Disposes the material
  54878. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54879. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54880. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54881. */
  54882. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54883. /** Creates the node editor window. */
  54884. private _createNodeEditor;
  54885. /**
  54886. * Launch the node material editor
  54887. * @param config Define the configuration of the editor
  54888. * @return a promise fulfilled when the node editor is visible
  54889. */
  54890. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54891. /**
  54892. * Clear the current material
  54893. */
  54894. clear(): void;
  54895. /**
  54896. * Clear the current material and set it to a default state
  54897. */
  54898. setToDefault(): void;
  54899. /**
  54900. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54901. * @param url defines the url to load from
  54902. * @returns a promise that will fullfil when the material is fully loaded
  54903. */
  54904. loadAsync(url: string): Promise<unknown>;
  54905. private _gatherBlocks;
  54906. /**
  54907. * Generate a string containing the code declaration required to create an equivalent of this material
  54908. * @returns a string
  54909. */
  54910. generateCode(): string;
  54911. /**
  54912. * Serializes this material in a JSON representation
  54913. * @returns the serialized material object
  54914. */
  54915. serialize(): any;
  54916. private _restoreConnections;
  54917. /**
  54918. * Clear the current graph and load a new one from a serialization object
  54919. * @param source defines the JSON representation of the material
  54920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54921. */
  54922. loadFromSerialization(source: any, rootUrl?: string): void;
  54923. /**
  54924. * Creates a node material from parsed material data
  54925. * @param source defines the JSON representation of the material
  54926. * @param scene defines the hosting scene
  54927. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54928. * @returns a new node material
  54929. */
  54930. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54931. /**
  54932. * Creates a new node material set to default basic configuration
  54933. * @param name defines the name of the material
  54934. * @param scene defines the hosting scene
  54935. * @returns a new NodeMaterial
  54936. */
  54937. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54938. }
  54939. }
  54940. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54943. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54947. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54948. import { Effect } from "babylonjs/Materials/effect";
  54949. import { Mesh } from "babylonjs/Meshes/mesh";
  54950. import { Nullable } from "babylonjs/types";
  54951. import { Scene } from "babylonjs/scene";
  54952. /**
  54953. * Block used to read a texture from a sampler
  54954. */
  54955. export class TextureBlock extends NodeMaterialBlock {
  54956. private _defineName;
  54957. private _samplerName;
  54958. private _transformedUVName;
  54959. private _textureTransformName;
  54960. private _textureInfoName;
  54961. private _mainUVName;
  54962. private _mainUVDefineName;
  54963. /**
  54964. * Gets or sets the texture associated with the node
  54965. */
  54966. texture: Nullable<BaseTexture>;
  54967. /**
  54968. * Create a new TextureBlock
  54969. * @param name defines the block name
  54970. */
  54971. constructor(name: string);
  54972. /**
  54973. * Gets the current class name
  54974. * @returns the class name
  54975. */
  54976. getClassName(): string;
  54977. /**
  54978. * Gets the uv input component
  54979. */
  54980. readonly uv: NodeMaterialConnectionPoint;
  54981. /**
  54982. * Gets the rgba output component
  54983. */
  54984. readonly rgba: NodeMaterialConnectionPoint;
  54985. /**
  54986. * Gets the rgb output component
  54987. */
  54988. readonly rgb: NodeMaterialConnectionPoint;
  54989. /**
  54990. * Gets the r output component
  54991. */
  54992. readonly r: NodeMaterialConnectionPoint;
  54993. /**
  54994. * Gets the g output component
  54995. */
  54996. readonly g: NodeMaterialConnectionPoint;
  54997. /**
  54998. * Gets the b output component
  54999. */
  55000. readonly b: NodeMaterialConnectionPoint;
  55001. /**
  55002. * Gets the a output component
  55003. */
  55004. readonly a: NodeMaterialConnectionPoint;
  55005. readonly target: NodeMaterialBlockTargets;
  55006. autoConfigure(material: NodeMaterial): void;
  55007. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55009. isReady(): boolean;
  55010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55011. private readonly _isMixed;
  55012. private _injectVertexCode;
  55013. private _writeOutput;
  55014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55015. protected _dumpPropertiesCode(): string;
  55016. serialize(): any;
  55017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55023. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55024. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55025. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55026. /**
  55027. * Class used to store shared data between 2 NodeMaterialBuildState
  55028. */
  55029. export class NodeMaterialBuildStateSharedData {
  55030. /**
  55031. * Gets the list of emitted varyings
  55032. */
  55033. temps: string[];
  55034. /**
  55035. * Gets the list of emitted varyings
  55036. */
  55037. varyings: string[];
  55038. /**
  55039. * Gets the varying declaration string
  55040. */
  55041. varyingDeclaration: string;
  55042. /**
  55043. * Input blocks
  55044. */
  55045. inputBlocks: InputBlock[];
  55046. /**
  55047. * Input blocks
  55048. */
  55049. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55050. /**
  55051. * Bindable blocks (Blocks that need to set data to the effect)
  55052. */
  55053. bindableBlocks: NodeMaterialBlock[];
  55054. /**
  55055. * List of blocks that can provide a compilation fallback
  55056. */
  55057. blocksWithFallbacks: NodeMaterialBlock[];
  55058. /**
  55059. * List of blocks that can provide a define update
  55060. */
  55061. blocksWithDefines: NodeMaterialBlock[];
  55062. /**
  55063. * List of blocks that can provide a repeatable content
  55064. */
  55065. repeatableContentBlocks: NodeMaterialBlock[];
  55066. /**
  55067. * List of blocks that can provide a dynamic list of uniforms
  55068. */
  55069. dynamicUniformBlocks: NodeMaterialBlock[];
  55070. /**
  55071. * List of blocks that can block the isReady function for the material
  55072. */
  55073. blockingBlocks: NodeMaterialBlock[];
  55074. /**
  55075. * Gets the list of animated inputs
  55076. */
  55077. animatedInputs: InputBlock[];
  55078. /**
  55079. * Build Id used to avoid multiple recompilations
  55080. */
  55081. buildId: number;
  55082. /** List of emitted variables */
  55083. variableNames: {
  55084. [key: string]: number;
  55085. };
  55086. /** List of emitted defines */
  55087. defineNames: {
  55088. [key: string]: number;
  55089. };
  55090. /** Should emit comments? */
  55091. emitComments: boolean;
  55092. /** Emit build activity */
  55093. verbose: boolean;
  55094. /**
  55095. * Gets the compilation hints emitted at compilation time
  55096. */
  55097. hints: {
  55098. needWorldViewMatrix: boolean;
  55099. needWorldViewProjectionMatrix: boolean;
  55100. needAlphaBlending: boolean;
  55101. needAlphaTesting: boolean;
  55102. };
  55103. /**
  55104. * List of compilation checks
  55105. */
  55106. checks: {
  55107. emitVertex: boolean;
  55108. emitFragment: boolean;
  55109. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55110. };
  55111. /** Creates a new shared data */
  55112. constructor();
  55113. /**
  55114. * Emits console errors and exceptions if there is a failing check
  55115. */
  55116. emitErrors(): void;
  55117. }
  55118. }
  55119. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55120. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55121. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55122. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55123. /**
  55124. * Class used to store node based material build state
  55125. */
  55126. export class NodeMaterialBuildState {
  55127. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55128. supportUniformBuffers: boolean;
  55129. /**
  55130. * Gets the list of emitted attributes
  55131. */
  55132. attributes: string[];
  55133. /**
  55134. * Gets the list of emitted uniforms
  55135. */
  55136. uniforms: string[];
  55137. /**
  55138. * Gets the list of emitted uniform buffers
  55139. */
  55140. uniformBuffers: string[];
  55141. /**
  55142. * Gets the list of emitted samplers
  55143. */
  55144. samplers: string[];
  55145. /**
  55146. * Gets the list of emitted functions
  55147. */
  55148. functions: {
  55149. [key: string]: string;
  55150. };
  55151. /**
  55152. * Gets the target of the compilation state
  55153. */
  55154. target: NodeMaterialBlockTargets;
  55155. /**
  55156. * Gets the list of emitted counters
  55157. */
  55158. counters: {
  55159. [key: string]: number;
  55160. };
  55161. /**
  55162. * Shared data between multiple NodeMaterialBuildState instances
  55163. */
  55164. sharedData: NodeMaterialBuildStateSharedData;
  55165. /** @hidden */
  55166. _vertexState: NodeMaterialBuildState;
  55167. /** @hidden */
  55168. _attributeDeclaration: string;
  55169. /** @hidden */
  55170. _uniformDeclaration: string;
  55171. /** @hidden */
  55172. _samplerDeclaration: string;
  55173. /** @hidden */
  55174. _varyingTransfer: string;
  55175. private _repeatableContentAnchorIndex;
  55176. /** @hidden */
  55177. _builtCompilationString: string;
  55178. /**
  55179. * Gets the emitted compilation strings
  55180. */
  55181. compilationString: string;
  55182. /**
  55183. * Finalize the compilation strings
  55184. * @param state defines the current compilation state
  55185. */
  55186. finalize(state: NodeMaterialBuildState): void;
  55187. /** @hidden */
  55188. readonly _repeatableContentAnchor: string;
  55189. /** @hidden */
  55190. _getFreeVariableName(prefix: string): string;
  55191. /** @hidden */
  55192. _getFreeDefineName(prefix: string): string;
  55193. /** @hidden */
  55194. _excludeVariableName(name: string): void;
  55195. /** @hidden */
  55196. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55197. /** @hidden */
  55198. _emitFunction(name: string, code: string, comments: string): void;
  55199. /** @hidden */
  55200. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55201. replaceStrings?: {
  55202. search: RegExp;
  55203. replace: string;
  55204. }[];
  55205. repeatKey?: string;
  55206. }): string;
  55207. /** @hidden */
  55208. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55209. repeatKey?: string;
  55210. removeAttributes?: boolean;
  55211. removeUniforms?: boolean;
  55212. removeVaryings?: boolean;
  55213. removeIfDef?: boolean;
  55214. replaceStrings?: {
  55215. search: RegExp;
  55216. replace: string;
  55217. }[];
  55218. }, storeKey?: string): void;
  55219. /** @hidden */
  55220. _registerTempVariable(name: string): boolean;
  55221. /** @hidden */
  55222. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55223. /** @hidden */
  55224. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55225. }
  55226. }
  55227. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55228. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55230. import { Nullable } from "babylonjs/types";
  55231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55232. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55233. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55235. import { Mesh } from "babylonjs/Meshes/mesh";
  55236. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55237. import { Scene } from "babylonjs/scene";
  55238. /**
  55239. * Defines a block that can be used inside a node based material
  55240. */
  55241. export class NodeMaterialBlock {
  55242. private _buildId;
  55243. private _buildTarget;
  55244. private _target;
  55245. private _isFinalMerger;
  55246. private _isInput;
  55247. /** @hidden */
  55248. _codeVariableName: string;
  55249. /** @hidden */
  55250. _inputs: NodeMaterialConnectionPoint[];
  55251. /** @hidden */
  55252. _outputs: NodeMaterialConnectionPoint[];
  55253. /** @hidden */
  55254. _preparationId: number;
  55255. /**
  55256. * Gets or sets the name of the block
  55257. */
  55258. name: string;
  55259. /**
  55260. * Gets or sets the unique id of the node
  55261. */
  55262. uniqueId: number;
  55263. /**
  55264. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55265. */
  55266. readonly isFinalMerger: boolean;
  55267. /**
  55268. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55269. */
  55270. readonly isInput: boolean;
  55271. /**
  55272. * Gets or sets the build Id
  55273. */
  55274. buildId: number;
  55275. /**
  55276. * Gets or sets the target of the block
  55277. */
  55278. target: NodeMaterialBlockTargets;
  55279. /**
  55280. * Gets the list of input points
  55281. */
  55282. readonly inputs: NodeMaterialConnectionPoint[];
  55283. /** Gets the list of output points */
  55284. readonly outputs: NodeMaterialConnectionPoint[];
  55285. /**
  55286. * Find an input by its name
  55287. * @param name defines the name of the input to look for
  55288. * @returns the input or null if not found
  55289. */
  55290. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55291. /**
  55292. * Find an output by its name
  55293. * @param name defines the name of the outputto look for
  55294. * @returns the output or null if not found
  55295. */
  55296. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55297. /**
  55298. * Creates a new NodeMaterialBlock
  55299. * @param name defines the block name
  55300. * @param target defines the target of that block (Vertex by default)
  55301. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55302. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55303. */
  55304. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55305. /**
  55306. * Initialize the block and prepare the context for build
  55307. * @param state defines the state that will be used for the build
  55308. */
  55309. initialize(state: NodeMaterialBuildState): void;
  55310. /**
  55311. * Bind data to effect. Will only be called for blocks with isBindable === true
  55312. * @param effect defines the effect to bind data to
  55313. * @param nodeMaterial defines the hosting NodeMaterial
  55314. * @param mesh defines the mesh that will be rendered
  55315. */
  55316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55317. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55318. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55319. protected _writeFloat(value: number): string;
  55320. /**
  55321. * Gets the current class name e.g. "NodeMaterialBlock"
  55322. * @returns the class name
  55323. */
  55324. getClassName(): string;
  55325. /**
  55326. * Register a new input. Must be called inside a block constructor
  55327. * @param name defines the connection point name
  55328. * @param type defines the connection point type
  55329. * @param isOptional defines a boolean indicating that this input can be omitted
  55330. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55331. * @returns the current block
  55332. */
  55333. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55334. /**
  55335. * Register a new output. Must be called inside a block constructor
  55336. * @param name defines the connection point name
  55337. * @param type defines the connection point type
  55338. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55339. * @returns the current block
  55340. */
  55341. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55342. /**
  55343. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55344. * @param forOutput defines an optional connection point to check compatibility with
  55345. * @returns the first available input or null
  55346. */
  55347. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55348. /**
  55349. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55350. * @param forBlock defines an optional block to check compatibility with
  55351. * @returns the first available input or null
  55352. */
  55353. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55354. /**
  55355. * Gets the sibling of the given output
  55356. * @param current defines the current output
  55357. * @returns the next output in the list or null
  55358. */
  55359. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55360. /**
  55361. * Connect current block with another block
  55362. * @param other defines the block to connect with
  55363. * @param options define the various options to help pick the right connections
  55364. * @returns the current block
  55365. */
  55366. connectTo(other: NodeMaterialBlock, options?: {
  55367. input?: string;
  55368. output?: string;
  55369. outputSwizzle?: string;
  55370. }): this | undefined;
  55371. protected _buildBlock(state: NodeMaterialBuildState): void;
  55372. /**
  55373. * Add uniforms, samplers and uniform buffers at compilation time
  55374. * @param state defines the state to update
  55375. * @param nodeMaterial defines the node material requesting the update
  55376. * @param defines defines the material defines to update
  55377. */
  55378. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55379. /**
  55380. * Add potential fallbacks if shader compilation fails
  55381. * @param mesh defines the mesh to be rendered
  55382. * @param fallbacks defines the current prioritized list of fallbacks
  55383. */
  55384. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55385. /**
  55386. * Update defines for shader compilation
  55387. * @param mesh defines the mesh to be rendered
  55388. * @param nodeMaterial defines the node material requesting the update
  55389. * @param defines defines the material defines to update
  55390. * @param useInstances specifies that instances should be used
  55391. */
  55392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55393. /**
  55394. * Initialize defines for shader compilation
  55395. * @param mesh defines the mesh to be rendered
  55396. * @param nodeMaterial defines the node material requesting the update
  55397. * @param defines defines the material defines to be prepared
  55398. * @param useInstances specifies that instances should be used
  55399. */
  55400. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55401. /**
  55402. * Lets the block try to connect some inputs automatically
  55403. * @param material defines the hosting NodeMaterial
  55404. */
  55405. autoConfigure(material: NodeMaterial): void;
  55406. /**
  55407. * Function called when a block is declared as repeatable content generator
  55408. * @param vertexShaderState defines the current compilation state for the vertex shader
  55409. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55410. * @param mesh defines the mesh to be rendered
  55411. * @param defines defines the material defines to update
  55412. */
  55413. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55414. /**
  55415. * Checks if the block is ready
  55416. * @param mesh defines the mesh to be rendered
  55417. * @param nodeMaterial defines the node material requesting the update
  55418. * @param defines defines the material defines to update
  55419. * @param useInstances specifies that instances should be used
  55420. * @returns true if the block is ready
  55421. */
  55422. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55423. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55424. private _processBuild;
  55425. /**
  55426. * Compile the current node and generate the shader code
  55427. * @param state defines the current compilation state (uniforms, samplers, current string)
  55428. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55429. * @returns true if already built
  55430. */
  55431. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55432. protected _inputRename(name: string): string;
  55433. protected _outputRename(name: string): string;
  55434. protected _dumpPropertiesCode(): string;
  55435. /** @hidden */
  55436. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55437. /**
  55438. * Clone the current block to a new identical block
  55439. * @param scene defines the hosting scene
  55440. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55441. * @returns a copy of the current block
  55442. */
  55443. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55444. /**
  55445. * Serializes this block in a JSON representation
  55446. * @returns the serialized block object
  55447. */
  55448. serialize(): any;
  55449. /** @hidden */
  55450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55451. }
  55452. }
  55453. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55454. /**
  55455. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55456. */
  55457. export enum NodeMaterialBlockConnectionPointMode {
  55458. /** Value is an uniform */
  55459. Uniform = 0,
  55460. /** Value is a mesh attribute */
  55461. Attribute = 1,
  55462. /** Value is a varying between vertex and fragment shaders */
  55463. Varying = 2,
  55464. /** Mode is undefined */
  55465. Undefined = 3
  55466. }
  55467. }
  55468. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55469. /**
  55470. * Enum defining the type of animations supported by InputBlock
  55471. */
  55472. export enum AnimatedInputBlockTypes {
  55473. /** No animation */
  55474. None = 0,
  55475. /** Time based animation. Will only work for floats */
  55476. Time = 1
  55477. }
  55478. }
  55479. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55481. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55482. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55483. import { Nullable } from "babylonjs/types";
  55484. import { Effect } from "babylonjs/Materials/effect";
  55485. import { Matrix } from "babylonjs/Maths/math.vector";
  55486. import { Scene } from "babylonjs/scene";
  55487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55489. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55490. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55491. /**
  55492. * Block used to expose an input value
  55493. */
  55494. export class InputBlock extends NodeMaterialBlock {
  55495. private _mode;
  55496. private _associatedVariableName;
  55497. private _storedValue;
  55498. private _valueCallback;
  55499. private _type;
  55500. private _animationType;
  55501. /** @hidden */
  55502. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55503. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55504. visibleInInspector: boolean;
  55505. /**
  55506. * Gets or sets the connection point type (default is float)
  55507. */
  55508. readonly type: NodeMaterialBlockConnectionPointTypes;
  55509. /**
  55510. * Creates a new InputBlock
  55511. * @param name defines the block name
  55512. * @param target defines the target of that block (Vertex by default)
  55513. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55514. */
  55515. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55516. /**
  55517. * Gets the output component
  55518. */
  55519. readonly output: NodeMaterialConnectionPoint;
  55520. /**
  55521. * Set the source of this connection point to a vertex attribute
  55522. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55523. * @returns the current connection point
  55524. */
  55525. setAsAttribute(attributeName?: string): InputBlock;
  55526. /**
  55527. * Set the source of this connection point to a well known value
  55528. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55529. * @returns the current connection point
  55530. */
  55531. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55532. /**
  55533. * Gets or sets the value of that point.
  55534. * Please note that this value will be ignored if valueCallback is defined
  55535. */
  55536. value: any;
  55537. /**
  55538. * Gets or sets a callback used to get the value of that point.
  55539. * Please note that setting this value will force the connection point to ignore the value property
  55540. */
  55541. valueCallback: () => any;
  55542. /**
  55543. * Gets or sets the associated variable name in the shader
  55544. */
  55545. associatedVariableName: string;
  55546. /** Gets or sets the type of animation applied to the input */
  55547. animationType: AnimatedInputBlockTypes;
  55548. /**
  55549. * Gets a boolean indicating that this connection point not defined yet
  55550. */
  55551. readonly isUndefined: boolean;
  55552. /**
  55553. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55554. * In this case the connection point name must be the name of the uniform to use.
  55555. * Can only be set on inputs
  55556. */
  55557. isUniform: boolean;
  55558. /**
  55559. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55560. * In this case the connection point name must be the name of the attribute to use
  55561. * Can only be set on inputs
  55562. */
  55563. isAttribute: boolean;
  55564. /**
  55565. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55566. * Can only be set on exit points
  55567. */
  55568. isVarying: boolean;
  55569. /**
  55570. * Gets a boolean indicating that the current connection point is a well known value
  55571. */
  55572. readonly isWellKnownValue: boolean;
  55573. /**
  55574. * Gets or sets the current well known value or null if not defined as well know value
  55575. */
  55576. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55577. /**
  55578. * Gets the current class name
  55579. * @returns the class name
  55580. */
  55581. getClassName(): string;
  55582. /**
  55583. * Animate the input if animationType !== None
  55584. * @param scene defines the rendering scene
  55585. */
  55586. animate(scene: Scene): void;
  55587. private _emitDefine;
  55588. /**
  55589. * Set the input block to its default value (based on its type)
  55590. */
  55591. setDefaultValue(): void;
  55592. protected _dumpPropertiesCode(): string;
  55593. private _emit;
  55594. /** @hidden */
  55595. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55596. /** @hidden */
  55597. _transmit(effect: Effect, scene: Scene): void;
  55598. protected _buildBlock(state: NodeMaterialBuildState): void;
  55599. serialize(): any;
  55600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55601. }
  55602. }
  55603. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55604. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55605. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55606. import { Nullable } from "babylonjs/types";
  55607. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55609. /**
  55610. * Defines a connection point for a block
  55611. */
  55612. export class NodeMaterialConnectionPoint {
  55613. /** @hidden */
  55614. _ownerBlock: NodeMaterialBlock;
  55615. /** @hidden */
  55616. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55617. private _endpoints;
  55618. private _associatedVariableName;
  55619. /** @hidden */
  55620. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55621. /** @hidden */
  55622. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55623. private _type;
  55624. /** @hidden */
  55625. _enforceAssociatedVariableName: boolean;
  55626. /**
  55627. * Gets or sets the additional types supported byt this connection point
  55628. */
  55629. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55630. /**
  55631. * Gets or sets the associated variable name in the shader
  55632. */
  55633. associatedVariableName: string;
  55634. /**
  55635. * Gets or sets the connection point type (default is float)
  55636. */
  55637. type: NodeMaterialBlockConnectionPointTypes;
  55638. /**
  55639. * Gets or sets the connection point name
  55640. */
  55641. name: string;
  55642. /**
  55643. * Gets or sets a boolean indicating that this connection point can be omitted
  55644. */
  55645. isOptional: boolean;
  55646. /**
  55647. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55648. */
  55649. define: string;
  55650. /** Gets or sets the target of that connection point */
  55651. target: NodeMaterialBlockTargets;
  55652. /**
  55653. * Gets a boolean indicating that the current point is connected
  55654. */
  55655. readonly isConnected: boolean;
  55656. /**
  55657. * Gets a boolean indicating that the current point is connected to an input block
  55658. */
  55659. readonly isConnectedToInputBlock: boolean;
  55660. /**
  55661. * Gets a the connected input block (if any)
  55662. */
  55663. readonly connectInputBlock: Nullable<InputBlock>;
  55664. /** Get the other side of the connection (if any) */
  55665. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55666. /** Get the block that owns this connection point */
  55667. readonly ownerBlock: NodeMaterialBlock;
  55668. /** Get the block connected on the other side of this connection (if any) */
  55669. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55670. /** Get the block connected on the endpoints of this connection (if any) */
  55671. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55672. /** Gets the list of connected endpoints */
  55673. readonly endpoints: NodeMaterialConnectionPoint[];
  55674. /** Gets a boolean indicating if that output point is connected to at least one input */
  55675. readonly hasEndpoints: boolean;
  55676. /**
  55677. * Creates a new connection point
  55678. * @param name defines the connection point name
  55679. * @param ownerBlock defines the block hosting this connection point
  55680. */
  55681. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55682. /**
  55683. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55684. * @returns the class name
  55685. */
  55686. getClassName(): string;
  55687. /**
  55688. * Gets an boolean indicating if the current point can be connected to another point
  55689. * @param connectionPoint defines the other connection point
  55690. * @returns true if the connection is possible
  55691. */
  55692. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55693. /**
  55694. * Connect this point to another connection point
  55695. * @param connectionPoint defines the other connection point
  55696. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55697. * @returns the current connection point
  55698. */
  55699. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55700. /**
  55701. * Disconnect this point from one of his endpoint
  55702. * @param endpoint defines the other connection point
  55703. * @returns the current connection point
  55704. */
  55705. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55706. /**
  55707. * Serializes this point in a JSON representation
  55708. * @returns the serialized point object
  55709. */
  55710. serialize(): any;
  55711. }
  55712. }
  55713. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55717. import { Mesh } from "babylonjs/Meshes/mesh";
  55718. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55720. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55721. /**
  55722. * Block used to add support for vertex skinning (bones)
  55723. */
  55724. export class BonesBlock extends NodeMaterialBlock {
  55725. /**
  55726. * Creates a new BonesBlock
  55727. * @param name defines the block name
  55728. */
  55729. constructor(name: string);
  55730. /**
  55731. * Initialize the block and prepare the context for build
  55732. * @param state defines the state that will be used for the build
  55733. */
  55734. initialize(state: NodeMaterialBuildState): void;
  55735. /**
  55736. * Gets the current class name
  55737. * @returns the class name
  55738. */
  55739. getClassName(): string;
  55740. /**
  55741. * Gets the matrix indices input component
  55742. */
  55743. readonly matricesIndices: NodeMaterialConnectionPoint;
  55744. /**
  55745. * Gets the matrix weights input component
  55746. */
  55747. readonly matricesWeights: NodeMaterialConnectionPoint;
  55748. /**
  55749. * Gets the extra matrix indices input component
  55750. */
  55751. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55752. /**
  55753. * Gets the extra matrix weights input component
  55754. */
  55755. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55756. /**
  55757. * Gets the world input component
  55758. */
  55759. readonly world: NodeMaterialConnectionPoint;
  55760. /**
  55761. * Gets the output component
  55762. */
  55763. readonly output: NodeMaterialConnectionPoint;
  55764. autoConfigure(material: NodeMaterial): void;
  55765. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55768. protected _buildBlock(state: NodeMaterialBuildState): this;
  55769. }
  55770. }
  55771. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55776. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55777. /**
  55778. * Block used to add support for instances
  55779. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55780. */
  55781. export class InstancesBlock extends NodeMaterialBlock {
  55782. /**
  55783. * Creates a new InstancesBlock
  55784. * @param name defines the block name
  55785. */
  55786. constructor(name: string);
  55787. /**
  55788. * Gets the current class name
  55789. * @returns the class name
  55790. */
  55791. getClassName(): string;
  55792. /**
  55793. * Gets the first world row input component
  55794. */
  55795. readonly world0: NodeMaterialConnectionPoint;
  55796. /**
  55797. * Gets the second world row input component
  55798. */
  55799. readonly world1: NodeMaterialConnectionPoint;
  55800. /**
  55801. * Gets the third world row input component
  55802. */
  55803. readonly world2: NodeMaterialConnectionPoint;
  55804. /**
  55805. * Gets the forth world row input component
  55806. */
  55807. readonly world3: NodeMaterialConnectionPoint;
  55808. /**
  55809. * Gets the world input component
  55810. */
  55811. readonly world: NodeMaterialConnectionPoint;
  55812. /**
  55813. * Gets the output component
  55814. */
  55815. readonly output: NodeMaterialConnectionPoint;
  55816. autoConfigure(material: NodeMaterial): void;
  55817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55818. protected _buildBlock(state: NodeMaterialBuildState): this;
  55819. }
  55820. }
  55821. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55826. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55827. import { Effect } from "babylonjs/Materials/effect";
  55828. import { Mesh } from "babylonjs/Meshes/mesh";
  55829. /**
  55830. * Block used to add morph targets support to vertex shader
  55831. */
  55832. export class MorphTargetsBlock extends NodeMaterialBlock {
  55833. private _repeatableContentAnchor;
  55834. private _repeatebleContentGenerated;
  55835. /**
  55836. * Create a new MorphTargetsBlock
  55837. * @param name defines the block name
  55838. */
  55839. constructor(name: string);
  55840. /**
  55841. * Gets the current class name
  55842. * @returns the class name
  55843. */
  55844. getClassName(): string;
  55845. /**
  55846. * Gets the position input component
  55847. */
  55848. readonly position: NodeMaterialConnectionPoint;
  55849. /**
  55850. * Gets the normal input component
  55851. */
  55852. readonly normal: NodeMaterialConnectionPoint;
  55853. /**
  55854. * Gets the tangent input component
  55855. */
  55856. readonly tangent: NodeMaterialConnectionPoint;
  55857. /**
  55858. * Gets the tangent input component
  55859. */
  55860. readonly uv: NodeMaterialConnectionPoint;
  55861. /**
  55862. * Gets the position output component
  55863. */
  55864. readonly positionOutput: NodeMaterialConnectionPoint;
  55865. /**
  55866. * Gets the normal output component
  55867. */
  55868. readonly normalOutput: NodeMaterialConnectionPoint;
  55869. /**
  55870. * Gets the tangent output component
  55871. */
  55872. readonly tangentOutput: NodeMaterialConnectionPoint;
  55873. /**
  55874. * Gets the tangent output component
  55875. */
  55876. readonly uvOutput: NodeMaterialConnectionPoint;
  55877. initialize(state: NodeMaterialBuildState): void;
  55878. autoConfigure(material: NodeMaterial): void;
  55879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55881. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55882. protected _buildBlock(state: NodeMaterialBuildState): this;
  55883. }
  55884. }
  55885. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55889. import { Nullable } from "babylonjs/types";
  55890. import { Scene } from "babylonjs/scene";
  55891. import { Effect } from "babylonjs/Materials/effect";
  55892. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55893. import { Mesh } from "babylonjs/Meshes/mesh";
  55894. import { Light } from "babylonjs/Lights/light";
  55895. /**
  55896. * Block used to get data information from a light
  55897. */
  55898. export class LightInformationBlock extends NodeMaterialBlock {
  55899. private _lightDataDefineName;
  55900. private _lightColorDefineName;
  55901. /**
  55902. * Gets or sets the light associated with this block
  55903. */
  55904. light: Nullable<Light>;
  55905. /**
  55906. * Creates a new LightInformationBlock
  55907. * @param name defines the block name
  55908. */
  55909. constructor(name: string);
  55910. /**
  55911. * Gets the current class name
  55912. * @returns the class name
  55913. */
  55914. getClassName(): string;
  55915. /**
  55916. * Gets the world position input component
  55917. */
  55918. readonly worldPosition: NodeMaterialConnectionPoint;
  55919. /**
  55920. * Gets the direction output component
  55921. */
  55922. readonly direction: NodeMaterialConnectionPoint;
  55923. /**
  55924. * Gets the direction output component
  55925. */
  55926. readonly color: NodeMaterialConnectionPoint;
  55927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55928. protected _buildBlock(state: NodeMaterialBuildState): this;
  55929. serialize(): any;
  55930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55931. }
  55932. }
  55933. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55934. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55935. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55936. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55937. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55938. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  55939. }
  55940. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55944. import { Scene } from "babylonjs/scene";
  55945. /**
  55946. * Block used to add an alpha test in the fragment shader
  55947. */
  55948. export class AlphaTestBlock extends NodeMaterialBlock {
  55949. /**
  55950. * Gets or sets the alpha value where alpha testing happens
  55951. */
  55952. alphaCutOff: number;
  55953. /**
  55954. * Create a new AlphaTestBlock
  55955. * @param name defines the block name
  55956. */
  55957. constructor(name: string);
  55958. /**
  55959. * Gets the current class name
  55960. * @returns the class name
  55961. */
  55962. getClassName(): string;
  55963. /**
  55964. * Gets the color input component
  55965. */
  55966. readonly color: NodeMaterialConnectionPoint;
  55967. /**
  55968. * Gets the alpha input component
  55969. */
  55970. readonly alpha: NodeMaterialConnectionPoint;
  55971. protected _buildBlock(state: NodeMaterialBuildState): this;
  55972. protected _dumpPropertiesCode(): string;
  55973. serialize(): any;
  55974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55975. }
  55976. }
  55977. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55982. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55983. import { Effect } from "babylonjs/Materials/effect";
  55984. import { Mesh } from "babylonjs/Meshes/mesh";
  55985. /**
  55986. * Block used to add image processing support to fragment shader
  55987. */
  55988. export class ImageProcessingBlock extends NodeMaterialBlock {
  55989. /**
  55990. * Create a new ImageProcessingBlock
  55991. * @param name defines the block name
  55992. */
  55993. constructor(name: string);
  55994. /**
  55995. * Gets the current class name
  55996. * @returns the class name
  55997. */
  55998. getClassName(): string;
  55999. /**
  56000. * Gets the color input component
  56001. */
  56002. readonly color: NodeMaterialConnectionPoint;
  56003. /**
  56004. * Gets the output component
  56005. */
  56006. readonly output: NodeMaterialConnectionPoint;
  56007. /**
  56008. * Initialize the block and prepare the context for build
  56009. * @param state defines the state that will be used for the build
  56010. */
  56011. initialize(state: NodeMaterialBuildState): void;
  56012. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56015. protected _buildBlock(state: NodeMaterialBuildState): this;
  56016. }
  56017. }
  56018. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56019. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56020. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56021. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56022. }
  56023. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56026. import { Mesh } from "babylonjs/Meshes/mesh";
  56027. import { Effect } from "babylonjs/Materials/effect";
  56028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56030. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56031. /**
  56032. * Block used to add support for scene fog
  56033. */
  56034. export class FogBlock extends NodeMaterialBlock {
  56035. private _fogDistanceName;
  56036. private _fogParameters;
  56037. /**
  56038. * Create a new FogBlock
  56039. * @param name defines the block name
  56040. */
  56041. constructor(name: string);
  56042. /**
  56043. * Gets the current class name
  56044. * @returns the class name
  56045. */
  56046. getClassName(): string;
  56047. /**
  56048. * Gets the world position input component
  56049. */
  56050. readonly worldPosition: NodeMaterialConnectionPoint;
  56051. /**
  56052. * Gets the view input component
  56053. */
  56054. readonly view: NodeMaterialConnectionPoint;
  56055. /**
  56056. * Gets the color input component
  56057. */
  56058. readonly input: NodeMaterialConnectionPoint;
  56059. /**
  56060. * Gets the fog color input component
  56061. */
  56062. readonly fogColor: NodeMaterialConnectionPoint;
  56063. /**
  56064. * Gets the output component
  56065. */
  56066. readonly output: NodeMaterialConnectionPoint;
  56067. autoConfigure(material: NodeMaterial): void;
  56068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56069. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56070. protected _buildBlock(state: NodeMaterialBuildState): this;
  56071. }
  56072. }
  56073. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56079. import { Effect } from "babylonjs/Materials/effect";
  56080. import { Mesh } from "babylonjs/Meshes/mesh";
  56081. import { Light } from "babylonjs/Lights/light";
  56082. import { Nullable } from "babylonjs/types";
  56083. import { Scene } from "babylonjs/scene";
  56084. /**
  56085. * Block used to add light in the fragment shader
  56086. */
  56087. export class LightBlock extends NodeMaterialBlock {
  56088. private _lightId;
  56089. /**
  56090. * Gets or sets the light associated with this block
  56091. */
  56092. light: Nullable<Light>;
  56093. /**
  56094. * Create a new LightBlock
  56095. * @param name defines the block name
  56096. */
  56097. constructor(name: string);
  56098. /**
  56099. * Gets the current class name
  56100. * @returns the class name
  56101. */
  56102. getClassName(): string;
  56103. /**
  56104. * Gets the world position input component
  56105. */
  56106. readonly worldPosition: NodeMaterialConnectionPoint;
  56107. /**
  56108. * Gets the world normal input component
  56109. */
  56110. readonly worldNormal: NodeMaterialConnectionPoint;
  56111. /**
  56112. * Gets the camera (or eye) position component
  56113. */
  56114. readonly cameraPosition: NodeMaterialConnectionPoint;
  56115. /**
  56116. * Gets the diffuse output component
  56117. */
  56118. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56119. /**
  56120. * Gets the specular output component
  56121. */
  56122. readonly specularOutput: NodeMaterialConnectionPoint;
  56123. autoConfigure(material: NodeMaterial): void;
  56124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56125. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56127. private _injectVertexCode;
  56128. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56129. serialize(): any;
  56130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56131. }
  56132. }
  56133. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56134. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56135. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56136. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56137. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56138. }
  56139. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56140. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56141. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56142. }
  56143. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56147. /**
  56148. * Block used to multiply 2 values
  56149. */
  56150. export class MultiplyBlock extends NodeMaterialBlock {
  56151. /**
  56152. * Creates a new MultiplyBlock
  56153. * @param name defines the block name
  56154. */
  56155. constructor(name: string);
  56156. /**
  56157. * Gets the current class name
  56158. * @returns the class name
  56159. */
  56160. getClassName(): string;
  56161. /**
  56162. * Gets the left operand input component
  56163. */
  56164. readonly left: NodeMaterialConnectionPoint;
  56165. /**
  56166. * Gets the right operand input component
  56167. */
  56168. readonly right: NodeMaterialConnectionPoint;
  56169. /**
  56170. * Gets the output component
  56171. */
  56172. readonly output: NodeMaterialConnectionPoint;
  56173. protected _buildBlock(state: NodeMaterialBuildState): this;
  56174. }
  56175. }
  56176. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56180. /**
  56181. * Block used to add 2 vectors
  56182. */
  56183. export class AddBlock extends NodeMaterialBlock {
  56184. /**
  56185. * Creates a new AddBlock
  56186. * @param name defines the block name
  56187. */
  56188. constructor(name: string);
  56189. /**
  56190. * Gets the current class name
  56191. * @returns the class name
  56192. */
  56193. getClassName(): string;
  56194. /**
  56195. * Gets the left operand input component
  56196. */
  56197. readonly left: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the right operand input component
  56200. */
  56201. readonly right: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the output component
  56204. */
  56205. readonly output: NodeMaterialConnectionPoint;
  56206. protected _buildBlock(state: NodeMaterialBuildState): this;
  56207. }
  56208. }
  56209. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56213. /**
  56214. * Block used to scale a vector by a float
  56215. */
  56216. export class ScaleBlock extends NodeMaterialBlock {
  56217. /**
  56218. * Creates a new ScaleBlock
  56219. * @param name defines the block name
  56220. */
  56221. constructor(name: string);
  56222. /**
  56223. * Gets the current class name
  56224. * @returns the class name
  56225. */
  56226. getClassName(): string;
  56227. /**
  56228. * Gets the input component
  56229. */
  56230. readonly input: NodeMaterialConnectionPoint;
  56231. /**
  56232. * Gets the factor input component
  56233. */
  56234. readonly factor: NodeMaterialConnectionPoint;
  56235. /**
  56236. * Gets the output component
  56237. */
  56238. readonly output: NodeMaterialConnectionPoint;
  56239. protected _buildBlock(state: NodeMaterialBuildState): this;
  56240. }
  56241. }
  56242. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56246. import { Scene } from "babylonjs/scene";
  56247. /**
  56248. * Block used to clamp a float
  56249. */
  56250. export class ClampBlock extends NodeMaterialBlock {
  56251. /** Gets or sets the minimum range */
  56252. minimum: number;
  56253. /** Gets or sets the maximum range */
  56254. maximum: number;
  56255. /**
  56256. * Creates a new ClampBlock
  56257. * @param name defines the block name
  56258. */
  56259. constructor(name: string);
  56260. /**
  56261. * Gets the current class name
  56262. * @returns the class name
  56263. */
  56264. getClassName(): string;
  56265. /**
  56266. * Gets the value input component
  56267. */
  56268. readonly value: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the output component
  56271. */
  56272. readonly output: NodeMaterialConnectionPoint;
  56273. protected _buildBlock(state: NodeMaterialBuildState): this;
  56274. protected _dumpPropertiesCode(): string;
  56275. serialize(): any;
  56276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56277. }
  56278. }
  56279. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56283. /**
  56284. * Block used to apply a cross product between 2 vectors
  56285. */
  56286. export class CrossBlock extends NodeMaterialBlock {
  56287. /**
  56288. * Creates a new CrossBlock
  56289. * @param name defines the block name
  56290. */
  56291. constructor(name: string);
  56292. /**
  56293. * Gets the current class name
  56294. * @returns the class name
  56295. */
  56296. getClassName(): string;
  56297. /**
  56298. * Gets the left operand input component
  56299. */
  56300. readonly left: NodeMaterialConnectionPoint;
  56301. /**
  56302. * Gets the right operand input component
  56303. */
  56304. readonly right: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the output component
  56307. */
  56308. readonly output: NodeMaterialConnectionPoint;
  56309. protected _buildBlock(state: NodeMaterialBuildState): this;
  56310. }
  56311. }
  56312. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56316. /**
  56317. * Block used to apply a dot product between 2 vectors
  56318. */
  56319. export class DotBlock extends NodeMaterialBlock {
  56320. /**
  56321. * Creates a new DotBlock
  56322. * @param name defines the block name
  56323. */
  56324. constructor(name: string);
  56325. /**
  56326. * Gets the current class name
  56327. * @returns the class name
  56328. */
  56329. getClassName(): string;
  56330. /**
  56331. * Gets the left operand input component
  56332. */
  56333. readonly left: NodeMaterialConnectionPoint;
  56334. /**
  56335. * Gets the right operand input component
  56336. */
  56337. readonly right: NodeMaterialConnectionPoint;
  56338. /**
  56339. * Gets the output component
  56340. */
  56341. readonly output: NodeMaterialConnectionPoint;
  56342. protected _buildBlock(state: NodeMaterialBuildState): this;
  56343. }
  56344. }
  56345. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56349. import { Vector2 } from "babylonjs/Maths/math.vector";
  56350. import { Scene } from "babylonjs/scene";
  56351. /**
  56352. * Block used to remap a float from a range to a new one
  56353. */
  56354. export class RemapBlock extends NodeMaterialBlock {
  56355. /**
  56356. * Gets or sets the source range
  56357. */
  56358. sourceRange: Vector2;
  56359. /**
  56360. * Gets or sets the target range
  56361. */
  56362. targetRange: Vector2;
  56363. /**
  56364. * Creates a new RemapBlock
  56365. * @param name defines the block name
  56366. */
  56367. constructor(name: string);
  56368. /**
  56369. * Gets the current class name
  56370. * @returns the class name
  56371. */
  56372. getClassName(): string;
  56373. /**
  56374. * Gets the input component
  56375. */
  56376. readonly input: NodeMaterialConnectionPoint;
  56377. /**
  56378. * Gets the output component
  56379. */
  56380. readonly output: NodeMaterialConnectionPoint;
  56381. protected _buildBlock(state: NodeMaterialBuildState): this;
  56382. protected _dumpPropertiesCode(): string;
  56383. serialize(): any;
  56384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56385. }
  56386. }
  56387. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56391. /**
  56392. * Block used to normalize a vector
  56393. */
  56394. export class NormalizeBlock extends NodeMaterialBlock {
  56395. /**
  56396. * Creates a new NormalizeBlock
  56397. * @param name defines the block name
  56398. */
  56399. constructor(name: string);
  56400. /**
  56401. * Gets the current class name
  56402. * @returns the class name
  56403. */
  56404. getClassName(): string;
  56405. /**
  56406. * Gets the input component
  56407. */
  56408. readonly input: NodeMaterialConnectionPoint;
  56409. /**
  56410. * Gets the output component
  56411. */
  56412. readonly output: NodeMaterialConnectionPoint;
  56413. protected _buildBlock(state: NodeMaterialBuildState): this;
  56414. }
  56415. }
  56416. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56420. import { Scene } from "babylonjs/scene";
  56421. /**
  56422. * Operations supported by the Trigonometry block
  56423. */
  56424. export enum TrigonometryBlockOperations {
  56425. /** Cos */
  56426. Cos = 0,
  56427. /** Sin */
  56428. Sin = 1,
  56429. /** Abs */
  56430. Abs = 2,
  56431. /** Exp */
  56432. Exp = 3,
  56433. /** Exp2 */
  56434. Exp2 = 4,
  56435. /** Round */
  56436. Round = 5,
  56437. /** Floor */
  56438. Floor = 6,
  56439. /** Ceiling */
  56440. Ceiling = 7
  56441. }
  56442. /**
  56443. * Block used to apply trigonometry operation to floats
  56444. */
  56445. export class TrigonometryBlock extends NodeMaterialBlock {
  56446. /**
  56447. * Gets or sets the operation applied by the block
  56448. */
  56449. operation: TrigonometryBlockOperations;
  56450. /**
  56451. * Creates a new TrigonometryBlock
  56452. * @param name defines the block name
  56453. */
  56454. constructor(name: string);
  56455. /**
  56456. * Gets the current class name
  56457. * @returns the class name
  56458. */
  56459. getClassName(): string;
  56460. /**
  56461. * Gets the input component
  56462. */
  56463. readonly input: NodeMaterialConnectionPoint;
  56464. /**
  56465. * Gets the output component
  56466. */
  56467. readonly output: NodeMaterialConnectionPoint;
  56468. protected _buildBlock(state: NodeMaterialBuildState): this;
  56469. serialize(): any;
  56470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56471. }
  56472. }
  56473. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56477. /**
  56478. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56479. */
  56480. export class ColorMergerBlock extends NodeMaterialBlock {
  56481. /**
  56482. * Create a new ColorMergerBlock
  56483. * @param name defines the block name
  56484. */
  56485. constructor(name: string);
  56486. /**
  56487. * Gets the current class name
  56488. * @returns the class name
  56489. */
  56490. getClassName(): string;
  56491. /**
  56492. * Gets the r component (input)
  56493. */
  56494. readonly r: NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the g component (input)
  56497. */
  56498. readonly g: NodeMaterialConnectionPoint;
  56499. /**
  56500. * Gets the b component (input)
  56501. */
  56502. readonly b: NodeMaterialConnectionPoint;
  56503. /**
  56504. * Gets the a component (input)
  56505. */
  56506. readonly a: NodeMaterialConnectionPoint;
  56507. /**
  56508. * Gets the rgba component (output)
  56509. */
  56510. readonly rgba: NodeMaterialConnectionPoint;
  56511. /**
  56512. * Gets the rgb component (output)
  56513. */
  56514. readonly rgb: NodeMaterialConnectionPoint;
  56515. protected _buildBlock(state: NodeMaterialBuildState): this;
  56516. }
  56517. }
  56518. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56522. /**
  56523. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56524. */
  56525. export class VectorMergerBlock extends NodeMaterialBlock {
  56526. /**
  56527. * Create a new VectorMergerBlock
  56528. * @param name defines the block name
  56529. */
  56530. constructor(name: string);
  56531. /**
  56532. * Gets the current class name
  56533. * @returns the class name
  56534. */
  56535. getClassName(): string;
  56536. /**
  56537. * Gets the x component (input)
  56538. */
  56539. readonly x: NodeMaterialConnectionPoint;
  56540. /**
  56541. * Gets the y component (input)
  56542. */
  56543. readonly y: NodeMaterialConnectionPoint;
  56544. /**
  56545. * Gets the z component (input)
  56546. */
  56547. readonly z: NodeMaterialConnectionPoint;
  56548. /**
  56549. * Gets the w component (input)
  56550. */
  56551. readonly w: NodeMaterialConnectionPoint;
  56552. /**
  56553. * Gets the xyzw component (output)
  56554. */
  56555. readonly xyzw: NodeMaterialConnectionPoint;
  56556. /**
  56557. * Gets the xyz component (output)
  56558. */
  56559. readonly xyz: NodeMaterialConnectionPoint;
  56560. /**
  56561. * Gets the xy component (output)
  56562. */
  56563. readonly xy: NodeMaterialConnectionPoint;
  56564. protected _buildBlock(state: NodeMaterialBuildState): this;
  56565. }
  56566. }
  56567. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56571. /**
  56572. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56573. */
  56574. export class ColorSplitterBlock extends NodeMaterialBlock {
  56575. /**
  56576. * Create a new ColorSplitterBlock
  56577. * @param name defines the block name
  56578. */
  56579. constructor(name: string);
  56580. /**
  56581. * Gets the current class name
  56582. * @returns the class name
  56583. */
  56584. getClassName(): string;
  56585. /**
  56586. * Gets the rgba component (input)
  56587. */
  56588. readonly rgba: NodeMaterialConnectionPoint;
  56589. /**
  56590. * Gets the rgb component (input)
  56591. */
  56592. readonly rgbIn: NodeMaterialConnectionPoint;
  56593. /**
  56594. * Gets the rgb component (output)
  56595. */
  56596. readonly rgbOut: NodeMaterialConnectionPoint;
  56597. /**
  56598. * Gets the r component (output)
  56599. */
  56600. readonly r: NodeMaterialConnectionPoint;
  56601. /**
  56602. * Gets the g component (output)
  56603. */
  56604. readonly g: NodeMaterialConnectionPoint;
  56605. /**
  56606. * Gets the b component (output)
  56607. */
  56608. readonly b: NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the a component (output)
  56611. */
  56612. readonly a: NodeMaterialConnectionPoint;
  56613. protected _inputRename(name: string): string;
  56614. protected _outputRename(name: string): string;
  56615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56616. }
  56617. }
  56618. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56622. /**
  56623. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56624. */
  56625. export class VectorSplitterBlock extends NodeMaterialBlock {
  56626. /**
  56627. * Create a new VectorSplitterBlock
  56628. * @param name defines the block name
  56629. */
  56630. constructor(name: string);
  56631. /**
  56632. * Gets the current class name
  56633. * @returns the class name
  56634. */
  56635. getClassName(): string;
  56636. /**
  56637. * Gets the xyzw component (input)
  56638. */
  56639. readonly xyzw: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the xyz component (input)
  56642. */
  56643. readonly xyzIn: NodeMaterialConnectionPoint;
  56644. /**
  56645. * Gets the xy component (input)
  56646. */
  56647. readonly xyIn: NodeMaterialConnectionPoint;
  56648. /**
  56649. * Gets the xyz component (output)
  56650. */
  56651. readonly xyzOut: NodeMaterialConnectionPoint;
  56652. /**
  56653. * Gets the xy component (output)
  56654. */
  56655. readonly xyOut: NodeMaterialConnectionPoint;
  56656. /**
  56657. * Gets the x component (output)
  56658. */
  56659. readonly x: NodeMaterialConnectionPoint;
  56660. /**
  56661. * Gets the y component (output)
  56662. */
  56663. readonly y: NodeMaterialConnectionPoint;
  56664. /**
  56665. * Gets the z component (output)
  56666. */
  56667. readonly z: NodeMaterialConnectionPoint;
  56668. /**
  56669. * Gets the w component (output)
  56670. */
  56671. readonly w: NodeMaterialConnectionPoint;
  56672. protected _inputRename(name: string): string;
  56673. protected _outputRename(name: string): string;
  56674. protected _buildBlock(state: NodeMaterialBuildState): this;
  56675. }
  56676. }
  56677. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56681. /**
  56682. * Block used to lerp 2 values
  56683. */
  56684. export class LerpBlock extends NodeMaterialBlock {
  56685. /**
  56686. * Creates a new LerpBlock
  56687. * @param name defines the block name
  56688. */
  56689. constructor(name: string);
  56690. /**
  56691. * Gets the current class name
  56692. * @returns the class name
  56693. */
  56694. getClassName(): string;
  56695. /**
  56696. * Gets the left operand input component
  56697. */
  56698. readonly left: NodeMaterialConnectionPoint;
  56699. /**
  56700. * Gets the right operand input component
  56701. */
  56702. readonly right: NodeMaterialConnectionPoint;
  56703. /**
  56704. * Gets the gradient operand input component
  56705. */
  56706. readonly gradient: NodeMaterialConnectionPoint;
  56707. /**
  56708. * Gets the output component
  56709. */
  56710. readonly output: NodeMaterialConnectionPoint;
  56711. protected _buildBlock(state: NodeMaterialBuildState): this;
  56712. }
  56713. }
  56714. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56717. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56718. /**
  56719. * Block used to divide 2 vectors
  56720. */
  56721. export class DivideBlock extends NodeMaterialBlock {
  56722. /**
  56723. * Creates a new DivideBlock
  56724. * @param name defines the block name
  56725. */
  56726. constructor(name: string);
  56727. /**
  56728. * Gets the current class name
  56729. * @returns the class name
  56730. */
  56731. getClassName(): string;
  56732. /**
  56733. * Gets the left operand input component
  56734. */
  56735. readonly left: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the right operand input component
  56738. */
  56739. readonly right: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the output component
  56742. */
  56743. readonly output: NodeMaterialConnectionPoint;
  56744. protected _buildBlock(state: NodeMaterialBuildState): this;
  56745. }
  56746. }
  56747. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56751. /**
  56752. * Block used to subtract 2 vectors
  56753. */
  56754. export class SubtractBlock extends NodeMaterialBlock {
  56755. /**
  56756. * Creates a new SubtractBlock
  56757. * @param name defines the block name
  56758. */
  56759. constructor(name: string);
  56760. /**
  56761. * Gets the current class name
  56762. * @returns the class name
  56763. */
  56764. getClassName(): string;
  56765. /**
  56766. * Gets the left operand input component
  56767. */
  56768. readonly left: NodeMaterialConnectionPoint;
  56769. /**
  56770. * Gets the right operand input component
  56771. */
  56772. readonly right: NodeMaterialConnectionPoint;
  56773. /**
  56774. * Gets the output component
  56775. */
  56776. readonly output: NodeMaterialConnectionPoint;
  56777. protected _buildBlock(state: NodeMaterialBuildState): this;
  56778. }
  56779. }
  56780. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56784. /**
  56785. * Block used to step a value
  56786. */
  56787. export class StepBlock extends NodeMaterialBlock {
  56788. /**
  56789. * Creates a new AddBlock
  56790. * @param name defines the block name
  56791. */
  56792. constructor(name: string);
  56793. /**
  56794. * Gets the current class name
  56795. * @returns the class name
  56796. */
  56797. getClassName(): string;
  56798. /**
  56799. * Gets the value operand input component
  56800. */
  56801. readonly value: NodeMaterialConnectionPoint;
  56802. /**
  56803. * Gets the edge operand input component
  56804. */
  56805. readonly edge: NodeMaterialConnectionPoint;
  56806. /**
  56807. * Gets the output component
  56808. */
  56809. readonly output: NodeMaterialConnectionPoint;
  56810. protected _buildBlock(state: NodeMaterialBuildState): this;
  56811. }
  56812. }
  56813. declare module "babylonjs/Materials/Node/Blocks/oppositeBlock" {
  56814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56817. /**
  56818. * Block used to get the opposite of a value
  56819. */
  56820. export class OppositeBlock extends NodeMaterialBlock {
  56821. /**
  56822. * Creates a new OppositeBlock
  56823. * @param name defines the block name
  56824. */
  56825. constructor(name: string);
  56826. /**
  56827. * Gets the current class name
  56828. * @returns the class name
  56829. */
  56830. getClassName(): string;
  56831. /**
  56832. * Gets the input component
  56833. */
  56834. readonly input: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the output component
  56837. */
  56838. readonly output: NodeMaterialConnectionPoint;
  56839. protected _buildBlock(state: NodeMaterialBuildState): this;
  56840. }
  56841. }
  56842. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56846. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56847. /**
  56848. * Block used to get the view direction
  56849. */
  56850. export class ViewDirectionBlock extends NodeMaterialBlock {
  56851. /**
  56852. * Creates a new ViewDirectionBlock
  56853. * @param name defines the block name
  56854. */
  56855. constructor(name: string);
  56856. /**
  56857. * Gets the current class name
  56858. * @returns the class name
  56859. */
  56860. getClassName(): string;
  56861. /**
  56862. * Gets the world position component
  56863. */
  56864. readonly worldPosition: NodeMaterialConnectionPoint;
  56865. /**
  56866. * Gets the camera position component
  56867. */
  56868. readonly cameraPosition: NodeMaterialConnectionPoint;
  56869. /**
  56870. * Gets the output component
  56871. */
  56872. readonly output: NodeMaterialConnectionPoint;
  56873. autoConfigure(material: NodeMaterial): void;
  56874. protected _buildBlock(state: NodeMaterialBuildState): this;
  56875. }
  56876. }
  56877. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  56878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56881. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56882. /**
  56883. * Block used to compute fresnel value
  56884. */
  56885. export class FresnelBlock extends NodeMaterialBlock {
  56886. /**
  56887. * Create a new FresnelBlock
  56888. * @param name defines the block name
  56889. */
  56890. constructor(name: string);
  56891. /**
  56892. * Gets the current class name
  56893. * @returns the class name
  56894. */
  56895. getClassName(): string;
  56896. /**
  56897. * Gets the world normal input component
  56898. */
  56899. readonly worldNormal: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the view direction input component
  56902. */
  56903. readonly viewDirection: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the bias input component
  56906. */
  56907. readonly bias: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the camera (or eye) position component
  56910. */
  56911. readonly power: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the fresnel output component
  56914. */
  56915. readonly fresnel: NodeMaterialConnectionPoint;
  56916. autoConfigure(material: NodeMaterial): void;
  56917. protected _buildBlock(state: NodeMaterialBuildState): this;
  56918. }
  56919. }
  56920. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  56921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56924. /**
  56925. * Block used to get the max of 2 values
  56926. */
  56927. export class MaxBlock extends NodeMaterialBlock {
  56928. /**
  56929. * Creates a new MaxBlock
  56930. * @param name defines the block name
  56931. */
  56932. constructor(name: string);
  56933. /**
  56934. * Gets the current class name
  56935. * @returns the class name
  56936. */
  56937. getClassName(): string;
  56938. /**
  56939. * Gets the left operand input component
  56940. */
  56941. readonly left: NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the right operand input component
  56944. */
  56945. readonly right: NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the output component
  56948. */
  56949. readonly output: NodeMaterialConnectionPoint;
  56950. protected _buildBlock(state: NodeMaterialBuildState): this;
  56951. }
  56952. }
  56953. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  56954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56957. /**
  56958. * Block used to get the min of 2 values
  56959. */
  56960. export class MinBlock extends NodeMaterialBlock {
  56961. /**
  56962. * Creates a new MinBlock
  56963. * @param name defines the block name
  56964. */
  56965. constructor(name: string);
  56966. /**
  56967. * Gets the current class name
  56968. * @returns the class name
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Gets the left operand input component
  56973. */
  56974. readonly left: NodeMaterialConnectionPoint;
  56975. /**
  56976. * Gets the right operand input component
  56977. */
  56978. readonly right: NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the output component
  56981. */
  56982. readonly output: NodeMaterialConnectionPoint;
  56983. protected _buildBlock(state: NodeMaterialBuildState): this;
  56984. }
  56985. }
  56986. declare module "babylonjs/Materials/Node/Blocks/index" {
  56987. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56988. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56989. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56990. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56991. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56992. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56993. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56994. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56995. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56996. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56997. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56998. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56999. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57000. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57001. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57002. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57003. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57004. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57005. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57006. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57007. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57008. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57009. export * from "babylonjs/Materials/Node/Blocks/oppositeBlock";
  57010. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57011. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57012. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57013. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57014. }
  57015. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57016. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57017. }
  57018. declare module "babylonjs/Materials/Node/index" {
  57019. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57020. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57021. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57022. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57023. export * from "babylonjs/Materials/Node/nodeMaterial";
  57024. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  57025. export * from "babylonjs/Materials/Node/Blocks/index";
  57026. export * from "babylonjs/Materials/Node/Optimizers/index";
  57027. }
  57028. declare module "babylonjs/Materials/effectRenderer" {
  57029. import { Nullable } from "babylonjs/types";
  57030. import { Texture } from "babylonjs/Materials/Textures/texture";
  57031. import { Engine } from "babylonjs/Engines/engine";
  57032. import { Viewport } from "babylonjs/Maths/math.viewport";
  57033. import { Observable } from "babylonjs/Misc/observable";
  57034. import { Effect } from "babylonjs/Materials/effect";
  57035. import "babylonjs/Shaders/postprocess.vertex";
  57036. /**
  57037. * Effect Render Options
  57038. */
  57039. export interface IEffectRendererOptions {
  57040. /**
  57041. * Defines the vertices positions.
  57042. */
  57043. positions?: number[];
  57044. /**
  57045. * Defines the indices.
  57046. */
  57047. indices?: number[];
  57048. }
  57049. /**
  57050. * Helper class to render one or more effects
  57051. */
  57052. export class EffectRenderer {
  57053. private engine;
  57054. private static _DefaultOptions;
  57055. private _vertexBuffers;
  57056. private _indexBuffer;
  57057. private _ringBufferIndex;
  57058. private _ringScreenBuffer;
  57059. private _fullscreenViewport;
  57060. private _getNextFrameBuffer;
  57061. /**
  57062. * Creates an effect renderer
  57063. * @param engine the engine to use for rendering
  57064. * @param options defines the options of the effect renderer
  57065. */
  57066. constructor(engine: Engine, options?: IEffectRendererOptions);
  57067. /**
  57068. * Sets the current viewport in normalized coordinates 0-1
  57069. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57070. */
  57071. setViewport(viewport?: Viewport): void;
  57072. /**
  57073. * Sets the current effect wrapper to use during draw.
  57074. * The effect needs to be ready before calling this api.
  57075. * This also sets the default full screen position attribute.
  57076. * @param effectWrapper Defines the effect to draw with
  57077. */
  57078. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57079. /**
  57080. * Draws a full screen quad.
  57081. */
  57082. draw(): void;
  57083. /**
  57084. * renders one or more effects to a specified texture
  57085. * @param effectWrappers list of effects to renderer
  57086. * @param outputTexture texture to draw to, if null it will render to the screen
  57087. */
  57088. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57089. /**
  57090. * Disposes of the effect renderer
  57091. */
  57092. dispose(): void;
  57093. }
  57094. /**
  57095. * Options to create an EffectWrapper
  57096. */
  57097. interface EffectWrapperCreationOptions {
  57098. /**
  57099. * Engine to use to create the effect
  57100. */
  57101. engine: Engine;
  57102. /**
  57103. * Fragment shader for the effect
  57104. */
  57105. fragmentShader: string;
  57106. /**
  57107. * Vertex shader for the effect
  57108. */
  57109. vertexShader?: string;
  57110. /**
  57111. * Attributes to use in the shader
  57112. */
  57113. attributeNames?: Array<string>;
  57114. /**
  57115. * Uniforms to use in the shader
  57116. */
  57117. uniformNames?: Array<string>;
  57118. /**
  57119. * Texture sampler names to use in the shader
  57120. */
  57121. samplerNames?: Array<string>;
  57122. /**
  57123. * The friendly name of the effect displayed in Spector.
  57124. */
  57125. name?: string;
  57126. }
  57127. /**
  57128. * Wraps an effect to be used for rendering
  57129. */
  57130. export class EffectWrapper {
  57131. /**
  57132. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57133. */
  57134. onApplyObservable: Observable<{}>;
  57135. /**
  57136. * The underlying effect
  57137. */
  57138. effect: Effect;
  57139. /**
  57140. * Creates an effect to be renderer
  57141. * @param creationOptions options to create the effect
  57142. */
  57143. constructor(creationOptions: EffectWrapperCreationOptions);
  57144. /**
  57145. * Disposes of the effect wrapper
  57146. */
  57147. dispose(): void;
  57148. }
  57149. }
  57150. declare module "babylonjs/Materials/index" {
  57151. export * from "babylonjs/Materials/Background/index";
  57152. export * from "babylonjs/Materials/colorCurves";
  57153. export * from "babylonjs/Materials/effect";
  57154. export * from "babylonjs/Materials/fresnelParameters";
  57155. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57156. export * from "babylonjs/Materials/material";
  57157. export * from "babylonjs/Materials/materialDefines";
  57158. export * from "babylonjs/Materials/materialHelper";
  57159. export * from "babylonjs/Materials/multiMaterial";
  57160. export * from "babylonjs/Materials/PBR/index";
  57161. export * from "babylonjs/Materials/pushMaterial";
  57162. export * from "babylonjs/Materials/shaderMaterial";
  57163. export * from "babylonjs/Materials/standardMaterial";
  57164. export * from "babylonjs/Materials/Textures/index";
  57165. export * from "babylonjs/Materials/uniformBuffer";
  57166. export * from "babylonjs/Materials/materialFlags";
  57167. export * from "babylonjs/Materials/Node/index";
  57168. export * from "babylonjs/Materials/effectRenderer";
  57169. }
  57170. declare module "babylonjs/Maths/index" {
  57171. export * from "babylonjs/Maths/math.scalar";
  57172. export * from "babylonjs/Maths/math";
  57173. export * from "babylonjs/Maths/sphericalPolynomial";
  57174. }
  57175. declare module "babylonjs/Misc/workerPool" {
  57176. import { IDisposable } from "babylonjs/scene";
  57177. /**
  57178. * Helper class to push actions to a pool of workers.
  57179. */
  57180. export class WorkerPool implements IDisposable {
  57181. private _workerInfos;
  57182. private _pendingActions;
  57183. /**
  57184. * Constructor
  57185. * @param workers Array of workers to use for actions
  57186. */
  57187. constructor(workers: Array<Worker>);
  57188. /**
  57189. * Terminates all workers and clears any pending actions.
  57190. */
  57191. dispose(): void;
  57192. /**
  57193. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57194. * pended until a worker has completed its action.
  57195. * @param action The action to perform. Call onComplete when the action is complete.
  57196. */
  57197. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57198. private _execute;
  57199. }
  57200. }
  57201. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57202. import { IDisposable } from "babylonjs/scene";
  57203. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57204. /**
  57205. * Configuration for Draco compression
  57206. */
  57207. export interface IDracoCompressionConfiguration {
  57208. /**
  57209. * Configuration for the decoder.
  57210. */
  57211. decoder: {
  57212. /**
  57213. * The url to the WebAssembly module.
  57214. */
  57215. wasmUrl?: string;
  57216. /**
  57217. * The url to the WebAssembly binary.
  57218. */
  57219. wasmBinaryUrl?: string;
  57220. /**
  57221. * The url to the fallback JavaScript module.
  57222. */
  57223. fallbackUrl?: string;
  57224. };
  57225. }
  57226. /**
  57227. * Draco compression (https://google.github.io/draco/)
  57228. *
  57229. * This class wraps the Draco module.
  57230. *
  57231. * **Encoder**
  57232. *
  57233. * The encoder is not currently implemented.
  57234. *
  57235. * **Decoder**
  57236. *
  57237. * 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.
  57238. *
  57239. * To update the configuration, use the following code:
  57240. * ```javascript
  57241. * DracoCompression.Configuration = {
  57242. * decoder: {
  57243. * wasmUrl: "<url to the WebAssembly library>",
  57244. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57245. * fallbackUrl: "<url to the fallback JavaScript library>",
  57246. * }
  57247. * };
  57248. * ```
  57249. *
  57250. * 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.
  57251. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57252. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57253. *
  57254. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57255. * ```javascript
  57256. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57257. * ```
  57258. *
  57259. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57260. */
  57261. export class DracoCompression implements IDisposable {
  57262. private _workerPoolPromise?;
  57263. private _decoderModulePromise?;
  57264. /**
  57265. * The configuration. Defaults to the following urls:
  57266. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57267. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57268. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57269. */
  57270. static Configuration: IDracoCompressionConfiguration;
  57271. /**
  57272. * Returns true if the decoder configuration is available.
  57273. */
  57274. static readonly DecoderAvailable: boolean;
  57275. /**
  57276. * Default number of workers to create when creating the draco compression object.
  57277. */
  57278. static DefaultNumWorkers: number;
  57279. private static GetDefaultNumWorkers;
  57280. private static _Default;
  57281. /**
  57282. * Default instance for the draco compression object.
  57283. */
  57284. static readonly Default: DracoCompression;
  57285. /**
  57286. * Constructor
  57287. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57288. */
  57289. constructor(numWorkers?: number);
  57290. /**
  57291. * Stop all async operations and release resources.
  57292. */
  57293. dispose(): void;
  57294. /**
  57295. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57296. * @returns a promise that resolves when ready
  57297. */
  57298. whenReadyAsync(): Promise<void>;
  57299. /**
  57300. * Decode Draco compressed mesh data to vertex data.
  57301. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57302. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57303. * @returns A promise that resolves with the decoded vertex data
  57304. */
  57305. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57306. [kind: string]: number;
  57307. }): Promise<VertexData>;
  57308. }
  57309. }
  57310. declare module "babylonjs/Meshes/Compression/index" {
  57311. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57312. }
  57313. declare module "babylonjs/Meshes/csg" {
  57314. import { Nullable } from "babylonjs/types";
  57315. import { Scene } from "babylonjs/scene";
  57316. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57317. import { Mesh } from "babylonjs/Meshes/mesh";
  57318. import { Material } from "babylonjs/Materials/material";
  57319. /**
  57320. * Class for building Constructive Solid Geometry
  57321. */
  57322. export class CSG {
  57323. private polygons;
  57324. /**
  57325. * The world matrix
  57326. */
  57327. matrix: Matrix;
  57328. /**
  57329. * Stores the position
  57330. */
  57331. position: Vector3;
  57332. /**
  57333. * Stores the rotation
  57334. */
  57335. rotation: Vector3;
  57336. /**
  57337. * Stores the rotation quaternion
  57338. */
  57339. rotationQuaternion: Nullable<Quaternion>;
  57340. /**
  57341. * Stores the scaling vector
  57342. */
  57343. scaling: Vector3;
  57344. /**
  57345. * Convert the Mesh to CSG
  57346. * @param mesh The Mesh to convert to CSG
  57347. * @returns A new CSG from the Mesh
  57348. */
  57349. static FromMesh(mesh: Mesh): CSG;
  57350. /**
  57351. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57352. * @param polygons Polygons used to construct a CSG solid
  57353. */
  57354. private static FromPolygons;
  57355. /**
  57356. * Clones, or makes a deep copy, of the CSG
  57357. * @returns A new CSG
  57358. */
  57359. clone(): CSG;
  57360. /**
  57361. * Unions this CSG with another CSG
  57362. * @param csg The CSG to union against this CSG
  57363. * @returns The unioned CSG
  57364. */
  57365. union(csg: CSG): CSG;
  57366. /**
  57367. * Unions this CSG with another CSG in place
  57368. * @param csg The CSG to union against this CSG
  57369. */
  57370. unionInPlace(csg: CSG): void;
  57371. /**
  57372. * Subtracts this CSG with another CSG
  57373. * @param csg The CSG to subtract against this CSG
  57374. * @returns A new CSG
  57375. */
  57376. subtract(csg: CSG): CSG;
  57377. /**
  57378. * Subtracts this CSG with another CSG in place
  57379. * @param csg The CSG to subtact against this CSG
  57380. */
  57381. subtractInPlace(csg: CSG): void;
  57382. /**
  57383. * Intersect this CSG with another CSG
  57384. * @param csg The CSG to intersect against this CSG
  57385. * @returns A new CSG
  57386. */
  57387. intersect(csg: CSG): CSG;
  57388. /**
  57389. * Intersects this CSG with another CSG in place
  57390. * @param csg The CSG to intersect against this CSG
  57391. */
  57392. intersectInPlace(csg: CSG): void;
  57393. /**
  57394. * Return a new CSG solid with solid and empty space switched. This solid is
  57395. * not modified.
  57396. * @returns A new CSG solid with solid and empty space switched
  57397. */
  57398. inverse(): CSG;
  57399. /**
  57400. * Inverses the CSG in place
  57401. */
  57402. inverseInPlace(): void;
  57403. /**
  57404. * This is used to keep meshes transformations so they can be restored
  57405. * when we build back a Babylon Mesh
  57406. * NB : All CSG operations are performed in world coordinates
  57407. * @param csg The CSG to copy the transform attributes from
  57408. * @returns This CSG
  57409. */
  57410. copyTransformAttributes(csg: CSG): CSG;
  57411. /**
  57412. * Build Raw mesh from CSG
  57413. * Coordinates here are in world space
  57414. * @param name The name of the mesh geometry
  57415. * @param scene The Scene
  57416. * @param keepSubMeshes Specifies if the submeshes should be kept
  57417. * @returns A new Mesh
  57418. */
  57419. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57420. /**
  57421. * Build Mesh from CSG taking material and transforms into account
  57422. * @param name The name of the Mesh
  57423. * @param material The material of the Mesh
  57424. * @param scene The Scene
  57425. * @param keepSubMeshes Specifies if submeshes should be kept
  57426. * @returns The new Mesh
  57427. */
  57428. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57429. }
  57430. }
  57431. declare module "babylonjs/Meshes/trailMesh" {
  57432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57433. import { Mesh } from "babylonjs/Meshes/mesh";
  57434. import { Scene } from "babylonjs/scene";
  57435. /**
  57436. * Class used to create a trail following a mesh
  57437. */
  57438. export class TrailMesh extends Mesh {
  57439. private _generator;
  57440. private _autoStart;
  57441. private _running;
  57442. private _diameter;
  57443. private _length;
  57444. private _sectionPolygonPointsCount;
  57445. private _sectionVectors;
  57446. private _sectionNormalVectors;
  57447. private _beforeRenderObserver;
  57448. /**
  57449. * @constructor
  57450. * @param name The value used by scene.getMeshByName() to do a lookup.
  57451. * @param generator The mesh to generate a trail.
  57452. * @param scene The scene to add this mesh to.
  57453. * @param diameter Diameter of trailing mesh. Default is 1.
  57454. * @param length Length of trailing mesh. Default is 60.
  57455. * @param autoStart Automatically start trailing mesh. Default true.
  57456. */
  57457. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57458. /**
  57459. * "TrailMesh"
  57460. * @returns "TrailMesh"
  57461. */
  57462. getClassName(): string;
  57463. private _createMesh;
  57464. /**
  57465. * Start trailing mesh.
  57466. */
  57467. start(): void;
  57468. /**
  57469. * Stop trailing mesh.
  57470. */
  57471. stop(): void;
  57472. /**
  57473. * Update trailing mesh geometry.
  57474. */
  57475. update(): void;
  57476. /**
  57477. * Returns a new TrailMesh object.
  57478. * @param name is a string, the name given to the new mesh
  57479. * @param newGenerator use new generator object for cloned trail mesh
  57480. * @returns a new mesh
  57481. */
  57482. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57483. /**
  57484. * Serializes this trail mesh
  57485. * @param serializationObject object to write serialization to
  57486. */
  57487. serialize(serializationObject: any): void;
  57488. /**
  57489. * Parses a serialized trail mesh
  57490. * @param parsedMesh the serialized mesh
  57491. * @param scene the scene to create the trail mesh in
  57492. * @returns the created trail mesh
  57493. */
  57494. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57495. }
  57496. }
  57497. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57498. import { Nullable } from "babylonjs/types";
  57499. import { Scene } from "babylonjs/scene";
  57500. import { Vector4 } from "babylonjs/Maths/math.vector";
  57501. import { Color4 } from "babylonjs/Maths/math.color";
  57502. import { Mesh } from "babylonjs/Meshes/mesh";
  57503. /**
  57504. * Class containing static functions to help procedurally build meshes
  57505. */
  57506. export class TiledBoxBuilder {
  57507. /**
  57508. * Creates a box mesh
  57509. * 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)
  57510. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57514. * @param name defines the name of the mesh
  57515. * @param options defines the options used to create the mesh
  57516. * @param scene defines the hosting scene
  57517. * @returns the box mesh
  57518. */
  57519. static CreateTiledBox(name: string, options: {
  57520. pattern?: number;
  57521. width?: number;
  57522. height?: number;
  57523. depth?: number;
  57524. tileSize?: number;
  57525. tileWidth?: number;
  57526. tileHeight?: number;
  57527. alignHorizontal?: number;
  57528. alignVertical?: number;
  57529. faceUV?: Vector4[];
  57530. faceColors?: Color4[];
  57531. sideOrientation?: number;
  57532. updatable?: boolean;
  57533. }, scene?: Nullable<Scene>): Mesh;
  57534. }
  57535. }
  57536. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57537. import { Vector4 } from "babylonjs/Maths/math.vector";
  57538. import { Mesh } from "babylonjs/Meshes/mesh";
  57539. /**
  57540. * Class containing static functions to help procedurally build meshes
  57541. */
  57542. export class TorusKnotBuilder {
  57543. /**
  57544. * Creates a torus knot mesh
  57545. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57546. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57547. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57548. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57552. * @param name defines the name of the mesh
  57553. * @param options defines the options used to create the mesh
  57554. * @param scene defines the hosting scene
  57555. * @returns the torus knot mesh
  57556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57557. */
  57558. static CreateTorusKnot(name: string, options: {
  57559. radius?: number;
  57560. tube?: number;
  57561. radialSegments?: number;
  57562. tubularSegments?: number;
  57563. p?: number;
  57564. q?: number;
  57565. updatable?: boolean;
  57566. sideOrientation?: number;
  57567. frontUVs?: Vector4;
  57568. backUVs?: Vector4;
  57569. }, scene: any): Mesh;
  57570. }
  57571. }
  57572. declare module "babylonjs/Meshes/polygonMesh" {
  57573. import { Scene } from "babylonjs/scene";
  57574. import { Vector2 } from "babylonjs/Maths/math.vector";
  57575. import { Mesh } from "babylonjs/Meshes/mesh";
  57576. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57577. import { Path2 } from "babylonjs/Maths/math.path";
  57578. /**
  57579. * Polygon
  57580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57581. */
  57582. export class Polygon {
  57583. /**
  57584. * Creates a rectangle
  57585. * @param xmin bottom X coord
  57586. * @param ymin bottom Y coord
  57587. * @param xmax top X coord
  57588. * @param ymax top Y coord
  57589. * @returns points that make the resulting rectation
  57590. */
  57591. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57592. /**
  57593. * Creates a circle
  57594. * @param radius radius of circle
  57595. * @param cx scale in x
  57596. * @param cy scale in y
  57597. * @param numberOfSides number of sides that make up the circle
  57598. * @returns points that make the resulting circle
  57599. */
  57600. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57601. /**
  57602. * Creates a polygon from input string
  57603. * @param input Input polygon data
  57604. * @returns the parsed points
  57605. */
  57606. static Parse(input: string): Vector2[];
  57607. /**
  57608. * Starts building a polygon from x and y coordinates
  57609. * @param x x coordinate
  57610. * @param y y coordinate
  57611. * @returns the started path2
  57612. */
  57613. static StartingAt(x: number, y: number): Path2;
  57614. }
  57615. /**
  57616. * Builds a polygon
  57617. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57618. */
  57619. export class PolygonMeshBuilder {
  57620. private _points;
  57621. private _outlinepoints;
  57622. private _holes;
  57623. private _name;
  57624. private _scene;
  57625. private _epoints;
  57626. private _eholes;
  57627. private _addToepoint;
  57628. /**
  57629. * Babylon reference to the earcut plugin.
  57630. */
  57631. bjsEarcut: any;
  57632. /**
  57633. * Creates a PolygonMeshBuilder
  57634. * @param name name of the builder
  57635. * @param contours Path of the polygon
  57636. * @param scene scene to add to when creating the mesh
  57637. * @param earcutInjection can be used to inject your own earcut reference
  57638. */
  57639. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57640. /**
  57641. * Adds a whole within the polygon
  57642. * @param hole Array of points defining the hole
  57643. * @returns this
  57644. */
  57645. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57646. /**
  57647. * Creates the polygon
  57648. * @param updatable If the mesh should be updatable
  57649. * @param depth The depth of the mesh created
  57650. * @returns the created mesh
  57651. */
  57652. build(updatable?: boolean, depth?: number): Mesh;
  57653. /**
  57654. * Creates the polygon
  57655. * @param depth The depth of the mesh created
  57656. * @returns the created VertexData
  57657. */
  57658. buildVertexData(depth?: number): VertexData;
  57659. /**
  57660. * Adds a side to the polygon
  57661. * @param positions points that make the polygon
  57662. * @param normals normals of the polygon
  57663. * @param uvs uvs of the polygon
  57664. * @param indices indices of the polygon
  57665. * @param bounds bounds of the polygon
  57666. * @param points points of the polygon
  57667. * @param depth depth of the polygon
  57668. * @param flip flip of the polygon
  57669. */
  57670. private addSide;
  57671. }
  57672. }
  57673. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57674. import { Scene } from "babylonjs/scene";
  57675. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57676. import { Color4 } from "babylonjs/Maths/math.color";
  57677. import { Mesh } from "babylonjs/Meshes/mesh";
  57678. import { Nullable } from "babylonjs/types";
  57679. /**
  57680. * Class containing static functions to help procedurally build meshes
  57681. */
  57682. export class PolygonBuilder {
  57683. /**
  57684. * Creates a polygon mesh
  57685. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57686. * * 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
  57687. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57690. * * Remember you can only change the shape positions, not their number when updating a polygon
  57691. * @param name defines the name of the mesh
  57692. * @param options defines the options used to create the mesh
  57693. * @param scene defines the hosting scene
  57694. * @param earcutInjection can be used to inject your own earcut reference
  57695. * @returns the polygon mesh
  57696. */
  57697. static CreatePolygon(name: string, options: {
  57698. shape: Vector3[];
  57699. holes?: Vector3[][];
  57700. depth?: number;
  57701. faceUV?: Vector4[];
  57702. faceColors?: Color4[];
  57703. updatable?: boolean;
  57704. sideOrientation?: number;
  57705. frontUVs?: Vector4;
  57706. backUVs?: Vector4;
  57707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57708. /**
  57709. * Creates an extruded polygon mesh, with depth in the Y direction.
  57710. * * 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)
  57711. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57712. * @param name defines the name of the mesh
  57713. * @param options defines the options used to create the mesh
  57714. * @param scene defines the hosting scene
  57715. * @param earcutInjection can be used to inject your own earcut reference
  57716. * @returns the polygon mesh
  57717. */
  57718. static ExtrudePolygon(name: string, options: {
  57719. shape: Vector3[];
  57720. holes?: Vector3[][];
  57721. depth?: number;
  57722. faceUV?: Vector4[];
  57723. faceColors?: Color4[];
  57724. updatable?: boolean;
  57725. sideOrientation?: number;
  57726. frontUVs?: Vector4;
  57727. backUVs?: Vector4;
  57728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57729. }
  57730. }
  57731. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57732. import { Scene } from "babylonjs/scene";
  57733. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57734. import { Mesh } from "babylonjs/Meshes/mesh";
  57735. import { Nullable } from "babylonjs/types";
  57736. /**
  57737. * Class containing static functions to help procedurally build meshes
  57738. */
  57739. export class LatheBuilder {
  57740. /**
  57741. * Creates lathe mesh.
  57742. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57743. * * 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
  57744. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57745. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57746. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57747. * * 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
  57748. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57749. * * 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
  57750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57754. * @param name defines the name of the mesh
  57755. * @param options defines the options used to create the mesh
  57756. * @param scene defines the hosting scene
  57757. * @returns the lathe mesh
  57758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57759. */
  57760. static CreateLathe(name: string, options: {
  57761. shape: Vector3[];
  57762. radius?: number;
  57763. tessellation?: number;
  57764. clip?: number;
  57765. arc?: number;
  57766. closed?: boolean;
  57767. updatable?: boolean;
  57768. sideOrientation?: number;
  57769. frontUVs?: Vector4;
  57770. backUVs?: Vector4;
  57771. cap?: number;
  57772. invertUV?: boolean;
  57773. }, scene?: Nullable<Scene>): Mesh;
  57774. }
  57775. }
  57776. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57777. import { Nullable } from "babylonjs/types";
  57778. import { Scene } from "babylonjs/scene";
  57779. import { Vector4 } from "babylonjs/Maths/math.vector";
  57780. import { Mesh } from "babylonjs/Meshes/mesh";
  57781. /**
  57782. * Class containing static functions to help procedurally build meshes
  57783. */
  57784. export class TiledPlaneBuilder {
  57785. /**
  57786. * Creates a tiled plane mesh
  57787. * * The parameter `pattern` will, depending on value, do nothing or
  57788. * * * flip (reflect about central vertical) alternate tiles across and up
  57789. * * * flip every tile on alternate rows
  57790. * * * rotate (180 degs) alternate tiles across and up
  57791. * * * rotate every tile on alternate rows
  57792. * * * flip and rotate alternate tiles across and up
  57793. * * * flip and rotate every tile on alternate rows
  57794. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57795. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57798. * * 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)
  57799. * * 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)
  57800. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57801. * @param name defines the name of the mesh
  57802. * @param options defines the options used to create the mesh
  57803. * @param scene defines the hosting scene
  57804. * @returns the box mesh
  57805. */
  57806. static CreateTiledPlane(name: string, options: {
  57807. pattern?: number;
  57808. tileSize?: number;
  57809. tileWidth?: number;
  57810. tileHeight?: number;
  57811. size?: number;
  57812. width?: number;
  57813. height?: number;
  57814. alignHorizontal?: number;
  57815. alignVertical?: number;
  57816. sideOrientation?: number;
  57817. frontUVs?: Vector4;
  57818. backUVs?: Vector4;
  57819. updatable?: boolean;
  57820. }, scene?: Nullable<Scene>): Mesh;
  57821. }
  57822. }
  57823. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57824. import { Nullable } from "babylonjs/types";
  57825. import { Scene } from "babylonjs/scene";
  57826. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57827. import { Mesh } from "babylonjs/Meshes/mesh";
  57828. /**
  57829. * Class containing static functions to help procedurally build meshes
  57830. */
  57831. export class TubeBuilder {
  57832. /**
  57833. * Creates a tube mesh.
  57834. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57835. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57836. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57837. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57838. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57839. * * 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)
  57840. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57841. * * 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
  57842. * * 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
  57843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57847. * @param name defines the name of the mesh
  57848. * @param options defines the options used to create the mesh
  57849. * @param scene defines the hosting scene
  57850. * @returns the tube mesh
  57851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57852. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57853. */
  57854. static CreateTube(name: string, options: {
  57855. path: Vector3[];
  57856. radius?: number;
  57857. tessellation?: number;
  57858. radiusFunction?: {
  57859. (i: number, distance: number): number;
  57860. };
  57861. cap?: number;
  57862. arc?: number;
  57863. updatable?: boolean;
  57864. sideOrientation?: number;
  57865. frontUVs?: Vector4;
  57866. backUVs?: Vector4;
  57867. instance?: Mesh;
  57868. invertUV?: boolean;
  57869. }, scene?: Nullable<Scene>): Mesh;
  57870. }
  57871. }
  57872. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57873. import { Scene } from "babylonjs/scene";
  57874. import { Vector4 } from "babylonjs/Maths/math.vector";
  57875. import { Mesh } from "babylonjs/Meshes/mesh";
  57876. import { Nullable } from "babylonjs/types";
  57877. /**
  57878. * Class containing static functions to help procedurally build meshes
  57879. */
  57880. export class IcoSphereBuilder {
  57881. /**
  57882. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57883. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57884. * * 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`)
  57885. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57886. * * 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
  57887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57890. * @param name defines the name of the mesh
  57891. * @param options defines the options used to create the mesh
  57892. * @param scene defines the hosting scene
  57893. * @returns the icosahedron mesh
  57894. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57895. */
  57896. static CreateIcoSphere(name: string, options: {
  57897. radius?: number;
  57898. radiusX?: number;
  57899. radiusY?: number;
  57900. radiusZ?: number;
  57901. flat?: boolean;
  57902. subdivisions?: number;
  57903. sideOrientation?: number;
  57904. frontUVs?: Vector4;
  57905. backUVs?: Vector4;
  57906. updatable?: boolean;
  57907. }, scene?: Nullable<Scene>): Mesh;
  57908. }
  57909. }
  57910. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57911. import { Vector3 } from "babylonjs/Maths/math.vector";
  57912. import { Mesh } from "babylonjs/Meshes/mesh";
  57913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57914. /**
  57915. * Class containing static functions to help procedurally build meshes
  57916. */
  57917. export class DecalBuilder {
  57918. /**
  57919. * Creates a decal mesh.
  57920. * 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
  57921. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57922. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57923. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57924. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57925. * @param name defines the name of the mesh
  57926. * @param sourceMesh defines the mesh where the decal must be applied
  57927. * @param options defines the options used to create the mesh
  57928. * @param scene defines the hosting scene
  57929. * @returns the decal mesh
  57930. * @see https://doc.babylonjs.com/how_to/decals
  57931. */
  57932. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57933. position?: Vector3;
  57934. normal?: Vector3;
  57935. size?: Vector3;
  57936. angle?: number;
  57937. }): Mesh;
  57938. }
  57939. }
  57940. declare module "babylonjs/Meshes/meshBuilder" {
  57941. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57942. import { Nullable } from "babylonjs/types";
  57943. import { Scene } from "babylonjs/scene";
  57944. import { Mesh } from "babylonjs/Meshes/mesh";
  57945. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57946. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57948. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57949. import { Plane } from "babylonjs/Maths/math.plane";
  57950. /**
  57951. * Class containing static functions to help procedurally build meshes
  57952. */
  57953. export class MeshBuilder {
  57954. /**
  57955. * Creates a box mesh
  57956. * * The parameter `size` sets the size (float) of each box side (default 1)
  57957. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57958. * * 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)
  57959. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57963. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57964. * @param name defines the name of the mesh
  57965. * @param options defines the options used to create the mesh
  57966. * @param scene defines the hosting scene
  57967. * @returns the box mesh
  57968. */
  57969. static CreateBox(name: string, options: {
  57970. size?: number;
  57971. width?: number;
  57972. height?: number;
  57973. depth?: number;
  57974. faceUV?: Vector4[];
  57975. faceColors?: Color4[];
  57976. sideOrientation?: number;
  57977. frontUVs?: Vector4;
  57978. backUVs?: Vector4;
  57979. updatable?: boolean;
  57980. }, scene?: Nullable<Scene>): Mesh;
  57981. /**
  57982. * Creates a tiled box mesh
  57983. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57985. * @param name defines the name of the mesh
  57986. * @param options defines the options used to create the mesh
  57987. * @param scene defines the hosting scene
  57988. * @returns the tiled box mesh
  57989. */
  57990. static CreateTiledBox(name: string, options: {
  57991. pattern?: number;
  57992. size?: number;
  57993. width?: number;
  57994. height?: number;
  57995. depth: number;
  57996. tileSize?: number;
  57997. tileWidth?: number;
  57998. tileHeight?: number;
  57999. faceUV?: Vector4[];
  58000. faceColors?: Color4[];
  58001. alignHorizontal?: number;
  58002. alignVertical?: number;
  58003. sideOrientation?: number;
  58004. updatable?: boolean;
  58005. }, scene?: Nullable<Scene>): Mesh;
  58006. /**
  58007. * Creates a sphere mesh
  58008. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58009. * * 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`)
  58010. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58011. * * 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
  58012. * * 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)
  58013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58016. * @param name defines the name of the mesh
  58017. * @param options defines the options used to create the mesh
  58018. * @param scene defines the hosting scene
  58019. * @returns the sphere mesh
  58020. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58021. */
  58022. static CreateSphere(name: string, options: {
  58023. segments?: number;
  58024. diameter?: number;
  58025. diameterX?: number;
  58026. diameterY?: number;
  58027. diameterZ?: number;
  58028. arc?: number;
  58029. slice?: number;
  58030. sideOrientation?: number;
  58031. frontUVs?: Vector4;
  58032. backUVs?: Vector4;
  58033. updatable?: boolean;
  58034. }, scene?: Nullable<Scene>): Mesh;
  58035. /**
  58036. * Creates a plane polygonal mesh. By default, this is a disc
  58037. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58038. * * 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
  58039. * * 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
  58040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58043. * @param name defines the name of the mesh
  58044. * @param options defines the options used to create the mesh
  58045. * @param scene defines the hosting scene
  58046. * @returns the plane polygonal mesh
  58047. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58048. */
  58049. static CreateDisc(name: string, options: {
  58050. radius?: number;
  58051. tessellation?: number;
  58052. arc?: number;
  58053. updatable?: boolean;
  58054. sideOrientation?: number;
  58055. frontUVs?: Vector4;
  58056. backUVs?: Vector4;
  58057. }, scene?: Nullable<Scene>): Mesh;
  58058. /**
  58059. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58060. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58061. * * 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`)
  58062. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58063. * * 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
  58064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58067. * @param name defines the name of the mesh
  58068. * @param options defines the options used to create the mesh
  58069. * @param scene defines the hosting scene
  58070. * @returns the icosahedron mesh
  58071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58072. */
  58073. static CreateIcoSphere(name: string, options: {
  58074. radius?: number;
  58075. radiusX?: number;
  58076. radiusY?: number;
  58077. radiusZ?: number;
  58078. flat?: boolean;
  58079. subdivisions?: number;
  58080. sideOrientation?: number;
  58081. frontUVs?: Vector4;
  58082. backUVs?: Vector4;
  58083. updatable?: boolean;
  58084. }, scene?: Nullable<Scene>): Mesh;
  58085. /**
  58086. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58087. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58088. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58089. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58090. * * 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
  58091. * * 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
  58092. * * 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
  58093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58096. * * 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
  58097. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58098. * * 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
  58099. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58101. * @param name defines the name of the mesh
  58102. * @param options defines the options used to create the mesh
  58103. * @param scene defines the hosting scene
  58104. * @returns the ribbon mesh
  58105. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58107. */
  58108. static CreateRibbon(name: string, options: {
  58109. pathArray: Vector3[][];
  58110. closeArray?: boolean;
  58111. closePath?: boolean;
  58112. offset?: number;
  58113. updatable?: boolean;
  58114. sideOrientation?: number;
  58115. frontUVs?: Vector4;
  58116. backUVs?: Vector4;
  58117. instance?: Mesh;
  58118. invertUV?: boolean;
  58119. uvs?: Vector2[];
  58120. colors?: Color4[];
  58121. }, scene?: Nullable<Scene>): Mesh;
  58122. /**
  58123. * Creates a cylinder or a cone mesh
  58124. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58125. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58126. * * 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.
  58127. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58128. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58129. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58130. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58131. * * 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).
  58132. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58133. * * 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).
  58134. * * 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
  58135. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58136. * * 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
  58137. * * 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.
  58138. * * If `enclose` is false, a ring surface is one element.
  58139. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58140. * * 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
  58141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58144. * @param name defines the name of the mesh
  58145. * @param options defines the options used to create the mesh
  58146. * @param scene defines the hosting scene
  58147. * @returns the cylinder mesh
  58148. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58149. */
  58150. static CreateCylinder(name: string, options: {
  58151. height?: number;
  58152. diameterTop?: number;
  58153. diameterBottom?: number;
  58154. diameter?: number;
  58155. tessellation?: number;
  58156. subdivisions?: number;
  58157. arc?: number;
  58158. faceColors?: Color4[];
  58159. faceUV?: Vector4[];
  58160. updatable?: boolean;
  58161. hasRings?: boolean;
  58162. enclose?: boolean;
  58163. cap?: number;
  58164. sideOrientation?: number;
  58165. frontUVs?: Vector4;
  58166. backUVs?: Vector4;
  58167. }, scene?: Nullable<Scene>): Mesh;
  58168. /**
  58169. * Creates a torus mesh
  58170. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58171. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58172. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58176. * @param name defines the name of the mesh
  58177. * @param options defines the options used to create the mesh
  58178. * @param scene defines the hosting scene
  58179. * @returns the torus mesh
  58180. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58181. */
  58182. static CreateTorus(name: string, options: {
  58183. diameter?: number;
  58184. thickness?: number;
  58185. tessellation?: number;
  58186. updatable?: boolean;
  58187. sideOrientation?: number;
  58188. frontUVs?: Vector4;
  58189. backUVs?: Vector4;
  58190. }, scene?: Nullable<Scene>): Mesh;
  58191. /**
  58192. * Creates a torus knot mesh
  58193. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58194. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58195. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58196. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58200. * @param name defines the name of the mesh
  58201. * @param options defines the options used to create the mesh
  58202. * @param scene defines the hosting scene
  58203. * @returns the torus knot mesh
  58204. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58205. */
  58206. static CreateTorusKnot(name: string, options: {
  58207. radius?: number;
  58208. tube?: number;
  58209. radialSegments?: number;
  58210. tubularSegments?: number;
  58211. p?: number;
  58212. q?: number;
  58213. updatable?: boolean;
  58214. sideOrientation?: number;
  58215. frontUVs?: Vector4;
  58216. backUVs?: Vector4;
  58217. }, scene?: Nullable<Scene>): Mesh;
  58218. /**
  58219. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58220. * * 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
  58221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58222. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58223. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58224. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58226. * * 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
  58227. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58230. * @param name defines the name of the new line system
  58231. * @param options defines the options used to create the line system
  58232. * @param scene defines the hosting scene
  58233. * @returns a new line system mesh
  58234. */
  58235. static CreateLineSystem(name: string, options: {
  58236. lines: Vector3[][];
  58237. updatable?: boolean;
  58238. instance?: Nullable<LinesMesh>;
  58239. colors?: Nullable<Color4[][]>;
  58240. useVertexAlpha?: boolean;
  58241. }, scene: Nullable<Scene>): LinesMesh;
  58242. /**
  58243. * Creates a line mesh
  58244. * 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
  58245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58246. * * The parameter `points` is an array successive Vector3
  58247. * * 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
  58248. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58250. * * When updating an instance, remember that only point positions can change, not the number of points
  58251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58253. * @param name defines the name of the new line system
  58254. * @param options defines the options used to create the line system
  58255. * @param scene defines the hosting scene
  58256. * @returns a new line mesh
  58257. */
  58258. static CreateLines(name: string, options: {
  58259. points: Vector3[];
  58260. updatable?: boolean;
  58261. instance?: Nullable<LinesMesh>;
  58262. colors?: Color4[];
  58263. useVertexAlpha?: boolean;
  58264. }, scene?: Nullable<Scene>): LinesMesh;
  58265. /**
  58266. * Creates a dashed line mesh
  58267. * * 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
  58268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58269. * * The parameter `points` is an array successive Vector3
  58270. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58271. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58272. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58273. * * 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
  58274. * * When updating an instance, remember that only point positions can change, not the number of points
  58275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58276. * @param name defines the name of the mesh
  58277. * @param options defines the options used to create the mesh
  58278. * @param scene defines the hosting scene
  58279. * @returns the dashed line mesh
  58280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58281. */
  58282. static CreateDashedLines(name: string, options: {
  58283. points: Vector3[];
  58284. dashSize?: number;
  58285. gapSize?: number;
  58286. dashNb?: number;
  58287. updatable?: boolean;
  58288. instance?: LinesMesh;
  58289. }, scene?: Nullable<Scene>): LinesMesh;
  58290. /**
  58291. * 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.
  58292. * * 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.
  58293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58294. * * 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.
  58295. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58296. * * 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
  58297. * * 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
  58298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58303. * @param name defines the name of the mesh
  58304. * @param options defines the options used to create the mesh
  58305. * @param scene defines the hosting scene
  58306. * @returns the extruded shape mesh
  58307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58309. */
  58310. static ExtrudeShape(name: string, options: {
  58311. shape: Vector3[];
  58312. path: Vector3[];
  58313. scale?: number;
  58314. rotation?: number;
  58315. cap?: number;
  58316. updatable?: boolean;
  58317. sideOrientation?: number;
  58318. frontUVs?: Vector4;
  58319. backUVs?: Vector4;
  58320. instance?: Mesh;
  58321. invertUV?: boolean;
  58322. }, scene?: Nullable<Scene>): Mesh;
  58323. /**
  58324. * Creates an custom extruded shape mesh.
  58325. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58326. * * 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.
  58327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58328. * * 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
  58329. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58330. * * 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
  58331. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58332. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58333. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58334. * * 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
  58335. * * 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
  58336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58341. * @param name defines the name of the mesh
  58342. * @param options defines the options used to create the mesh
  58343. * @param scene defines the hosting scene
  58344. * @returns the custom extruded shape mesh
  58345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58348. */
  58349. static ExtrudeShapeCustom(name: string, options: {
  58350. shape: Vector3[];
  58351. path: Vector3[];
  58352. scaleFunction?: any;
  58353. rotationFunction?: any;
  58354. ribbonCloseArray?: boolean;
  58355. ribbonClosePath?: boolean;
  58356. cap?: number;
  58357. updatable?: boolean;
  58358. sideOrientation?: number;
  58359. frontUVs?: Vector4;
  58360. backUVs?: Vector4;
  58361. instance?: Mesh;
  58362. invertUV?: boolean;
  58363. }, scene?: Nullable<Scene>): Mesh;
  58364. /**
  58365. * Creates lathe mesh.
  58366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58367. * * 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
  58368. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58369. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58370. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58371. * * 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
  58372. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58373. * * 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
  58374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58378. * @param name defines the name of the mesh
  58379. * @param options defines the options used to create the mesh
  58380. * @param scene defines the hosting scene
  58381. * @returns the lathe mesh
  58382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58383. */
  58384. static CreateLathe(name: string, options: {
  58385. shape: Vector3[];
  58386. radius?: number;
  58387. tessellation?: number;
  58388. clip?: number;
  58389. arc?: number;
  58390. closed?: boolean;
  58391. updatable?: boolean;
  58392. sideOrientation?: number;
  58393. frontUVs?: Vector4;
  58394. backUVs?: Vector4;
  58395. cap?: number;
  58396. invertUV?: boolean;
  58397. }, scene?: Nullable<Scene>): Mesh;
  58398. /**
  58399. * Creates a tiled plane mesh
  58400. * * You can set a limited pattern arrangement with the tiles
  58401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58404. * @param name defines the name of the mesh
  58405. * @param options defines the options used to create the mesh
  58406. * @param scene defines the hosting scene
  58407. * @returns the plane mesh
  58408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58409. */
  58410. static CreateTiledPlane(name: string, options: {
  58411. pattern?: number;
  58412. tileSize?: number;
  58413. tileWidth?: number;
  58414. tileHeight?: number;
  58415. size?: number;
  58416. width?: number;
  58417. height?: number;
  58418. alignHorizontal?: number;
  58419. alignVertical?: number;
  58420. sideOrientation?: number;
  58421. frontUVs?: Vector4;
  58422. backUVs?: Vector4;
  58423. updatable?: boolean;
  58424. }, scene?: Nullable<Scene>): Mesh;
  58425. /**
  58426. * Creates a plane mesh
  58427. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58428. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58429. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58433. * @param name defines the name of the mesh
  58434. * @param options defines the options used to create the mesh
  58435. * @param scene defines the hosting scene
  58436. * @returns the plane mesh
  58437. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58438. */
  58439. static CreatePlane(name: string, options: {
  58440. size?: number;
  58441. width?: number;
  58442. height?: number;
  58443. sideOrientation?: number;
  58444. frontUVs?: Vector4;
  58445. backUVs?: Vector4;
  58446. updatable?: boolean;
  58447. sourcePlane?: Plane;
  58448. }, scene?: Nullable<Scene>): Mesh;
  58449. /**
  58450. * Creates a ground mesh
  58451. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58452. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58454. * @param name defines the name of the mesh
  58455. * @param options defines the options used to create the mesh
  58456. * @param scene defines the hosting scene
  58457. * @returns the ground mesh
  58458. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58459. */
  58460. static CreateGround(name: string, options: {
  58461. width?: number;
  58462. height?: number;
  58463. subdivisions?: number;
  58464. subdivisionsX?: number;
  58465. subdivisionsY?: number;
  58466. updatable?: boolean;
  58467. }, scene?: Nullable<Scene>): Mesh;
  58468. /**
  58469. * Creates a tiled ground mesh
  58470. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58471. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58472. * * 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
  58473. * * 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
  58474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58475. * @param name defines the name of the mesh
  58476. * @param options defines the options used to create the mesh
  58477. * @param scene defines the hosting scene
  58478. * @returns the tiled ground mesh
  58479. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58480. */
  58481. static CreateTiledGround(name: string, options: {
  58482. xmin: number;
  58483. zmin: number;
  58484. xmax: number;
  58485. zmax: number;
  58486. subdivisions?: {
  58487. w: number;
  58488. h: number;
  58489. };
  58490. precision?: {
  58491. w: number;
  58492. h: number;
  58493. };
  58494. updatable?: boolean;
  58495. }, scene?: Nullable<Scene>): Mesh;
  58496. /**
  58497. * Creates a ground mesh from a height map
  58498. * * The parameter `url` sets the URL of the height map image resource.
  58499. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58500. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58501. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58502. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58503. * * 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.
  58504. * * 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).
  58505. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58507. * @param name defines the name of the mesh
  58508. * @param url defines the url to the height map
  58509. * @param options defines the options used to create the mesh
  58510. * @param scene defines the hosting scene
  58511. * @returns the ground mesh
  58512. * @see https://doc.babylonjs.com/babylon101/height_map
  58513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58514. */
  58515. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58516. width?: number;
  58517. height?: number;
  58518. subdivisions?: number;
  58519. minHeight?: number;
  58520. maxHeight?: number;
  58521. colorFilter?: Color3;
  58522. alphaFilter?: number;
  58523. updatable?: boolean;
  58524. onReady?: (mesh: GroundMesh) => void;
  58525. }, scene?: Nullable<Scene>): GroundMesh;
  58526. /**
  58527. * Creates a polygon mesh
  58528. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58529. * * 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
  58530. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58533. * * Remember you can only change the shape positions, not their number when updating a polygon
  58534. * @param name defines the name of the mesh
  58535. * @param options defines the options used to create the mesh
  58536. * @param scene defines the hosting scene
  58537. * @param earcutInjection can be used to inject your own earcut reference
  58538. * @returns the polygon mesh
  58539. */
  58540. static CreatePolygon(name: string, options: {
  58541. shape: Vector3[];
  58542. holes?: Vector3[][];
  58543. depth?: number;
  58544. faceUV?: Vector4[];
  58545. faceColors?: Color4[];
  58546. updatable?: boolean;
  58547. sideOrientation?: number;
  58548. frontUVs?: Vector4;
  58549. backUVs?: Vector4;
  58550. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58551. /**
  58552. * Creates an extruded polygon mesh, with depth in the Y direction.
  58553. * * 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)
  58554. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58555. * @param name defines the name of the mesh
  58556. * @param options defines the options used to create the mesh
  58557. * @param scene defines the hosting scene
  58558. * @param earcutInjection can be used to inject your own earcut reference
  58559. * @returns the polygon mesh
  58560. */
  58561. static ExtrudePolygon(name: string, options: {
  58562. shape: Vector3[];
  58563. holes?: Vector3[][];
  58564. depth?: number;
  58565. faceUV?: Vector4[];
  58566. faceColors?: Color4[];
  58567. updatable?: boolean;
  58568. sideOrientation?: number;
  58569. frontUVs?: Vector4;
  58570. backUVs?: Vector4;
  58571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58572. /**
  58573. * Creates a tube mesh.
  58574. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58575. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58576. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58577. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58578. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58579. * * 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)
  58580. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58581. * * 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
  58582. * * 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
  58583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58587. * @param name defines the name of the mesh
  58588. * @param options defines the options used to create the mesh
  58589. * @param scene defines the hosting scene
  58590. * @returns the tube mesh
  58591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58592. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58593. */
  58594. static CreateTube(name: string, options: {
  58595. path: Vector3[];
  58596. radius?: number;
  58597. tessellation?: number;
  58598. radiusFunction?: {
  58599. (i: number, distance: number): number;
  58600. };
  58601. cap?: number;
  58602. arc?: number;
  58603. updatable?: boolean;
  58604. sideOrientation?: number;
  58605. frontUVs?: Vector4;
  58606. backUVs?: Vector4;
  58607. instance?: Mesh;
  58608. invertUV?: boolean;
  58609. }, scene?: Nullable<Scene>): Mesh;
  58610. /**
  58611. * Creates a polyhedron mesh
  58612. * * 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
  58613. * * The parameter `size` (positive float, default 1) sets the polygon size
  58614. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58615. * * 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`
  58616. * * 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
  58617. * * 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)`)
  58618. * * 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
  58619. * * 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
  58620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58623. * @param name defines the name of the mesh
  58624. * @param options defines the options used to create the mesh
  58625. * @param scene defines the hosting scene
  58626. * @returns the polyhedron mesh
  58627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58628. */
  58629. static CreatePolyhedron(name: string, options: {
  58630. type?: number;
  58631. size?: number;
  58632. sizeX?: number;
  58633. sizeY?: number;
  58634. sizeZ?: number;
  58635. custom?: any;
  58636. faceUV?: Vector4[];
  58637. faceColors?: Color4[];
  58638. flat?: boolean;
  58639. updatable?: boolean;
  58640. sideOrientation?: number;
  58641. frontUVs?: Vector4;
  58642. backUVs?: Vector4;
  58643. }, scene?: Nullable<Scene>): Mesh;
  58644. /**
  58645. * Creates a decal mesh.
  58646. * 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
  58647. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58648. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58649. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58650. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58651. * @param name defines the name of the mesh
  58652. * @param sourceMesh defines the mesh where the decal must be applied
  58653. * @param options defines the options used to create the mesh
  58654. * @param scene defines the hosting scene
  58655. * @returns the decal mesh
  58656. * @see https://doc.babylonjs.com/how_to/decals
  58657. */
  58658. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58659. position?: Vector3;
  58660. normal?: Vector3;
  58661. size?: Vector3;
  58662. angle?: number;
  58663. }): Mesh;
  58664. }
  58665. }
  58666. declare module "babylonjs/Meshes/meshSimplification" {
  58667. import { Mesh } from "babylonjs/Meshes/mesh";
  58668. /**
  58669. * A simplifier interface for future simplification implementations
  58670. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58671. */
  58672. export interface ISimplifier {
  58673. /**
  58674. * Simplification of a given mesh according to the given settings.
  58675. * Since this requires computation, it is assumed that the function runs async.
  58676. * @param settings The settings of the simplification, including quality and distance
  58677. * @param successCallback A callback that will be called after the mesh was simplified.
  58678. * @param errorCallback in case of an error, this callback will be called. optional.
  58679. */
  58680. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58681. }
  58682. /**
  58683. * Expected simplification settings.
  58684. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58685. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58686. */
  58687. export interface ISimplificationSettings {
  58688. /**
  58689. * Gets or sets the expected quality
  58690. */
  58691. quality: number;
  58692. /**
  58693. * Gets or sets the distance when this optimized version should be used
  58694. */
  58695. distance: number;
  58696. /**
  58697. * Gets an already optimized mesh
  58698. */
  58699. optimizeMesh?: boolean;
  58700. }
  58701. /**
  58702. * Class used to specify simplification options
  58703. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58704. */
  58705. export class SimplificationSettings implements ISimplificationSettings {
  58706. /** expected quality */
  58707. quality: number;
  58708. /** distance when this optimized version should be used */
  58709. distance: number;
  58710. /** already optimized mesh */
  58711. optimizeMesh?: boolean | undefined;
  58712. /**
  58713. * Creates a SimplificationSettings
  58714. * @param quality expected quality
  58715. * @param distance distance when this optimized version should be used
  58716. * @param optimizeMesh already optimized mesh
  58717. */
  58718. constructor(
  58719. /** expected quality */
  58720. quality: number,
  58721. /** distance when this optimized version should be used */
  58722. distance: number,
  58723. /** already optimized mesh */
  58724. optimizeMesh?: boolean | undefined);
  58725. }
  58726. /**
  58727. * Interface used to define a simplification task
  58728. */
  58729. export interface ISimplificationTask {
  58730. /**
  58731. * Array of settings
  58732. */
  58733. settings: Array<ISimplificationSettings>;
  58734. /**
  58735. * Simplification type
  58736. */
  58737. simplificationType: SimplificationType;
  58738. /**
  58739. * Mesh to simplify
  58740. */
  58741. mesh: Mesh;
  58742. /**
  58743. * Callback called on success
  58744. */
  58745. successCallback?: () => void;
  58746. /**
  58747. * Defines if parallel processing can be used
  58748. */
  58749. parallelProcessing: boolean;
  58750. }
  58751. /**
  58752. * Queue used to order the simplification tasks
  58753. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58754. */
  58755. export class SimplificationQueue {
  58756. private _simplificationArray;
  58757. /**
  58758. * Gets a boolean indicating that the process is still running
  58759. */
  58760. running: boolean;
  58761. /**
  58762. * Creates a new queue
  58763. */
  58764. constructor();
  58765. /**
  58766. * Adds a new simplification task
  58767. * @param task defines a task to add
  58768. */
  58769. addTask(task: ISimplificationTask): void;
  58770. /**
  58771. * Execute next task
  58772. */
  58773. executeNext(): void;
  58774. /**
  58775. * Execute a simplification task
  58776. * @param task defines the task to run
  58777. */
  58778. runSimplification(task: ISimplificationTask): void;
  58779. private getSimplifier;
  58780. }
  58781. /**
  58782. * The implemented types of simplification
  58783. * At the moment only Quadratic Error Decimation is implemented
  58784. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58785. */
  58786. export enum SimplificationType {
  58787. /** Quadratic error decimation */
  58788. QUADRATIC = 0
  58789. }
  58790. }
  58791. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58792. import { Scene } from "babylonjs/scene";
  58793. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58794. import { ISceneComponent } from "babylonjs/sceneComponent";
  58795. module "babylonjs/scene" {
  58796. interface Scene {
  58797. /** @hidden (Backing field) */
  58798. _simplificationQueue: SimplificationQueue;
  58799. /**
  58800. * Gets or sets the simplification queue attached to the scene
  58801. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58802. */
  58803. simplificationQueue: SimplificationQueue;
  58804. }
  58805. }
  58806. module "babylonjs/Meshes/mesh" {
  58807. interface Mesh {
  58808. /**
  58809. * Simplify the mesh according to the given array of settings.
  58810. * Function will return immediately and will simplify async
  58811. * @param settings a collection of simplification settings
  58812. * @param parallelProcessing should all levels calculate parallel or one after the other
  58813. * @param simplificationType the type of simplification to run
  58814. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58815. * @returns the current mesh
  58816. */
  58817. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58818. }
  58819. }
  58820. /**
  58821. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58822. * created in a scene
  58823. */
  58824. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58825. /**
  58826. * The component name helpfull to identify the component in the list of scene components.
  58827. */
  58828. readonly name: string;
  58829. /**
  58830. * The scene the component belongs to.
  58831. */
  58832. scene: Scene;
  58833. /**
  58834. * Creates a new instance of the component for the given scene
  58835. * @param scene Defines the scene to register the component in
  58836. */
  58837. constructor(scene: Scene);
  58838. /**
  58839. * Registers the component in a given scene
  58840. */
  58841. register(): void;
  58842. /**
  58843. * Rebuilds the elements related to this component in case of
  58844. * context lost for instance.
  58845. */
  58846. rebuild(): void;
  58847. /**
  58848. * Disposes the component and the associated ressources
  58849. */
  58850. dispose(): void;
  58851. private _beforeCameraUpdate;
  58852. }
  58853. }
  58854. declare module "babylonjs/Meshes/Builders/index" {
  58855. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58856. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58857. export * from "babylonjs/Meshes/Builders/discBuilder";
  58858. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58859. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58860. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58861. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58862. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58863. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58864. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58865. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58866. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58867. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58868. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58869. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58870. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58871. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58872. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58873. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58874. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58875. }
  58876. declare module "babylonjs/Meshes/index" {
  58877. export * from "babylonjs/Meshes/abstractMesh";
  58878. export * from "babylonjs/Meshes/buffer";
  58879. export * from "babylonjs/Meshes/Compression/index";
  58880. export * from "babylonjs/Meshes/csg";
  58881. export * from "babylonjs/Meshes/geometry";
  58882. export * from "babylonjs/Meshes/groundMesh";
  58883. export * from "babylonjs/Meshes/trailMesh";
  58884. export * from "babylonjs/Meshes/instancedMesh";
  58885. export * from "babylonjs/Meshes/linesMesh";
  58886. export * from "babylonjs/Meshes/mesh";
  58887. export * from "babylonjs/Meshes/mesh.vertexData";
  58888. export * from "babylonjs/Meshes/meshBuilder";
  58889. export * from "babylonjs/Meshes/meshSimplification";
  58890. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58891. export * from "babylonjs/Meshes/polygonMesh";
  58892. export * from "babylonjs/Meshes/subMesh";
  58893. export * from "babylonjs/Meshes/meshLODLevel";
  58894. export * from "babylonjs/Meshes/transformNode";
  58895. export * from "babylonjs/Meshes/Builders/index";
  58896. export * from "babylonjs/Meshes/dataBuffer";
  58897. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58898. }
  58899. declare module "babylonjs/Morph/index" {
  58900. export * from "babylonjs/Morph/morphTarget";
  58901. export * from "babylonjs/Morph/morphTargetManager";
  58902. }
  58903. declare module "babylonjs/Navigation/INavigationEngine" {
  58904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58905. import { Vector3 } from "babylonjs/Maths/math";
  58906. import { Mesh } from "babylonjs/Meshes/mesh";
  58907. import { Scene } from "babylonjs/scene";
  58908. /**
  58909. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58910. */
  58911. export interface INavigationEnginePlugin {
  58912. /**
  58913. * plugin name
  58914. */
  58915. name: string;
  58916. /**
  58917. * Creates a navigation mesh
  58918. * @param meshes array of all the geometry used to compute the navigatio mesh
  58919. * @param parameters bunch of parameters used to filter geometry
  58920. */
  58921. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58922. /**
  58923. * Create a navigation mesh debug mesh
  58924. * @param scene is where the mesh will be added
  58925. * @returns debug display mesh
  58926. */
  58927. createDebugNavMesh(scene: Scene): Mesh;
  58928. /**
  58929. * Get a navigation mesh constrained position, closest to the parameter position
  58930. * @param position world position
  58931. * @returns the closest point to position constrained by the navigation mesh
  58932. */
  58933. getClosestPoint(position: Vector3): Vector3;
  58934. /**
  58935. * Get a navigation mesh constrained position, within a particular radius
  58936. * @param position world position
  58937. * @param maxRadius the maximum distance to the constrained world position
  58938. * @returns the closest point to position constrained by the navigation mesh
  58939. */
  58940. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58941. /**
  58942. * Compute the final position from a segment made of destination-position
  58943. * @param position world position
  58944. * @param destination world position
  58945. * @returns the resulting point along the navmesh
  58946. */
  58947. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58948. /**
  58949. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58950. * @param start world position
  58951. * @param end world position
  58952. * @returns array containing world position composing the path
  58953. */
  58954. computePath(start: Vector3, end: Vector3): Vector3[];
  58955. /**
  58956. * If this plugin is supported
  58957. * @returns true if plugin is supported
  58958. */
  58959. isSupported(): boolean;
  58960. /**
  58961. * Create a new Crowd so you can add agents
  58962. * @param maxAgents the maximum agent count in the crowd
  58963. * @param maxAgentRadius the maximum radius an agent can have
  58964. * @param scene to attach the crowd to
  58965. * @returns the crowd you can add agents to
  58966. */
  58967. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58968. /**
  58969. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58970. * The queries will try to find a solution within those bounds
  58971. * default is (1,1,1)
  58972. * @param extent x,y,z value that define the extent around the queries point of reference
  58973. */
  58974. setDefaultQueryExtent(extent: Vector3): void;
  58975. /**
  58976. * Get the Bounding box extent specified by setDefaultQueryExtent
  58977. * @returns the box extent values
  58978. */
  58979. getDefaultQueryExtent(): Vector3;
  58980. /**
  58981. * Release all resources
  58982. */
  58983. dispose(): void;
  58984. }
  58985. /**
  58986. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58987. */
  58988. export interface ICrowd {
  58989. /**
  58990. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58991. * You can attach anything to that node. The node position is updated in the scene update tick.
  58992. * @param pos world position that will be constrained by the navigation mesh
  58993. * @param parameters agent parameters
  58994. * @param transform hooked to the agent that will be update by the scene
  58995. * @returns agent index
  58996. */
  58997. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58998. /**
  58999. * Returns the agent position in world space
  59000. * @param index agent index returned by addAgent
  59001. * @returns world space position
  59002. */
  59003. getAgentPosition(index: number): Vector3;
  59004. /**
  59005. * Gets the agent velocity in world space
  59006. * @param index agent index returned by addAgent
  59007. * @returns world space velocity
  59008. */
  59009. getAgentVelocity(index: number): Vector3;
  59010. /**
  59011. * remove a particular agent previously created
  59012. * @param index agent index returned by addAgent
  59013. */
  59014. removeAgent(index: number): void;
  59015. /**
  59016. * get the list of all agents attached to this crowd
  59017. * @returns list of agent indices
  59018. */
  59019. getAgents(): number[];
  59020. /**
  59021. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59022. * @param deltaTime in seconds
  59023. */
  59024. update(deltaTime: number): void;
  59025. /**
  59026. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59027. * @param index agent index returned by addAgent
  59028. * @param destination targeted world position
  59029. */
  59030. agentGoto(index: number, destination: Vector3): void;
  59031. /**
  59032. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59033. * The queries will try to find a solution within those bounds
  59034. * default is (1,1,1)
  59035. * @param extent x,y,z value that define the extent around the queries point of reference
  59036. */
  59037. setDefaultQueryExtent(extent: Vector3): void;
  59038. /**
  59039. * Get the Bounding box extent specified by setDefaultQueryExtent
  59040. * @returns the box extent values
  59041. */
  59042. getDefaultQueryExtent(): Vector3;
  59043. /**
  59044. * Release all resources
  59045. */
  59046. dispose(): void;
  59047. }
  59048. /**
  59049. * Configures an agent
  59050. */
  59051. export interface IAgentParameters {
  59052. /**
  59053. * Agent radius. [Limit: >= 0]
  59054. */
  59055. radius: number;
  59056. /**
  59057. * Agent height. [Limit: > 0]
  59058. */
  59059. height: number;
  59060. /**
  59061. * Maximum allowed acceleration. [Limit: >= 0]
  59062. */
  59063. maxAcceleration: number;
  59064. /**
  59065. * Maximum allowed speed. [Limit: >= 0]
  59066. */
  59067. maxSpeed: number;
  59068. /**
  59069. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59070. */
  59071. collisionQueryRange: number;
  59072. /**
  59073. * The path visibility optimization range. [Limit: > 0]
  59074. */
  59075. pathOptimizationRange: number;
  59076. /**
  59077. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59078. */
  59079. separationWeight: number;
  59080. }
  59081. /**
  59082. * Configures the navigation mesh creation
  59083. */
  59084. export interface INavMeshParameters {
  59085. /**
  59086. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59087. */
  59088. cs: number;
  59089. /**
  59090. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59091. */
  59092. ch: number;
  59093. /**
  59094. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59095. */
  59096. walkableSlopeAngle: number;
  59097. /**
  59098. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59099. * be considered walkable. [Limit: >= 3] [Units: vx]
  59100. */
  59101. walkableHeight: number;
  59102. /**
  59103. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59104. */
  59105. walkableClimb: number;
  59106. /**
  59107. * The distance to erode/shrink the walkable area of the heightfield away from
  59108. * obstructions. [Limit: >=0] [Units: vx]
  59109. */
  59110. walkableRadius: number;
  59111. /**
  59112. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59113. */
  59114. maxEdgeLen: number;
  59115. /**
  59116. * The maximum distance a simplfied contour's border edges should deviate
  59117. * the original raw contour. [Limit: >=0] [Units: vx]
  59118. */
  59119. maxSimplificationError: number;
  59120. /**
  59121. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59122. */
  59123. minRegionArea: number;
  59124. /**
  59125. * Any regions with a span count smaller than this value will, if possible,
  59126. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59127. */
  59128. mergeRegionArea: number;
  59129. /**
  59130. * The maximum number of vertices allowed for polygons generated during the
  59131. * contour to polygon conversion process. [Limit: >= 3]
  59132. */
  59133. maxVertsPerPoly: number;
  59134. /**
  59135. * Sets the sampling distance to use when generating the detail mesh.
  59136. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59137. */
  59138. detailSampleDist: number;
  59139. /**
  59140. * The maximum distance the detail mesh surface should deviate from heightfield
  59141. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59142. */
  59143. detailSampleMaxError: number;
  59144. }
  59145. }
  59146. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59147. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59148. import { Mesh } from "babylonjs/Meshes/mesh";
  59149. import { Scene } from "babylonjs/scene";
  59150. import { Vector3 } from "babylonjs/Maths/math";
  59151. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59152. /**
  59153. * RecastJS navigation plugin
  59154. */
  59155. export class RecastJSPlugin implements INavigationEnginePlugin {
  59156. /**
  59157. * Reference to the Recast library
  59158. */
  59159. bjsRECAST: any;
  59160. /**
  59161. * plugin name
  59162. */
  59163. name: string;
  59164. /**
  59165. * the first navmesh created. We might extend this to support multiple navmeshes
  59166. */
  59167. navMesh: any;
  59168. /**
  59169. * Initializes the recastJS plugin
  59170. * @param recastInjection can be used to inject your own recast reference
  59171. */
  59172. constructor(recastInjection?: any);
  59173. /**
  59174. * Creates a navigation mesh
  59175. * @param meshes array of all the geometry used to compute the navigatio mesh
  59176. * @param parameters bunch of parameters used to filter geometry
  59177. */
  59178. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59179. /**
  59180. * Create a navigation mesh debug mesh
  59181. * @param scene is where the mesh will be added
  59182. * @returns debug display mesh
  59183. */
  59184. createDebugNavMesh(scene: Scene): Mesh;
  59185. /**
  59186. * Get a navigation mesh constrained position, closest to the parameter position
  59187. * @param position world position
  59188. * @returns the closest point to position constrained by the navigation mesh
  59189. */
  59190. getClosestPoint(position: Vector3): Vector3;
  59191. /**
  59192. * Get a navigation mesh constrained position, within a particular radius
  59193. * @param position world position
  59194. * @param maxRadius the maximum distance to the constrained world position
  59195. * @returns the closest point to position constrained by the navigation mesh
  59196. */
  59197. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59198. /**
  59199. * Compute the final position from a segment made of destination-position
  59200. * @param position world position
  59201. * @param destination world position
  59202. * @returns the resulting point along the navmesh
  59203. */
  59204. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59205. /**
  59206. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59207. * @param start world position
  59208. * @param end world position
  59209. * @returns array containing world position composing the path
  59210. */
  59211. computePath(start: Vector3, end: Vector3): Vector3[];
  59212. /**
  59213. * Create a new Crowd so you can add agents
  59214. * @param maxAgents the maximum agent count in the crowd
  59215. * @param maxAgentRadius the maximum radius an agent can have
  59216. * @param scene to attach the crowd to
  59217. * @returns the crowd you can add agents to
  59218. */
  59219. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59220. /**
  59221. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59222. * The queries will try to find a solution within those bounds
  59223. * default is (1,1,1)
  59224. * @param extent x,y,z value that define the extent around the queries point of reference
  59225. */
  59226. setDefaultQueryExtent(extent: Vector3): void;
  59227. /**
  59228. * Get the Bounding box extent specified by setDefaultQueryExtent
  59229. * @returns the box extent values
  59230. */
  59231. getDefaultQueryExtent(): Vector3;
  59232. /**
  59233. * Disposes
  59234. */
  59235. dispose(): void;
  59236. /**
  59237. * If this plugin is supported
  59238. * @returns true if plugin is supported
  59239. */
  59240. isSupported(): boolean;
  59241. }
  59242. /**
  59243. * Recast detour crowd implementation
  59244. */
  59245. export class RecastJSCrowd implements ICrowd {
  59246. /**
  59247. * Recast/detour plugin
  59248. */
  59249. bjsRECASTPlugin: RecastJSPlugin;
  59250. /**
  59251. * Link to the detour crowd
  59252. */
  59253. recastCrowd: any;
  59254. /**
  59255. * One transform per agent
  59256. */
  59257. transforms: TransformNode[];
  59258. /**
  59259. * All agents created
  59260. */
  59261. agents: number[];
  59262. /**
  59263. * Link to the scene is kept to unregister the crowd from the scene
  59264. */
  59265. private _scene;
  59266. /**
  59267. * Observer for crowd updates
  59268. */
  59269. private _onBeforeAnimationsObserver;
  59270. /**
  59271. * Constructor
  59272. * @param plugin recastJS plugin
  59273. * @param maxAgents the maximum agent count in the crowd
  59274. * @param maxAgentRadius the maximum radius an agent can have
  59275. * @param scene to attach the crowd to
  59276. * @returns the crowd you can add agents to
  59277. */
  59278. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59279. /**
  59280. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59281. * You can attach anything to that node. The node position is updated in the scene update tick.
  59282. * @param pos world position that will be constrained by the navigation mesh
  59283. * @param parameters agent parameters
  59284. * @param transform hooked to the agent that will be update by the scene
  59285. * @returns agent index
  59286. */
  59287. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59288. /**
  59289. * Returns the agent position in world space
  59290. * @param index agent index returned by addAgent
  59291. * @returns world space position
  59292. */
  59293. getAgentPosition(index: number): Vector3;
  59294. /**
  59295. * Returns the agent velocity in world space
  59296. * @param index agent index returned by addAgent
  59297. * @returns world space velocity
  59298. */
  59299. getAgentVelocity(index: number): Vector3;
  59300. /**
  59301. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59302. * @param index agent index returned by addAgent
  59303. * @param destination targeted world position
  59304. */
  59305. agentGoto(index: number, destination: Vector3): void;
  59306. /**
  59307. * remove a particular agent previously created
  59308. * @param index agent index returned by addAgent
  59309. */
  59310. removeAgent(index: number): void;
  59311. /**
  59312. * get the list of all agents attached to this crowd
  59313. * @returns list of agent indices
  59314. */
  59315. getAgents(): number[];
  59316. /**
  59317. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59318. * @param deltaTime in seconds
  59319. */
  59320. update(deltaTime: number): void;
  59321. /**
  59322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59323. * The queries will try to find a solution within those bounds
  59324. * default is (1,1,1)
  59325. * @param extent x,y,z value that define the extent around the queries point of reference
  59326. */
  59327. setDefaultQueryExtent(extent: Vector3): void;
  59328. /**
  59329. * Get the Bounding box extent specified by setDefaultQueryExtent
  59330. * @returns the box extent values
  59331. */
  59332. getDefaultQueryExtent(): Vector3;
  59333. /**
  59334. * Release all resources
  59335. */
  59336. dispose(): void;
  59337. }
  59338. }
  59339. declare module "babylonjs/Navigation/Plugins/index" {
  59340. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59341. }
  59342. declare module "babylonjs/Navigation/index" {
  59343. export * from "babylonjs/Navigation/INavigationEngine";
  59344. export * from "babylonjs/Navigation/Plugins/index";
  59345. }
  59346. declare module "babylonjs/Offline/database" {
  59347. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59348. /**
  59349. * Class used to enable access to IndexedDB
  59350. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59351. */
  59352. export class Database implements IOfflineProvider {
  59353. private _callbackManifestChecked;
  59354. private _currentSceneUrl;
  59355. private _db;
  59356. private _enableSceneOffline;
  59357. private _enableTexturesOffline;
  59358. private _manifestVersionFound;
  59359. private _mustUpdateRessources;
  59360. private _hasReachedQuota;
  59361. private _isSupported;
  59362. private _idbFactory;
  59363. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59364. private static IsUASupportingBlobStorage;
  59365. /**
  59366. * Gets a boolean indicating if Database storate is enabled (off by default)
  59367. */
  59368. static IDBStorageEnabled: boolean;
  59369. /**
  59370. * Gets a boolean indicating if scene must be saved in the database
  59371. */
  59372. readonly enableSceneOffline: boolean;
  59373. /**
  59374. * Gets a boolean indicating if textures must be saved in the database
  59375. */
  59376. readonly enableTexturesOffline: boolean;
  59377. /**
  59378. * Creates a new Database
  59379. * @param urlToScene defines the url to load the scene
  59380. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59381. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59382. */
  59383. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59384. private static _ParseURL;
  59385. private static _ReturnFullUrlLocation;
  59386. private _checkManifestFile;
  59387. /**
  59388. * Open the database and make it available
  59389. * @param successCallback defines the callback to call on success
  59390. * @param errorCallback defines the callback to call on error
  59391. */
  59392. open(successCallback: () => void, errorCallback: () => void): void;
  59393. /**
  59394. * Loads an image from the database
  59395. * @param url defines the url to load from
  59396. * @param image defines the target DOM image
  59397. */
  59398. loadImage(url: string, image: HTMLImageElement): void;
  59399. private _loadImageFromDBAsync;
  59400. private _saveImageIntoDBAsync;
  59401. private _checkVersionFromDB;
  59402. private _loadVersionFromDBAsync;
  59403. private _saveVersionIntoDBAsync;
  59404. /**
  59405. * Loads a file from database
  59406. * @param url defines the URL to load from
  59407. * @param sceneLoaded defines a callback to call on success
  59408. * @param progressCallBack defines a callback to call when progress changed
  59409. * @param errorCallback defines a callback to call on error
  59410. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59411. */
  59412. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59413. private _loadFileAsync;
  59414. private _saveFileAsync;
  59415. /**
  59416. * Validates if xhr data is correct
  59417. * @param xhr defines the request to validate
  59418. * @param dataType defines the expected data type
  59419. * @returns true if data is correct
  59420. */
  59421. private static _ValidateXHRData;
  59422. }
  59423. }
  59424. declare module "babylonjs/Offline/index" {
  59425. export * from "babylonjs/Offline/database";
  59426. export * from "babylonjs/Offline/IOfflineProvider";
  59427. }
  59428. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59429. /** @hidden */
  59430. export var gpuUpdateParticlesPixelShader: {
  59431. name: string;
  59432. shader: string;
  59433. };
  59434. }
  59435. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59436. /** @hidden */
  59437. export var gpuUpdateParticlesVertexShader: {
  59438. name: string;
  59439. shader: string;
  59440. };
  59441. }
  59442. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59443. /** @hidden */
  59444. export var clipPlaneFragmentDeclaration2: {
  59445. name: string;
  59446. shader: string;
  59447. };
  59448. }
  59449. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59450. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59451. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59453. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59454. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59455. /** @hidden */
  59456. export var gpuRenderParticlesPixelShader: {
  59457. name: string;
  59458. shader: string;
  59459. };
  59460. }
  59461. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59462. /** @hidden */
  59463. export var clipPlaneVertexDeclaration2: {
  59464. name: string;
  59465. shader: string;
  59466. };
  59467. }
  59468. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59469. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59471. /** @hidden */
  59472. export var gpuRenderParticlesVertexShader: {
  59473. name: string;
  59474. shader: string;
  59475. };
  59476. }
  59477. declare module "babylonjs/Particles/gpuParticleSystem" {
  59478. import { Nullable } from "babylonjs/types";
  59479. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59480. import { Observable } from "babylonjs/Misc/observable";
  59481. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59482. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59483. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59484. import { Scene, IDisposable } from "babylonjs/scene";
  59485. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59486. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59487. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59488. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59489. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59490. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59491. /**
  59492. * This represents a GPU particle system in Babylon
  59493. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59494. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59495. */
  59496. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59497. /**
  59498. * The layer mask we are rendering the particles through.
  59499. */
  59500. layerMask: number;
  59501. private _capacity;
  59502. private _activeCount;
  59503. private _currentActiveCount;
  59504. private _accumulatedCount;
  59505. private _renderEffect;
  59506. private _updateEffect;
  59507. private _buffer0;
  59508. private _buffer1;
  59509. private _spriteBuffer;
  59510. private _updateVAO;
  59511. private _renderVAO;
  59512. private _targetIndex;
  59513. private _sourceBuffer;
  59514. private _targetBuffer;
  59515. private _engine;
  59516. private _currentRenderId;
  59517. private _started;
  59518. private _stopped;
  59519. private _timeDelta;
  59520. private _randomTexture;
  59521. private _randomTexture2;
  59522. private _attributesStrideSize;
  59523. private _updateEffectOptions;
  59524. private _randomTextureSize;
  59525. private _actualFrame;
  59526. private readonly _rawTextureWidth;
  59527. /**
  59528. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59529. */
  59530. static readonly IsSupported: boolean;
  59531. /**
  59532. * An event triggered when the system is disposed.
  59533. */
  59534. onDisposeObservable: Observable<GPUParticleSystem>;
  59535. /**
  59536. * Gets the maximum number of particles active at the same time.
  59537. * @returns The max number of active particles.
  59538. */
  59539. getCapacity(): number;
  59540. /**
  59541. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59542. * to override the particles.
  59543. */
  59544. forceDepthWrite: boolean;
  59545. /**
  59546. * Gets or set the number of active particles
  59547. */
  59548. activeParticleCount: number;
  59549. private _preWarmDone;
  59550. /**
  59551. * Is this system ready to be used/rendered
  59552. * @return true if the system is ready
  59553. */
  59554. isReady(): boolean;
  59555. /**
  59556. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59557. * @returns True if it has been started, otherwise false.
  59558. */
  59559. isStarted(): boolean;
  59560. /**
  59561. * Starts the particle system and begins to emit
  59562. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59563. */
  59564. start(delay?: number): void;
  59565. /**
  59566. * Stops the particle system.
  59567. */
  59568. stop(): void;
  59569. /**
  59570. * Remove all active particles
  59571. */
  59572. reset(): void;
  59573. /**
  59574. * Returns the string "GPUParticleSystem"
  59575. * @returns a string containing the class name
  59576. */
  59577. getClassName(): string;
  59578. private _colorGradientsTexture;
  59579. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59580. /**
  59581. * Adds a new color gradient
  59582. * @param gradient defines the gradient to use (between 0 and 1)
  59583. * @param color1 defines the color to affect to the specified gradient
  59584. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59585. * @returns the current particle system
  59586. */
  59587. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59588. /**
  59589. * Remove a specific color gradient
  59590. * @param gradient defines the gradient to remove
  59591. * @returns the current particle system
  59592. */
  59593. removeColorGradient(gradient: number): GPUParticleSystem;
  59594. private _angularSpeedGradientsTexture;
  59595. private _sizeGradientsTexture;
  59596. private _velocityGradientsTexture;
  59597. private _limitVelocityGradientsTexture;
  59598. private _dragGradientsTexture;
  59599. private _addFactorGradient;
  59600. /**
  59601. * Adds a new size gradient
  59602. * @param gradient defines the gradient to use (between 0 and 1)
  59603. * @param factor defines the size factor to affect to the specified gradient
  59604. * @returns the current particle system
  59605. */
  59606. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59607. /**
  59608. * Remove a specific size gradient
  59609. * @param gradient defines the gradient to remove
  59610. * @returns the current particle system
  59611. */
  59612. removeSizeGradient(gradient: number): GPUParticleSystem;
  59613. /**
  59614. * Adds a new angular speed gradient
  59615. * @param gradient defines the gradient to use (between 0 and 1)
  59616. * @param factor defines the angular speed to affect to the specified gradient
  59617. * @returns the current particle system
  59618. */
  59619. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59620. /**
  59621. * Remove a specific angular speed gradient
  59622. * @param gradient defines the gradient to remove
  59623. * @returns the current particle system
  59624. */
  59625. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59626. /**
  59627. * Adds a new velocity gradient
  59628. * @param gradient defines the gradient to use (between 0 and 1)
  59629. * @param factor defines the velocity to affect to the specified gradient
  59630. * @returns the current particle system
  59631. */
  59632. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59633. /**
  59634. * Remove a specific velocity gradient
  59635. * @param gradient defines the gradient to remove
  59636. * @returns the current particle system
  59637. */
  59638. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59639. /**
  59640. * Adds a new limit velocity gradient
  59641. * @param gradient defines the gradient to use (between 0 and 1)
  59642. * @param factor defines the limit velocity value to affect to the specified gradient
  59643. * @returns the current particle system
  59644. */
  59645. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59646. /**
  59647. * Remove a specific limit velocity gradient
  59648. * @param gradient defines the gradient to remove
  59649. * @returns the current particle system
  59650. */
  59651. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59652. /**
  59653. * Adds a new drag gradient
  59654. * @param gradient defines the gradient to use (between 0 and 1)
  59655. * @param factor defines the drag value to affect to the specified gradient
  59656. * @returns the current particle system
  59657. */
  59658. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59659. /**
  59660. * Remove a specific drag gradient
  59661. * @param gradient defines the gradient to remove
  59662. * @returns the current particle system
  59663. */
  59664. removeDragGradient(gradient: number): GPUParticleSystem;
  59665. /**
  59666. * Not supported by GPUParticleSystem
  59667. * @param gradient defines the gradient to use (between 0 and 1)
  59668. * @param factor defines the emit rate value to affect to the specified gradient
  59669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59670. * @returns the current particle system
  59671. */
  59672. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59673. /**
  59674. * Not supported by GPUParticleSystem
  59675. * @param gradient defines the gradient to remove
  59676. * @returns the current particle system
  59677. */
  59678. removeEmitRateGradient(gradient: number): IParticleSystem;
  59679. /**
  59680. * Not supported by GPUParticleSystem
  59681. * @param gradient defines the gradient to use (between 0 and 1)
  59682. * @param factor defines the start size value to affect to the specified gradient
  59683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59684. * @returns the current particle system
  59685. */
  59686. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59687. /**
  59688. * Not supported by GPUParticleSystem
  59689. * @param gradient defines the gradient to remove
  59690. * @returns the current particle system
  59691. */
  59692. removeStartSizeGradient(gradient: number): IParticleSystem;
  59693. /**
  59694. * Not supported by GPUParticleSystem
  59695. * @param gradient defines the gradient to use (between 0 and 1)
  59696. * @param min defines the color remap minimal range
  59697. * @param max defines the color remap maximal range
  59698. * @returns the current particle system
  59699. */
  59700. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59701. /**
  59702. * Not supported by GPUParticleSystem
  59703. * @param gradient defines the gradient to remove
  59704. * @returns the current particle system
  59705. */
  59706. removeColorRemapGradient(): IParticleSystem;
  59707. /**
  59708. * Not supported by GPUParticleSystem
  59709. * @param gradient defines the gradient to use (between 0 and 1)
  59710. * @param min defines the alpha remap minimal range
  59711. * @param max defines the alpha remap maximal range
  59712. * @returns the current particle system
  59713. */
  59714. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59715. /**
  59716. * Not supported by GPUParticleSystem
  59717. * @param gradient defines the gradient to remove
  59718. * @returns the current particle system
  59719. */
  59720. removeAlphaRemapGradient(): IParticleSystem;
  59721. /**
  59722. * Not supported by GPUParticleSystem
  59723. * @param gradient defines the gradient to use (between 0 and 1)
  59724. * @param color defines the color to affect to the specified gradient
  59725. * @returns the current particle system
  59726. */
  59727. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59728. /**
  59729. * Not supported by GPUParticleSystem
  59730. * @param gradient defines the gradient to remove
  59731. * @returns the current particle system
  59732. */
  59733. removeRampGradient(): IParticleSystem;
  59734. /**
  59735. * Not supported by GPUParticleSystem
  59736. * @returns the list of ramp gradients
  59737. */
  59738. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59739. /**
  59740. * Not supported by GPUParticleSystem
  59741. * Gets or sets a boolean indicating that ramp gradients must be used
  59742. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59743. */
  59744. useRampGradients: boolean;
  59745. /**
  59746. * Not supported by GPUParticleSystem
  59747. * @param gradient defines the gradient to use (between 0 and 1)
  59748. * @param factor defines the life time factor to affect to the specified gradient
  59749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59750. * @returns the current particle system
  59751. */
  59752. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59753. /**
  59754. * Not supported by GPUParticleSystem
  59755. * @param gradient defines the gradient to remove
  59756. * @returns the current particle system
  59757. */
  59758. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59759. /**
  59760. * Instantiates a GPU particle system.
  59761. * 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.
  59762. * @param name The name of the particle system
  59763. * @param options The options used to create the system
  59764. * @param scene The scene the particle system belongs to
  59765. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59766. */
  59767. constructor(name: string, options: Partial<{
  59768. capacity: number;
  59769. randomTextureSize: number;
  59770. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59771. protected _reset(): void;
  59772. private _createUpdateVAO;
  59773. private _createRenderVAO;
  59774. private _initialize;
  59775. /** @hidden */
  59776. _recreateUpdateEffect(): void;
  59777. /** @hidden */
  59778. _recreateRenderEffect(): void;
  59779. /**
  59780. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59781. * @param preWarm defines if we are in the pre-warmimg phase
  59782. */
  59783. animate(preWarm?: boolean): void;
  59784. private _createFactorGradientTexture;
  59785. private _createSizeGradientTexture;
  59786. private _createAngularSpeedGradientTexture;
  59787. private _createVelocityGradientTexture;
  59788. private _createLimitVelocityGradientTexture;
  59789. private _createDragGradientTexture;
  59790. private _createColorGradientTexture;
  59791. /**
  59792. * Renders the particle system in its current state
  59793. * @param preWarm defines if the system should only update the particles but not render them
  59794. * @returns the current number of particles
  59795. */
  59796. render(preWarm?: boolean): number;
  59797. /**
  59798. * Rebuilds the particle system
  59799. */
  59800. rebuild(): void;
  59801. private _releaseBuffers;
  59802. private _releaseVAOs;
  59803. /**
  59804. * Disposes the particle system and free the associated resources
  59805. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59806. */
  59807. dispose(disposeTexture?: boolean): void;
  59808. /**
  59809. * Clones the particle system.
  59810. * @param name The name of the cloned object
  59811. * @param newEmitter The new emitter to use
  59812. * @returns the cloned particle system
  59813. */
  59814. clone(name: string, newEmitter: any): GPUParticleSystem;
  59815. /**
  59816. * Serializes the particle system to a JSON object.
  59817. * @returns the JSON object
  59818. */
  59819. serialize(): any;
  59820. /**
  59821. * Parses a JSON object to create a GPU particle system.
  59822. * @param parsedParticleSystem The JSON object to parse
  59823. * @param scene The scene to create the particle system in
  59824. * @param rootUrl The root url to use to load external dependencies like texture
  59825. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59826. * @returns the parsed GPU particle system
  59827. */
  59828. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59829. }
  59830. }
  59831. declare module "babylonjs/Particles/particleSystemSet" {
  59832. import { Nullable } from "babylonjs/types";
  59833. import { Color3 } from "babylonjs/Maths/math.color";
  59834. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59836. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59837. import { Scene, IDisposable } from "babylonjs/scene";
  59838. /**
  59839. * Represents a set of particle systems working together to create a specific effect
  59840. */
  59841. export class ParticleSystemSet implements IDisposable {
  59842. private _emitterCreationOptions;
  59843. private _emitterNode;
  59844. /**
  59845. * Gets the particle system list
  59846. */
  59847. systems: IParticleSystem[];
  59848. /**
  59849. * Gets the emitter node used with this set
  59850. */
  59851. readonly emitterNode: Nullable<TransformNode>;
  59852. /**
  59853. * Creates a new emitter mesh as a sphere
  59854. * @param options defines the options used to create the sphere
  59855. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59856. * @param scene defines the hosting scene
  59857. */
  59858. setEmitterAsSphere(options: {
  59859. diameter: number;
  59860. segments: number;
  59861. color: Color3;
  59862. }, renderingGroupId: number, scene: Scene): void;
  59863. /**
  59864. * Starts all particle systems of the set
  59865. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59866. */
  59867. start(emitter?: AbstractMesh): void;
  59868. /**
  59869. * Release all associated resources
  59870. */
  59871. dispose(): void;
  59872. /**
  59873. * Serialize the set into a JSON compatible object
  59874. * @returns a JSON compatible representation of the set
  59875. */
  59876. serialize(): any;
  59877. /**
  59878. * Parse a new ParticleSystemSet from a serialized source
  59879. * @param data defines a JSON compatible representation of the set
  59880. * @param scene defines the hosting scene
  59881. * @param gpu defines if we want GPU particles or CPU particles
  59882. * @returns a new ParticleSystemSet
  59883. */
  59884. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59885. }
  59886. }
  59887. declare module "babylonjs/Particles/particleHelper" {
  59888. import { Nullable } from "babylonjs/types";
  59889. import { Scene } from "babylonjs/scene";
  59890. import { Vector3 } from "babylonjs/Maths/math.vector";
  59891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59892. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59893. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59894. /**
  59895. * This class is made for on one-liner static method to help creating particle system set.
  59896. */
  59897. export class ParticleHelper {
  59898. /**
  59899. * Gets or sets base Assets URL
  59900. */
  59901. static BaseAssetsUrl: string;
  59902. /**
  59903. * Create a default particle system that you can tweak
  59904. * @param emitter defines the emitter to use
  59905. * @param capacity defines the system capacity (default is 500 particles)
  59906. * @param scene defines the hosting scene
  59907. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59908. * @returns the new Particle system
  59909. */
  59910. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59911. /**
  59912. * This is the main static method (one-liner) of this helper to create different particle systems
  59913. * @param type This string represents the type to the particle system to create
  59914. * @param scene The scene where the particle system should live
  59915. * @param gpu If the system will use gpu
  59916. * @returns the ParticleSystemSet created
  59917. */
  59918. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59919. /**
  59920. * Static function used to export a particle system to a ParticleSystemSet variable.
  59921. * Please note that the emitter shape is not exported
  59922. * @param systems defines the particle systems to export
  59923. * @returns the created particle system set
  59924. */
  59925. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59926. }
  59927. }
  59928. declare module "babylonjs/Particles/particleSystemComponent" {
  59929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59930. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59931. import "babylonjs/Shaders/particles.vertex";
  59932. module "babylonjs/Engines/engine" {
  59933. interface Engine {
  59934. /**
  59935. * Create an effect to use with particle systems.
  59936. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59937. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59938. * @param uniformsNames defines a list of attribute names
  59939. * @param samplers defines an array of string used to represent textures
  59940. * @param defines defines the string containing the defines to use to compile the shaders
  59941. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59942. * @param onCompiled defines a function to call when the effect creation is successful
  59943. * @param onError defines a function to call when the effect creation has failed
  59944. * @returns the new Effect
  59945. */
  59946. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59947. }
  59948. }
  59949. module "babylonjs/Meshes/mesh" {
  59950. interface Mesh {
  59951. /**
  59952. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59953. * @returns an array of IParticleSystem
  59954. */
  59955. getEmittedParticleSystems(): IParticleSystem[];
  59956. /**
  59957. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59958. * @returns an array of IParticleSystem
  59959. */
  59960. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59961. }
  59962. }
  59963. /**
  59964. * @hidden
  59965. */
  59966. export var _IDoNeedToBeInTheBuild: number;
  59967. }
  59968. declare module "babylonjs/Particles/index" {
  59969. export * from "babylonjs/Particles/baseParticleSystem";
  59970. export * from "babylonjs/Particles/EmitterTypes/index";
  59971. export * from "babylonjs/Particles/gpuParticleSystem";
  59972. export * from "babylonjs/Particles/IParticleSystem";
  59973. export * from "babylonjs/Particles/particle";
  59974. export * from "babylonjs/Particles/particleHelper";
  59975. export * from "babylonjs/Particles/particleSystem";
  59976. export * from "babylonjs/Particles/particleSystemComponent";
  59977. export * from "babylonjs/Particles/particleSystemSet";
  59978. export * from "babylonjs/Particles/solidParticle";
  59979. export * from "babylonjs/Particles/solidParticleSystem";
  59980. export * from "babylonjs/Particles/subEmitter";
  59981. }
  59982. declare module "babylonjs/Physics/physicsEngineComponent" {
  59983. import { Nullable } from "babylonjs/types";
  59984. import { Observable, Observer } from "babylonjs/Misc/observable";
  59985. import { Vector3 } from "babylonjs/Maths/math.vector";
  59986. import { Mesh } from "babylonjs/Meshes/mesh";
  59987. import { ISceneComponent } from "babylonjs/sceneComponent";
  59988. import { Scene } from "babylonjs/scene";
  59989. import { Node } from "babylonjs/node";
  59990. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59991. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59992. module "babylonjs/scene" {
  59993. interface Scene {
  59994. /** @hidden (Backing field) */
  59995. _physicsEngine: Nullable<IPhysicsEngine>;
  59996. /**
  59997. * Gets the current physics engine
  59998. * @returns a IPhysicsEngine or null if none attached
  59999. */
  60000. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60001. /**
  60002. * Enables physics to the current scene
  60003. * @param gravity defines the scene's gravity for the physics engine
  60004. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60005. * @return a boolean indicating if the physics engine was initialized
  60006. */
  60007. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60008. /**
  60009. * Disables and disposes the physics engine associated with the scene
  60010. */
  60011. disablePhysicsEngine(): void;
  60012. /**
  60013. * Gets a boolean indicating if there is an active physics engine
  60014. * @returns a boolean indicating if there is an active physics engine
  60015. */
  60016. isPhysicsEnabled(): boolean;
  60017. /**
  60018. * Deletes a physics compound impostor
  60019. * @param compound defines the compound to delete
  60020. */
  60021. deleteCompoundImpostor(compound: any): void;
  60022. /**
  60023. * An event triggered when physic simulation is about to be run
  60024. */
  60025. onBeforePhysicsObservable: Observable<Scene>;
  60026. /**
  60027. * An event triggered when physic simulation has been done
  60028. */
  60029. onAfterPhysicsObservable: Observable<Scene>;
  60030. }
  60031. }
  60032. module "babylonjs/Meshes/abstractMesh" {
  60033. interface AbstractMesh {
  60034. /** @hidden */
  60035. _physicsImpostor: Nullable<PhysicsImpostor>;
  60036. /**
  60037. * Gets or sets impostor used for physic simulation
  60038. * @see http://doc.babylonjs.com/features/physics_engine
  60039. */
  60040. physicsImpostor: Nullable<PhysicsImpostor>;
  60041. /**
  60042. * Gets the current physics impostor
  60043. * @see http://doc.babylonjs.com/features/physics_engine
  60044. * @returns a physics impostor or null
  60045. */
  60046. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60047. /** Apply a physic impulse to the mesh
  60048. * @param force defines the force to apply
  60049. * @param contactPoint defines where to apply the force
  60050. * @returns the current mesh
  60051. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60052. */
  60053. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60054. /**
  60055. * Creates a physic joint between two meshes
  60056. * @param otherMesh defines the other mesh to use
  60057. * @param pivot1 defines the pivot to use on this mesh
  60058. * @param pivot2 defines the pivot to use on the other mesh
  60059. * @param options defines additional options (can be plugin dependent)
  60060. * @returns the current mesh
  60061. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60062. */
  60063. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60064. /** @hidden */
  60065. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60066. }
  60067. }
  60068. /**
  60069. * Defines the physics engine scene component responsible to manage a physics engine
  60070. */
  60071. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60072. /**
  60073. * The component name helpful to identify the component in the list of scene components.
  60074. */
  60075. readonly name: string;
  60076. /**
  60077. * The scene the component belongs to.
  60078. */
  60079. scene: Scene;
  60080. /**
  60081. * Creates a new instance of the component for the given scene
  60082. * @param scene Defines the scene to register the component in
  60083. */
  60084. constructor(scene: Scene);
  60085. /**
  60086. * Registers the component in a given scene
  60087. */
  60088. register(): void;
  60089. /**
  60090. * Rebuilds the elements related to this component in case of
  60091. * context lost for instance.
  60092. */
  60093. rebuild(): void;
  60094. /**
  60095. * Disposes the component and the associated ressources
  60096. */
  60097. dispose(): void;
  60098. }
  60099. }
  60100. declare module "babylonjs/Physics/physicsHelper" {
  60101. import { Nullable } from "babylonjs/types";
  60102. import { Vector3 } from "babylonjs/Maths/math.vector";
  60103. import { Mesh } from "babylonjs/Meshes/mesh";
  60104. import { Scene } from "babylonjs/scene";
  60105. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60106. /**
  60107. * A helper for physics simulations
  60108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60109. */
  60110. export class PhysicsHelper {
  60111. private _scene;
  60112. private _physicsEngine;
  60113. /**
  60114. * Initializes the Physics helper
  60115. * @param scene Babylon.js scene
  60116. */
  60117. constructor(scene: Scene);
  60118. /**
  60119. * Applies a radial explosion impulse
  60120. * @param origin the origin of the explosion
  60121. * @param radiusOrEventOptions the radius or the options of radial explosion
  60122. * @param strength the explosion strength
  60123. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60124. * @returns A physics radial explosion event, or null
  60125. */
  60126. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60127. /**
  60128. * Applies a radial explosion force
  60129. * @param origin the origin of the explosion
  60130. * @param radiusOrEventOptions the radius or the options of radial explosion
  60131. * @param strength the explosion strength
  60132. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60133. * @returns A physics radial explosion event, or null
  60134. */
  60135. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60136. /**
  60137. * Creates a gravitational field
  60138. * @param origin the origin of the explosion
  60139. * @param radiusOrEventOptions the radius or the options of radial explosion
  60140. * @param strength the explosion strength
  60141. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60142. * @returns A physics gravitational field event, or null
  60143. */
  60144. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60145. /**
  60146. * Creates a physics updraft event
  60147. * @param origin the origin of the updraft
  60148. * @param radiusOrEventOptions the radius or the options of the updraft
  60149. * @param strength the strength of the updraft
  60150. * @param height the height of the updraft
  60151. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60152. * @returns A physics updraft event, or null
  60153. */
  60154. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60155. /**
  60156. * Creates a physics vortex event
  60157. * @param origin the of the vortex
  60158. * @param radiusOrEventOptions the radius or the options of the vortex
  60159. * @param strength the strength of the vortex
  60160. * @param height the height of the vortex
  60161. * @returns a Physics vortex event, or null
  60162. * A physics vortex event or null
  60163. */
  60164. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60165. }
  60166. /**
  60167. * Represents a physics radial explosion event
  60168. */
  60169. class PhysicsRadialExplosionEvent {
  60170. private _scene;
  60171. private _options;
  60172. private _sphere;
  60173. private _dataFetched;
  60174. /**
  60175. * Initializes a radial explosioin event
  60176. * @param _scene BabylonJS scene
  60177. * @param _options The options for the vortex event
  60178. */
  60179. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60180. /**
  60181. * Returns the data related to the radial explosion event (sphere).
  60182. * @returns The radial explosion event data
  60183. */
  60184. getData(): PhysicsRadialExplosionEventData;
  60185. /**
  60186. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60187. * @param impostor A physics imposter
  60188. * @param origin the origin of the explosion
  60189. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60190. */
  60191. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60192. /**
  60193. * Triggers affecterd impostors callbacks
  60194. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60195. */
  60196. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60197. /**
  60198. * Disposes the sphere.
  60199. * @param force Specifies if the sphere should be disposed by force
  60200. */
  60201. dispose(force?: boolean): void;
  60202. /*** Helpers ***/
  60203. private _prepareSphere;
  60204. private _intersectsWithSphere;
  60205. }
  60206. /**
  60207. * Represents a gravitational field event
  60208. */
  60209. class PhysicsGravitationalFieldEvent {
  60210. private _physicsHelper;
  60211. private _scene;
  60212. private _origin;
  60213. private _options;
  60214. private _tickCallback;
  60215. private _sphere;
  60216. private _dataFetched;
  60217. /**
  60218. * Initializes the physics gravitational field event
  60219. * @param _physicsHelper A physics helper
  60220. * @param _scene BabylonJS scene
  60221. * @param _origin The origin position of the gravitational field event
  60222. * @param _options The options for the vortex event
  60223. */
  60224. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60225. /**
  60226. * Returns the data related to the gravitational field event (sphere).
  60227. * @returns A gravitational field event
  60228. */
  60229. getData(): PhysicsGravitationalFieldEventData;
  60230. /**
  60231. * Enables the gravitational field.
  60232. */
  60233. enable(): void;
  60234. /**
  60235. * Disables the gravitational field.
  60236. */
  60237. disable(): void;
  60238. /**
  60239. * Disposes the sphere.
  60240. * @param force The force to dispose from the gravitational field event
  60241. */
  60242. dispose(force?: boolean): void;
  60243. private _tick;
  60244. }
  60245. /**
  60246. * Represents a physics updraft event
  60247. */
  60248. class PhysicsUpdraftEvent {
  60249. private _scene;
  60250. private _origin;
  60251. private _options;
  60252. private _physicsEngine;
  60253. private _originTop;
  60254. private _originDirection;
  60255. private _tickCallback;
  60256. private _cylinder;
  60257. private _cylinderPosition;
  60258. private _dataFetched;
  60259. /**
  60260. * Initializes the physics updraft event
  60261. * @param _scene BabylonJS scene
  60262. * @param _origin The origin position of the updraft
  60263. * @param _options The options for the updraft event
  60264. */
  60265. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60266. /**
  60267. * Returns the data related to the updraft event (cylinder).
  60268. * @returns A physics updraft event
  60269. */
  60270. getData(): PhysicsUpdraftEventData;
  60271. /**
  60272. * Enables the updraft.
  60273. */
  60274. enable(): void;
  60275. /**
  60276. * Disables the updraft.
  60277. */
  60278. disable(): void;
  60279. /**
  60280. * Disposes the cylinder.
  60281. * @param force Specifies if the updraft should be disposed by force
  60282. */
  60283. dispose(force?: boolean): void;
  60284. private getImpostorHitData;
  60285. private _tick;
  60286. /*** Helpers ***/
  60287. private _prepareCylinder;
  60288. private _intersectsWithCylinder;
  60289. }
  60290. /**
  60291. * Represents a physics vortex event
  60292. */
  60293. class PhysicsVortexEvent {
  60294. private _scene;
  60295. private _origin;
  60296. private _options;
  60297. private _physicsEngine;
  60298. private _originTop;
  60299. private _tickCallback;
  60300. private _cylinder;
  60301. private _cylinderPosition;
  60302. private _dataFetched;
  60303. /**
  60304. * Initializes the physics vortex event
  60305. * @param _scene The BabylonJS scene
  60306. * @param _origin The origin position of the vortex
  60307. * @param _options The options for the vortex event
  60308. */
  60309. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60310. /**
  60311. * Returns the data related to the vortex event (cylinder).
  60312. * @returns The physics vortex event data
  60313. */
  60314. getData(): PhysicsVortexEventData;
  60315. /**
  60316. * Enables the vortex.
  60317. */
  60318. enable(): void;
  60319. /**
  60320. * Disables the cortex.
  60321. */
  60322. disable(): void;
  60323. /**
  60324. * Disposes the sphere.
  60325. * @param force
  60326. */
  60327. dispose(force?: boolean): void;
  60328. private getImpostorHitData;
  60329. private _tick;
  60330. /*** Helpers ***/
  60331. private _prepareCylinder;
  60332. private _intersectsWithCylinder;
  60333. }
  60334. /**
  60335. * Options fot the radial explosion event
  60336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60337. */
  60338. export class PhysicsRadialExplosionEventOptions {
  60339. /**
  60340. * The radius of the sphere for the radial explosion.
  60341. */
  60342. radius: number;
  60343. /**
  60344. * The strenth of the explosion.
  60345. */
  60346. strength: number;
  60347. /**
  60348. * The strenght of the force in correspondence to the distance of the affected object
  60349. */
  60350. falloff: PhysicsRadialImpulseFalloff;
  60351. /**
  60352. * Sphere options for the radial explosion.
  60353. */
  60354. sphere: {
  60355. segments: number;
  60356. diameter: number;
  60357. };
  60358. /**
  60359. * Sphere options for the radial explosion.
  60360. */
  60361. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60362. }
  60363. /**
  60364. * Options fot the updraft event
  60365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60366. */
  60367. export class PhysicsUpdraftEventOptions {
  60368. /**
  60369. * The radius of the cylinder for the vortex
  60370. */
  60371. radius: number;
  60372. /**
  60373. * The strenth of the updraft.
  60374. */
  60375. strength: number;
  60376. /**
  60377. * The height of the cylinder for the updraft.
  60378. */
  60379. height: number;
  60380. /**
  60381. * The mode for the the updraft.
  60382. */
  60383. updraftMode: PhysicsUpdraftMode;
  60384. }
  60385. /**
  60386. * Options fot the vortex event
  60387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60388. */
  60389. export class PhysicsVortexEventOptions {
  60390. /**
  60391. * The radius of the cylinder for the vortex
  60392. */
  60393. radius: number;
  60394. /**
  60395. * The strenth of the vortex.
  60396. */
  60397. strength: number;
  60398. /**
  60399. * The height of the cylinder for the vortex.
  60400. */
  60401. height: number;
  60402. /**
  60403. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60404. */
  60405. centripetalForceThreshold: number;
  60406. /**
  60407. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60408. */
  60409. centripetalForceMultiplier: number;
  60410. /**
  60411. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60412. */
  60413. centrifugalForceMultiplier: number;
  60414. /**
  60415. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60416. */
  60417. updraftForceMultiplier: number;
  60418. }
  60419. /**
  60420. * The strenght of the force in correspondence to the distance of the affected object
  60421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60422. */
  60423. export enum PhysicsRadialImpulseFalloff {
  60424. /** Defines that impulse is constant in strength across it's whole radius */
  60425. Constant = 0,
  60426. /** Defines that impulse gets weaker if it's further from the origin */
  60427. Linear = 1
  60428. }
  60429. /**
  60430. * The strength of the force in correspondence to the distance of the affected object
  60431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60432. */
  60433. export enum PhysicsUpdraftMode {
  60434. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60435. Center = 0,
  60436. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60437. Perpendicular = 1
  60438. }
  60439. /**
  60440. * Interface for a physics hit data
  60441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60442. */
  60443. export interface PhysicsHitData {
  60444. /**
  60445. * The force applied at the contact point
  60446. */
  60447. force: Vector3;
  60448. /**
  60449. * The contact point
  60450. */
  60451. contactPoint: Vector3;
  60452. /**
  60453. * The distance from the origin to the contact point
  60454. */
  60455. distanceFromOrigin: number;
  60456. }
  60457. /**
  60458. * Interface for radial explosion event data
  60459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60460. */
  60461. export interface PhysicsRadialExplosionEventData {
  60462. /**
  60463. * A sphere used for the radial explosion event
  60464. */
  60465. sphere: Mesh;
  60466. }
  60467. /**
  60468. * Interface for gravitational field event data
  60469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60470. */
  60471. export interface PhysicsGravitationalFieldEventData {
  60472. /**
  60473. * A sphere mesh used for the gravitational field event
  60474. */
  60475. sphere: Mesh;
  60476. }
  60477. /**
  60478. * Interface for updraft event data
  60479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60480. */
  60481. export interface PhysicsUpdraftEventData {
  60482. /**
  60483. * A cylinder used for the updraft event
  60484. */
  60485. cylinder: Mesh;
  60486. }
  60487. /**
  60488. * Interface for vortex event data
  60489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60490. */
  60491. export interface PhysicsVortexEventData {
  60492. /**
  60493. * A cylinder used for the vortex event
  60494. */
  60495. cylinder: Mesh;
  60496. }
  60497. /**
  60498. * Interface for an affected physics impostor
  60499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60500. */
  60501. export interface PhysicsAffectedImpostorWithData {
  60502. /**
  60503. * The impostor affected by the effect
  60504. */
  60505. impostor: PhysicsImpostor;
  60506. /**
  60507. * The data about the hit/horce from the explosion
  60508. */
  60509. hitData: PhysicsHitData;
  60510. }
  60511. }
  60512. declare module "babylonjs/Physics/Plugins/index" {
  60513. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60514. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60515. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60516. }
  60517. declare module "babylonjs/Physics/index" {
  60518. export * from "babylonjs/Physics/IPhysicsEngine";
  60519. export * from "babylonjs/Physics/physicsEngine";
  60520. export * from "babylonjs/Physics/physicsEngineComponent";
  60521. export * from "babylonjs/Physics/physicsHelper";
  60522. export * from "babylonjs/Physics/physicsImpostor";
  60523. export * from "babylonjs/Physics/physicsJoint";
  60524. export * from "babylonjs/Physics/Plugins/index";
  60525. }
  60526. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60527. /** @hidden */
  60528. export var blackAndWhitePixelShader: {
  60529. name: string;
  60530. shader: string;
  60531. };
  60532. }
  60533. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60535. import { Camera } from "babylonjs/Cameras/camera";
  60536. import { Engine } from "babylonjs/Engines/engine";
  60537. import "babylonjs/Shaders/blackAndWhite.fragment";
  60538. /**
  60539. * Post process used to render in black and white
  60540. */
  60541. export class BlackAndWhitePostProcess extends PostProcess {
  60542. /**
  60543. * Linear about to convert he result to black and white (default: 1)
  60544. */
  60545. degree: number;
  60546. /**
  60547. * Creates a black and white post process
  60548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60549. * @param name The name of the effect.
  60550. * @param options The required width/height ratio to downsize to before computing the render pass.
  60551. * @param camera The camera to apply the render pass to.
  60552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60553. * @param engine The engine which the post process will be applied. (default: current engine)
  60554. * @param reusable If the post process can be reused on the same frame. (default: false)
  60555. */
  60556. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60557. }
  60558. }
  60559. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60560. import { Nullable } from "babylonjs/types";
  60561. import { Camera } from "babylonjs/Cameras/camera";
  60562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60563. import { Engine } from "babylonjs/Engines/engine";
  60564. /**
  60565. * This represents a set of one or more post processes in Babylon.
  60566. * A post process can be used to apply a shader to a texture after it is rendered.
  60567. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60568. */
  60569. export class PostProcessRenderEffect {
  60570. private _postProcesses;
  60571. private _getPostProcesses;
  60572. private _singleInstance;
  60573. private _cameras;
  60574. private _indicesForCamera;
  60575. /**
  60576. * Name of the effect
  60577. * @hidden
  60578. */
  60579. _name: string;
  60580. /**
  60581. * Instantiates a post process render effect.
  60582. * A post process can be used to apply a shader to a texture after it is rendered.
  60583. * @param engine The engine the effect is tied to
  60584. * @param name The name of the effect
  60585. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60586. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60587. */
  60588. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60589. /**
  60590. * Checks if all the post processes in the effect are supported.
  60591. */
  60592. readonly isSupported: boolean;
  60593. /**
  60594. * Updates the current state of the effect
  60595. * @hidden
  60596. */
  60597. _update(): void;
  60598. /**
  60599. * Attaches the effect on cameras
  60600. * @param cameras The camera to attach to.
  60601. * @hidden
  60602. */
  60603. _attachCameras(cameras: Camera): void;
  60604. /**
  60605. * Attaches the effect on cameras
  60606. * @param cameras The camera to attach to.
  60607. * @hidden
  60608. */
  60609. _attachCameras(cameras: Camera[]): void;
  60610. /**
  60611. * Detaches the effect on cameras
  60612. * @param cameras The camera to detatch from.
  60613. * @hidden
  60614. */
  60615. _detachCameras(cameras: Camera): void;
  60616. /**
  60617. * Detatches the effect on cameras
  60618. * @param cameras The camera to detatch from.
  60619. * @hidden
  60620. */
  60621. _detachCameras(cameras: Camera[]): void;
  60622. /**
  60623. * Enables the effect on given cameras
  60624. * @param cameras The camera to enable.
  60625. * @hidden
  60626. */
  60627. _enable(cameras: Camera): void;
  60628. /**
  60629. * Enables the effect on given cameras
  60630. * @param cameras The camera to enable.
  60631. * @hidden
  60632. */
  60633. _enable(cameras: Nullable<Camera[]>): void;
  60634. /**
  60635. * Disables the effect on the given cameras
  60636. * @param cameras The camera to disable.
  60637. * @hidden
  60638. */
  60639. _disable(cameras: Camera): void;
  60640. /**
  60641. * Disables the effect on the given cameras
  60642. * @param cameras The camera to disable.
  60643. * @hidden
  60644. */
  60645. _disable(cameras: Nullable<Camera[]>): void;
  60646. /**
  60647. * Gets a list of the post processes contained in the effect.
  60648. * @param camera The camera to get the post processes on.
  60649. * @returns The list of the post processes in the effect.
  60650. */
  60651. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60652. }
  60653. }
  60654. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60655. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60656. /** @hidden */
  60657. export var extractHighlightsPixelShader: {
  60658. name: string;
  60659. shader: string;
  60660. };
  60661. }
  60662. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60663. import { Nullable } from "babylonjs/types";
  60664. import { Camera } from "babylonjs/Cameras/camera";
  60665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60666. import { Engine } from "babylonjs/Engines/engine";
  60667. import "babylonjs/Shaders/extractHighlights.fragment";
  60668. /**
  60669. * 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.
  60670. */
  60671. export class ExtractHighlightsPostProcess extends PostProcess {
  60672. /**
  60673. * The luminance threshold, pixels below this value will be set to black.
  60674. */
  60675. threshold: number;
  60676. /** @hidden */
  60677. _exposure: number;
  60678. /**
  60679. * Post process which has the input texture to be used when performing highlight extraction
  60680. * @hidden
  60681. */
  60682. _inputPostProcess: Nullable<PostProcess>;
  60683. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60684. }
  60685. }
  60686. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60687. /** @hidden */
  60688. export var bloomMergePixelShader: {
  60689. name: string;
  60690. shader: string;
  60691. };
  60692. }
  60693. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60695. import { Nullable } from "babylonjs/types";
  60696. import { Engine } from "babylonjs/Engines/engine";
  60697. import { Camera } from "babylonjs/Cameras/camera";
  60698. import "babylonjs/Shaders/bloomMerge.fragment";
  60699. /**
  60700. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60701. */
  60702. export class BloomMergePostProcess extends PostProcess {
  60703. /** Weight of the bloom to be added to the original input. */
  60704. weight: number;
  60705. /**
  60706. * Creates a new instance of @see BloomMergePostProcess
  60707. * @param name The name of the effect.
  60708. * @param originalFromInput Post process which's input will be used for the merge.
  60709. * @param blurred Blurred highlights post process which's output will be used.
  60710. * @param weight Weight of the bloom to be added to the original input.
  60711. * @param options The required width/height ratio to downsize to before computing the render pass.
  60712. * @param camera The camera to apply the render pass to.
  60713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60714. * @param engine The engine which the post process will be applied. (default: current engine)
  60715. * @param reusable If the post process can be reused on the same frame. (default: false)
  60716. * @param textureType Type of textures used when performing the post process. (default: 0)
  60717. * @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)
  60718. */
  60719. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60720. /** Weight of the bloom to be added to the original input. */
  60721. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60722. }
  60723. }
  60724. declare module "babylonjs/PostProcesses/bloomEffect" {
  60725. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60727. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60728. import { Camera } from "babylonjs/Cameras/camera";
  60729. import { Scene } from "babylonjs/scene";
  60730. /**
  60731. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60732. */
  60733. export class BloomEffect extends PostProcessRenderEffect {
  60734. private bloomScale;
  60735. /**
  60736. * @hidden Internal
  60737. */
  60738. _effects: Array<PostProcess>;
  60739. /**
  60740. * @hidden Internal
  60741. */
  60742. _downscale: ExtractHighlightsPostProcess;
  60743. private _blurX;
  60744. private _blurY;
  60745. private _merge;
  60746. /**
  60747. * The luminance threshold to find bright areas of the image to bloom.
  60748. */
  60749. threshold: number;
  60750. /**
  60751. * The strength of the bloom.
  60752. */
  60753. weight: number;
  60754. /**
  60755. * Specifies the size of the bloom blur kernel, relative to the final output size
  60756. */
  60757. kernel: number;
  60758. /**
  60759. * Creates a new instance of @see BloomEffect
  60760. * @param scene The scene the effect belongs to.
  60761. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60762. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60763. * @param bloomWeight The the strength of bloom.
  60764. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60765. * @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)
  60766. */
  60767. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60768. /**
  60769. * Disposes each of the internal effects for a given camera.
  60770. * @param camera The camera to dispose the effect on.
  60771. */
  60772. disposeEffects(camera: Camera): void;
  60773. /**
  60774. * @hidden Internal
  60775. */
  60776. _updateEffects(): void;
  60777. /**
  60778. * Internal
  60779. * @returns if all the contained post processes are ready.
  60780. * @hidden
  60781. */
  60782. _isReady(): boolean;
  60783. }
  60784. }
  60785. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60786. /** @hidden */
  60787. export var chromaticAberrationPixelShader: {
  60788. name: string;
  60789. shader: string;
  60790. };
  60791. }
  60792. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60793. import { Vector2 } from "babylonjs/Maths/math.vector";
  60794. import { Nullable } from "babylonjs/types";
  60795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60796. import { Camera } from "babylonjs/Cameras/camera";
  60797. import { Engine } from "babylonjs/Engines/engine";
  60798. import "babylonjs/Shaders/chromaticAberration.fragment";
  60799. /**
  60800. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60801. */
  60802. export class ChromaticAberrationPostProcess extends PostProcess {
  60803. /**
  60804. * The amount of seperation of rgb channels (default: 30)
  60805. */
  60806. aberrationAmount: number;
  60807. /**
  60808. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60809. */
  60810. radialIntensity: number;
  60811. /**
  60812. * 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))
  60813. */
  60814. direction: Vector2;
  60815. /**
  60816. * 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))
  60817. */
  60818. centerPosition: Vector2;
  60819. /**
  60820. * Creates a new instance ChromaticAberrationPostProcess
  60821. * @param name The name of the effect.
  60822. * @param screenWidth The width of the screen to apply the effect on.
  60823. * @param screenHeight The height of the screen to apply the effect on.
  60824. * @param options The required width/height ratio to downsize to before computing the render pass.
  60825. * @param camera The camera to apply the render pass to.
  60826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60827. * @param engine The engine which the post process will be applied. (default: current engine)
  60828. * @param reusable If the post process can be reused on the same frame. (default: false)
  60829. * @param textureType Type of textures used when performing the post process. (default: 0)
  60830. * @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)
  60831. */
  60832. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60833. }
  60834. }
  60835. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60836. /** @hidden */
  60837. export var circleOfConfusionPixelShader: {
  60838. name: string;
  60839. shader: string;
  60840. };
  60841. }
  60842. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60843. import { Nullable } from "babylonjs/types";
  60844. import { Engine } from "babylonjs/Engines/engine";
  60845. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60846. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60847. import { Camera } from "babylonjs/Cameras/camera";
  60848. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60849. /**
  60850. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60851. */
  60852. export class CircleOfConfusionPostProcess extends PostProcess {
  60853. /**
  60854. * 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.
  60855. */
  60856. lensSize: number;
  60857. /**
  60858. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60859. */
  60860. fStop: number;
  60861. /**
  60862. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60863. */
  60864. focusDistance: number;
  60865. /**
  60866. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60867. */
  60868. focalLength: number;
  60869. private _depthTexture;
  60870. /**
  60871. * Creates a new instance CircleOfConfusionPostProcess
  60872. * @param name The name of the effect.
  60873. * @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.
  60874. * @param options The required width/height ratio to downsize to before computing the render pass.
  60875. * @param camera The camera to apply the render pass to.
  60876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60877. * @param engine The engine which the post process will be applied. (default: current engine)
  60878. * @param reusable If the post process can be reused on the same frame. (default: false)
  60879. * @param textureType Type of textures used when performing the post process. (default: 0)
  60880. * @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)
  60881. */
  60882. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60883. /**
  60884. * 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.
  60885. */
  60886. depthTexture: RenderTargetTexture;
  60887. }
  60888. }
  60889. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60890. /** @hidden */
  60891. export var colorCorrectionPixelShader: {
  60892. name: string;
  60893. shader: string;
  60894. };
  60895. }
  60896. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60897. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60898. import { Engine } from "babylonjs/Engines/engine";
  60899. import { Camera } from "babylonjs/Cameras/camera";
  60900. import "babylonjs/Shaders/colorCorrection.fragment";
  60901. /**
  60902. *
  60903. * This post-process allows the modification of rendered colors by using
  60904. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60905. *
  60906. * The object needs to be provided an url to a texture containing the color
  60907. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60908. * Use an image editing software to tweak the LUT to match your needs.
  60909. *
  60910. * For an example of a color LUT, see here:
  60911. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60912. * For explanations on color grading, see here:
  60913. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60914. *
  60915. */
  60916. export class ColorCorrectionPostProcess extends PostProcess {
  60917. private _colorTableTexture;
  60918. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60919. }
  60920. }
  60921. declare module "babylonjs/Shaders/convolution.fragment" {
  60922. /** @hidden */
  60923. export var convolutionPixelShader: {
  60924. name: string;
  60925. shader: string;
  60926. };
  60927. }
  60928. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60929. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60930. import { Nullable } from "babylonjs/types";
  60931. import { Camera } from "babylonjs/Cameras/camera";
  60932. import { Engine } from "babylonjs/Engines/engine";
  60933. import "babylonjs/Shaders/convolution.fragment";
  60934. /**
  60935. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60936. * input texture to perform effects such as edge detection or sharpening
  60937. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60938. */
  60939. export class ConvolutionPostProcess extends PostProcess {
  60940. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60941. kernel: number[];
  60942. /**
  60943. * Creates a new instance ConvolutionPostProcess
  60944. * @param name The name of the effect.
  60945. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60946. * @param options The required width/height ratio to downsize to before computing the render pass.
  60947. * @param camera The camera to apply the render pass to.
  60948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60949. * @param engine The engine which the post process will be applied. (default: current engine)
  60950. * @param reusable If the post process can be reused on the same frame. (default: false)
  60951. * @param textureType Type of textures used when performing the post process. (default: 0)
  60952. */
  60953. constructor(name: string,
  60954. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60955. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60956. /**
  60957. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60958. */
  60959. static EdgeDetect0Kernel: number[];
  60960. /**
  60961. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60962. */
  60963. static EdgeDetect1Kernel: number[];
  60964. /**
  60965. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60966. */
  60967. static EdgeDetect2Kernel: number[];
  60968. /**
  60969. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60970. */
  60971. static SharpenKernel: number[];
  60972. /**
  60973. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60974. */
  60975. static EmbossKernel: number[];
  60976. /**
  60977. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60978. */
  60979. static GaussianKernel: number[];
  60980. }
  60981. }
  60982. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60983. import { Nullable } from "babylonjs/types";
  60984. import { Vector2 } from "babylonjs/Maths/math.vector";
  60985. import { Camera } from "babylonjs/Cameras/camera";
  60986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60987. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60988. import { Engine } from "babylonjs/Engines/engine";
  60989. import { Scene } from "babylonjs/scene";
  60990. /**
  60991. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60992. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60993. * based on samples that have a large difference in distance than the center pixel.
  60994. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60995. */
  60996. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60997. direction: Vector2;
  60998. /**
  60999. * Creates a new instance CircleOfConfusionPostProcess
  61000. * @param name The name of the effect.
  61001. * @param scene The scene the effect belongs to.
  61002. * @param direction The direction the blur should be applied.
  61003. * @param kernel The size of the kernel used to blur.
  61004. * @param options The required width/height ratio to downsize to before computing the render pass.
  61005. * @param camera The camera to apply the render pass to.
  61006. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61007. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61009. * @param engine The engine which the post process will be applied. (default: current engine)
  61010. * @param reusable If the post process can be reused on the same frame. (default: false)
  61011. * @param textureType Type of textures used when performing the post process. (default: 0)
  61012. * @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)
  61013. */
  61014. 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);
  61015. }
  61016. }
  61017. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61018. /** @hidden */
  61019. export var depthOfFieldMergePixelShader: {
  61020. name: string;
  61021. shader: string;
  61022. };
  61023. }
  61024. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61025. import { Nullable } from "babylonjs/types";
  61026. import { Camera } from "babylonjs/Cameras/camera";
  61027. import { Effect } from "babylonjs/Materials/effect";
  61028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61029. import { Engine } from "babylonjs/Engines/engine";
  61030. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61031. /**
  61032. * Options to be set when merging outputs from the default pipeline.
  61033. */
  61034. export class DepthOfFieldMergePostProcessOptions {
  61035. /**
  61036. * The original image to merge on top of
  61037. */
  61038. originalFromInput: PostProcess;
  61039. /**
  61040. * Parameters to perform the merge of the depth of field effect
  61041. */
  61042. depthOfField?: {
  61043. circleOfConfusion: PostProcess;
  61044. blurSteps: Array<PostProcess>;
  61045. };
  61046. /**
  61047. * Parameters to perform the merge of bloom effect
  61048. */
  61049. bloom?: {
  61050. blurred: PostProcess;
  61051. weight: number;
  61052. };
  61053. }
  61054. /**
  61055. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61056. */
  61057. export class DepthOfFieldMergePostProcess extends PostProcess {
  61058. private blurSteps;
  61059. /**
  61060. * Creates a new instance of DepthOfFieldMergePostProcess
  61061. * @param name The name of the effect.
  61062. * @param originalFromInput Post process which's input will be used for the merge.
  61063. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61064. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61065. * @param options The required width/height ratio to downsize to before computing the render pass.
  61066. * @param camera The camera to apply the render pass to.
  61067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61068. * @param engine The engine which the post process will be applied. (default: current engine)
  61069. * @param reusable If the post process can be reused on the same frame. (default: false)
  61070. * @param textureType Type of textures used when performing the post process. (default: 0)
  61071. * @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)
  61072. */
  61073. 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);
  61074. /**
  61075. * Updates the effect with the current post process compile time values and recompiles the shader.
  61076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61079. * @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
  61080. * @param onCompiled Called when the shader has been compiled.
  61081. * @param onError Called if there is an error when compiling a shader.
  61082. */
  61083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61084. }
  61085. }
  61086. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61087. import { Nullable } from "babylonjs/types";
  61088. import { Camera } from "babylonjs/Cameras/camera";
  61089. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61091. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61092. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61093. import { Scene } from "babylonjs/scene";
  61094. /**
  61095. * Specifies the level of max blur that should be applied when using the depth of field effect
  61096. */
  61097. export enum DepthOfFieldEffectBlurLevel {
  61098. /**
  61099. * Subtle blur
  61100. */
  61101. Low = 0,
  61102. /**
  61103. * Medium blur
  61104. */
  61105. Medium = 1,
  61106. /**
  61107. * Large blur
  61108. */
  61109. High = 2
  61110. }
  61111. /**
  61112. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61113. */
  61114. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61115. private _circleOfConfusion;
  61116. /**
  61117. * @hidden Internal, blurs from high to low
  61118. */
  61119. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61120. private _depthOfFieldBlurY;
  61121. private _dofMerge;
  61122. /**
  61123. * @hidden Internal post processes in depth of field effect
  61124. */
  61125. _effects: Array<PostProcess>;
  61126. /**
  61127. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61128. */
  61129. focalLength: number;
  61130. /**
  61131. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61132. */
  61133. fStop: number;
  61134. /**
  61135. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61136. */
  61137. focusDistance: number;
  61138. /**
  61139. * 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.
  61140. */
  61141. lensSize: number;
  61142. /**
  61143. * Creates a new instance DepthOfFieldEffect
  61144. * @param scene The scene the effect belongs to.
  61145. * @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.
  61146. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61147. * @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)
  61148. */
  61149. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61150. /**
  61151. * Get the current class name of the current effet
  61152. * @returns "DepthOfFieldEffect"
  61153. */
  61154. getClassName(): string;
  61155. /**
  61156. * 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.
  61157. */
  61158. depthTexture: RenderTargetTexture;
  61159. /**
  61160. * Disposes each of the internal effects for a given camera.
  61161. * @param camera The camera to dispose the effect on.
  61162. */
  61163. disposeEffects(camera: Camera): void;
  61164. /**
  61165. * @hidden Internal
  61166. */
  61167. _updateEffects(): void;
  61168. /**
  61169. * Internal
  61170. * @returns if all the contained post processes are ready.
  61171. * @hidden
  61172. */
  61173. _isReady(): boolean;
  61174. }
  61175. }
  61176. declare module "babylonjs/Shaders/displayPass.fragment" {
  61177. /** @hidden */
  61178. export var displayPassPixelShader: {
  61179. name: string;
  61180. shader: string;
  61181. };
  61182. }
  61183. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61184. import { Nullable } from "babylonjs/types";
  61185. import { Camera } from "babylonjs/Cameras/camera";
  61186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61187. import { Engine } from "babylonjs/Engines/engine";
  61188. import "babylonjs/Shaders/displayPass.fragment";
  61189. /**
  61190. * DisplayPassPostProcess which produces an output the same as it's input
  61191. */
  61192. export class DisplayPassPostProcess extends PostProcess {
  61193. /**
  61194. * Creates the DisplayPassPostProcess
  61195. * @param name The name of the effect.
  61196. * @param options The required width/height ratio to downsize to before computing the render pass.
  61197. * @param camera The camera to apply the render pass to.
  61198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61199. * @param engine The engine which the post process will be applied. (default: current engine)
  61200. * @param reusable If the post process can be reused on the same frame. (default: false)
  61201. */
  61202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61203. }
  61204. }
  61205. declare module "babylonjs/Shaders/filter.fragment" {
  61206. /** @hidden */
  61207. export var filterPixelShader: {
  61208. name: string;
  61209. shader: string;
  61210. };
  61211. }
  61212. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61213. import { Nullable } from "babylonjs/types";
  61214. import { Matrix } from "babylonjs/Maths/math.vector";
  61215. import { Camera } from "babylonjs/Cameras/camera";
  61216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61217. import { Engine } from "babylonjs/Engines/engine";
  61218. import "babylonjs/Shaders/filter.fragment";
  61219. /**
  61220. * Applies a kernel filter to the image
  61221. */
  61222. export class FilterPostProcess extends PostProcess {
  61223. /** The matrix to be applied to the image */
  61224. kernelMatrix: Matrix;
  61225. /**
  61226. *
  61227. * @param name The name of the effect.
  61228. * @param kernelMatrix The matrix to be applied to the image
  61229. * @param options The required width/height ratio to downsize to before computing the render pass.
  61230. * @param camera The camera to apply the render pass to.
  61231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61232. * @param engine The engine which the post process will be applied. (default: current engine)
  61233. * @param reusable If the post process can be reused on the same frame. (default: false)
  61234. */
  61235. constructor(name: string,
  61236. /** The matrix to be applied to the image */
  61237. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61238. }
  61239. }
  61240. declare module "babylonjs/Shaders/fxaa.fragment" {
  61241. /** @hidden */
  61242. export var fxaaPixelShader: {
  61243. name: string;
  61244. shader: string;
  61245. };
  61246. }
  61247. declare module "babylonjs/Shaders/fxaa.vertex" {
  61248. /** @hidden */
  61249. export var fxaaVertexShader: {
  61250. name: string;
  61251. shader: string;
  61252. };
  61253. }
  61254. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61255. import { Nullable } from "babylonjs/types";
  61256. import { Camera } from "babylonjs/Cameras/camera";
  61257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61258. import { Engine } from "babylonjs/Engines/engine";
  61259. import "babylonjs/Shaders/fxaa.fragment";
  61260. import "babylonjs/Shaders/fxaa.vertex";
  61261. /**
  61262. * Fxaa post process
  61263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61264. */
  61265. export class FxaaPostProcess extends PostProcess {
  61266. /** @hidden */
  61267. texelWidth: number;
  61268. /** @hidden */
  61269. texelHeight: number;
  61270. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61271. private _getDefines;
  61272. }
  61273. }
  61274. declare module "babylonjs/Shaders/grain.fragment" {
  61275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61276. /** @hidden */
  61277. export var grainPixelShader: {
  61278. name: string;
  61279. shader: string;
  61280. };
  61281. }
  61282. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61283. import { Nullable } from "babylonjs/types";
  61284. import { Camera } from "babylonjs/Cameras/camera";
  61285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61286. import { Engine } from "babylonjs/Engines/engine";
  61287. import "babylonjs/Shaders/grain.fragment";
  61288. /**
  61289. * The GrainPostProcess adds noise to the image at mid luminance levels
  61290. */
  61291. export class GrainPostProcess extends PostProcess {
  61292. /**
  61293. * The intensity of the grain added (default: 30)
  61294. */
  61295. intensity: number;
  61296. /**
  61297. * If the grain should be randomized on every frame
  61298. */
  61299. animated: boolean;
  61300. /**
  61301. * Creates a new instance of @see GrainPostProcess
  61302. * @param name The name of the effect.
  61303. * @param options The required width/height ratio to downsize to before computing the render pass.
  61304. * @param camera The camera to apply the render pass to.
  61305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61306. * @param engine The engine which the post process will be applied. (default: current engine)
  61307. * @param reusable If the post process can be reused on the same frame. (default: false)
  61308. * @param textureType Type of textures used when performing the post process. (default: 0)
  61309. * @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)
  61310. */
  61311. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61312. }
  61313. }
  61314. declare module "babylonjs/Shaders/highlights.fragment" {
  61315. /** @hidden */
  61316. export var highlightsPixelShader: {
  61317. name: string;
  61318. shader: string;
  61319. };
  61320. }
  61321. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61322. import { Nullable } from "babylonjs/types";
  61323. import { Camera } from "babylonjs/Cameras/camera";
  61324. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61325. import { Engine } from "babylonjs/Engines/engine";
  61326. import "babylonjs/Shaders/highlights.fragment";
  61327. /**
  61328. * Extracts highlights from the image
  61329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61330. */
  61331. export class HighlightsPostProcess extends PostProcess {
  61332. /**
  61333. * Extracts highlights from the image
  61334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61335. * @param name The name of the effect.
  61336. * @param options The required width/height ratio to downsize to before computing the render pass.
  61337. * @param camera The camera to apply the render pass to.
  61338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61339. * @param engine The engine which the post process will be applied. (default: current engine)
  61340. * @param reusable If the post process can be reused on the same frame. (default: false)
  61341. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61342. */
  61343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61344. }
  61345. }
  61346. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61347. /** @hidden */
  61348. export var mrtFragmentDeclaration: {
  61349. name: string;
  61350. shader: string;
  61351. };
  61352. }
  61353. declare module "babylonjs/Shaders/geometry.fragment" {
  61354. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61355. /** @hidden */
  61356. export var geometryPixelShader: {
  61357. name: string;
  61358. shader: string;
  61359. };
  61360. }
  61361. declare module "babylonjs/Shaders/geometry.vertex" {
  61362. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61364. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61365. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61367. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61368. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61369. /** @hidden */
  61370. export var geometryVertexShader: {
  61371. name: string;
  61372. shader: string;
  61373. };
  61374. }
  61375. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61376. import { Matrix } from "babylonjs/Maths/math.vector";
  61377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61378. import { Mesh } from "babylonjs/Meshes/mesh";
  61379. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61380. import { Effect } from "babylonjs/Materials/effect";
  61381. import { Scene } from "babylonjs/scene";
  61382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61383. import "babylonjs/Shaders/geometry.fragment";
  61384. import "babylonjs/Shaders/geometry.vertex";
  61385. /** @hidden */
  61386. interface ISavedTransformationMatrix {
  61387. world: Matrix;
  61388. viewProjection: Matrix;
  61389. }
  61390. /**
  61391. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61392. */
  61393. export class GeometryBufferRenderer {
  61394. /**
  61395. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61396. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61397. */
  61398. static readonly POSITION_TEXTURE_TYPE: number;
  61399. /**
  61400. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61401. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61402. */
  61403. static readonly VELOCITY_TEXTURE_TYPE: number;
  61404. /**
  61405. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61406. * in order to compute objects velocities when enableVelocity is set to "true"
  61407. * @hidden
  61408. */
  61409. _previousTransformationMatrices: {
  61410. [index: number]: ISavedTransformationMatrix;
  61411. };
  61412. /**
  61413. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61414. * in order to compute objects velocities when enableVelocity is set to "true"
  61415. * @hidden
  61416. */
  61417. _previousBonesTransformationMatrices: {
  61418. [index: number]: Float32Array;
  61419. };
  61420. /**
  61421. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61422. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61423. */
  61424. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61425. private _scene;
  61426. private _multiRenderTarget;
  61427. private _ratio;
  61428. private _enablePosition;
  61429. private _enableVelocity;
  61430. private _positionIndex;
  61431. private _velocityIndex;
  61432. protected _effect: Effect;
  61433. protected _cachedDefines: string;
  61434. /**
  61435. * Set the render list (meshes to be rendered) used in the G buffer.
  61436. */
  61437. renderList: Mesh[];
  61438. /**
  61439. * Gets wether or not G buffer are supported by the running hardware.
  61440. * This requires draw buffer supports
  61441. */
  61442. readonly isSupported: boolean;
  61443. /**
  61444. * Returns the index of the given texture type in the G-Buffer textures array
  61445. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61446. * @returns the index of the given texture type in the G-Buffer textures array
  61447. */
  61448. getTextureIndex(textureType: number): number;
  61449. /**
  61450. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61451. */
  61452. /**
  61453. * Sets whether or not objects positions are enabled for the G buffer.
  61454. */
  61455. enablePosition: boolean;
  61456. /**
  61457. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61458. */
  61459. /**
  61460. * Sets wether or not objects velocities are enabled for the G buffer.
  61461. */
  61462. enableVelocity: boolean;
  61463. /**
  61464. * Gets the scene associated with the buffer.
  61465. */
  61466. readonly scene: Scene;
  61467. /**
  61468. * Gets the ratio used by the buffer during its creation.
  61469. * How big is the buffer related to the main canvas.
  61470. */
  61471. readonly ratio: number;
  61472. /** @hidden */
  61473. static _SceneComponentInitialization: (scene: Scene) => void;
  61474. /**
  61475. * Creates a new G Buffer for the scene
  61476. * @param scene The scene the buffer belongs to
  61477. * @param ratio How big is the buffer related to the main canvas.
  61478. */
  61479. constructor(scene: Scene, ratio?: number);
  61480. /**
  61481. * Checks wether everything is ready to render a submesh to the G buffer.
  61482. * @param subMesh the submesh to check readiness for
  61483. * @param useInstances is the mesh drawn using instance or not
  61484. * @returns true if ready otherwise false
  61485. */
  61486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61487. /**
  61488. * Gets the current underlying G Buffer.
  61489. * @returns the buffer
  61490. */
  61491. getGBuffer(): MultiRenderTarget;
  61492. /**
  61493. * Gets the number of samples used to render the buffer (anti aliasing).
  61494. */
  61495. /**
  61496. * Sets the number of samples used to render the buffer (anti aliasing).
  61497. */
  61498. samples: number;
  61499. /**
  61500. * Disposes the renderer and frees up associated resources.
  61501. */
  61502. dispose(): void;
  61503. protected _createRenderTargets(): void;
  61504. private _copyBonesTransformationMatrices;
  61505. }
  61506. }
  61507. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61508. import { Nullable } from "babylonjs/types";
  61509. import { Scene } from "babylonjs/scene";
  61510. import { ISceneComponent } from "babylonjs/sceneComponent";
  61511. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61512. module "babylonjs/scene" {
  61513. interface Scene {
  61514. /** @hidden (Backing field) */
  61515. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61516. /**
  61517. * Gets or Sets the current geometry buffer associated to the scene.
  61518. */
  61519. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61520. /**
  61521. * Enables a GeometryBufferRender and associates it with the scene
  61522. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61523. * @returns the GeometryBufferRenderer
  61524. */
  61525. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61526. /**
  61527. * Disables the GeometryBufferRender associated with the scene
  61528. */
  61529. disableGeometryBufferRenderer(): void;
  61530. }
  61531. }
  61532. /**
  61533. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61534. * in several rendering techniques.
  61535. */
  61536. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61537. /**
  61538. * The component name helpful to identify the component in the list of scene components.
  61539. */
  61540. readonly name: string;
  61541. /**
  61542. * The scene the component belongs to.
  61543. */
  61544. scene: Scene;
  61545. /**
  61546. * Creates a new instance of the component for the given scene
  61547. * @param scene Defines the scene to register the component in
  61548. */
  61549. constructor(scene: Scene);
  61550. /**
  61551. * Registers the component in a given scene
  61552. */
  61553. register(): void;
  61554. /**
  61555. * Rebuilds the elements related to this component in case of
  61556. * context lost for instance.
  61557. */
  61558. rebuild(): void;
  61559. /**
  61560. * Disposes the component and the associated ressources
  61561. */
  61562. dispose(): void;
  61563. private _gatherRenderTargets;
  61564. }
  61565. }
  61566. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61567. /** @hidden */
  61568. export var motionBlurPixelShader: {
  61569. name: string;
  61570. shader: string;
  61571. };
  61572. }
  61573. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61574. import { Nullable } from "babylonjs/types";
  61575. import { Camera } from "babylonjs/Cameras/camera";
  61576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61577. import { Scene } from "babylonjs/scene";
  61578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61579. import "babylonjs/Animations/animatable";
  61580. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61581. import "babylonjs/Shaders/motionBlur.fragment";
  61582. import { Engine } from "babylonjs/Engines/engine";
  61583. /**
  61584. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61585. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61586. * As an example, all you have to do is to create the post-process:
  61587. * var mb = new BABYLON.MotionBlurPostProcess(
  61588. * 'mb', // The name of the effect.
  61589. * scene, // The scene containing the objects to blur according to their velocity.
  61590. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61591. * camera // The camera to apply the render pass to.
  61592. * );
  61593. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61594. */
  61595. export class MotionBlurPostProcess extends PostProcess {
  61596. /**
  61597. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61598. */
  61599. motionStrength: number;
  61600. /**
  61601. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61602. */
  61603. /**
  61604. * Sets the number of iterations to be used for motion blur quality
  61605. */
  61606. motionBlurSamples: number;
  61607. private _motionBlurSamples;
  61608. private _geometryBufferRenderer;
  61609. /**
  61610. * Creates a new instance MotionBlurPostProcess
  61611. * @param name The name of the effect.
  61612. * @param scene The scene containing the objects to blur according to their velocity.
  61613. * @param options The required width/height ratio to downsize to before computing the render pass.
  61614. * @param camera The camera to apply the render pass to.
  61615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61616. * @param engine The engine which the post process will be applied. (default: current engine)
  61617. * @param reusable If the post process can be reused on the same frame. (default: false)
  61618. * @param textureType Type of textures used when performing the post process. (default: 0)
  61619. * @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)
  61620. */
  61621. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61622. /**
  61623. * Excludes the given skinned mesh from computing bones velocities.
  61624. * 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.
  61625. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61626. */
  61627. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61628. /**
  61629. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61630. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61631. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61632. */
  61633. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61634. /**
  61635. * Disposes the post process.
  61636. * @param camera The camera to dispose the post process on.
  61637. */
  61638. dispose(camera?: Camera): void;
  61639. }
  61640. }
  61641. declare module "babylonjs/Shaders/refraction.fragment" {
  61642. /** @hidden */
  61643. export var refractionPixelShader: {
  61644. name: string;
  61645. shader: string;
  61646. };
  61647. }
  61648. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61649. import { Color3 } from "babylonjs/Maths/math.color";
  61650. import { Camera } from "babylonjs/Cameras/camera";
  61651. import { Texture } from "babylonjs/Materials/Textures/texture";
  61652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61653. import { Engine } from "babylonjs/Engines/engine";
  61654. import "babylonjs/Shaders/refraction.fragment";
  61655. /**
  61656. * Post process which applies a refractin texture
  61657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61658. */
  61659. export class RefractionPostProcess extends PostProcess {
  61660. /** the base color of the refraction (used to taint the rendering) */
  61661. color: Color3;
  61662. /** simulated refraction depth */
  61663. depth: number;
  61664. /** the coefficient of the base color (0 to remove base color tainting) */
  61665. colorLevel: number;
  61666. private _refTexture;
  61667. private _ownRefractionTexture;
  61668. /**
  61669. * Gets or sets the refraction texture
  61670. * Please note that you are responsible for disposing the texture if you set it manually
  61671. */
  61672. refractionTexture: Texture;
  61673. /**
  61674. * Initializes the RefractionPostProcess
  61675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61676. * @param name The name of the effect.
  61677. * @param refractionTextureUrl Url of the refraction texture to use
  61678. * @param color the base color of the refraction (used to taint the rendering)
  61679. * @param depth simulated refraction depth
  61680. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61681. * @param camera The camera to apply the render pass to.
  61682. * @param options The required width/height ratio to downsize to before computing the render pass.
  61683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61684. * @param engine The engine which the post process will be applied. (default: current engine)
  61685. * @param reusable If the post process can be reused on the same frame. (default: false)
  61686. */
  61687. constructor(name: string, refractionTextureUrl: string,
  61688. /** the base color of the refraction (used to taint the rendering) */
  61689. color: Color3,
  61690. /** simulated refraction depth */
  61691. depth: number,
  61692. /** the coefficient of the base color (0 to remove base color tainting) */
  61693. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61694. /**
  61695. * Disposes of the post process
  61696. * @param camera Camera to dispose post process on
  61697. */
  61698. dispose(camera: Camera): void;
  61699. }
  61700. }
  61701. declare module "babylonjs/Shaders/sharpen.fragment" {
  61702. /** @hidden */
  61703. export var sharpenPixelShader: {
  61704. name: string;
  61705. shader: string;
  61706. };
  61707. }
  61708. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61709. import { Nullable } from "babylonjs/types";
  61710. import { Camera } from "babylonjs/Cameras/camera";
  61711. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61712. import "babylonjs/Shaders/sharpen.fragment";
  61713. import { Engine } from "babylonjs/Engines/engine";
  61714. /**
  61715. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61716. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61717. */
  61718. export class SharpenPostProcess extends PostProcess {
  61719. /**
  61720. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61721. */
  61722. colorAmount: number;
  61723. /**
  61724. * How much sharpness should be applied (default: 0.3)
  61725. */
  61726. edgeAmount: number;
  61727. /**
  61728. * Creates a new instance ConvolutionPostProcess
  61729. * @param name The name of the effect.
  61730. * @param options The required width/height ratio to downsize to before computing the render pass.
  61731. * @param camera The camera to apply the render pass to.
  61732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61733. * @param engine The engine which the post process will be applied. (default: current engine)
  61734. * @param reusable If the post process can be reused on the same frame. (default: false)
  61735. * @param textureType Type of textures used when performing the post process. (default: 0)
  61736. * @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)
  61737. */
  61738. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61739. }
  61740. }
  61741. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61742. import { Nullable } from "babylonjs/types";
  61743. import { Camera } from "babylonjs/Cameras/camera";
  61744. import { Engine } from "babylonjs/Engines/engine";
  61745. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61746. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61747. /**
  61748. * PostProcessRenderPipeline
  61749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61750. */
  61751. export class PostProcessRenderPipeline {
  61752. private engine;
  61753. private _renderEffects;
  61754. private _renderEffectsForIsolatedPass;
  61755. /**
  61756. * List of inspectable custom properties (used by the Inspector)
  61757. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61758. */
  61759. inspectableCustomProperties: IInspectable[];
  61760. /**
  61761. * @hidden
  61762. */
  61763. protected _cameras: Camera[];
  61764. /** @hidden */
  61765. _name: string;
  61766. /**
  61767. * Gets pipeline name
  61768. */
  61769. readonly name: string;
  61770. /**
  61771. * Initializes a PostProcessRenderPipeline
  61772. * @param engine engine to add the pipeline to
  61773. * @param name name of the pipeline
  61774. */
  61775. constructor(engine: Engine, name: string);
  61776. /**
  61777. * Gets the class name
  61778. * @returns "PostProcessRenderPipeline"
  61779. */
  61780. getClassName(): string;
  61781. /**
  61782. * If all the render effects in the pipeline are supported
  61783. */
  61784. readonly isSupported: boolean;
  61785. /**
  61786. * Adds an effect to the pipeline
  61787. * @param renderEffect the effect to add
  61788. */
  61789. addEffect(renderEffect: PostProcessRenderEffect): void;
  61790. /** @hidden */
  61791. _rebuild(): void;
  61792. /** @hidden */
  61793. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61794. /** @hidden */
  61795. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61796. /** @hidden */
  61797. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61798. /** @hidden */
  61799. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61800. /** @hidden */
  61801. _attachCameras(cameras: Camera, unique: boolean): void;
  61802. /** @hidden */
  61803. _attachCameras(cameras: Camera[], unique: boolean): void;
  61804. /** @hidden */
  61805. _detachCameras(cameras: Camera): void;
  61806. /** @hidden */
  61807. _detachCameras(cameras: Nullable<Camera[]>): void;
  61808. /** @hidden */
  61809. _update(): void;
  61810. /** @hidden */
  61811. _reset(): void;
  61812. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61813. /**
  61814. * Disposes of the pipeline
  61815. */
  61816. dispose(): void;
  61817. }
  61818. }
  61819. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61820. import { Camera } from "babylonjs/Cameras/camera";
  61821. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61822. /**
  61823. * PostProcessRenderPipelineManager class
  61824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61825. */
  61826. export class PostProcessRenderPipelineManager {
  61827. private _renderPipelines;
  61828. /**
  61829. * Initializes a PostProcessRenderPipelineManager
  61830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61831. */
  61832. constructor();
  61833. /**
  61834. * Gets the list of supported render pipelines
  61835. */
  61836. readonly supportedPipelines: PostProcessRenderPipeline[];
  61837. /**
  61838. * Adds a pipeline to the manager
  61839. * @param renderPipeline The pipeline to add
  61840. */
  61841. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61842. /**
  61843. * Attaches a camera to the pipeline
  61844. * @param renderPipelineName The name of the pipeline to attach to
  61845. * @param cameras the camera to attach
  61846. * @param unique if the camera can be attached multiple times to the pipeline
  61847. */
  61848. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61849. /**
  61850. * Detaches a camera from the pipeline
  61851. * @param renderPipelineName The name of the pipeline to detach from
  61852. * @param cameras the camera to detach
  61853. */
  61854. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61855. /**
  61856. * Enables an effect by name on a pipeline
  61857. * @param renderPipelineName the name of the pipeline to enable the effect in
  61858. * @param renderEffectName the name of the effect to enable
  61859. * @param cameras the cameras that the effect should be enabled on
  61860. */
  61861. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61862. /**
  61863. * Disables an effect by name on a pipeline
  61864. * @param renderPipelineName the name of the pipeline to disable the effect in
  61865. * @param renderEffectName the name of the effect to disable
  61866. * @param cameras the cameras that the effect should be disabled on
  61867. */
  61868. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61869. /**
  61870. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61871. */
  61872. update(): void;
  61873. /** @hidden */
  61874. _rebuild(): void;
  61875. /**
  61876. * Disposes of the manager and pipelines
  61877. */
  61878. dispose(): void;
  61879. }
  61880. }
  61881. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61882. import { ISceneComponent } from "babylonjs/sceneComponent";
  61883. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61884. import { Scene } from "babylonjs/scene";
  61885. module "babylonjs/scene" {
  61886. interface Scene {
  61887. /** @hidden (Backing field) */
  61888. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61889. /**
  61890. * Gets the postprocess render pipeline manager
  61891. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61892. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61893. */
  61894. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61895. }
  61896. }
  61897. /**
  61898. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61899. */
  61900. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61901. /**
  61902. * The component name helpfull to identify the component in the list of scene components.
  61903. */
  61904. readonly name: string;
  61905. /**
  61906. * The scene the component belongs to.
  61907. */
  61908. scene: Scene;
  61909. /**
  61910. * Creates a new instance of the component for the given scene
  61911. * @param scene Defines the scene to register the component in
  61912. */
  61913. constructor(scene: Scene);
  61914. /**
  61915. * Registers the component in a given scene
  61916. */
  61917. register(): void;
  61918. /**
  61919. * Rebuilds the elements related to this component in case of
  61920. * context lost for instance.
  61921. */
  61922. rebuild(): void;
  61923. /**
  61924. * Disposes the component and the associated ressources
  61925. */
  61926. dispose(): void;
  61927. private _gatherRenderTargets;
  61928. }
  61929. }
  61930. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61931. import { Nullable } from "babylonjs/types";
  61932. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61933. import { Camera } from "babylonjs/Cameras/camera";
  61934. import { IDisposable } from "babylonjs/scene";
  61935. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61936. import { Scene } from "babylonjs/scene";
  61937. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61938. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61939. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61940. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61941. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61942. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61943. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61944. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61945. import { Animation } from "babylonjs/Animations/animation";
  61946. /**
  61947. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61948. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61949. */
  61950. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61951. private _scene;
  61952. private _camerasToBeAttached;
  61953. /**
  61954. * ID of the sharpen post process,
  61955. */
  61956. private readonly SharpenPostProcessId;
  61957. /**
  61958. * @ignore
  61959. * ID of the image processing post process;
  61960. */
  61961. readonly ImageProcessingPostProcessId: string;
  61962. /**
  61963. * @ignore
  61964. * ID of the Fast Approximate Anti-Aliasing post process;
  61965. */
  61966. readonly FxaaPostProcessId: string;
  61967. /**
  61968. * ID of the chromatic aberration post process,
  61969. */
  61970. private readonly ChromaticAberrationPostProcessId;
  61971. /**
  61972. * ID of the grain post process
  61973. */
  61974. private readonly GrainPostProcessId;
  61975. /**
  61976. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61977. */
  61978. sharpen: SharpenPostProcess;
  61979. private _sharpenEffect;
  61980. private bloom;
  61981. /**
  61982. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61983. */
  61984. depthOfField: DepthOfFieldEffect;
  61985. /**
  61986. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61987. */
  61988. fxaa: FxaaPostProcess;
  61989. /**
  61990. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61991. */
  61992. imageProcessing: ImageProcessingPostProcess;
  61993. /**
  61994. * Chromatic aberration post process which will shift rgb colors in the image
  61995. */
  61996. chromaticAberration: ChromaticAberrationPostProcess;
  61997. private _chromaticAberrationEffect;
  61998. /**
  61999. * Grain post process which add noise to the image
  62000. */
  62001. grain: GrainPostProcess;
  62002. private _grainEffect;
  62003. /**
  62004. * Glow post process which adds a glow to emissive areas of the image
  62005. */
  62006. private _glowLayer;
  62007. /**
  62008. * Animations which can be used to tweak settings over a period of time
  62009. */
  62010. animations: Animation[];
  62011. private _imageProcessingConfigurationObserver;
  62012. private _sharpenEnabled;
  62013. private _bloomEnabled;
  62014. private _depthOfFieldEnabled;
  62015. private _depthOfFieldBlurLevel;
  62016. private _fxaaEnabled;
  62017. private _imageProcessingEnabled;
  62018. private _defaultPipelineTextureType;
  62019. private _bloomScale;
  62020. private _chromaticAberrationEnabled;
  62021. private _grainEnabled;
  62022. private _buildAllowed;
  62023. /**
  62024. * Gets active scene
  62025. */
  62026. readonly scene: Scene;
  62027. /**
  62028. * Enable or disable the sharpen process from the pipeline
  62029. */
  62030. sharpenEnabled: boolean;
  62031. private _resizeObserver;
  62032. private _hardwareScaleLevel;
  62033. private _bloomKernel;
  62034. /**
  62035. * Specifies the size of the bloom blur kernel, relative to the final output size
  62036. */
  62037. bloomKernel: number;
  62038. /**
  62039. * Specifies the weight of the bloom in the final rendering
  62040. */
  62041. private _bloomWeight;
  62042. /**
  62043. * Specifies the luma threshold for the area that will be blurred by the bloom
  62044. */
  62045. private _bloomThreshold;
  62046. private _hdr;
  62047. /**
  62048. * The strength of the bloom.
  62049. */
  62050. bloomWeight: number;
  62051. /**
  62052. * The strength of the bloom.
  62053. */
  62054. bloomThreshold: number;
  62055. /**
  62056. * The scale of the bloom, lower value will provide better performance.
  62057. */
  62058. bloomScale: number;
  62059. /**
  62060. * Enable or disable the bloom from the pipeline
  62061. */
  62062. bloomEnabled: boolean;
  62063. private _rebuildBloom;
  62064. /**
  62065. * If the depth of field is enabled.
  62066. */
  62067. depthOfFieldEnabled: boolean;
  62068. /**
  62069. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62070. */
  62071. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62072. /**
  62073. * If the anti aliasing is enabled.
  62074. */
  62075. fxaaEnabled: boolean;
  62076. private _samples;
  62077. /**
  62078. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62079. */
  62080. samples: number;
  62081. /**
  62082. * If image processing is enabled.
  62083. */
  62084. imageProcessingEnabled: boolean;
  62085. /**
  62086. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62087. */
  62088. glowLayerEnabled: boolean;
  62089. /**
  62090. * Gets the glow layer (or null if not defined)
  62091. */
  62092. readonly glowLayer: Nullable<GlowLayer>;
  62093. /**
  62094. * Enable or disable the chromaticAberration process from the pipeline
  62095. */
  62096. chromaticAberrationEnabled: boolean;
  62097. /**
  62098. * Enable or disable the grain process from the pipeline
  62099. */
  62100. grainEnabled: boolean;
  62101. /**
  62102. * @constructor
  62103. * @param name - The rendering pipeline name (default: "")
  62104. * @param hdr - If high dynamic range textures should be used (default: true)
  62105. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62106. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62107. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62108. */
  62109. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62110. /**
  62111. * Get the class name
  62112. * @returns "DefaultRenderingPipeline"
  62113. */
  62114. getClassName(): string;
  62115. /**
  62116. * Force the compilation of the entire pipeline.
  62117. */
  62118. prepare(): void;
  62119. private _hasCleared;
  62120. private _prevPostProcess;
  62121. private _prevPrevPostProcess;
  62122. private _setAutoClearAndTextureSharing;
  62123. private _depthOfFieldSceneObserver;
  62124. private _buildPipeline;
  62125. private _disposePostProcesses;
  62126. /**
  62127. * Adds a camera to the pipeline
  62128. * @param camera the camera to be added
  62129. */
  62130. addCamera(camera: Camera): void;
  62131. /**
  62132. * Removes a camera from the pipeline
  62133. * @param camera the camera to remove
  62134. */
  62135. removeCamera(camera: Camera): void;
  62136. /**
  62137. * Dispose of the pipeline and stop all post processes
  62138. */
  62139. dispose(): void;
  62140. /**
  62141. * Serialize the rendering pipeline (Used when exporting)
  62142. * @returns the serialized object
  62143. */
  62144. serialize(): any;
  62145. /**
  62146. * Parse the serialized pipeline
  62147. * @param source Source pipeline.
  62148. * @param scene The scene to load the pipeline to.
  62149. * @param rootUrl The URL of the serialized pipeline.
  62150. * @returns An instantiated pipeline from the serialized object.
  62151. */
  62152. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62153. }
  62154. }
  62155. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62156. /** @hidden */
  62157. export var lensHighlightsPixelShader: {
  62158. name: string;
  62159. shader: string;
  62160. };
  62161. }
  62162. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62163. /** @hidden */
  62164. export var depthOfFieldPixelShader: {
  62165. name: string;
  62166. shader: string;
  62167. };
  62168. }
  62169. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62170. import { Camera } from "babylonjs/Cameras/camera";
  62171. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62172. import { Scene } from "babylonjs/scene";
  62173. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62174. import "babylonjs/Shaders/chromaticAberration.fragment";
  62175. import "babylonjs/Shaders/lensHighlights.fragment";
  62176. import "babylonjs/Shaders/depthOfField.fragment";
  62177. /**
  62178. * BABYLON.JS Chromatic Aberration GLSL Shader
  62179. * Author: Olivier Guyot
  62180. * Separates very slightly R, G and B colors on the edges of the screen
  62181. * Inspired by Francois Tarlier & Martins Upitis
  62182. */
  62183. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62184. /**
  62185. * @ignore
  62186. * The chromatic aberration PostProcess id in the pipeline
  62187. */
  62188. LensChromaticAberrationEffect: string;
  62189. /**
  62190. * @ignore
  62191. * The highlights enhancing PostProcess id in the pipeline
  62192. */
  62193. HighlightsEnhancingEffect: string;
  62194. /**
  62195. * @ignore
  62196. * The depth-of-field PostProcess id in the pipeline
  62197. */
  62198. LensDepthOfFieldEffect: string;
  62199. private _scene;
  62200. private _depthTexture;
  62201. private _grainTexture;
  62202. private _chromaticAberrationPostProcess;
  62203. private _highlightsPostProcess;
  62204. private _depthOfFieldPostProcess;
  62205. private _edgeBlur;
  62206. private _grainAmount;
  62207. private _chromaticAberration;
  62208. private _distortion;
  62209. private _highlightsGain;
  62210. private _highlightsThreshold;
  62211. private _dofDistance;
  62212. private _dofAperture;
  62213. private _dofDarken;
  62214. private _dofPentagon;
  62215. private _blurNoise;
  62216. /**
  62217. * @constructor
  62218. *
  62219. * Effect parameters are as follow:
  62220. * {
  62221. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62222. * edge_blur: number; // from 0 to x (1 for realism)
  62223. * distortion: number; // from 0 to x (1 for realism)
  62224. * grain_amount: number; // from 0 to 1
  62225. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62226. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62227. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62228. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62229. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62230. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62231. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62232. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62233. * }
  62234. * Note: if an effect parameter is unset, effect is disabled
  62235. *
  62236. * @param name The rendering pipeline name
  62237. * @param parameters - An object containing all parameters (see above)
  62238. * @param scene The scene linked to this pipeline
  62239. * @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)
  62240. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62241. */
  62242. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62243. /**
  62244. * Get the class name
  62245. * @returns "LensRenderingPipeline"
  62246. */
  62247. getClassName(): string;
  62248. /**
  62249. * Gets associated scene
  62250. */
  62251. readonly scene: Scene;
  62252. /**
  62253. * Gets or sets the edge blur
  62254. */
  62255. edgeBlur: number;
  62256. /**
  62257. * Gets or sets the grain amount
  62258. */
  62259. grainAmount: number;
  62260. /**
  62261. * Gets or sets the chromatic aberration amount
  62262. */
  62263. chromaticAberration: number;
  62264. /**
  62265. * Gets or sets the depth of field aperture
  62266. */
  62267. dofAperture: number;
  62268. /**
  62269. * Gets or sets the edge distortion
  62270. */
  62271. edgeDistortion: number;
  62272. /**
  62273. * Gets or sets the depth of field distortion
  62274. */
  62275. dofDistortion: number;
  62276. /**
  62277. * Gets or sets the darken out of focus amount
  62278. */
  62279. darkenOutOfFocus: number;
  62280. /**
  62281. * Gets or sets a boolean indicating if blur noise is enabled
  62282. */
  62283. blurNoise: boolean;
  62284. /**
  62285. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62286. */
  62287. pentagonBokeh: boolean;
  62288. /**
  62289. * Gets or sets the highlight grain amount
  62290. */
  62291. highlightsGain: number;
  62292. /**
  62293. * Gets or sets the highlight threshold
  62294. */
  62295. highlightsThreshold: number;
  62296. /**
  62297. * Sets the amount of blur at the edges
  62298. * @param amount blur amount
  62299. */
  62300. setEdgeBlur(amount: number): void;
  62301. /**
  62302. * Sets edge blur to 0
  62303. */
  62304. disableEdgeBlur(): void;
  62305. /**
  62306. * Sets the amout of grain
  62307. * @param amount Amount of grain
  62308. */
  62309. setGrainAmount(amount: number): void;
  62310. /**
  62311. * Set grain amount to 0
  62312. */
  62313. disableGrain(): void;
  62314. /**
  62315. * Sets the chromatic aberration amount
  62316. * @param amount amount of chromatic aberration
  62317. */
  62318. setChromaticAberration(amount: number): void;
  62319. /**
  62320. * Sets chromatic aberration amount to 0
  62321. */
  62322. disableChromaticAberration(): void;
  62323. /**
  62324. * Sets the EdgeDistortion amount
  62325. * @param amount amount of EdgeDistortion
  62326. */
  62327. setEdgeDistortion(amount: number): void;
  62328. /**
  62329. * Sets edge distortion to 0
  62330. */
  62331. disableEdgeDistortion(): void;
  62332. /**
  62333. * Sets the FocusDistance amount
  62334. * @param amount amount of FocusDistance
  62335. */
  62336. setFocusDistance(amount: number): void;
  62337. /**
  62338. * Disables depth of field
  62339. */
  62340. disableDepthOfField(): void;
  62341. /**
  62342. * Sets the Aperture amount
  62343. * @param amount amount of Aperture
  62344. */
  62345. setAperture(amount: number): void;
  62346. /**
  62347. * Sets the DarkenOutOfFocus amount
  62348. * @param amount amount of DarkenOutOfFocus
  62349. */
  62350. setDarkenOutOfFocus(amount: number): void;
  62351. private _pentagonBokehIsEnabled;
  62352. /**
  62353. * Creates a pentagon bokeh effect
  62354. */
  62355. enablePentagonBokeh(): void;
  62356. /**
  62357. * Disables the pentagon bokeh effect
  62358. */
  62359. disablePentagonBokeh(): void;
  62360. /**
  62361. * Enables noise blur
  62362. */
  62363. enableNoiseBlur(): void;
  62364. /**
  62365. * Disables noise blur
  62366. */
  62367. disableNoiseBlur(): void;
  62368. /**
  62369. * Sets the HighlightsGain amount
  62370. * @param amount amount of HighlightsGain
  62371. */
  62372. setHighlightsGain(amount: number): void;
  62373. /**
  62374. * Sets the HighlightsThreshold amount
  62375. * @param amount amount of HighlightsThreshold
  62376. */
  62377. setHighlightsThreshold(amount: number): void;
  62378. /**
  62379. * Disables highlights
  62380. */
  62381. disableHighlights(): void;
  62382. /**
  62383. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62384. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62385. */
  62386. dispose(disableDepthRender?: boolean): void;
  62387. private _createChromaticAberrationPostProcess;
  62388. private _createHighlightsPostProcess;
  62389. private _createDepthOfFieldPostProcess;
  62390. private _createGrainTexture;
  62391. }
  62392. }
  62393. declare module "babylonjs/Shaders/ssao2.fragment" {
  62394. /** @hidden */
  62395. export var ssao2PixelShader: {
  62396. name: string;
  62397. shader: string;
  62398. };
  62399. }
  62400. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62401. /** @hidden */
  62402. export var ssaoCombinePixelShader: {
  62403. name: string;
  62404. shader: string;
  62405. };
  62406. }
  62407. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62408. import { Camera } from "babylonjs/Cameras/camera";
  62409. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62410. import { Scene } from "babylonjs/scene";
  62411. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62412. import "babylonjs/Shaders/ssao2.fragment";
  62413. import "babylonjs/Shaders/ssaoCombine.fragment";
  62414. /**
  62415. * Render pipeline to produce ssao effect
  62416. */
  62417. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62418. /**
  62419. * @ignore
  62420. * The PassPostProcess id in the pipeline that contains the original scene color
  62421. */
  62422. SSAOOriginalSceneColorEffect: string;
  62423. /**
  62424. * @ignore
  62425. * The SSAO PostProcess id in the pipeline
  62426. */
  62427. SSAORenderEffect: string;
  62428. /**
  62429. * @ignore
  62430. * The horizontal blur PostProcess id in the pipeline
  62431. */
  62432. SSAOBlurHRenderEffect: string;
  62433. /**
  62434. * @ignore
  62435. * The vertical blur PostProcess id in the pipeline
  62436. */
  62437. SSAOBlurVRenderEffect: string;
  62438. /**
  62439. * @ignore
  62440. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62441. */
  62442. SSAOCombineRenderEffect: string;
  62443. /**
  62444. * The output strength of the SSAO post-process. Default value is 1.0.
  62445. */
  62446. totalStrength: number;
  62447. /**
  62448. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62449. */
  62450. maxZ: number;
  62451. /**
  62452. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62453. */
  62454. minZAspect: number;
  62455. private _samples;
  62456. /**
  62457. * Number of samples used for the SSAO calculations. Default value is 8
  62458. */
  62459. samples: number;
  62460. private _textureSamples;
  62461. /**
  62462. * Number of samples to use for antialiasing
  62463. */
  62464. textureSamples: number;
  62465. /**
  62466. * Ratio object used for SSAO ratio and blur ratio
  62467. */
  62468. private _ratio;
  62469. /**
  62470. * Dynamically generated sphere sampler.
  62471. */
  62472. private _sampleSphere;
  62473. /**
  62474. * Blur filter offsets
  62475. */
  62476. private _samplerOffsets;
  62477. private _expensiveBlur;
  62478. /**
  62479. * If bilateral blur should be used
  62480. */
  62481. expensiveBlur: boolean;
  62482. /**
  62483. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62484. */
  62485. radius: number;
  62486. /**
  62487. * The base color of the SSAO post-process
  62488. * The final result is "base + ssao" between [0, 1]
  62489. */
  62490. base: number;
  62491. /**
  62492. * Support test.
  62493. */
  62494. static readonly IsSupported: boolean;
  62495. private _scene;
  62496. private _depthTexture;
  62497. private _normalTexture;
  62498. private _randomTexture;
  62499. private _originalColorPostProcess;
  62500. private _ssaoPostProcess;
  62501. private _blurHPostProcess;
  62502. private _blurVPostProcess;
  62503. private _ssaoCombinePostProcess;
  62504. private _firstUpdate;
  62505. /**
  62506. * Gets active scene
  62507. */
  62508. readonly scene: Scene;
  62509. /**
  62510. * @constructor
  62511. * @param name The rendering pipeline name
  62512. * @param scene The scene linked to this pipeline
  62513. * @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 }
  62514. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62515. */
  62516. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62517. /**
  62518. * Get the class name
  62519. * @returns "SSAO2RenderingPipeline"
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62524. */
  62525. dispose(disableGeometryBufferRenderer?: boolean): void;
  62526. private _createBlurPostProcess;
  62527. /** @hidden */
  62528. _rebuild(): void;
  62529. private _bits;
  62530. private _radicalInverse_VdC;
  62531. private _hammersley;
  62532. private _hemisphereSample_uniform;
  62533. private _generateHemisphere;
  62534. private _createSSAOPostProcess;
  62535. private _createSSAOCombinePostProcess;
  62536. private _createRandomTexture;
  62537. /**
  62538. * Serialize the rendering pipeline (Used when exporting)
  62539. * @returns the serialized object
  62540. */
  62541. serialize(): any;
  62542. /**
  62543. * Parse the serialized pipeline
  62544. * @param source Source pipeline.
  62545. * @param scene The scene to load the pipeline to.
  62546. * @param rootUrl The URL of the serialized pipeline.
  62547. * @returns An instantiated pipeline from the serialized object.
  62548. */
  62549. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62550. }
  62551. }
  62552. declare module "babylonjs/Shaders/ssao.fragment" {
  62553. /** @hidden */
  62554. export var ssaoPixelShader: {
  62555. name: string;
  62556. shader: string;
  62557. };
  62558. }
  62559. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62560. import { Camera } from "babylonjs/Cameras/camera";
  62561. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62562. import { Scene } from "babylonjs/scene";
  62563. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62564. import "babylonjs/Shaders/ssao.fragment";
  62565. import "babylonjs/Shaders/ssaoCombine.fragment";
  62566. /**
  62567. * Render pipeline to produce ssao effect
  62568. */
  62569. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62570. /**
  62571. * @ignore
  62572. * The PassPostProcess id in the pipeline that contains the original scene color
  62573. */
  62574. SSAOOriginalSceneColorEffect: string;
  62575. /**
  62576. * @ignore
  62577. * The SSAO PostProcess id in the pipeline
  62578. */
  62579. SSAORenderEffect: string;
  62580. /**
  62581. * @ignore
  62582. * The horizontal blur PostProcess id in the pipeline
  62583. */
  62584. SSAOBlurHRenderEffect: string;
  62585. /**
  62586. * @ignore
  62587. * The vertical blur PostProcess id in the pipeline
  62588. */
  62589. SSAOBlurVRenderEffect: string;
  62590. /**
  62591. * @ignore
  62592. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62593. */
  62594. SSAOCombineRenderEffect: string;
  62595. /**
  62596. * The output strength of the SSAO post-process. Default value is 1.0.
  62597. */
  62598. totalStrength: number;
  62599. /**
  62600. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62601. */
  62602. radius: number;
  62603. /**
  62604. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62605. * Must not be equal to fallOff and superior to fallOff.
  62606. * Default value is 0.0075
  62607. */
  62608. area: number;
  62609. /**
  62610. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62611. * Must not be equal to area and inferior to area.
  62612. * Default value is 0.000001
  62613. */
  62614. fallOff: number;
  62615. /**
  62616. * The base color of the SSAO post-process
  62617. * The final result is "base + ssao" between [0, 1]
  62618. */
  62619. base: number;
  62620. private _scene;
  62621. private _depthTexture;
  62622. private _randomTexture;
  62623. private _originalColorPostProcess;
  62624. private _ssaoPostProcess;
  62625. private _blurHPostProcess;
  62626. private _blurVPostProcess;
  62627. private _ssaoCombinePostProcess;
  62628. private _firstUpdate;
  62629. /**
  62630. * Gets active scene
  62631. */
  62632. readonly scene: Scene;
  62633. /**
  62634. * @constructor
  62635. * @param name - The rendering pipeline name
  62636. * @param scene - The scene linked to this pipeline
  62637. * @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 }
  62638. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62639. */
  62640. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62641. /**
  62642. * Get the class name
  62643. * @returns "SSAORenderingPipeline"
  62644. */
  62645. getClassName(): string;
  62646. /**
  62647. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62648. */
  62649. dispose(disableDepthRender?: boolean): void;
  62650. private _createBlurPostProcess;
  62651. /** @hidden */
  62652. _rebuild(): void;
  62653. private _createSSAOPostProcess;
  62654. private _createSSAOCombinePostProcess;
  62655. private _createRandomTexture;
  62656. }
  62657. }
  62658. declare module "babylonjs/Shaders/standard.fragment" {
  62659. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62660. /** @hidden */
  62661. export var standardPixelShader: {
  62662. name: string;
  62663. shader: string;
  62664. };
  62665. }
  62666. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62667. import { Nullable } from "babylonjs/types";
  62668. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62669. import { Camera } from "babylonjs/Cameras/camera";
  62670. import { Texture } from "babylonjs/Materials/Textures/texture";
  62671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62672. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62673. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62674. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62675. import { IDisposable } from "babylonjs/scene";
  62676. import { SpotLight } from "babylonjs/Lights/spotLight";
  62677. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62678. import { Scene } from "babylonjs/scene";
  62679. import { Animation } from "babylonjs/Animations/animation";
  62680. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62681. import "babylonjs/Shaders/standard.fragment";
  62682. /**
  62683. * Standard rendering pipeline
  62684. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62685. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62686. */
  62687. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62688. /**
  62689. * Public members
  62690. */
  62691. /**
  62692. * Post-process which contains the original scene color before the pipeline applies all the effects
  62693. */
  62694. originalPostProcess: Nullable<PostProcess>;
  62695. /**
  62696. * Post-process used to down scale an image x4
  62697. */
  62698. downSampleX4PostProcess: Nullable<PostProcess>;
  62699. /**
  62700. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62701. */
  62702. brightPassPostProcess: Nullable<PostProcess>;
  62703. /**
  62704. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62705. */
  62706. blurHPostProcesses: PostProcess[];
  62707. /**
  62708. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62709. */
  62710. blurVPostProcesses: PostProcess[];
  62711. /**
  62712. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62713. */
  62714. textureAdderPostProcess: Nullable<PostProcess>;
  62715. /**
  62716. * Post-process used to create volumetric lighting effect
  62717. */
  62718. volumetricLightPostProcess: Nullable<PostProcess>;
  62719. /**
  62720. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62721. */
  62722. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62723. /**
  62724. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62725. */
  62726. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62727. /**
  62728. * Post-process used to merge the volumetric light effect and the real scene color
  62729. */
  62730. volumetricLightMergePostProces: Nullable<PostProcess>;
  62731. /**
  62732. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62733. */
  62734. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62735. /**
  62736. * Base post-process used to calculate the average luminance of the final image for HDR
  62737. */
  62738. luminancePostProcess: Nullable<PostProcess>;
  62739. /**
  62740. * Post-processes used to create down sample post-processes in order to get
  62741. * the average luminance of the final image for HDR
  62742. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62743. */
  62744. luminanceDownSamplePostProcesses: PostProcess[];
  62745. /**
  62746. * Post-process used to create a HDR effect (light adaptation)
  62747. */
  62748. hdrPostProcess: Nullable<PostProcess>;
  62749. /**
  62750. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62751. */
  62752. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62753. /**
  62754. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62755. */
  62756. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62757. /**
  62758. * Post-process used to merge the final HDR post-process and the real scene color
  62759. */
  62760. hdrFinalPostProcess: Nullable<PostProcess>;
  62761. /**
  62762. * Post-process used to create a lens flare effect
  62763. */
  62764. lensFlarePostProcess: Nullable<PostProcess>;
  62765. /**
  62766. * Post-process that merges the result of the lens flare post-process and the real scene color
  62767. */
  62768. lensFlareComposePostProcess: Nullable<PostProcess>;
  62769. /**
  62770. * Post-process used to create a motion blur effect
  62771. */
  62772. motionBlurPostProcess: Nullable<PostProcess>;
  62773. /**
  62774. * Post-process used to create a depth of field effect
  62775. */
  62776. depthOfFieldPostProcess: Nullable<PostProcess>;
  62777. /**
  62778. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62779. */
  62780. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62781. /**
  62782. * Represents the brightness threshold in order to configure the illuminated surfaces
  62783. */
  62784. brightThreshold: number;
  62785. /**
  62786. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62787. */
  62788. blurWidth: number;
  62789. /**
  62790. * Sets if the blur for highlighted surfaces must be only horizontal
  62791. */
  62792. horizontalBlur: boolean;
  62793. /**
  62794. * Gets the overall exposure used by the pipeline
  62795. */
  62796. /**
  62797. * Sets the overall exposure used by the pipeline
  62798. */
  62799. exposure: number;
  62800. /**
  62801. * Texture used typically to simulate "dirty" on camera lens
  62802. */
  62803. lensTexture: Nullable<Texture>;
  62804. /**
  62805. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62806. */
  62807. volumetricLightCoefficient: number;
  62808. /**
  62809. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62810. */
  62811. volumetricLightPower: number;
  62812. /**
  62813. * Used the set the blur intensity to smooth the volumetric lights
  62814. */
  62815. volumetricLightBlurScale: number;
  62816. /**
  62817. * Light (spot or directional) used to generate the volumetric lights rays
  62818. * The source light must have a shadow generate so the pipeline can get its
  62819. * depth map
  62820. */
  62821. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62822. /**
  62823. * For eye adaptation, represents the minimum luminance the eye can see
  62824. */
  62825. hdrMinimumLuminance: number;
  62826. /**
  62827. * For eye adaptation, represents the decrease luminance speed
  62828. */
  62829. hdrDecreaseRate: number;
  62830. /**
  62831. * For eye adaptation, represents the increase luminance speed
  62832. */
  62833. hdrIncreaseRate: number;
  62834. /**
  62835. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62836. */
  62837. /**
  62838. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62839. */
  62840. hdrAutoExposure: boolean;
  62841. /**
  62842. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62843. */
  62844. lensColorTexture: Nullable<Texture>;
  62845. /**
  62846. * The overall strengh for the lens flare effect
  62847. */
  62848. lensFlareStrength: number;
  62849. /**
  62850. * Dispersion coefficient for lens flare ghosts
  62851. */
  62852. lensFlareGhostDispersal: number;
  62853. /**
  62854. * Main lens flare halo width
  62855. */
  62856. lensFlareHaloWidth: number;
  62857. /**
  62858. * Based on the lens distortion effect, defines how much the lens flare result
  62859. * is distorted
  62860. */
  62861. lensFlareDistortionStrength: number;
  62862. /**
  62863. * Configures the blur intensity used for for lens flare (halo)
  62864. */
  62865. lensFlareBlurWidth: number;
  62866. /**
  62867. * Lens star texture must be used to simulate rays on the flares and is available
  62868. * in the documentation
  62869. */
  62870. lensStarTexture: Nullable<Texture>;
  62871. /**
  62872. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62873. * flare effect by taking account of the dirt texture
  62874. */
  62875. lensFlareDirtTexture: Nullable<Texture>;
  62876. /**
  62877. * Represents the focal length for the depth of field effect
  62878. */
  62879. depthOfFieldDistance: number;
  62880. /**
  62881. * Represents the blur intensity for the blurred part of the depth of field effect
  62882. */
  62883. depthOfFieldBlurWidth: number;
  62884. /**
  62885. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62886. */
  62887. /**
  62888. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62889. */
  62890. motionStrength: number;
  62891. /**
  62892. * Gets wether or not the motion blur post-process is object based or screen based.
  62893. */
  62894. /**
  62895. * Sets wether or not the motion blur post-process should be object based or screen based
  62896. */
  62897. objectBasedMotionBlur: boolean;
  62898. /**
  62899. * List of animations for the pipeline (IAnimatable implementation)
  62900. */
  62901. animations: Animation[];
  62902. /**
  62903. * Private members
  62904. */
  62905. private _scene;
  62906. private _currentDepthOfFieldSource;
  62907. private _basePostProcess;
  62908. private _fixedExposure;
  62909. private _currentExposure;
  62910. private _hdrAutoExposure;
  62911. private _hdrCurrentLuminance;
  62912. private _motionStrength;
  62913. private _isObjectBasedMotionBlur;
  62914. private _floatTextureType;
  62915. private _camerasToBeAttached;
  62916. private _ratio;
  62917. private _bloomEnabled;
  62918. private _depthOfFieldEnabled;
  62919. private _vlsEnabled;
  62920. private _lensFlareEnabled;
  62921. private _hdrEnabled;
  62922. private _motionBlurEnabled;
  62923. private _fxaaEnabled;
  62924. private _motionBlurSamples;
  62925. private _volumetricLightStepsCount;
  62926. private _samples;
  62927. /**
  62928. * @ignore
  62929. * Specifies if the bloom pipeline is enabled
  62930. */
  62931. BloomEnabled: boolean;
  62932. /**
  62933. * @ignore
  62934. * Specifies if the depth of field pipeline is enabed
  62935. */
  62936. DepthOfFieldEnabled: boolean;
  62937. /**
  62938. * @ignore
  62939. * Specifies if the lens flare pipeline is enabed
  62940. */
  62941. LensFlareEnabled: boolean;
  62942. /**
  62943. * @ignore
  62944. * Specifies if the HDR pipeline is enabled
  62945. */
  62946. HDREnabled: boolean;
  62947. /**
  62948. * @ignore
  62949. * Specifies if the volumetric lights scattering effect is enabled
  62950. */
  62951. VLSEnabled: boolean;
  62952. /**
  62953. * @ignore
  62954. * Specifies if the motion blur effect is enabled
  62955. */
  62956. MotionBlurEnabled: boolean;
  62957. /**
  62958. * Specifies if anti-aliasing is enabled
  62959. */
  62960. fxaaEnabled: boolean;
  62961. /**
  62962. * Specifies the number of steps used to calculate the volumetric lights
  62963. * Typically in interval [50, 200]
  62964. */
  62965. volumetricLightStepsCount: number;
  62966. /**
  62967. * Specifies the number of samples used for the motion blur effect
  62968. * Typically in interval [16, 64]
  62969. */
  62970. motionBlurSamples: number;
  62971. /**
  62972. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62973. */
  62974. samples: number;
  62975. /**
  62976. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62977. * @constructor
  62978. * @param name The rendering pipeline name
  62979. * @param scene The scene linked to this pipeline
  62980. * @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)
  62981. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62982. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62983. */
  62984. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62985. private _buildPipeline;
  62986. private _createDownSampleX4PostProcess;
  62987. private _createBrightPassPostProcess;
  62988. private _createBlurPostProcesses;
  62989. private _createTextureAdderPostProcess;
  62990. private _createVolumetricLightPostProcess;
  62991. private _createLuminancePostProcesses;
  62992. private _createHdrPostProcess;
  62993. private _createLensFlarePostProcess;
  62994. private _createDepthOfFieldPostProcess;
  62995. private _createMotionBlurPostProcess;
  62996. private _getDepthTexture;
  62997. private _disposePostProcesses;
  62998. /**
  62999. * Dispose of the pipeline and stop all post processes
  63000. */
  63001. dispose(): void;
  63002. /**
  63003. * Serialize the rendering pipeline (Used when exporting)
  63004. * @returns the serialized object
  63005. */
  63006. serialize(): any;
  63007. /**
  63008. * Parse the serialized pipeline
  63009. * @param source Source pipeline.
  63010. * @param scene The scene to load the pipeline to.
  63011. * @param rootUrl The URL of the serialized pipeline.
  63012. * @returns An instantiated pipeline from the serialized object.
  63013. */
  63014. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63015. /**
  63016. * Luminance steps
  63017. */
  63018. static LuminanceSteps: number;
  63019. }
  63020. }
  63021. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63022. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63023. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63024. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63025. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63026. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63027. }
  63028. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63029. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63030. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63031. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63032. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63033. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63034. }
  63035. declare module "babylonjs/Shaders/tonemap.fragment" {
  63036. /** @hidden */
  63037. export var tonemapPixelShader: {
  63038. name: string;
  63039. shader: string;
  63040. };
  63041. }
  63042. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63043. import { Camera } from "babylonjs/Cameras/camera";
  63044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63045. import "babylonjs/Shaders/tonemap.fragment";
  63046. import { Engine } from "babylonjs/Engines/engine";
  63047. /** Defines operator used for tonemapping */
  63048. export enum TonemappingOperator {
  63049. /** Hable */
  63050. Hable = 0,
  63051. /** Reinhard */
  63052. Reinhard = 1,
  63053. /** HejiDawson */
  63054. HejiDawson = 2,
  63055. /** Photographic */
  63056. Photographic = 3
  63057. }
  63058. /**
  63059. * Defines a post process to apply tone mapping
  63060. */
  63061. export class TonemapPostProcess extends PostProcess {
  63062. private _operator;
  63063. /** Defines the required exposure adjustement */
  63064. exposureAdjustment: number;
  63065. /**
  63066. * Creates a new TonemapPostProcess
  63067. * @param name defines the name of the postprocess
  63068. * @param _operator defines the operator to use
  63069. * @param exposureAdjustment defines the required exposure adjustement
  63070. * @param camera defines the camera to use (can be null)
  63071. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63072. * @param engine defines the hosting engine (can be ignore if camera is set)
  63073. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63074. */
  63075. constructor(name: string, _operator: TonemappingOperator,
  63076. /** Defines the required exposure adjustement */
  63077. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63078. }
  63079. }
  63080. declare module "babylonjs/Shaders/depth.vertex" {
  63081. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63083. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63085. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63086. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63087. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63088. /** @hidden */
  63089. export var depthVertexShader: {
  63090. name: string;
  63091. shader: string;
  63092. };
  63093. }
  63094. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63095. /** @hidden */
  63096. export var volumetricLightScatteringPixelShader: {
  63097. name: string;
  63098. shader: string;
  63099. };
  63100. }
  63101. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63102. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63104. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63105. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63106. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63107. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63108. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63109. /** @hidden */
  63110. export var volumetricLightScatteringPassVertexShader: {
  63111. name: string;
  63112. shader: string;
  63113. };
  63114. }
  63115. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63116. /** @hidden */
  63117. export var volumetricLightScatteringPassPixelShader: {
  63118. name: string;
  63119. shader: string;
  63120. };
  63121. }
  63122. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63123. import { Vector3 } from "babylonjs/Maths/math.vector";
  63124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63125. import { Mesh } from "babylonjs/Meshes/mesh";
  63126. import { Camera } from "babylonjs/Cameras/camera";
  63127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63128. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63129. import { Scene } from "babylonjs/scene";
  63130. import "babylonjs/Meshes/Builders/planeBuilder";
  63131. import "babylonjs/Shaders/depth.vertex";
  63132. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63133. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63134. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63135. import { Engine } from "babylonjs/Engines/engine";
  63136. /**
  63137. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63138. */
  63139. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63140. private _volumetricLightScatteringPass;
  63141. private _volumetricLightScatteringRTT;
  63142. private _viewPort;
  63143. private _screenCoordinates;
  63144. private _cachedDefines;
  63145. /**
  63146. * If not undefined, the mesh position is computed from the attached node position
  63147. */
  63148. attachedNode: {
  63149. position: Vector3;
  63150. };
  63151. /**
  63152. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63153. */
  63154. customMeshPosition: Vector3;
  63155. /**
  63156. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63157. */
  63158. useCustomMeshPosition: boolean;
  63159. /**
  63160. * If the post-process should inverse the light scattering direction
  63161. */
  63162. invert: boolean;
  63163. /**
  63164. * The internal mesh used by the post-process
  63165. */
  63166. mesh: Mesh;
  63167. /**
  63168. * @hidden
  63169. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63170. */
  63171. useDiffuseColor: boolean;
  63172. /**
  63173. * Array containing the excluded meshes not rendered in the internal pass
  63174. */
  63175. excludedMeshes: AbstractMesh[];
  63176. /**
  63177. * Controls the overall intensity of the post-process
  63178. */
  63179. exposure: number;
  63180. /**
  63181. * Dissipates each sample's contribution in range [0, 1]
  63182. */
  63183. decay: number;
  63184. /**
  63185. * Controls the overall intensity of each sample
  63186. */
  63187. weight: number;
  63188. /**
  63189. * Controls the density of each sample
  63190. */
  63191. density: number;
  63192. /**
  63193. * @constructor
  63194. * @param name The post-process name
  63195. * @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)
  63196. * @param camera The camera that the post-process will be attached to
  63197. * @param mesh The mesh used to create the light scattering
  63198. * @param samples The post-process quality, default 100
  63199. * @param samplingModeThe post-process filtering mode
  63200. * @param engine The babylon engine
  63201. * @param reusable If the post-process is reusable
  63202. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63203. */
  63204. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63205. /**
  63206. * Returns the string "VolumetricLightScatteringPostProcess"
  63207. * @returns "VolumetricLightScatteringPostProcess"
  63208. */
  63209. getClassName(): string;
  63210. private _isReady;
  63211. /**
  63212. * Sets the new light position for light scattering effect
  63213. * @param position The new custom light position
  63214. */
  63215. setCustomMeshPosition(position: Vector3): void;
  63216. /**
  63217. * Returns the light position for light scattering effect
  63218. * @return Vector3 The custom light position
  63219. */
  63220. getCustomMeshPosition(): Vector3;
  63221. /**
  63222. * Disposes the internal assets and detaches the post-process from the camera
  63223. */
  63224. dispose(camera: Camera): void;
  63225. /**
  63226. * Returns the render target texture used by the post-process
  63227. * @return the render target texture used by the post-process
  63228. */
  63229. getPass(): RenderTargetTexture;
  63230. private _meshExcluded;
  63231. private _createPass;
  63232. private _updateMeshScreenCoordinates;
  63233. /**
  63234. * Creates a default mesh for the Volumeric Light Scattering post-process
  63235. * @param name The mesh name
  63236. * @param scene The scene where to create the mesh
  63237. * @return the default mesh
  63238. */
  63239. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63240. }
  63241. }
  63242. declare module "babylonjs/PostProcesses/index" {
  63243. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63244. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63245. export * from "babylonjs/PostProcesses/bloomEffect";
  63246. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63247. export * from "babylonjs/PostProcesses/blurPostProcess";
  63248. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63249. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63250. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63251. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63252. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63253. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63254. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63255. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63256. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63257. export * from "babylonjs/PostProcesses/filterPostProcess";
  63258. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63259. export * from "babylonjs/PostProcesses/grainPostProcess";
  63260. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63261. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63262. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63263. export * from "babylonjs/PostProcesses/passPostProcess";
  63264. export * from "babylonjs/PostProcesses/postProcess";
  63265. export * from "babylonjs/PostProcesses/postProcessManager";
  63266. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63267. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63268. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63269. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63270. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63271. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63272. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63273. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63274. }
  63275. declare module "babylonjs/Probes/index" {
  63276. export * from "babylonjs/Probes/reflectionProbe";
  63277. }
  63278. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63279. import { Scene } from "babylonjs/scene";
  63280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63281. import { SmartArray } from "babylonjs/Misc/smartArray";
  63282. import { ISceneComponent } from "babylonjs/sceneComponent";
  63283. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63284. import "babylonjs/Meshes/Builders/boxBuilder";
  63285. import "babylonjs/Shaders/color.fragment";
  63286. import "babylonjs/Shaders/color.vertex";
  63287. import { Color3 } from "babylonjs/Maths/math.color";
  63288. module "babylonjs/scene" {
  63289. interface Scene {
  63290. /** @hidden (Backing field) */
  63291. _boundingBoxRenderer: BoundingBoxRenderer;
  63292. /** @hidden (Backing field) */
  63293. _forceShowBoundingBoxes: boolean;
  63294. /**
  63295. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63296. */
  63297. forceShowBoundingBoxes: boolean;
  63298. /**
  63299. * Gets the bounding box renderer associated with the scene
  63300. * @returns a BoundingBoxRenderer
  63301. */
  63302. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63303. }
  63304. }
  63305. module "babylonjs/Meshes/abstractMesh" {
  63306. interface AbstractMesh {
  63307. /** @hidden (Backing field) */
  63308. _showBoundingBox: boolean;
  63309. /**
  63310. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63311. */
  63312. showBoundingBox: boolean;
  63313. }
  63314. }
  63315. /**
  63316. * Component responsible of rendering the bounding box of the meshes in a scene.
  63317. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63318. */
  63319. export class BoundingBoxRenderer implements ISceneComponent {
  63320. /**
  63321. * The component name helpfull to identify the component in the list of scene components.
  63322. */
  63323. readonly name: string;
  63324. /**
  63325. * The scene the component belongs to.
  63326. */
  63327. scene: Scene;
  63328. /**
  63329. * Color of the bounding box lines placed in front of an object
  63330. */
  63331. frontColor: Color3;
  63332. /**
  63333. * Color of the bounding box lines placed behind an object
  63334. */
  63335. backColor: Color3;
  63336. /**
  63337. * Defines if the renderer should show the back lines or not
  63338. */
  63339. showBackLines: boolean;
  63340. /**
  63341. * @hidden
  63342. */
  63343. renderList: SmartArray<BoundingBox>;
  63344. private _colorShader;
  63345. private _vertexBuffers;
  63346. private _indexBuffer;
  63347. private _fillIndexBuffer;
  63348. private _fillIndexData;
  63349. /**
  63350. * Instantiates a new bounding box renderer in a scene.
  63351. * @param scene the scene the renderer renders in
  63352. */
  63353. constructor(scene: Scene);
  63354. /**
  63355. * Registers the component in a given scene
  63356. */
  63357. register(): void;
  63358. private _evaluateSubMesh;
  63359. private _activeMesh;
  63360. private _prepareRessources;
  63361. private _createIndexBuffer;
  63362. /**
  63363. * Rebuilds the elements related to this component in case of
  63364. * context lost for instance.
  63365. */
  63366. rebuild(): void;
  63367. /**
  63368. * @hidden
  63369. */
  63370. reset(): void;
  63371. /**
  63372. * Render the bounding boxes of a specific rendering group
  63373. * @param renderingGroupId defines the rendering group to render
  63374. */
  63375. render(renderingGroupId: number): void;
  63376. /**
  63377. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63378. * @param mesh Define the mesh to render the occlusion bounding box for
  63379. */
  63380. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63381. /**
  63382. * Dispose and release the resources attached to this renderer.
  63383. */
  63384. dispose(): void;
  63385. }
  63386. }
  63387. declare module "babylonjs/Shaders/depth.fragment" {
  63388. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63389. /** @hidden */
  63390. export var depthPixelShader: {
  63391. name: string;
  63392. shader: string;
  63393. };
  63394. }
  63395. declare module "babylonjs/Rendering/depthRenderer" {
  63396. import { Nullable } from "babylonjs/types";
  63397. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63398. import { Scene } from "babylonjs/scene";
  63399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63400. import { Camera } from "babylonjs/Cameras/camera";
  63401. import "babylonjs/Shaders/depth.fragment";
  63402. import "babylonjs/Shaders/depth.vertex";
  63403. /**
  63404. * This represents a depth renderer in Babylon.
  63405. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63406. */
  63407. export class DepthRenderer {
  63408. private _scene;
  63409. private _depthMap;
  63410. private _effect;
  63411. private readonly _storeNonLinearDepth;
  63412. private readonly _clearColor;
  63413. /** Get if the depth renderer is using packed depth or not */
  63414. readonly isPacked: boolean;
  63415. private _cachedDefines;
  63416. private _camera;
  63417. /**
  63418. * Specifiess that the depth renderer will only be used within
  63419. * the camera it is created for.
  63420. * This can help forcing its rendering during the camera processing.
  63421. */
  63422. useOnlyInActiveCamera: boolean;
  63423. /** @hidden */
  63424. static _SceneComponentInitialization: (scene: Scene) => void;
  63425. /**
  63426. * Instantiates a depth renderer
  63427. * @param scene The scene the renderer belongs to
  63428. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63429. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63430. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63431. */
  63432. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63433. /**
  63434. * Creates the depth rendering effect and checks if the effect is ready.
  63435. * @param subMesh The submesh to be used to render the depth map of
  63436. * @param useInstances If multiple world instances should be used
  63437. * @returns if the depth renderer is ready to render the depth map
  63438. */
  63439. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63440. /**
  63441. * Gets the texture which the depth map will be written to.
  63442. * @returns The depth map texture
  63443. */
  63444. getDepthMap(): RenderTargetTexture;
  63445. /**
  63446. * Disposes of the depth renderer.
  63447. */
  63448. dispose(): void;
  63449. }
  63450. }
  63451. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63452. import { Nullable } from "babylonjs/types";
  63453. import { Scene } from "babylonjs/scene";
  63454. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63455. import { Camera } from "babylonjs/Cameras/camera";
  63456. import { ISceneComponent } from "babylonjs/sceneComponent";
  63457. module "babylonjs/scene" {
  63458. interface Scene {
  63459. /** @hidden (Backing field) */
  63460. _depthRenderer: {
  63461. [id: string]: DepthRenderer;
  63462. };
  63463. /**
  63464. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63465. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63466. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63467. * @returns the created depth renderer
  63468. */
  63469. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63470. /**
  63471. * Disables a depth renderer for a given camera
  63472. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63473. */
  63474. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63475. }
  63476. }
  63477. /**
  63478. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63479. * in several rendering techniques.
  63480. */
  63481. export class DepthRendererSceneComponent implements ISceneComponent {
  63482. /**
  63483. * The component name helpfull to identify the component in the list of scene components.
  63484. */
  63485. readonly name: string;
  63486. /**
  63487. * The scene the component belongs to.
  63488. */
  63489. scene: Scene;
  63490. /**
  63491. * Creates a new instance of the component for the given scene
  63492. * @param scene Defines the scene to register the component in
  63493. */
  63494. constructor(scene: Scene);
  63495. /**
  63496. * Registers the component in a given scene
  63497. */
  63498. register(): void;
  63499. /**
  63500. * Rebuilds the elements related to this component in case of
  63501. * context lost for instance.
  63502. */
  63503. rebuild(): void;
  63504. /**
  63505. * Disposes the component and the associated ressources
  63506. */
  63507. dispose(): void;
  63508. private _gatherRenderTargets;
  63509. private _gatherActiveCameraRenderTargets;
  63510. }
  63511. }
  63512. declare module "babylonjs/Shaders/outline.fragment" {
  63513. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63514. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63515. /** @hidden */
  63516. export var outlinePixelShader: {
  63517. name: string;
  63518. shader: string;
  63519. };
  63520. }
  63521. declare module "babylonjs/Shaders/outline.vertex" {
  63522. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63524. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63525. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63526. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63528. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63529. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63530. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63531. /** @hidden */
  63532. export var outlineVertexShader: {
  63533. name: string;
  63534. shader: string;
  63535. };
  63536. }
  63537. declare module "babylonjs/Rendering/outlineRenderer" {
  63538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63539. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63540. import { Scene } from "babylonjs/scene";
  63541. import { ISceneComponent } from "babylonjs/sceneComponent";
  63542. import "babylonjs/Shaders/outline.fragment";
  63543. import "babylonjs/Shaders/outline.vertex";
  63544. module "babylonjs/scene" {
  63545. interface Scene {
  63546. /** @hidden */
  63547. _outlineRenderer: OutlineRenderer;
  63548. /**
  63549. * Gets the outline renderer associated with the scene
  63550. * @returns a OutlineRenderer
  63551. */
  63552. getOutlineRenderer(): OutlineRenderer;
  63553. }
  63554. }
  63555. module "babylonjs/Meshes/abstractMesh" {
  63556. interface AbstractMesh {
  63557. /** @hidden (Backing field) */
  63558. _renderOutline: boolean;
  63559. /**
  63560. * Gets or sets a boolean indicating if the outline must be rendered as well
  63561. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63562. */
  63563. renderOutline: boolean;
  63564. /** @hidden (Backing field) */
  63565. _renderOverlay: boolean;
  63566. /**
  63567. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63568. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63569. */
  63570. renderOverlay: boolean;
  63571. }
  63572. }
  63573. /**
  63574. * This class is responsible to draw bothe outline/overlay of meshes.
  63575. * It should not be used directly but through the available method on mesh.
  63576. */
  63577. export class OutlineRenderer implements ISceneComponent {
  63578. /**
  63579. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63580. */
  63581. private static _StencilReference;
  63582. /**
  63583. * The name of the component. Each component must have a unique name.
  63584. */
  63585. name: string;
  63586. /**
  63587. * The scene the component belongs to.
  63588. */
  63589. scene: Scene;
  63590. /**
  63591. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63592. */
  63593. zOffset: number;
  63594. private _engine;
  63595. private _effect;
  63596. private _cachedDefines;
  63597. private _savedDepthWrite;
  63598. /**
  63599. * Instantiates a new outline renderer. (There could be only one per scene).
  63600. * @param scene Defines the scene it belongs to
  63601. */
  63602. constructor(scene: Scene);
  63603. /**
  63604. * Register the component to one instance of a scene.
  63605. */
  63606. register(): void;
  63607. /**
  63608. * Rebuilds the elements related to this component in case of
  63609. * context lost for instance.
  63610. */
  63611. rebuild(): void;
  63612. /**
  63613. * Disposes the component and the associated ressources.
  63614. */
  63615. dispose(): void;
  63616. /**
  63617. * Renders the outline in the canvas.
  63618. * @param subMesh Defines the sumesh to render
  63619. * @param batch Defines the batch of meshes in case of instances
  63620. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63621. */
  63622. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63623. /**
  63624. * Returns whether or not the outline renderer is ready for a given submesh.
  63625. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63626. * @param subMesh Defines the submesh to check readyness for
  63627. * @param useInstances Defines wheter wee are trying to render instances or not
  63628. * @returns true if ready otherwise false
  63629. */
  63630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63631. private _beforeRenderingMesh;
  63632. private _afterRenderingMesh;
  63633. }
  63634. }
  63635. declare module "babylonjs/Rendering/index" {
  63636. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63637. export * from "babylonjs/Rendering/depthRenderer";
  63638. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63639. export * from "babylonjs/Rendering/edgesRenderer";
  63640. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63641. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63642. export * from "babylonjs/Rendering/outlineRenderer";
  63643. export * from "babylonjs/Rendering/renderingGroup";
  63644. export * from "babylonjs/Rendering/renderingManager";
  63645. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63646. }
  63647. declare module "babylonjs/Sprites/spritePackedManager" {
  63648. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63649. import { Scene } from "babylonjs/scene";
  63650. /**
  63651. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63652. * @see http://doc.babylonjs.com/babylon101/sprites
  63653. */
  63654. export class SpritePackedManager extends SpriteManager {
  63655. /** defines the packed manager's name */
  63656. name: string;
  63657. /**
  63658. * Creates a new sprite manager from a packed sprite sheet
  63659. * @param name defines the manager's name
  63660. * @param imgUrl defines the sprite sheet url
  63661. * @param capacity defines the maximum allowed number of sprites
  63662. * @param scene defines the hosting scene
  63663. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63664. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63665. * @param samplingMode defines the smapling mode to use with spritesheet
  63666. * @param fromPacked set to true; do not alter
  63667. */
  63668. constructor(
  63669. /** defines the packed manager's name */
  63670. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63671. }
  63672. }
  63673. declare module "babylonjs/Sprites/index" {
  63674. export * from "babylonjs/Sprites/sprite";
  63675. export * from "babylonjs/Sprites/spriteManager";
  63676. export * from "babylonjs/Sprites/spritePackedManager";
  63677. export * from "babylonjs/Sprites/spriteSceneComponent";
  63678. }
  63679. declare module "babylonjs/Misc/assetsManager" {
  63680. import { Scene } from "babylonjs/scene";
  63681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63682. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63683. import { Skeleton } from "babylonjs/Bones/skeleton";
  63684. import { Observable } from "babylonjs/Misc/observable";
  63685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63686. import { Texture } from "babylonjs/Materials/Textures/texture";
  63687. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63688. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63689. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63690. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63691. /**
  63692. * Defines the list of states available for a task inside a AssetsManager
  63693. */
  63694. export enum AssetTaskState {
  63695. /**
  63696. * Initialization
  63697. */
  63698. INIT = 0,
  63699. /**
  63700. * Running
  63701. */
  63702. RUNNING = 1,
  63703. /**
  63704. * Done
  63705. */
  63706. DONE = 2,
  63707. /**
  63708. * Error
  63709. */
  63710. ERROR = 3
  63711. }
  63712. /**
  63713. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63714. */
  63715. export abstract class AbstractAssetTask {
  63716. /**
  63717. * Task name
  63718. */ name: string;
  63719. /**
  63720. * Callback called when the task is successful
  63721. */
  63722. onSuccess: (task: any) => void;
  63723. /**
  63724. * Callback called when the task is not successful
  63725. */
  63726. onError: (task: any, message?: string, exception?: any) => void;
  63727. /**
  63728. * Creates a new AssetsManager
  63729. * @param name defines the name of the task
  63730. */
  63731. constructor(
  63732. /**
  63733. * Task name
  63734. */ name: string);
  63735. private _isCompleted;
  63736. private _taskState;
  63737. private _errorObject;
  63738. /**
  63739. * Get if the task is completed
  63740. */
  63741. readonly isCompleted: boolean;
  63742. /**
  63743. * Gets the current state of the task
  63744. */
  63745. readonly taskState: AssetTaskState;
  63746. /**
  63747. * Gets the current error object (if task is in error)
  63748. */
  63749. readonly errorObject: {
  63750. message?: string;
  63751. exception?: any;
  63752. };
  63753. /**
  63754. * Internal only
  63755. * @hidden
  63756. */
  63757. _setErrorObject(message?: string, exception?: any): void;
  63758. /**
  63759. * Execute the current task
  63760. * @param scene defines the scene where you want your assets to be loaded
  63761. * @param onSuccess is a callback called when the task is successfully executed
  63762. * @param onError is a callback called if an error occurs
  63763. */
  63764. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63765. /**
  63766. * Execute the current task
  63767. * @param scene defines the scene where you want your assets to be loaded
  63768. * @param onSuccess is a callback called when the task is successfully executed
  63769. * @param onError is a callback called if an error occurs
  63770. */
  63771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63772. /**
  63773. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63774. * This can be used with failed tasks that have the reason for failure fixed.
  63775. */
  63776. reset(): void;
  63777. private onErrorCallback;
  63778. private onDoneCallback;
  63779. }
  63780. /**
  63781. * Define the interface used by progress events raised during assets loading
  63782. */
  63783. export interface IAssetsProgressEvent {
  63784. /**
  63785. * Defines the number of remaining tasks to process
  63786. */
  63787. remainingCount: number;
  63788. /**
  63789. * Defines the total number of tasks
  63790. */
  63791. totalCount: number;
  63792. /**
  63793. * Defines the task that was just processed
  63794. */
  63795. task: AbstractAssetTask;
  63796. }
  63797. /**
  63798. * Class used to share progress information about assets loading
  63799. */
  63800. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63801. /**
  63802. * Defines the number of remaining tasks to process
  63803. */
  63804. remainingCount: number;
  63805. /**
  63806. * Defines the total number of tasks
  63807. */
  63808. totalCount: number;
  63809. /**
  63810. * Defines the task that was just processed
  63811. */
  63812. task: AbstractAssetTask;
  63813. /**
  63814. * Creates a AssetsProgressEvent
  63815. * @param remainingCount defines the number of remaining tasks to process
  63816. * @param totalCount defines the total number of tasks
  63817. * @param task defines the task that was just processed
  63818. */
  63819. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63820. }
  63821. /**
  63822. * Define a task used by AssetsManager to load meshes
  63823. */
  63824. export class MeshAssetTask extends AbstractAssetTask {
  63825. /**
  63826. * Defines the name of the task
  63827. */
  63828. name: string;
  63829. /**
  63830. * Defines the list of mesh's names you want to load
  63831. */
  63832. meshesNames: any;
  63833. /**
  63834. * Defines the root url to use as a base to load your meshes and associated resources
  63835. */
  63836. rootUrl: string;
  63837. /**
  63838. * Defines the filename of the scene to load from
  63839. */
  63840. sceneFilename: string;
  63841. /**
  63842. * Gets the list of loaded meshes
  63843. */
  63844. loadedMeshes: Array<AbstractMesh>;
  63845. /**
  63846. * Gets the list of loaded particle systems
  63847. */
  63848. loadedParticleSystems: Array<IParticleSystem>;
  63849. /**
  63850. * Gets the list of loaded skeletons
  63851. */
  63852. loadedSkeletons: Array<Skeleton>;
  63853. /**
  63854. * Gets the list of loaded animation groups
  63855. */
  63856. loadedAnimationGroups: Array<AnimationGroup>;
  63857. /**
  63858. * Callback called when the task is successful
  63859. */
  63860. onSuccess: (task: MeshAssetTask) => void;
  63861. /**
  63862. * Callback called when the task is successful
  63863. */
  63864. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63865. /**
  63866. * Creates a new MeshAssetTask
  63867. * @param name defines the name of the task
  63868. * @param meshesNames defines the list of mesh's names you want to load
  63869. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63870. * @param sceneFilename defines the filename of the scene to load from
  63871. */
  63872. constructor(
  63873. /**
  63874. * Defines the name of the task
  63875. */
  63876. name: string,
  63877. /**
  63878. * Defines the list of mesh's names you want to load
  63879. */
  63880. meshesNames: any,
  63881. /**
  63882. * Defines the root url to use as a base to load your meshes and associated resources
  63883. */
  63884. rootUrl: string,
  63885. /**
  63886. * Defines the filename of the scene to load from
  63887. */
  63888. sceneFilename: string);
  63889. /**
  63890. * Execute the current task
  63891. * @param scene defines the scene where you want your assets to be loaded
  63892. * @param onSuccess is a callback called when the task is successfully executed
  63893. * @param onError is a callback called if an error occurs
  63894. */
  63895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63896. }
  63897. /**
  63898. * Define a task used by AssetsManager to load text content
  63899. */
  63900. export class TextFileAssetTask extends AbstractAssetTask {
  63901. /**
  63902. * Defines the name of the task
  63903. */
  63904. name: string;
  63905. /**
  63906. * Defines the location of the file to load
  63907. */
  63908. url: string;
  63909. /**
  63910. * Gets the loaded text string
  63911. */
  63912. text: string;
  63913. /**
  63914. * Callback called when the task is successful
  63915. */
  63916. onSuccess: (task: TextFileAssetTask) => void;
  63917. /**
  63918. * Callback called when the task is successful
  63919. */
  63920. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63921. /**
  63922. * Creates a new TextFileAssetTask object
  63923. * @param name defines the name of the task
  63924. * @param url defines the location of the file to load
  63925. */
  63926. constructor(
  63927. /**
  63928. * Defines the name of the task
  63929. */
  63930. name: string,
  63931. /**
  63932. * Defines the location of the file to load
  63933. */
  63934. url: string);
  63935. /**
  63936. * Execute the current task
  63937. * @param scene defines the scene where you want your assets to be loaded
  63938. * @param onSuccess is a callback called when the task is successfully executed
  63939. * @param onError is a callback called if an error occurs
  63940. */
  63941. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63942. }
  63943. /**
  63944. * Define a task used by AssetsManager to load binary data
  63945. */
  63946. export class BinaryFileAssetTask extends AbstractAssetTask {
  63947. /**
  63948. * Defines the name of the task
  63949. */
  63950. name: string;
  63951. /**
  63952. * Defines the location of the file to load
  63953. */
  63954. url: string;
  63955. /**
  63956. * Gets the lodaded data (as an array buffer)
  63957. */
  63958. data: ArrayBuffer;
  63959. /**
  63960. * Callback called when the task is successful
  63961. */
  63962. onSuccess: (task: BinaryFileAssetTask) => void;
  63963. /**
  63964. * Callback called when the task is successful
  63965. */
  63966. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63967. /**
  63968. * Creates a new BinaryFileAssetTask object
  63969. * @param name defines the name of the new task
  63970. * @param url defines the location of the file to load
  63971. */
  63972. constructor(
  63973. /**
  63974. * Defines the name of the task
  63975. */
  63976. name: string,
  63977. /**
  63978. * Defines the location of the file to load
  63979. */
  63980. url: string);
  63981. /**
  63982. * Execute the current task
  63983. * @param scene defines the scene where you want your assets to be loaded
  63984. * @param onSuccess is a callback called when the task is successfully executed
  63985. * @param onError is a callback called if an error occurs
  63986. */
  63987. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63988. }
  63989. /**
  63990. * Define a task used by AssetsManager to load images
  63991. */
  63992. export class ImageAssetTask extends AbstractAssetTask {
  63993. /**
  63994. * Defines the name of the task
  63995. */
  63996. name: string;
  63997. /**
  63998. * Defines the location of the image to load
  63999. */
  64000. url: string;
  64001. /**
  64002. * Gets the loaded images
  64003. */
  64004. image: HTMLImageElement;
  64005. /**
  64006. * Callback called when the task is successful
  64007. */
  64008. onSuccess: (task: ImageAssetTask) => void;
  64009. /**
  64010. * Callback called when the task is successful
  64011. */
  64012. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64013. /**
  64014. * Creates a new ImageAssetTask
  64015. * @param name defines the name of the task
  64016. * @param url defines the location of the image to load
  64017. */
  64018. constructor(
  64019. /**
  64020. * Defines the name of the task
  64021. */
  64022. name: string,
  64023. /**
  64024. * Defines the location of the image to load
  64025. */
  64026. url: string);
  64027. /**
  64028. * Execute the current task
  64029. * @param scene defines the scene where you want your assets to be loaded
  64030. * @param onSuccess is a callback called when the task is successfully executed
  64031. * @param onError is a callback called if an error occurs
  64032. */
  64033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64034. }
  64035. /**
  64036. * Defines the interface used by texture loading tasks
  64037. */
  64038. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64039. /**
  64040. * Gets the loaded texture
  64041. */
  64042. texture: TEX;
  64043. }
  64044. /**
  64045. * Define a task used by AssetsManager to load 2D textures
  64046. */
  64047. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64048. /**
  64049. * Defines the name of the task
  64050. */
  64051. name: string;
  64052. /**
  64053. * Defines the location of the file to load
  64054. */
  64055. url: string;
  64056. /**
  64057. * Defines if mipmap should not be generated (default is false)
  64058. */
  64059. noMipmap?: boolean | undefined;
  64060. /**
  64061. * Defines if texture must be inverted on Y axis (default is false)
  64062. */
  64063. invertY?: boolean | undefined;
  64064. /**
  64065. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64066. */
  64067. samplingMode: number;
  64068. /**
  64069. * Gets the loaded texture
  64070. */
  64071. texture: Texture;
  64072. /**
  64073. * Callback called when the task is successful
  64074. */
  64075. onSuccess: (task: TextureAssetTask) => void;
  64076. /**
  64077. * Callback called when the task is successful
  64078. */
  64079. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64080. /**
  64081. * Creates a new TextureAssetTask object
  64082. * @param name defines the name of the task
  64083. * @param url defines the location of the file to load
  64084. * @param noMipmap defines if mipmap should not be generated (default is false)
  64085. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64086. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64087. */
  64088. constructor(
  64089. /**
  64090. * Defines the name of the task
  64091. */
  64092. name: string,
  64093. /**
  64094. * Defines the location of the file to load
  64095. */
  64096. url: string,
  64097. /**
  64098. * Defines if mipmap should not be generated (default is false)
  64099. */
  64100. noMipmap?: boolean | undefined,
  64101. /**
  64102. * Defines if texture must be inverted on Y axis (default is false)
  64103. */
  64104. invertY?: boolean | undefined,
  64105. /**
  64106. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64107. */
  64108. samplingMode?: number);
  64109. /**
  64110. * Execute the current task
  64111. * @param scene defines the scene where you want your assets to be loaded
  64112. * @param onSuccess is a callback called when the task is successfully executed
  64113. * @param onError is a callback called if an error occurs
  64114. */
  64115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64116. }
  64117. /**
  64118. * Define a task used by AssetsManager to load cube textures
  64119. */
  64120. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64121. /**
  64122. * Defines the name of the task
  64123. */
  64124. name: string;
  64125. /**
  64126. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64127. */
  64128. url: string;
  64129. /**
  64130. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64131. */
  64132. extensions?: string[] | undefined;
  64133. /**
  64134. * Defines if mipmaps should not be generated (default is false)
  64135. */
  64136. noMipmap?: boolean | undefined;
  64137. /**
  64138. * Defines the explicit list of files (undefined by default)
  64139. */
  64140. files?: string[] | undefined;
  64141. /**
  64142. * Gets the loaded texture
  64143. */
  64144. texture: CubeTexture;
  64145. /**
  64146. * Callback called when the task is successful
  64147. */
  64148. onSuccess: (task: CubeTextureAssetTask) => void;
  64149. /**
  64150. * Callback called when the task is successful
  64151. */
  64152. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64153. /**
  64154. * Creates a new CubeTextureAssetTask
  64155. * @param name defines the name of the task
  64156. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64157. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64158. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64159. * @param files defines the explicit list of files (undefined by default)
  64160. */
  64161. constructor(
  64162. /**
  64163. * Defines the name of the task
  64164. */
  64165. name: string,
  64166. /**
  64167. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64168. */
  64169. url: string,
  64170. /**
  64171. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64172. */
  64173. extensions?: string[] | undefined,
  64174. /**
  64175. * Defines if mipmaps should not be generated (default is false)
  64176. */
  64177. noMipmap?: boolean | undefined,
  64178. /**
  64179. * Defines the explicit list of files (undefined by default)
  64180. */
  64181. files?: string[] | undefined);
  64182. /**
  64183. * Execute the current task
  64184. * @param scene defines the scene where you want your assets to be loaded
  64185. * @param onSuccess is a callback called when the task is successfully executed
  64186. * @param onError is a callback called if an error occurs
  64187. */
  64188. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64189. }
  64190. /**
  64191. * Define a task used by AssetsManager to load HDR cube textures
  64192. */
  64193. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64194. /**
  64195. * Defines the name of the task
  64196. */
  64197. name: string;
  64198. /**
  64199. * Defines the location of the file to load
  64200. */
  64201. url: string;
  64202. /**
  64203. * Defines the desired size (the more it increases the longer the generation will be)
  64204. */
  64205. size: number;
  64206. /**
  64207. * Defines if mipmaps should not be generated (default is false)
  64208. */
  64209. noMipmap: boolean;
  64210. /**
  64211. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64212. */
  64213. generateHarmonics: boolean;
  64214. /**
  64215. * 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)
  64216. */
  64217. gammaSpace: boolean;
  64218. /**
  64219. * Internal Use Only
  64220. */
  64221. reserved: boolean;
  64222. /**
  64223. * Gets the loaded texture
  64224. */
  64225. texture: HDRCubeTexture;
  64226. /**
  64227. * Callback called when the task is successful
  64228. */
  64229. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64230. /**
  64231. * Callback called when the task is successful
  64232. */
  64233. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64234. /**
  64235. * Creates a new HDRCubeTextureAssetTask object
  64236. * @param name defines the name of the task
  64237. * @param url defines the location of the file to load
  64238. * @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.
  64239. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64240. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64241. * @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)
  64242. * @param reserved Internal use only
  64243. */
  64244. constructor(
  64245. /**
  64246. * Defines the name of the task
  64247. */
  64248. name: string,
  64249. /**
  64250. * Defines the location of the file to load
  64251. */
  64252. url: string,
  64253. /**
  64254. * Defines the desired size (the more it increases the longer the generation will be)
  64255. */
  64256. size: number,
  64257. /**
  64258. * Defines if mipmaps should not be generated (default is false)
  64259. */
  64260. noMipmap?: boolean,
  64261. /**
  64262. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64263. */
  64264. generateHarmonics?: boolean,
  64265. /**
  64266. * 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)
  64267. */
  64268. gammaSpace?: boolean,
  64269. /**
  64270. * Internal Use Only
  64271. */
  64272. reserved?: boolean);
  64273. /**
  64274. * Execute the current task
  64275. * @param scene defines the scene where you want your assets to be loaded
  64276. * @param onSuccess is a callback called when the task is successfully executed
  64277. * @param onError is a callback called if an error occurs
  64278. */
  64279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64280. }
  64281. /**
  64282. * Define a task used by AssetsManager to load Equirectangular cube textures
  64283. */
  64284. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64285. /**
  64286. * Defines the name of the task
  64287. */
  64288. name: string;
  64289. /**
  64290. * Defines the location of the file to load
  64291. */
  64292. url: string;
  64293. /**
  64294. * Defines the desired size (the more it increases the longer the generation will be)
  64295. */
  64296. size: number;
  64297. /**
  64298. * Defines if mipmaps should not be generated (default is false)
  64299. */
  64300. noMipmap: boolean;
  64301. /**
  64302. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64303. * but the standard material would require them in Gamma space) (default is true)
  64304. */
  64305. gammaSpace: boolean;
  64306. /**
  64307. * Gets the loaded texture
  64308. */
  64309. texture: EquiRectangularCubeTexture;
  64310. /**
  64311. * Callback called when the task is successful
  64312. */
  64313. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64314. /**
  64315. * Callback called when the task is successful
  64316. */
  64317. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64318. /**
  64319. * Creates a new EquiRectangularCubeTextureAssetTask object
  64320. * @param name defines the name of the task
  64321. * @param url defines the location of the file to load
  64322. * @param size defines the desired size (the more it increases the longer the generation will be)
  64323. * If the size is omitted this implies you are using a preprocessed cubemap.
  64324. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64325. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64326. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64327. * (default is true)
  64328. */
  64329. constructor(
  64330. /**
  64331. * Defines the name of the task
  64332. */
  64333. name: string,
  64334. /**
  64335. * Defines the location of the file to load
  64336. */
  64337. url: string,
  64338. /**
  64339. * Defines the desired size (the more it increases the longer the generation will be)
  64340. */
  64341. size: number,
  64342. /**
  64343. * Defines if mipmaps should not be generated (default is false)
  64344. */
  64345. noMipmap?: boolean,
  64346. /**
  64347. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64348. * but the standard material would require them in Gamma space) (default is true)
  64349. */
  64350. gammaSpace?: boolean);
  64351. /**
  64352. * Execute the current task
  64353. * @param scene defines the scene where you want your assets to be loaded
  64354. * @param onSuccess is a callback called when the task is successfully executed
  64355. * @param onError is a callback called if an error occurs
  64356. */
  64357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64358. }
  64359. /**
  64360. * This class can be used to easily import assets into a scene
  64361. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64362. */
  64363. export class AssetsManager {
  64364. private _scene;
  64365. private _isLoading;
  64366. protected _tasks: AbstractAssetTask[];
  64367. protected _waitingTasksCount: number;
  64368. protected _totalTasksCount: number;
  64369. /**
  64370. * Callback called when all tasks are processed
  64371. */
  64372. onFinish: (tasks: AbstractAssetTask[]) => void;
  64373. /**
  64374. * Callback called when a task is successful
  64375. */
  64376. onTaskSuccess: (task: AbstractAssetTask) => void;
  64377. /**
  64378. * Callback called when a task had an error
  64379. */
  64380. onTaskError: (task: AbstractAssetTask) => void;
  64381. /**
  64382. * Callback called when a task is done (whatever the result is)
  64383. */
  64384. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64385. /**
  64386. * Observable called when all tasks are processed
  64387. */
  64388. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64389. /**
  64390. * Observable called when a task had an error
  64391. */
  64392. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64393. /**
  64394. * Observable called when all tasks were executed
  64395. */
  64396. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64397. /**
  64398. * Observable called when a task is done (whatever the result is)
  64399. */
  64400. onProgressObservable: Observable<IAssetsProgressEvent>;
  64401. /**
  64402. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64403. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64404. */
  64405. useDefaultLoadingScreen: boolean;
  64406. /**
  64407. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64408. * when all assets have been downloaded.
  64409. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64410. */
  64411. autoHideLoadingUI: boolean;
  64412. /**
  64413. * Creates a new AssetsManager
  64414. * @param scene defines the scene to work on
  64415. */
  64416. constructor(scene: Scene);
  64417. /**
  64418. * Add a MeshAssetTask to the list of active tasks
  64419. * @param taskName defines the name of the new task
  64420. * @param meshesNames defines the name of meshes to load
  64421. * @param rootUrl defines the root url to use to locate files
  64422. * @param sceneFilename defines the filename of the scene file
  64423. * @returns a new MeshAssetTask object
  64424. */
  64425. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64426. /**
  64427. * Add a TextFileAssetTask to the list of active tasks
  64428. * @param taskName defines the name of the new task
  64429. * @param url defines the url of the file to load
  64430. * @returns a new TextFileAssetTask object
  64431. */
  64432. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64433. /**
  64434. * Add a BinaryFileAssetTask to the list of active tasks
  64435. * @param taskName defines the name of the new task
  64436. * @param url defines the url of the file to load
  64437. * @returns a new BinaryFileAssetTask object
  64438. */
  64439. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64440. /**
  64441. * Add a ImageAssetTask to the list of active tasks
  64442. * @param taskName defines the name of the new task
  64443. * @param url defines the url of the file to load
  64444. * @returns a new ImageAssetTask object
  64445. */
  64446. addImageTask(taskName: string, url: string): ImageAssetTask;
  64447. /**
  64448. * Add a TextureAssetTask to the list of active tasks
  64449. * @param taskName defines the name of the new task
  64450. * @param url defines the url of the file to load
  64451. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64452. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64453. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64454. * @returns a new TextureAssetTask object
  64455. */
  64456. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64457. /**
  64458. * Add a CubeTextureAssetTask to the list of active tasks
  64459. * @param taskName defines the name of the new task
  64460. * @param url defines the url of the file to load
  64461. * @param extensions defines the extension to use to load the cube map (can be null)
  64462. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64463. * @param files defines the list of files to load (can be null)
  64464. * @returns a new CubeTextureAssetTask object
  64465. */
  64466. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64467. /**
  64468. *
  64469. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64470. * @param taskName defines the name of the new task
  64471. * @param url defines the url of the file to load
  64472. * @param size defines the size you want for the cubemap (can be null)
  64473. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64474. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64475. * @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)
  64476. * @param reserved Internal use only
  64477. * @returns a new HDRCubeTextureAssetTask object
  64478. */
  64479. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64480. /**
  64481. *
  64482. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64483. * @param taskName defines the name of the new task
  64484. * @param url defines the url of the file to load
  64485. * @param size defines the size you want for the cubemap (can be null)
  64486. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64487. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64488. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64489. * @returns a new EquiRectangularCubeTextureAssetTask object
  64490. */
  64491. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64492. /**
  64493. * Remove a task from the assets manager.
  64494. * @param task the task to remove
  64495. */
  64496. removeTask(task: AbstractAssetTask): void;
  64497. private _decreaseWaitingTasksCount;
  64498. private _runTask;
  64499. /**
  64500. * Reset the AssetsManager and remove all tasks
  64501. * @return the current instance of the AssetsManager
  64502. */
  64503. reset(): AssetsManager;
  64504. /**
  64505. * Start the loading process
  64506. * @return the current instance of the AssetsManager
  64507. */
  64508. load(): AssetsManager;
  64509. /**
  64510. * Start the loading process as an async operation
  64511. * @return a promise returning the list of failed tasks
  64512. */
  64513. loadAsync(): Promise<void>;
  64514. }
  64515. }
  64516. declare module "babylonjs/Misc/deferred" {
  64517. /**
  64518. * Wrapper class for promise with external resolve and reject.
  64519. */
  64520. export class Deferred<T> {
  64521. /**
  64522. * The promise associated with this deferred object.
  64523. */
  64524. readonly promise: Promise<T>;
  64525. private _resolve;
  64526. private _reject;
  64527. /**
  64528. * The resolve method of the promise associated with this deferred object.
  64529. */
  64530. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64531. /**
  64532. * The reject method of the promise associated with this deferred object.
  64533. */
  64534. readonly reject: (reason?: any) => void;
  64535. /**
  64536. * Constructor for this deferred object.
  64537. */
  64538. constructor();
  64539. }
  64540. }
  64541. declare module "babylonjs/Misc/meshExploder" {
  64542. import { Mesh } from "babylonjs/Meshes/mesh";
  64543. /**
  64544. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64545. */
  64546. export class MeshExploder {
  64547. private _centerMesh;
  64548. private _meshes;
  64549. private _meshesOrigins;
  64550. private _toCenterVectors;
  64551. private _scaledDirection;
  64552. private _newPosition;
  64553. private _centerPosition;
  64554. /**
  64555. * Explodes meshes from a center mesh.
  64556. * @param meshes The meshes to explode.
  64557. * @param centerMesh The mesh to be center of explosion.
  64558. */
  64559. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64560. private _setCenterMesh;
  64561. /**
  64562. * Get class name
  64563. * @returns "MeshExploder"
  64564. */
  64565. getClassName(): string;
  64566. /**
  64567. * "Exploded meshes"
  64568. * @returns Array of meshes with the centerMesh at index 0.
  64569. */
  64570. getMeshes(): Array<Mesh>;
  64571. /**
  64572. * Explodes meshes giving a specific direction
  64573. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64574. */
  64575. explode(direction?: number): void;
  64576. }
  64577. }
  64578. declare module "babylonjs/Misc/filesInput" {
  64579. import { Engine } from "babylonjs/Engines/engine";
  64580. import { Scene } from "babylonjs/scene";
  64581. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64582. /**
  64583. * Class used to help managing file picking and drag'n'drop
  64584. */
  64585. export class FilesInput {
  64586. /**
  64587. * List of files ready to be loaded
  64588. */
  64589. static readonly FilesToLoad: {
  64590. [key: string]: File;
  64591. };
  64592. /**
  64593. * Callback called when a file is processed
  64594. */
  64595. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64596. private _engine;
  64597. private _currentScene;
  64598. private _sceneLoadedCallback;
  64599. private _progressCallback;
  64600. private _additionalRenderLoopLogicCallback;
  64601. private _textureLoadingCallback;
  64602. private _startingProcessingFilesCallback;
  64603. private _onReloadCallback;
  64604. private _errorCallback;
  64605. private _elementToMonitor;
  64606. private _sceneFileToLoad;
  64607. private _filesToLoad;
  64608. /**
  64609. * Creates a new FilesInput
  64610. * @param engine defines the rendering engine
  64611. * @param scene defines the hosting scene
  64612. * @param sceneLoadedCallback callback called when scene is loaded
  64613. * @param progressCallback callback called to track progress
  64614. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64615. * @param textureLoadingCallback callback called when a texture is loading
  64616. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64617. * @param onReloadCallback callback called when a reload is requested
  64618. * @param errorCallback callback call if an error occurs
  64619. */
  64620. 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);
  64621. private _dragEnterHandler;
  64622. private _dragOverHandler;
  64623. private _dropHandler;
  64624. /**
  64625. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64626. * @param elementToMonitor defines the DOM element to track
  64627. */
  64628. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64629. /**
  64630. * Release all associated resources
  64631. */
  64632. dispose(): void;
  64633. private renderFunction;
  64634. private drag;
  64635. private drop;
  64636. private _traverseFolder;
  64637. private _processFiles;
  64638. /**
  64639. * Load files from a drop event
  64640. * @param event defines the drop event to use as source
  64641. */
  64642. loadFiles(event: any): void;
  64643. private _processReload;
  64644. /**
  64645. * Reload the current scene from the loaded files
  64646. */
  64647. reload(): void;
  64648. }
  64649. }
  64650. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64651. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64652. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64653. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64654. }
  64655. declare module "babylonjs/Misc/sceneOptimizer" {
  64656. import { Scene, IDisposable } from "babylonjs/scene";
  64657. import { Observable } from "babylonjs/Misc/observable";
  64658. /**
  64659. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64661. */
  64662. export class SceneOptimization {
  64663. /**
  64664. * Defines the priority of this optimization (0 by default which means first in the list)
  64665. */
  64666. priority: number;
  64667. /**
  64668. * Gets a string describing the action executed by the current optimization
  64669. * @returns description string
  64670. */
  64671. getDescription(): string;
  64672. /**
  64673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64674. * @param scene defines the current scene where to apply this optimization
  64675. * @param optimizer defines the current optimizer
  64676. * @returns true if everything that can be done was applied
  64677. */
  64678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64679. /**
  64680. * Creates the SceneOptimization object
  64681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64682. * @param desc defines the description associated with the optimization
  64683. */
  64684. constructor(
  64685. /**
  64686. * Defines the priority of this optimization (0 by default which means first in the list)
  64687. */
  64688. priority?: number);
  64689. }
  64690. /**
  64691. * Defines an optimization used to reduce the size of render target textures
  64692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64693. */
  64694. export class TextureOptimization extends SceneOptimization {
  64695. /**
  64696. * Defines the priority of this optimization (0 by default which means first in the list)
  64697. */
  64698. priority: number;
  64699. /**
  64700. * 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
  64701. */
  64702. maximumSize: number;
  64703. /**
  64704. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64705. */
  64706. step: number;
  64707. /**
  64708. * Gets a string describing the action executed by the current optimization
  64709. * @returns description string
  64710. */
  64711. getDescription(): string;
  64712. /**
  64713. * Creates the TextureOptimization object
  64714. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64715. * @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
  64716. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64717. */
  64718. constructor(
  64719. /**
  64720. * Defines the priority of this optimization (0 by default which means first in the list)
  64721. */
  64722. priority?: number,
  64723. /**
  64724. * 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
  64725. */
  64726. maximumSize?: number,
  64727. /**
  64728. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64729. */
  64730. step?: number);
  64731. /**
  64732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64733. * @param scene defines the current scene where to apply this optimization
  64734. * @param optimizer defines the current optimizer
  64735. * @returns true if everything that can be done was applied
  64736. */
  64737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64738. }
  64739. /**
  64740. * Defines an optimization used to increase or decrease the rendering resolution
  64741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64742. */
  64743. export class HardwareScalingOptimization extends SceneOptimization {
  64744. /**
  64745. * Defines the priority of this optimization (0 by default which means first in the list)
  64746. */
  64747. priority: number;
  64748. /**
  64749. * Defines the maximum scale to use (2 by default)
  64750. */
  64751. maximumScale: number;
  64752. /**
  64753. * Defines the step to use between two passes (0.5 by default)
  64754. */
  64755. step: number;
  64756. private _currentScale;
  64757. private _directionOffset;
  64758. /**
  64759. * Gets a string describing the action executed by the current optimization
  64760. * @return description string
  64761. */
  64762. getDescription(): string;
  64763. /**
  64764. * Creates the HardwareScalingOptimization object
  64765. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64766. * @param maximumScale defines the maximum scale to use (2 by default)
  64767. * @param step defines the step to use between two passes (0.5 by default)
  64768. */
  64769. constructor(
  64770. /**
  64771. * Defines the priority of this optimization (0 by default which means first in the list)
  64772. */
  64773. priority?: number,
  64774. /**
  64775. * Defines the maximum scale to use (2 by default)
  64776. */
  64777. maximumScale?: number,
  64778. /**
  64779. * Defines the step to use between two passes (0.5 by default)
  64780. */
  64781. step?: number);
  64782. /**
  64783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64784. * @param scene defines the current scene where to apply this optimization
  64785. * @param optimizer defines the current optimizer
  64786. * @returns true if everything that can be done was applied
  64787. */
  64788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64789. }
  64790. /**
  64791. * Defines an optimization used to remove shadows
  64792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64793. */
  64794. export class ShadowsOptimization extends SceneOptimization {
  64795. /**
  64796. * Gets a string describing the action executed by the current optimization
  64797. * @return description string
  64798. */
  64799. getDescription(): string;
  64800. /**
  64801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64802. * @param scene defines the current scene where to apply this optimization
  64803. * @param optimizer defines the current optimizer
  64804. * @returns true if everything that can be done was applied
  64805. */
  64806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64807. }
  64808. /**
  64809. * Defines an optimization used to turn post-processes off
  64810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64811. */
  64812. export class PostProcessesOptimization extends SceneOptimization {
  64813. /**
  64814. * Gets a string describing the action executed by the current optimization
  64815. * @return description string
  64816. */
  64817. getDescription(): string;
  64818. /**
  64819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64820. * @param scene defines the current scene where to apply this optimization
  64821. * @param optimizer defines the current optimizer
  64822. * @returns true if everything that can be done was applied
  64823. */
  64824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64825. }
  64826. /**
  64827. * Defines an optimization used to turn lens flares off
  64828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64829. */
  64830. export class LensFlaresOptimization extends SceneOptimization {
  64831. /**
  64832. * Gets a string describing the action executed by the current optimization
  64833. * @return description string
  64834. */
  64835. getDescription(): string;
  64836. /**
  64837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64838. * @param scene defines the current scene where to apply this optimization
  64839. * @param optimizer defines the current optimizer
  64840. * @returns true if everything that can be done was applied
  64841. */
  64842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64843. }
  64844. /**
  64845. * Defines an optimization based on user defined callback.
  64846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64847. */
  64848. export class CustomOptimization extends SceneOptimization {
  64849. /**
  64850. * Callback called to apply the custom optimization.
  64851. */
  64852. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64853. /**
  64854. * Callback called to get custom description
  64855. */
  64856. onGetDescription: () => string;
  64857. /**
  64858. * Gets a string describing the action executed by the current optimization
  64859. * @returns description string
  64860. */
  64861. getDescription(): string;
  64862. /**
  64863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64864. * @param scene defines the current scene where to apply this optimization
  64865. * @param optimizer defines the current optimizer
  64866. * @returns true if everything that can be done was applied
  64867. */
  64868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64869. }
  64870. /**
  64871. * Defines an optimization used to turn particles off
  64872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64873. */
  64874. export class ParticlesOptimization extends SceneOptimization {
  64875. /**
  64876. * Gets a string describing the action executed by the current optimization
  64877. * @return description string
  64878. */
  64879. getDescription(): string;
  64880. /**
  64881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64882. * @param scene defines the current scene where to apply this optimization
  64883. * @param optimizer defines the current optimizer
  64884. * @returns true if everything that can be done was applied
  64885. */
  64886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64887. }
  64888. /**
  64889. * Defines an optimization used to turn render targets off
  64890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64891. */
  64892. export class RenderTargetsOptimization extends SceneOptimization {
  64893. /**
  64894. * Gets a string describing the action executed by the current optimization
  64895. * @return description string
  64896. */
  64897. getDescription(): string;
  64898. /**
  64899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64900. * @param scene defines the current scene where to apply this optimization
  64901. * @param optimizer defines the current optimizer
  64902. * @returns true if everything that can be done was applied
  64903. */
  64904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64905. }
  64906. /**
  64907. * Defines an optimization used to merge meshes with compatible materials
  64908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64909. */
  64910. export class MergeMeshesOptimization extends SceneOptimization {
  64911. private static _UpdateSelectionTree;
  64912. /**
  64913. * Gets or sets a boolean which defines if optimization octree has to be updated
  64914. */
  64915. /**
  64916. * Gets or sets a boolean which defines if optimization octree has to be updated
  64917. */
  64918. static UpdateSelectionTree: boolean;
  64919. /**
  64920. * Gets a string describing the action executed by the current optimization
  64921. * @return description string
  64922. */
  64923. getDescription(): string;
  64924. private _canBeMerged;
  64925. /**
  64926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64927. * @param scene defines the current scene where to apply this optimization
  64928. * @param optimizer defines the current optimizer
  64929. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64930. * @returns true if everything that can be done was applied
  64931. */
  64932. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64933. }
  64934. /**
  64935. * Defines a list of options used by SceneOptimizer
  64936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64937. */
  64938. export class SceneOptimizerOptions {
  64939. /**
  64940. * Defines the target frame rate to reach (60 by default)
  64941. */
  64942. targetFrameRate: number;
  64943. /**
  64944. * Defines the interval between two checkes (2000ms by default)
  64945. */
  64946. trackerDuration: number;
  64947. /**
  64948. * Gets the list of optimizations to apply
  64949. */
  64950. optimizations: SceneOptimization[];
  64951. /**
  64952. * Creates a new list of options used by SceneOptimizer
  64953. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64954. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64955. */
  64956. constructor(
  64957. /**
  64958. * Defines the target frame rate to reach (60 by default)
  64959. */
  64960. targetFrameRate?: number,
  64961. /**
  64962. * Defines the interval between two checkes (2000ms by default)
  64963. */
  64964. trackerDuration?: number);
  64965. /**
  64966. * Add a new optimization
  64967. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64968. * @returns the current SceneOptimizerOptions
  64969. */
  64970. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64971. /**
  64972. * Add a new custom optimization
  64973. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64974. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64975. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64976. * @returns the current SceneOptimizerOptions
  64977. */
  64978. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64979. /**
  64980. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64981. * @param targetFrameRate defines the target frame rate (60 by default)
  64982. * @returns a SceneOptimizerOptions object
  64983. */
  64984. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64985. /**
  64986. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64987. * @param targetFrameRate defines the target frame rate (60 by default)
  64988. * @returns a SceneOptimizerOptions object
  64989. */
  64990. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64991. /**
  64992. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64993. * @param targetFrameRate defines the target frame rate (60 by default)
  64994. * @returns a SceneOptimizerOptions object
  64995. */
  64996. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64997. }
  64998. /**
  64999. * Class used to run optimizations in order to reach a target frame rate
  65000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65001. */
  65002. export class SceneOptimizer implements IDisposable {
  65003. private _isRunning;
  65004. private _options;
  65005. private _scene;
  65006. private _currentPriorityLevel;
  65007. private _targetFrameRate;
  65008. private _trackerDuration;
  65009. private _currentFrameRate;
  65010. private _sceneDisposeObserver;
  65011. private _improvementMode;
  65012. /**
  65013. * Defines an observable called when the optimizer reaches the target frame rate
  65014. */
  65015. onSuccessObservable: Observable<SceneOptimizer>;
  65016. /**
  65017. * Defines an observable called when the optimizer enables an optimization
  65018. */
  65019. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65020. /**
  65021. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65022. */
  65023. onFailureObservable: Observable<SceneOptimizer>;
  65024. /**
  65025. * Gets a boolean indicating if the optimizer is in improvement mode
  65026. */
  65027. readonly isInImprovementMode: boolean;
  65028. /**
  65029. * Gets the current priority level (0 at start)
  65030. */
  65031. readonly currentPriorityLevel: number;
  65032. /**
  65033. * Gets the current frame rate checked by the SceneOptimizer
  65034. */
  65035. readonly currentFrameRate: number;
  65036. /**
  65037. * Gets or sets the current target frame rate (60 by default)
  65038. */
  65039. /**
  65040. * Gets or sets the current target frame rate (60 by default)
  65041. */
  65042. targetFrameRate: number;
  65043. /**
  65044. * Gets or sets the current interval between two checks (every 2000ms by default)
  65045. */
  65046. /**
  65047. * Gets or sets the current interval between two checks (every 2000ms by default)
  65048. */
  65049. trackerDuration: number;
  65050. /**
  65051. * Gets the list of active optimizations
  65052. */
  65053. readonly optimizations: SceneOptimization[];
  65054. /**
  65055. * Creates a new SceneOptimizer
  65056. * @param scene defines the scene to work on
  65057. * @param options defines the options to use with the SceneOptimizer
  65058. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65059. * @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)
  65060. */
  65061. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65062. /**
  65063. * Stops the current optimizer
  65064. */
  65065. stop(): void;
  65066. /**
  65067. * Reset the optimizer to initial step (current priority level = 0)
  65068. */
  65069. reset(): void;
  65070. /**
  65071. * Start the optimizer. By default it will try to reach a specific framerate
  65072. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65073. */
  65074. start(): void;
  65075. private _checkCurrentState;
  65076. /**
  65077. * Release all resources
  65078. */
  65079. dispose(): void;
  65080. /**
  65081. * Helper function to create a SceneOptimizer with one single line of code
  65082. * @param scene defines the scene to work on
  65083. * @param options defines the options to use with the SceneOptimizer
  65084. * @param onSuccess defines a callback to call on success
  65085. * @param onFailure defines a callback to call on failure
  65086. * @returns the new SceneOptimizer object
  65087. */
  65088. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65089. }
  65090. }
  65091. declare module "babylonjs/Misc/sceneSerializer" {
  65092. import { Scene } from "babylonjs/scene";
  65093. /**
  65094. * Class used to serialize a scene into a string
  65095. */
  65096. export class SceneSerializer {
  65097. /**
  65098. * Clear cache used by a previous serialization
  65099. */
  65100. static ClearCache(): void;
  65101. /**
  65102. * Serialize a scene into a JSON compatible object
  65103. * @param scene defines the scene to serialize
  65104. * @returns a JSON compatible object
  65105. */
  65106. static Serialize(scene: Scene): any;
  65107. /**
  65108. * Serialize a mesh into a JSON compatible object
  65109. * @param toSerialize defines the mesh to serialize
  65110. * @param withParents defines if parents must be serialized as well
  65111. * @param withChildren defines if children must be serialized as well
  65112. * @returns a JSON compatible object
  65113. */
  65114. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65115. }
  65116. }
  65117. declare module "babylonjs/Misc/textureTools" {
  65118. import { Texture } from "babylonjs/Materials/Textures/texture";
  65119. /**
  65120. * Class used to host texture specific utilities
  65121. */
  65122. export class TextureTools {
  65123. /**
  65124. * Uses the GPU to create a copy texture rescaled at a given size
  65125. * @param texture Texture to copy from
  65126. * @param width defines the desired width
  65127. * @param height defines the desired height
  65128. * @param useBilinearMode defines if bilinear mode has to be used
  65129. * @return the generated texture
  65130. */
  65131. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65132. }
  65133. }
  65134. declare module "babylonjs/Misc/videoRecorder" {
  65135. import { Nullable } from "babylonjs/types";
  65136. import { Engine } from "babylonjs/Engines/engine";
  65137. /**
  65138. * This represents the different options available for the video capture.
  65139. */
  65140. export interface VideoRecorderOptions {
  65141. /** Defines the mime type of the video. */
  65142. mimeType: string;
  65143. /** Defines the FPS the video should be recorded at. */
  65144. fps: number;
  65145. /** Defines the chunk size for the recording data. */
  65146. recordChunckSize: number;
  65147. /** The audio tracks to attach to the recording. */
  65148. audioTracks?: MediaStreamTrack[];
  65149. }
  65150. /**
  65151. * This can help with recording videos from BabylonJS.
  65152. * This is based on the available WebRTC functionalities of the browser.
  65153. *
  65154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65155. */
  65156. export class VideoRecorder {
  65157. private static readonly _defaultOptions;
  65158. /**
  65159. * Returns whether or not the VideoRecorder is available in your browser.
  65160. * @param engine Defines the Babylon Engine.
  65161. * @returns true if supported otherwise false.
  65162. */
  65163. static IsSupported(engine: Engine): boolean;
  65164. private readonly _options;
  65165. private _canvas;
  65166. private _mediaRecorder;
  65167. private _recordedChunks;
  65168. private _fileName;
  65169. private _resolve;
  65170. private _reject;
  65171. /**
  65172. * True when a recording is already in progress.
  65173. */
  65174. readonly isRecording: boolean;
  65175. /**
  65176. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65177. * @param engine Defines the BabylonJS Engine you wish to record.
  65178. * @param options Defines options that can be used to customize the capture.
  65179. */
  65180. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65181. /**
  65182. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65183. */
  65184. stopRecording(): void;
  65185. /**
  65186. * Starts recording the canvas for a max duration specified in parameters.
  65187. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65188. * If null no automatic download will start and you can rely on the promise to get the data back.
  65189. * @param maxDuration Defines the maximum recording time in seconds.
  65190. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65191. * @return A promise callback at the end of the recording with the video data in Blob.
  65192. */
  65193. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65194. /**
  65195. * Releases internal resources used during the recording.
  65196. */
  65197. dispose(): void;
  65198. private _handleDataAvailable;
  65199. private _handleError;
  65200. private _handleStop;
  65201. }
  65202. }
  65203. declare module "babylonjs/Misc/screenshotTools" {
  65204. import { Camera } from "babylonjs/Cameras/camera";
  65205. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65206. import { Engine } from "babylonjs/Engines/engine";
  65207. /**
  65208. * Class containing a set of static utilities functions for screenshots
  65209. */
  65210. export class ScreenshotTools {
  65211. /**
  65212. * Captures a screenshot of the current rendering
  65213. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65214. * @param engine defines the rendering engine
  65215. * @param camera defines the source camera
  65216. * @param size This parameter can be set to a single number or to an object with the
  65217. * following (optional) properties: precision, width, height. If a single number is passed,
  65218. * it will be used for both width and height. If an object is passed, the screenshot size
  65219. * will be derived from the parameters. The precision property is a multiplier allowing
  65220. * rendering at a higher or lower resolution
  65221. * @param successCallback defines the callback receives a single parameter which contains the
  65222. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65223. * src parameter of an <img> to display it
  65224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65225. * Check your browser for supported MIME types
  65226. */
  65227. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65228. /**
  65229. * Captures a screenshot of the current rendering
  65230. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65231. * @param engine defines the rendering engine
  65232. * @param camera defines the source camera
  65233. * @param size This parameter can be set to a single number or to an object with the
  65234. * following (optional) properties: precision, width, height. If a single number is passed,
  65235. * it will be used for both width and height. If an object is passed, the screenshot size
  65236. * will be derived from the parameters. The precision property is a multiplier allowing
  65237. * rendering at a higher or lower resolution
  65238. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65239. * Check your browser for supported MIME types
  65240. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65241. * to the src parameter of an <img> to display it
  65242. */
  65243. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65244. /**
  65245. * Generates an image screenshot from the specified camera.
  65246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65247. * @param engine The engine to use for rendering
  65248. * @param camera The camera to use for rendering
  65249. * @param size This parameter can be set to a single number or to an object with the
  65250. * following (optional) properties: precision, width, height. If a single number is passed,
  65251. * it will be used for both width and height. If an object is passed, the screenshot size
  65252. * will be derived from the parameters. The precision property is a multiplier allowing
  65253. * rendering at a higher or lower resolution
  65254. * @param successCallback The callback receives a single parameter which contains the
  65255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65256. * src parameter of an <img> to display it
  65257. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65258. * Check your browser for supported MIME types
  65259. * @param samples Texture samples (default: 1)
  65260. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65261. * @param fileName A name for for the downloaded file.
  65262. */
  65263. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65264. /**
  65265. * Generates an image screenshot from the specified camera.
  65266. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65267. * @param engine The engine to use for rendering
  65268. * @param camera The camera to use for rendering
  65269. * @param size This parameter can be set to a single number or to an object with the
  65270. * following (optional) properties: precision, width, height. If a single number is passed,
  65271. * it will be used for both width and height. If an object is passed, the screenshot size
  65272. * will be derived from the parameters. The precision property is a multiplier allowing
  65273. * rendering at a higher or lower resolution
  65274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65275. * Check your browser for supported MIME types
  65276. * @param samples Texture samples (default: 1)
  65277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65278. * @param fileName A name for for the downloaded file.
  65279. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65280. * to the src parameter of an <img> to display it
  65281. */
  65282. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65283. /**
  65284. * Gets height and width for screenshot size
  65285. * @private
  65286. */
  65287. private static _getScreenshotSize;
  65288. }
  65289. }
  65290. declare module "babylonjs/Misc/index" {
  65291. export * from "babylonjs/Misc/andOrNotEvaluator";
  65292. export * from "babylonjs/Misc/assetsManager";
  65293. export * from "babylonjs/Misc/dds";
  65294. export * from "babylonjs/Misc/decorators";
  65295. export * from "babylonjs/Misc/deferred";
  65296. export * from "babylonjs/Misc/environmentTextureTools";
  65297. export * from "babylonjs/Misc/meshExploder";
  65298. export * from "babylonjs/Misc/filesInput";
  65299. export * from "babylonjs/Misc/HighDynamicRange/index";
  65300. export * from "babylonjs/Misc/khronosTextureContainer";
  65301. export * from "babylonjs/Misc/observable";
  65302. export * from "babylonjs/Misc/performanceMonitor";
  65303. export * from "babylonjs/Misc/promise";
  65304. export * from "babylonjs/Misc/sceneOptimizer";
  65305. export * from "babylonjs/Misc/sceneSerializer";
  65306. export * from "babylonjs/Misc/smartArray";
  65307. export * from "babylonjs/Misc/stringDictionary";
  65308. export * from "babylonjs/Misc/tags";
  65309. export * from "babylonjs/Misc/textureTools";
  65310. export * from "babylonjs/Misc/tga";
  65311. export * from "babylonjs/Misc/tools";
  65312. export * from "babylonjs/Misc/videoRecorder";
  65313. export * from "babylonjs/Misc/virtualJoystick";
  65314. export * from "babylonjs/Misc/workerPool";
  65315. export * from "babylonjs/Misc/logger";
  65316. export * from "babylonjs/Misc/typeStore";
  65317. export * from "babylonjs/Misc/filesInputStore";
  65318. export * from "babylonjs/Misc/deepCopier";
  65319. export * from "babylonjs/Misc/pivotTools";
  65320. export * from "babylonjs/Misc/precisionDate";
  65321. export * from "babylonjs/Misc/screenshotTools";
  65322. export * from "babylonjs/Misc/typeStore";
  65323. export * from "babylonjs/Misc/webRequest";
  65324. export * from "babylonjs/Misc/iInspectable";
  65325. export * from "babylonjs/Misc/brdfTextureTools";
  65326. export * from "babylonjs/Misc/gradients";
  65327. export * from "babylonjs/Misc/perfCounter";
  65328. export * from "babylonjs/Misc/fileRequest";
  65329. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65330. export * from "babylonjs/Misc/retryStrategy";
  65331. export * from "babylonjs/Misc/loadFileError";
  65332. }
  65333. declare module "babylonjs/index" {
  65334. export * from "babylonjs/abstractScene";
  65335. export * from "babylonjs/Actions/index";
  65336. export * from "babylonjs/Animations/index";
  65337. export * from "babylonjs/assetContainer";
  65338. export * from "babylonjs/Audio/index";
  65339. export * from "babylonjs/Behaviors/index";
  65340. export * from "babylonjs/Bones/index";
  65341. export * from "babylonjs/Cameras/index";
  65342. export * from "babylonjs/Collisions/index";
  65343. export * from "babylonjs/Culling/index";
  65344. export * from "babylonjs/Debug/index";
  65345. export * from "babylonjs/Engines/index";
  65346. export * from "babylonjs/Events/index";
  65347. export * from "babylonjs/Gamepads/index";
  65348. export * from "babylonjs/Gizmos/index";
  65349. export * from "babylonjs/Helpers/index";
  65350. export * from "babylonjs/Instrumentation/index";
  65351. export * from "babylonjs/Layers/index";
  65352. export * from "babylonjs/LensFlares/index";
  65353. export * from "babylonjs/Lights/index";
  65354. export * from "babylonjs/Loading/index";
  65355. export * from "babylonjs/Materials/index";
  65356. export * from "babylonjs/Maths/index";
  65357. export * from "babylonjs/Meshes/index";
  65358. export * from "babylonjs/Morph/index";
  65359. export * from "babylonjs/Navigation/index";
  65360. export * from "babylonjs/node";
  65361. export * from "babylonjs/Offline/index";
  65362. export * from "babylonjs/Particles/index";
  65363. export * from "babylonjs/Physics/index";
  65364. export * from "babylonjs/PostProcesses/index";
  65365. export * from "babylonjs/Probes/index";
  65366. export * from "babylonjs/Rendering/index";
  65367. export * from "babylonjs/scene";
  65368. export * from "babylonjs/sceneComponent";
  65369. export * from "babylonjs/Sprites/index";
  65370. export * from "babylonjs/States/index";
  65371. export * from "babylonjs/Misc/index";
  65372. export * from "babylonjs/types";
  65373. }
  65374. declare module "babylonjs/Animations/pathCursor" {
  65375. import { Vector3 } from "babylonjs/Maths/math.vector";
  65376. import { Path2 } from "babylonjs/Maths/math.path";
  65377. /**
  65378. * A cursor which tracks a point on a path
  65379. */
  65380. export class PathCursor {
  65381. private path;
  65382. /**
  65383. * Stores path cursor callbacks for when an onchange event is triggered
  65384. */
  65385. private _onchange;
  65386. /**
  65387. * The value of the path cursor
  65388. */
  65389. value: number;
  65390. /**
  65391. * The animation array of the path cursor
  65392. */
  65393. animations: Animation[];
  65394. /**
  65395. * Initializes the path cursor
  65396. * @param path The path to track
  65397. */
  65398. constructor(path: Path2);
  65399. /**
  65400. * Gets the cursor point on the path
  65401. * @returns A point on the path cursor at the cursor location
  65402. */
  65403. getPoint(): Vector3;
  65404. /**
  65405. * Moves the cursor ahead by the step amount
  65406. * @param step The amount to move the cursor forward
  65407. * @returns This path cursor
  65408. */
  65409. moveAhead(step?: number): PathCursor;
  65410. /**
  65411. * Moves the cursor behind by the step amount
  65412. * @param step The amount to move the cursor back
  65413. * @returns This path cursor
  65414. */
  65415. moveBack(step?: number): PathCursor;
  65416. /**
  65417. * Moves the cursor by the step amount
  65418. * If the step amount is greater than one, an exception is thrown
  65419. * @param step The amount to move the cursor
  65420. * @returns This path cursor
  65421. */
  65422. move(step: number): PathCursor;
  65423. /**
  65424. * Ensures that the value is limited between zero and one
  65425. * @returns This path cursor
  65426. */
  65427. private ensureLimits;
  65428. /**
  65429. * Runs onchange callbacks on change (used by the animation engine)
  65430. * @returns This path cursor
  65431. */
  65432. private raiseOnChange;
  65433. /**
  65434. * Executes a function on change
  65435. * @param f A path cursor onchange callback
  65436. * @returns This path cursor
  65437. */
  65438. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65439. }
  65440. }
  65441. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65442. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65443. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65444. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65445. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65446. }
  65447. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65448. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65449. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65450. }
  65451. declare module "babylonjs/Engines/Processors/index" {
  65452. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65453. export * from "babylonjs/Engines/Processors/Expressions/index";
  65454. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65455. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65456. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65457. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65458. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65459. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65460. }
  65461. declare module "babylonjs/Legacy/legacy" {
  65462. import * as Babylon from "babylonjs/index";
  65463. export * from "babylonjs/index";
  65464. }
  65465. declare module "babylonjs/Shaders/blur.fragment" {
  65466. /** @hidden */
  65467. export var blurPixelShader: {
  65468. name: string;
  65469. shader: string;
  65470. };
  65471. }
  65472. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65473. /** @hidden */
  65474. export var pointCloudVertexDeclaration: {
  65475. name: string;
  65476. shader: string;
  65477. };
  65478. }
  65479. declare module "babylonjs" {
  65480. export * from "babylonjs/Legacy/legacy";
  65481. }
  65482. declare module BABYLON {
  65483. /** Alias type for value that can be null */
  65484. export type Nullable<T> = T | null;
  65485. /**
  65486. * Alias type for number that are floats
  65487. * @ignorenaming
  65488. */
  65489. export type float = number;
  65490. /**
  65491. * Alias type for number that are doubles.
  65492. * @ignorenaming
  65493. */
  65494. export type double = number;
  65495. /**
  65496. * Alias type for number that are integer
  65497. * @ignorenaming
  65498. */
  65499. export type int = number;
  65500. /** Alias type for number array or Float32Array */
  65501. export type FloatArray = number[] | Float32Array;
  65502. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65503. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65504. /**
  65505. * Alias for types that can be used by a Buffer or VertexBuffer.
  65506. */
  65507. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65508. /**
  65509. * Alias type for primitive types
  65510. * @ignorenaming
  65511. */
  65512. type Primitive = undefined | null | boolean | string | number | Function;
  65513. /**
  65514. * Type modifier to make all the properties of an object Readonly
  65515. */
  65516. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65517. /**
  65518. * Type modifier to make all the properties of an object Readonly recursively
  65519. */
  65520. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65521. /** @hidden */
  65522. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65523. }
  65524. /** @hidden */
  65525. /** @hidden */
  65526. type DeepImmutableObject<T> = {
  65527. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65528. };
  65529. }
  65530. declare module BABYLON {
  65531. /**
  65532. * A class serves as a medium between the observable and its observers
  65533. */
  65534. export class EventState {
  65535. /**
  65536. * Create a new EventState
  65537. * @param mask defines the mask associated with this state
  65538. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65539. * @param target defines the original target of the state
  65540. * @param currentTarget defines the current target of the state
  65541. */
  65542. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65543. /**
  65544. * Initialize the current event state
  65545. * @param mask defines the mask associated with this state
  65546. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65547. * @param target defines the original target of the state
  65548. * @param currentTarget defines the current target of the state
  65549. * @returns the current event state
  65550. */
  65551. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65552. /**
  65553. * An Observer can set this property to true to prevent subsequent observers of being notified
  65554. */
  65555. skipNextObservers: boolean;
  65556. /**
  65557. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65558. */
  65559. mask: number;
  65560. /**
  65561. * The object that originally notified the event
  65562. */
  65563. target?: any;
  65564. /**
  65565. * The current object in the bubbling phase
  65566. */
  65567. currentTarget?: any;
  65568. /**
  65569. * This will be populated with the return value of the last function that was executed.
  65570. * If it is the first function in the callback chain it will be the event data.
  65571. */
  65572. lastReturnValue?: any;
  65573. }
  65574. /**
  65575. * Represent an Observer registered to a given Observable object.
  65576. */
  65577. export class Observer<T> {
  65578. /**
  65579. * Defines the callback to call when the observer is notified
  65580. */
  65581. callback: (eventData: T, eventState: EventState) => void;
  65582. /**
  65583. * Defines the mask of the observer (used to filter notifications)
  65584. */
  65585. mask: number;
  65586. /**
  65587. * Defines the current scope used to restore the JS context
  65588. */
  65589. scope: any;
  65590. /** @hidden */
  65591. _willBeUnregistered: boolean;
  65592. /**
  65593. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65594. */
  65595. unregisterOnNextCall: boolean;
  65596. /**
  65597. * Creates a new observer
  65598. * @param callback defines the callback to call when the observer is notified
  65599. * @param mask defines the mask of the observer (used to filter notifications)
  65600. * @param scope defines the current scope used to restore the JS context
  65601. */
  65602. constructor(
  65603. /**
  65604. * Defines the callback to call when the observer is notified
  65605. */
  65606. callback: (eventData: T, eventState: EventState) => void,
  65607. /**
  65608. * Defines the mask of the observer (used to filter notifications)
  65609. */
  65610. mask: number,
  65611. /**
  65612. * Defines the current scope used to restore the JS context
  65613. */
  65614. scope?: any);
  65615. }
  65616. /**
  65617. * Represent a list of observers registered to multiple Observables object.
  65618. */
  65619. export class MultiObserver<T> {
  65620. private _observers;
  65621. private _observables;
  65622. /**
  65623. * Release associated resources
  65624. */
  65625. dispose(): void;
  65626. /**
  65627. * Raise a callback when one of the observable will notify
  65628. * @param observables defines a list of observables to watch
  65629. * @param callback defines the callback to call on notification
  65630. * @param mask defines the mask used to filter notifications
  65631. * @param scope defines the current scope used to restore the JS context
  65632. * @returns the new MultiObserver
  65633. */
  65634. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65635. }
  65636. /**
  65637. * The Observable class is a simple implementation of the Observable pattern.
  65638. *
  65639. * 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.
  65640. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65641. * 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).
  65642. * 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.
  65643. */
  65644. export class Observable<T> {
  65645. private _observers;
  65646. private _eventState;
  65647. private _onObserverAdded;
  65648. /**
  65649. * Gets the list of observers
  65650. */
  65651. readonly observers: Array<Observer<T>>;
  65652. /**
  65653. * Creates a new observable
  65654. * @param onObserverAdded defines a callback to call when a new observer is added
  65655. */
  65656. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65657. /**
  65658. * Create a new Observer with the specified callback
  65659. * @param callback the callback that will be executed for that Observer
  65660. * @param mask the mask used to filter observers
  65661. * @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.
  65662. * @param scope optional scope for the callback to be called from
  65663. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65664. * @returns the new observer created for the callback
  65665. */
  65666. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65667. /**
  65668. * Create a new Observer with the specified callback and unregisters after the next notification
  65669. * @param callback the callback that will be executed for that Observer
  65670. * @returns the new observer created for the callback
  65671. */
  65672. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65673. /**
  65674. * Remove an Observer from the Observable object
  65675. * @param observer the instance of the Observer to remove
  65676. * @returns false if it doesn't belong to this Observable
  65677. */
  65678. remove(observer: Nullable<Observer<T>>): boolean;
  65679. /**
  65680. * Remove a callback from the Observable object
  65681. * @param callback the callback to remove
  65682. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65683. * @returns false if it doesn't belong to this Observable
  65684. */
  65685. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65686. private _deferUnregister;
  65687. private _remove;
  65688. /**
  65689. * Moves the observable to the top of the observer list making it get called first when notified
  65690. * @param observer the observer to move
  65691. */
  65692. makeObserverTopPriority(observer: Observer<T>): void;
  65693. /**
  65694. * Moves the observable to the bottom of the observer list making it get called last when notified
  65695. * @param observer the observer to move
  65696. */
  65697. makeObserverBottomPriority(observer: Observer<T>): void;
  65698. /**
  65699. * Notify all Observers by calling their respective callback with the given data
  65700. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65701. * @param eventData defines the data to send to all observers
  65702. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65703. * @param target defines the original target of the state
  65704. * @param currentTarget defines the current target of the state
  65705. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65706. */
  65707. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65708. /**
  65709. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65710. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65711. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65712. * and it is crucial that all callbacks will be executed.
  65713. * The order of the callbacks is kept, callbacks are not executed parallel.
  65714. *
  65715. * @param eventData The data to be sent to each callback
  65716. * @param mask is used to filter observers defaults to -1
  65717. * @param target defines the callback target (see EventState)
  65718. * @param currentTarget defines he current object in the bubbling phase
  65719. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65720. */
  65721. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65722. /**
  65723. * Notify a specific observer
  65724. * @param observer defines the observer to notify
  65725. * @param eventData defines the data to be sent to each callback
  65726. * @param mask is used to filter observers defaults to -1
  65727. */
  65728. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65729. /**
  65730. * Gets a boolean indicating if the observable has at least one observer
  65731. * @returns true is the Observable has at least one Observer registered
  65732. */
  65733. hasObservers(): boolean;
  65734. /**
  65735. * Clear the list of observers
  65736. */
  65737. clear(): void;
  65738. /**
  65739. * Clone the current observable
  65740. * @returns a new observable
  65741. */
  65742. clone(): Observable<T>;
  65743. /**
  65744. * Does this observable handles observer registered with a given mask
  65745. * @param mask defines the mask to be tested
  65746. * @return whether or not one observer registered with the given mask is handeled
  65747. **/
  65748. hasSpecificMask(mask?: number): boolean;
  65749. }
  65750. }
  65751. declare module BABYLON {
  65752. /**
  65753. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65754. * Babylon.js
  65755. */
  65756. export class DomManagement {
  65757. /**
  65758. * Checks if the window object exists
  65759. * @returns true if the window object exists
  65760. */
  65761. static IsWindowObjectExist(): boolean;
  65762. /**
  65763. * Checks if the navigator object exists
  65764. * @returns true if the navigator object exists
  65765. */
  65766. static IsNavigatorAvailable(): boolean;
  65767. /**
  65768. * Extracts text content from a DOM element hierarchy
  65769. * @param element defines the root element
  65770. * @returns a string
  65771. */
  65772. static GetDOMTextContent(element: HTMLElement): string;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /**
  65777. * Logger used througouht the application to allow configuration of
  65778. * the log level required for the messages.
  65779. */
  65780. export class Logger {
  65781. /**
  65782. * No log
  65783. */
  65784. static readonly NoneLogLevel: number;
  65785. /**
  65786. * Only message logs
  65787. */
  65788. static readonly MessageLogLevel: number;
  65789. /**
  65790. * Only warning logs
  65791. */
  65792. static readonly WarningLogLevel: number;
  65793. /**
  65794. * Only error logs
  65795. */
  65796. static readonly ErrorLogLevel: number;
  65797. /**
  65798. * All logs
  65799. */
  65800. static readonly AllLogLevel: number;
  65801. private static _LogCache;
  65802. /**
  65803. * Gets a value indicating the number of loading errors
  65804. * @ignorenaming
  65805. */
  65806. static errorsCount: number;
  65807. /**
  65808. * Callback called when a new log is added
  65809. */
  65810. static OnNewCacheEntry: (entry: string) => void;
  65811. private static _AddLogEntry;
  65812. private static _FormatMessage;
  65813. private static _LogDisabled;
  65814. private static _LogEnabled;
  65815. private static _WarnDisabled;
  65816. private static _WarnEnabled;
  65817. private static _ErrorDisabled;
  65818. private static _ErrorEnabled;
  65819. /**
  65820. * Log a message to the console
  65821. */
  65822. static Log: (message: string) => void;
  65823. /**
  65824. * Write a warning message to the console
  65825. */
  65826. static Warn: (message: string) => void;
  65827. /**
  65828. * Write an error message to the console
  65829. */
  65830. static Error: (message: string) => void;
  65831. /**
  65832. * Gets current log cache (list of logs)
  65833. */
  65834. static readonly LogCache: string;
  65835. /**
  65836. * Clears the log cache
  65837. */
  65838. static ClearLogCache(): void;
  65839. /**
  65840. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65841. */
  65842. static LogLevels: number;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /** @hidden */
  65847. export class _TypeStore {
  65848. /** @hidden */
  65849. static RegisteredTypes: {
  65850. [key: string]: Object;
  65851. };
  65852. /** @hidden */
  65853. static GetClass(fqdn: string): any;
  65854. }
  65855. }
  65856. declare module BABYLON {
  65857. /**
  65858. * Class containing a set of static utilities functions for deep copy.
  65859. */
  65860. export class DeepCopier {
  65861. /**
  65862. * Tries to copy an object by duplicating every property
  65863. * @param source defines the source object
  65864. * @param destination defines the target object
  65865. * @param doNotCopyList defines a list of properties to avoid
  65866. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65867. */
  65868. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65869. }
  65870. }
  65871. declare module BABYLON {
  65872. /**
  65873. * Class containing a set of static utilities functions for precision date
  65874. */
  65875. export class PrecisionDate {
  65876. /**
  65877. * Gets either window.performance.now() if supported or Date.now() else
  65878. */
  65879. static readonly Now: number;
  65880. }
  65881. }
  65882. declare module BABYLON {
  65883. /** @hidden */
  65884. export class _DevTools {
  65885. static WarnImport(name: string): string;
  65886. }
  65887. }
  65888. declare module BABYLON {
  65889. /**
  65890. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65891. */
  65892. export class WebRequest {
  65893. private _xhr;
  65894. /**
  65895. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65896. * i.e. when loading files, where the server/service expects an Authorization header
  65897. */
  65898. static CustomRequestHeaders: {
  65899. [key: string]: string;
  65900. };
  65901. /**
  65902. * Add callback functions in this array to update all the requests before they get sent to the network
  65903. */
  65904. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65905. private _injectCustomRequestHeaders;
  65906. /**
  65907. * Gets or sets a function to be called when loading progress changes
  65908. */
  65909. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65910. /**
  65911. * Returns client's state
  65912. */
  65913. readonly readyState: number;
  65914. /**
  65915. * Returns client's status
  65916. */
  65917. readonly status: number;
  65918. /**
  65919. * Returns client's status as a text
  65920. */
  65921. readonly statusText: string;
  65922. /**
  65923. * Returns client's response
  65924. */
  65925. readonly response: any;
  65926. /**
  65927. * Returns client's response url
  65928. */
  65929. readonly responseURL: string;
  65930. /**
  65931. * Returns client's response as text
  65932. */
  65933. readonly responseText: string;
  65934. /**
  65935. * Gets or sets the expected response type
  65936. */
  65937. responseType: XMLHttpRequestResponseType;
  65938. /** @hidden */
  65939. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65940. /** @hidden */
  65941. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65942. /**
  65943. * Cancels any network activity
  65944. */
  65945. abort(): void;
  65946. /**
  65947. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65948. * @param body defines an optional request body
  65949. */
  65950. send(body?: Document | BodyInit | null): void;
  65951. /**
  65952. * Sets the request method, request URL
  65953. * @param method defines the method to use (GET, POST, etc..)
  65954. * @param url defines the url to connect with
  65955. */
  65956. open(method: string, url: string): void;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * File request interface
  65962. */
  65963. export interface IFileRequest {
  65964. /**
  65965. * Raised when the request is complete (success or error).
  65966. */
  65967. onCompleteObservable: Observable<IFileRequest>;
  65968. /**
  65969. * Aborts the request for a file.
  65970. */
  65971. abort: () => void;
  65972. }
  65973. }
  65974. declare module BABYLON {
  65975. /**
  65976. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65977. */
  65978. export class PerformanceMonitor {
  65979. private _enabled;
  65980. private _rollingFrameTime;
  65981. private _lastFrameTimeMs;
  65982. /**
  65983. * constructor
  65984. * @param frameSampleSize The number of samples required to saturate the sliding window
  65985. */
  65986. constructor(frameSampleSize?: number);
  65987. /**
  65988. * Samples current frame
  65989. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65990. */
  65991. sampleFrame(timeMs?: number): void;
  65992. /**
  65993. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65994. */
  65995. readonly averageFrameTime: number;
  65996. /**
  65997. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65998. */
  65999. readonly averageFrameTimeVariance: number;
  66000. /**
  66001. * Returns the frame time of the most recent frame
  66002. */
  66003. readonly instantaneousFrameTime: number;
  66004. /**
  66005. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66006. */
  66007. readonly averageFPS: number;
  66008. /**
  66009. * Returns the average framerate in frames per second using the most recent frame time
  66010. */
  66011. readonly instantaneousFPS: number;
  66012. /**
  66013. * Returns true if enough samples have been taken to completely fill the sliding window
  66014. */
  66015. readonly isSaturated: boolean;
  66016. /**
  66017. * Enables contributions to the sliding window sample set
  66018. */
  66019. enable(): void;
  66020. /**
  66021. * Disables contributions to the sliding window sample set
  66022. * Samples will not be interpolated over the disabled period
  66023. */
  66024. disable(): void;
  66025. /**
  66026. * Returns true if sampling is enabled
  66027. */
  66028. readonly isEnabled: boolean;
  66029. /**
  66030. * Resets performance monitor
  66031. */
  66032. reset(): void;
  66033. }
  66034. /**
  66035. * RollingAverage
  66036. *
  66037. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66038. */
  66039. export class RollingAverage {
  66040. /**
  66041. * Current average
  66042. */
  66043. average: number;
  66044. /**
  66045. * Current variance
  66046. */
  66047. variance: number;
  66048. protected _samples: Array<number>;
  66049. protected _sampleCount: number;
  66050. protected _pos: number;
  66051. protected _m2: number;
  66052. /**
  66053. * constructor
  66054. * @param length The number of samples required to saturate the sliding window
  66055. */
  66056. constructor(length: number);
  66057. /**
  66058. * Adds a sample to the sample set
  66059. * @param v The sample value
  66060. */
  66061. add(v: number): void;
  66062. /**
  66063. * Returns previously added values or null if outside of history or outside the sliding window domain
  66064. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66065. * @return Value previously recorded with add() or null if outside of range
  66066. */
  66067. history(i: number): number;
  66068. /**
  66069. * Returns true if enough samples have been taken to completely fill the sliding window
  66070. * @return true if sample-set saturated
  66071. */
  66072. isSaturated(): boolean;
  66073. /**
  66074. * Resets the rolling average (equivalent to 0 samples taken so far)
  66075. */
  66076. reset(): void;
  66077. /**
  66078. * Wraps a value around the sample range boundaries
  66079. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66080. * @return Wrapped position in sample range
  66081. */
  66082. protected _wrapPosition(i: number): number;
  66083. }
  66084. }
  66085. declare module BABYLON {
  66086. /**
  66087. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66088. * The underlying implementation relies on an associative array to ensure the best performances.
  66089. * The value can be anything including 'null' but except 'undefined'
  66090. */
  66091. export class StringDictionary<T> {
  66092. /**
  66093. * This will clear this dictionary and copy the content from the 'source' one.
  66094. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66095. * @param source the dictionary to take the content from and copy to this dictionary
  66096. */
  66097. copyFrom(source: StringDictionary<T>): void;
  66098. /**
  66099. * Get a value based from its key
  66100. * @param key the given key to get the matching value from
  66101. * @return the value if found, otherwise undefined is returned
  66102. */
  66103. get(key: string): T | undefined;
  66104. /**
  66105. * Get a value from its key or add it if it doesn't exist.
  66106. * This method will ensure you that a given key/data will be present in the dictionary.
  66107. * @param key the given key to get the matching value from
  66108. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66109. * The factory will only be invoked if there's no data for the given key.
  66110. * @return the value corresponding to the key.
  66111. */
  66112. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66113. /**
  66114. * Get a value from its key if present in the dictionary otherwise add it
  66115. * @param key the key to get the value from
  66116. * @param val if there's no such key/value pair in the dictionary add it with this value
  66117. * @return the value corresponding to the key
  66118. */
  66119. getOrAdd(key: string, val: T): T;
  66120. /**
  66121. * Check if there's a given key in the dictionary
  66122. * @param key the key to check for
  66123. * @return true if the key is present, false otherwise
  66124. */
  66125. contains(key: string): boolean;
  66126. /**
  66127. * Add a new key and its corresponding value
  66128. * @param key the key to add
  66129. * @param value the value corresponding to the key
  66130. * @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
  66131. */
  66132. add(key: string, value: T): boolean;
  66133. /**
  66134. * Update a specific value associated to a key
  66135. * @param key defines the key to use
  66136. * @param value defines the value to store
  66137. * @returns true if the value was updated (or false if the key was not found)
  66138. */
  66139. set(key: string, value: T): boolean;
  66140. /**
  66141. * Get the element of the given key and remove it from the dictionary
  66142. * @param key defines the key to search
  66143. * @returns the value associated with the key or null if not found
  66144. */
  66145. getAndRemove(key: string): Nullable<T>;
  66146. /**
  66147. * Remove a key/value from the dictionary.
  66148. * @param key the key to remove
  66149. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66150. */
  66151. remove(key: string): boolean;
  66152. /**
  66153. * Clear the whole content of the dictionary
  66154. */
  66155. clear(): void;
  66156. /**
  66157. * Gets the current count
  66158. */
  66159. readonly count: number;
  66160. /**
  66161. * Execute a callback on each key/val of the dictionary.
  66162. * Note that you can remove any element in this dictionary in the callback implementation
  66163. * @param callback the callback to execute on a given key/value pair
  66164. */
  66165. forEach(callback: (key: string, val: T) => void): void;
  66166. /**
  66167. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66168. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66169. * Note that you can remove any element in this dictionary in the callback implementation
  66170. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66171. * @returns the first item
  66172. */
  66173. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66174. private _count;
  66175. private _data;
  66176. }
  66177. }
  66178. declare module BABYLON {
  66179. /**
  66180. * Class used to store gfx data (like WebGLBuffer)
  66181. */
  66182. export class DataBuffer {
  66183. /**
  66184. * Gets or sets the number of objects referencing this buffer
  66185. */
  66186. references: number;
  66187. /** Gets or sets the size of the underlying buffer */
  66188. capacity: number;
  66189. /**
  66190. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66191. */
  66192. is32Bits: boolean;
  66193. /**
  66194. * Gets the underlying buffer
  66195. */
  66196. readonly underlyingResource: any;
  66197. }
  66198. }
  66199. declare module BABYLON {
  66200. /**
  66201. * Class used to store data that will be store in GPU memory
  66202. */
  66203. export class Buffer {
  66204. private _engine;
  66205. private _buffer;
  66206. /** @hidden */
  66207. _data: Nullable<DataArray>;
  66208. private _updatable;
  66209. private _instanced;
  66210. /**
  66211. * Gets the byte stride.
  66212. */
  66213. readonly byteStride: number;
  66214. /**
  66215. * Constructor
  66216. * @param engine the engine
  66217. * @param data the data to use for this buffer
  66218. * @param updatable whether the data is updatable
  66219. * @param stride the stride (optional)
  66220. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66221. * @param instanced whether the buffer is instanced (optional)
  66222. * @param useBytes set to true if the stride in in bytes (optional)
  66223. */
  66224. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66225. /**
  66226. * Create a new VertexBuffer based on the current buffer
  66227. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66228. * @param offset defines offset in the buffer (0 by default)
  66229. * @param size defines the size in floats of attributes (position is 3 for instance)
  66230. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66231. * @param instanced defines if the vertex buffer contains indexed data
  66232. * @param useBytes defines if the offset and stride are in bytes
  66233. * @returns the new vertex buffer
  66234. */
  66235. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66236. /**
  66237. * Gets a boolean indicating if the Buffer is updatable?
  66238. * @returns true if the buffer is updatable
  66239. */
  66240. isUpdatable(): boolean;
  66241. /**
  66242. * Gets current buffer's data
  66243. * @returns a DataArray or null
  66244. */
  66245. getData(): Nullable<DataArray>;
  66246. /**
  66247. * Gets underlying native buffer
  66248. * @returns underlying native buffer
  66249. */
  66250. getBuffer(): Nullable<DataBuffer>;
  66251. /**
  66252. * Gets the stride in float32 units (i.e. byte stride / 4).
  66253. * May not be an integer if the byte stride is not divisible by 4.
  66254. * DEPRECATED. Use byteStride instead.
  66255. * @returns the stride in float32 units
  66256. */
  66257. getStrideSize(): number;
  66258. /**
  66259. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66260. * @param data defines the data to store
  66261. */
  66262. create(data?: Nullable<DataArray>): void;
  66263. /** @hidden */
  66264. _rebuild(): void;
  66265. /**
  66266. * Update current buffer data
  66267. * @param data defines the data to store
  66268. */
  66269. update(data: DataArray): void;
  66270. /**
  66271. * Updates the data directly.
  66272. * @param data the new data
  66273. * @param offset the new offset
  66274. * @param vertexCount the vertex count (optional)
  66275. * @param useBytes set to true if the offset is in bytes
  66276. */
  66277. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66278. /**
  66279. * Release all resources
  66280. */
  66281. dispose(): void;
  66282. }
  66283. /**
  66284. * Specialized buffer used to store vertex data
  66285. */
  66286. export class VertexBuffer {
  66287. /** @hidden */
  66288. _buffer: Buffer;
  66289. private _kind;
  66290. private _size;
  66291. private _ownsBuffer;
  66292. private _instanced;
  66293. private _instanceDivisor;
  66294. /**
  66295. * The byte type.
  66296. */
  66297. static readonly BYTE: number;
  66298. /**
  66299. * The unsigned byte type.
  66300. */
  66301. static readonly UNSIGNED_BYTE: number;
  66302. /**
  66303. * The short type.
  66304. */
  66305. static readonly SHORT: number;
  66306. /**
  66307. * The unsigned short type.
  66308. */
  66309. static readonly UNSIGNED_SHORT: number;
  66310. /**
  66311. * The integer type.
  66312. */
  66313. static readonly INT: number;
  66314. /**
  66315. * The unsigned integer type.
  66316. */
  66317. static readonly UNSIGNED_INT: number;
  66318. /**
  66319. * The float type.
  66320. */
  66321. static readonly FLOAT: number;
  66322. /**
  66323. * Gets or sets the instance divisor when in instanced mode
  66324. */
  66325. instanceDivisor: number;
  66326. /**
  66327. * Gets the byte stride.
  66328. */
  66329. readonly byteStride: number;
  66330. /**
  66331. * Gets the byte offset.
  66332. */
  66333. readonly byteOffset: number;
  66334. /**
  66335. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66336. */
  66337. readonly normalized: boolean;
  66338. /**
  66339. * Gets the data type of each component in the array.
  66340. */
  66341. readonly type: number;
  66342. /**
  66343. * Constructor
  66344. * @param engine the engine
  66345. * @param data the data to use for this vertex buffer
  66346. * @param kind the vertex buffer kind
  66347. * @param updatable whether the data is updatable
  66348. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66349. * @param stride the stride (optional)
  66350. * @param instanced whether the buffer is instanced (optional)
  66351. * @param offset the offset of the data (optional)
  66352. * @param size the number of components (optional)
  66353. * @param type the type of the component (optional)
  66354. * @param normalized whether the data contains normalized data (optional)
  66355. * @param useBytes set to true if stride and offset are in bytes (optional)
  66356. */
  66357. 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);
  66358. /** @hidden */
  66359. _rebuild(): void;
  66360. /**
  66361. * Returns the kind of the VertexBuffer (string)
  66362. * @returns a string
  66363. */
  66364. getKind(): string;
  66365. /**
  66366. * Gets a boolean indicating if the VertexBuffer is updatable?
  66367. * @returns true if the buffer is updatable
  66368. */
  66369. isUpdatable(): boolean;
  66370. /**
  66371. * Gets current buffer's data
  66372. * @returns a DataArray or null
  66373. */
  66374. getData(): Nullable<DataArray>;
  66375. /**
  66376. * Gets underlying native buffer
  66377. * @returns underlying native buffer
  66378. */
  66379. getBuffer(): Nullable<DataBuffer>;
  66380. /**
  66381. * Gets the stride in float32 units (i.e. byte stride / 4).
  66382. * May not be an integer if the byte stride is not divisible by 4.
  66383. * DEPRECATED. Use byteStride instead.
  66384. * @returns the stride in float32 units
  66385. */
  66386. getStrideSize(): number;
  66387. /**
  66388. * Returns the offset as a multiple of the type byte length.
  66389. * DEPRECATED. Use byteOffset instead.
  66390. * @returns the offset in bytes
  66391. */
  66392. getOffset(): number;
  66393. /**
  66394. * Returns the number of components per vertex attribute (integer)
  66395. * @returns the size in float
  66396. */
  66397. getSize(): number;
  66398. /**
  66399. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66400. * @returns true if this buffer is instanced
  66401. */
  66402. getIsInstanced(): boolean;
  66403. /**
  66404. * Returns the instancing divisor, zero for non-instanced (integer).
  66405. * @returns a number
  66406. */
  66407. getInstanceDivisor(): number;
  66408. /**
  66409. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66410. * @param data defines the data to store
  66411. */
  66412. create(data?: DataArray): void;
  66413. /**
  66414. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66415. * This function will create a new buffer if the current one is not updatable
  66416. * @param data defines the data to store
  66417. */
  66418. update(data: DataArray): void;
  66419. /**
  66420. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66421. * Returns the directly updated WebGLBuffer.
  66422. * @param data the new data
  66423. * @param offset the new offset
  66424. * @param useBytes set to true if the offset is in bytes
  66425. */
  66426. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66427. /**
  66428. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66429. */
  66430. dispose(): void;
  66431. /**
  66432. * Enumerates each value of this vertex buffer as numbers.
  66433. * @param count the number of values to enumerate
  66434. * @param callback the callback function called for each value
  66435. */
  66436. forEach(count: number, callback: (value: number, index: number) => void): void;
  66437. /**
  66438. * Positions
  66439. */
  66440. static readonly PositionKind: string;
  66441. /**
  66442. * Normals
  66443. */
  66444. static readonly NormalKind: string;
  66445. /**
  66446. * Tangents
  66447. */
  66448. static readonly TangentKind: string;
  66449. /**
  66450. * Texture coordinates
  66451. */
  66452. static readonly UVKind: string;
  66453. /**
  66454. * Texture coordinates 2
  66455. */
  66456. static readonly UV2Kind: string;
  66457. /**
  66458. * Texture coordinates 3
  66459. */
  66460. static readonly UV3Kind: string;
  66461. /**
  66462. * Texture coordinates 4
  66463. */
  66464. static readonly UV4Kind: string;
  66465. /**
  66466. * Texture coordinates 5
  66467. */
  66468. static readonly UV5Kind: string;
  66469. /**
  66470. * Texture coordinates 6
  66471. */
  66472. static readonly UV6Kind: string;
  66473. /**
  66474. * Colors
  66475. */
  66476. static readonly ColorKind: string;
  66477. /**
  66478. * Matrix indices (for bones)
  66479. */
  66480. static readonly MatricesIndicesKind: string;
  66481. /**
  66482. * Matrix weights (for bones)
  66483. */
  66484. static readonly MatricesWeightsKind: string;
  66485. /**
  66486. * Additional matrix indices (for bones)
  66487. */
  66488. static readonly MatricesIndicesExtraKind: string;
  66489. /**
  66490. * Additional matrix weights (for bones)
  66491. */
  66492. static readonly MatricesWeightsExtraKind: string;
  66493. /**
  66494. * Deduces the stride given a kind.
  66495. * @param kind The kind string to deduce
  66496. * @returns The deduced stride
  66497. */
  66498. static DeduceStride(kind: string): number;
  66499. /**
  66500. * Gets the byte length of the given type.
  66501. * @param type the type
  66502. * @returns the number of bytes
  66503. */
  66504. static GetTypeByteLength(type: number): number;
  66505. /**
  66506. * Enumerates each value of the given parameters as numbers.
  66507. * @param data the data to enumerate
  66508. * @param byteOffset the byte offset of the data
  66509. * @param byteStride the byte stride of the data
  66510. * @param componentCount the number of components per element
  66511. * @param componentType the type of the component
  66512. * @param count the number of values to enumerate
  66513. * @param normalized whether the data is normalized
  66514. * @param callback the callback function called for each value
  66515. */
  66516. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66517. private static _GetFloatValue;
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. /**
  66522. * Scalar computation library
  66523. */
  66524. export class Scalar {
  66525. /**
  66526. * Two pi constants convenient for computation.
  66527. */
  66528. static TwoPi: number;
  66529. /**
  66530. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66531. * @param a number
  66532. * @param b number
  66533. * @param epsilon (default = 1.401298E-45)
  66534. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66535. */
  66536. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66537. /**
  66538. * Returns a string : the upper case translation of the number i to hexadecimal.
  66539. * @param i number
  66540. * @returns the upper case translation of the number i to hexadecimal.
  66541. */
  66542. static ToHex(i: number): string;
  66543. /**
  66544. * Returns -1 if value is negative and +1 is value is positive.
  66545. * @param value the value
  66546. * @returns the value itself if it's equal to zero.
  66547. */
  66548. static Sign(value: number): number;
  66549. /**
  66550. * Returns the value itself if it's between min and max.
  66551. * Returns min if the value is lower than min.
  66552. * Returns max if the value is greater than max.
  66553. * @param value the value to clmap
  66554. * @param min the min value to clamp to (default: 0)
  66555. * @param max the max value to clamp to (default: 1)
  66556. * @returns the clamped value
  66557. */
  66558. static Clamp(value: number, min?: number, max?: number): number;
  66559. /**
  66560. * the log2 of value.
  66561. * @param value the value to compute log2 of
  66562. * @returns the log2 of value.
  66563. */
  66564. static Log2(value: number): number;
  66565. /**
  66566. * Loops the value, so that it is never larger than length and never smaller than 0.
  66567. *
  66568. * This is similar to the modulo operator but it works with floating point numbers.
  66569. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66570. * With t = 5 and length = 2.5, the result would be 0.0.
  66571. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66572. * @param value the value
  66573. * @param length the length
  66574. * @returns the looped value
  66575. */
  66576. static Repeat(value: number, length: number): number;
  66577. /**
  66578. * Normalize the value between 0.0 and 1.0 using min and max values
  66579. * @param value value to normalize
  66580. * @param min max to normalize between
  66581. * @param max min to normalize between
  66582. * @returns the normalized value
  66583. */
  66584. static Normalize(value: number, min: number, max: number): number;
  66585. /**
  66586. * Denormalize the value from 0.0 and 1.0 using min and max values
  66587. * @param normalized value to denormalize
  66588. * @param min max to denormalize between
  66589. * @param max min to denormalize between
  66590. * @returns the denormalized value
  66591. */
  66592. static Denormalize(normalized: number, min: number, max: number): number;
  66593. /**
  66594. * Calculates the shortest difference between two given angles given in degrees.
  66595. * @param current current angle in degrees
  66596. * @param target target angle in degrees
  66597. * @returns the delta
  66598. */
  66599. static DeltaAngle(current: number, target: number): number;
  66600. /**
  66601. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66602. * @param tx value
  66603. * @param length length
  66604. * @returns The returned value will move back and forth between 0 and length
  66605. */
  66606. static PingPong(tx: number, length: number): number;
  66607. /**
  66608. * Interpolates between min and max with smoothing at the limits.
  66609. *
  66610. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66611. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66612. * @param from from
  66613. * @param to to
  66614. * @param tx value
  66615. * @returns the smooth stepped value
  66616. */
  66617. static SmoothStep(from: number, to: number, tx: number): number;
  66618. /**
  66619. * Moves a value current towards target.
  66620. *
  66621. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66622. * Negative values of maxDelta pushes the value away from target.
  66623. * @param current current value
  66624. * @param target target value
  66625. * @param maxDelta max distance to move
  66626. * @returns resulting value
  66627. */
  66628. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66629. /**
  66630. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66631. *
  66632. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66633. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66634. * @param current current value
  66635. * @param target target value
  66636. * @param maxDelta max distance to move
  66637. * @returns resulting angle
  66638. */
  66639. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66640. /**
  66641. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66642. * @param start start value
  66643. * @param end target value
  66644. * @param amount amount to lerp between
  66645. * @returns the lerped value
  66646. */
  66647. static Lerp(start: number, end: number, amount: number): number;
  66648. /**
  66649. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66650. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66651. * @param start start value
  66652. * @param end target value
  66653. * @param amount amount to lerp between
  66654. * @returns the lerped value
  66655. */
  66656. static LerpAngle(start: number, end: number, amount: number): number;
  66657. /**
  66658. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66659. * @param a start value
  66660. * @param b target value
  66661. * @param value value between a and b
  66662. * @returns the inverseLerp value
  66663. */
  66664. static InverseLerp(a: number, b: number, value: number): number;
  66665. /**
  66666. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66667. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66668. * @param value1 spline value
  66669. * @param tangent1 spline value
  66670. * @param value2 spline value
  66671. * @param tangent2 spline value
  66672. * @param amount input value
  66673. * @returns hermite result
  66674. */
  66675. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66676. /**
  66677. * Returns a random float number between and min and max values
  66678. * @param min min value of random
  66679. * @param max max value of random
  66680. * @returns random value
  66681. */
  66682. static RandomRange(min: number, max: number): number;
  66683. /**
  66684. * This function returns percentage of a number in a given range.
  66685. *
  66686. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66687. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66688. * @param number to convert to percentage
  66689. * @param min min range
  66690. * @param max max range
  66691. * @returns the percentage
  66692. */
  66693. static RangeToPercent(number: number, min: number, max: number): number;
  66694. /**
  66695. * This function returns number that corresponds to the percentage in a given range.
  66696. *
  66697. * PercentToRange(0.34,0,100) will return 34.
  66698. * @param percent to convert to number
  66699. * @param min min range
  66700. * @param max max range
  66701. * @returns the number
  66702. */
  66703. static PercentToRange(percent: number, min: number, max: number): number;
  66704. /**
  66705. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66706. * @param angle The angle to normalize in radian.
  66707. * @return The converted angle.
  66708. */
  66709. static NormalizeRadians(angle: number): number;
  66710. }
  66711. }
  66712. declare module BABYLON {
  66713. /**
  66714. * Constant used to convert a value to gamma space
  66715. * @ignorenaming
  66716. */
  66717. export const ToGammaSpace: number;
  66718. /**
  66719. * Constant used to convert a value to linear space
  66720. * @ignorenaming
  66721. */
  66722. export const ToLinearSpace = 2.2;
  66723. /**
  66724. * Constant used to define the minimal number value in Babylon.js
  66725. * @ignorenaming
  66726. */
  66727. let Epsilon: number;
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * Class used to represent a viewport on screen
  66732. */
  66733. export class Viewport {
  66734. /** viewport left coordinate */
  66735. x: number;
  66736. /** viewport top coordinate */
  66737. y: number;
  66738. /**viewport width */
  66739. width: number;
  66740. /** viewport height */
  66741. height: number;
  66742. /**
  66743. * Creates a Viewport object located at (x, y) and sized (width, height)
  66744. * @param x defines viewport left coordinate
  66745. * @param y defines viewport top coordinate
  66746. * @param width defines the viewport width
  66747. * @param height defines the viewport height
  66748. */
  66749. constructor(
  66750. /** viewport left coordinate */
  66751. x: number,
  66752. /** viewport top coordinate */
  66753. y: number,
  66754. /**viewport width */
  66755. width: number,
  66756. /** viewport height */
  66757. height: number);
  66758. /**
  66759. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66760. * @param renderWidth defines the rendering width
  66761. * @param renderHeight defines the rendering height
  66762. * @returns a new Viewport
  66763. */
  66764. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66765. /**
  66766. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66767. * @param renderWidth defines the rendering width
  66768. * @param renderHeight defines the rendering height
  66769. * @param ref defines the target viewport
  66770. * @returns the current viewport
  66771. */
  66772. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66773. /**
  66774. * Returns a new Viewport copied from the current one
  66775. * @returns a new Viewport
  66776. */
  66777. clone(): Viewport;
  66778. }
  66779. }
  66780. declare module BABYLON {
  66781. /**
  66782. * Class containing a set of static utilities functions for arrays.
  66783. */
  66784. export class ArrayTools {
  66785. /**
  66786. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66787. * @param size the number of element to construct and put in the array
  66788. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66789. * @returns a new array filled with new objects
  66790. */
  66791. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66792. }
  66793. }
  66794. declare module BABYLON {
  66795. /**
  66796. * @hidden
  66797. */
  66798. export interface IColor4Like {
  66799. r: float;
  66800. g: float;
  66801. b: float;
  66802. a: float;
  66803. }
  66804. /**
  66805. * @hidden
  66806. */
  66807. export interface IColor3Like {
  66808. r: float;
  66809. g: float;
  66810. b: float;
  66811. }
  66812. /**
  66813. * @hidden
  66814. */
  66815. export interface IVector4Like {
  66816. x: float;
  66817. y: float;
  66818. z: float;
  66819. w: float;
  66820. }
  66821. /**
  66822. * @hidden
  66823. */
  66824. export interface IVector3Like {
  66825. x: float;
  66826. y: float;
  66827. z: float;
  66828. }
  66829. /**
  66830. * @hidden
  66831. */
  66832. export interface IVector2Like {
  66833. x: float;
  66834. y: float;
  66835. }
  66836. /**
  66837. * @hidden
  66838. */
  66839. export interface IMatrixLike {
  66840. toArray(): DeepImmutable<Float32Array>;
  66841. updateFlag: int;
  66842. }
  66843. /**
  66844. * @hidden
  66845. */
  66846. export interface IViewportLike {
  66847. x: float;
  66848. y: float;
  66849. width: float;
  66850. height: float;
  66851. }
  66852. /**
  66853. * @hidden
  66854. */
  66855. export interface IPlaneLike {
  66856. normal: IVector3Like;
  66857. d: float;
  66858. normalize(): void;
  66859. }
  66860. }
  66861. declare module BABYLON {
  66862. /**
  66863. * Class representing a vector containing 2 coordinates
  66864. */
  66865. export class Vector2 {
  66866. /** defines the first coordinate */
  66867. x: number;
  66868. /** defines the second coordinate */
  66869. y: number;
  66870. /**
  66871. * Creates a new Vector2 from the given x and y coordinates
  66872. * @param x defines the first coordinate
  66873. * @param y defines the second coordinate
  66874. */
  66875. constructor(
  66876. /** defines the first coordinate */
  66877. x?: number,
  66878. /** defines the second coordinate */
  66879. y?: number);
  66880. /**
  66881. * Gets a string with the Vector2 coordinates
  66882. * @returns a string with the Vector2 coordinates
  66883. */
  66884. toString(): string;
  66885. /**
  66886. * Gets class name
  66887. * @returns the string "Vector2"
  66888. */
  66889. getClassName(): string;
  66890. /**
  66891. * Gets current vector hash code
  66892. * @returns the Vector2 hash code as a number
  66893. */
  66894. getHashCode(): number;
  66895. /**
  66896. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66897. * @param array defines the source array
  66898. * @param index defines the offset in source array
  66899. * @returns the current Vector2
  66900. */
  66901. toArray(array: FloatArray, index?: number): Vector2;
  66902. /**
  66903. * Copy the current vector to an array
  66904. * @returns a new array with 2 elements: the Vector2 coordinates.
  66905. */
  66906. asArray(): number[];
  66907. /**
  66908. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66909. * @param source defines the source Vector2
  66910. * @returns the current updated Vector2
  66911. */
  66912. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66913. /**
  66914. * Sets the Vector2 coordinates with the given floats
  66915. * @param x defines the first coordinate
  66916. * @param y defines the second coordinate
  66917. * @returns the current updated Vector2
  66918. */
  66919. copyFromFloats(x: number, y: number): Vector2;
  66920. /**
  66921. * Sets the Vector2 coordinates with the given floats
  66922. * @param x defines the first coordinate
  66923. * @param y defines the second coordinate
  66924. * @returns the current updated Vector2
  66925. */
  66926. set(x: number, y: number): Vector2;
  66927. /**
  66928. * Add another vector with the current one
  66929. * @param otherVector defines the other vector
  66930. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66931. */
  66932. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66933. /**
  66934. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66935. * @param otherVector defines the other vector
  66936. * @param result defines the target vector
  66937. * @returns the unmodified current Vector2
  66938. */
  66939. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66940. /**
  66941. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66942. * @param otherVector defines the other vector
  66943. * @returns the current updated Vector2
  66944. */
  66945. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66946. /**
  66947. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66948. * @param otherVector defines the other vector
  66949. * @returns a new Vector2
  66950. */
  66951. addVector3(otherVector: Vector3): Vector2;
  66952. /**
  66953. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66954. * @param otherVector defines the other vector
  66955. * @returns a new Vector2
  66956. */
  66957. subtract(otherVector: Vector2): Vector2;
  66958. /**
  66959. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66960. * @param otherVector defines the other vector
  66961. * @param result defines the target vector
  66962. * @returns the unmodified current Vector2
  66963. */
  66964. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66965. /**
  66966. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66967. * @param otherVector defines the other vector
  66968. * @returns the current updated Vector2
  66969. */
  66970. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66971. /**
  66972. * Multiplies in place the current Vector2 coordinates by the given ones
  66973. * @param otherVector defines the other vector
  66974. * @returns the current updated Vector2
  66975. */
  66976. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66977. /**
  66978. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66979. * @param otherVector defines the other vector
  66980. * @returns a new Vector2
  66981. */
  66982. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66983. /**
  66984. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66985. * @param otherVector defines the other vector
  66986. * @param result defines the target vector
  66987. * @returns the unmodified current Vector2
  66988. */
  66989. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66990. /**
  66991. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66992. * @param x defines the first coordinate
  66993. * @param y defines the second coordinate
  66994. * @returns a new Vector2
  66995. */
  66996. multiplyByFloats(x: number, y: number): Vector2;
  66997. /**
  66998. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66999. * @param otherVector defines the other vector
  67000. * @returns a new Vector2
  67001. */
  67002. divide(otherVector: Vector2): Vector2;
  67003. /**
  67004. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67005. * @param otherVector defines the other vector
  67006. * @param result defines the target vector
  67007. * @returns the unmodified current Vector2
  67008. */
  67009. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67010. /**
  67011. * Divides the current Vector2 coordinates by the given ones
  67012. * @param otherVector defines the other vector
  67013. * @returns the current updated Vector2
  67014. */
  67015. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67016. /**
  67017. * Gets a new Vector2 with current Vector2 negated coordinates
  67018. * @returns a new Vector2
  67019. */
  67020. negate(): Vector2;
  67021. /**
  67022. * Multiply the Vector2 coordinates by scale
  67023. * @param scale defines the scaling factor
  67024. * @returns the current updated Vector2
  67025. */
  67026. scaleInPlace(scale: number): Vector2;
  67027. /**
  67028. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67029. * @param scale defines the scaling factor
  67030. * @returns a new Vector2
  67031. */
  67032. scale(scale: number): Vector2;
  67033. /**
  67034. * Scale the current Vector2 values by a factor to a given Vector2
  67035. * @param scale defines the scale factor
  67036. * @param result defines the Vector2 object where to store the result
  67037. * @returns the unmodified current Vector2
  67038. */
  67039. scaleToRef(scale: number, result: Vector2): Vector2;
  67040. /**
  67041. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67042. * @param scale defines the scale factor
  67043. * @param result defines the Vector2 object where to store the result
  67044. * @returns the unmodified current Vector2
  67045. */
  67046. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67047. /**
  67048. * Gets a boolean if two vectors are equals
  67049. * @param otherVector defines the other vector
  67050. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67051. */
  67052. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67053. /**
  67054. * Gets a boolean if two vectors are equals (using an epsilon value)
  67055. * @param otherVector defines the other vector
  67056. * @param epsilon defines the minimal distance to consider equality
  67057. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67058. */
  67059. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67060. /**
  67061. * Gets a new Vector2 from current Vector2 floored values
  67062. * @returns a new Vector2
  67063. */
  67064. floor(): Vector2;
  67065. /**
  67066. * Gets a new Vector2 from current Vector2 floored values
  67067. * @returns a new Vector2
  67068. */
  67069. fract(): Vector2;
  67070. /**
  67071. * Gets the length of the vector
  67072. * @returns the vector length (float)
  67073. */
  67074. length(): number;
  67075. /**
  67076. * Gets the vector squared length
  67077. * @returns the vector squared length (float)
  67078. */
  67079. lengthSquared(): number;
  67080. /**
  67081. * Normalize the vector
  67082. * @returns the current updated Vector2
  67083. */
  67084. normalize(): Vector2;
  67085. /**
  67086. * Gets a new Vector2 copied from the Vector2
  67087. * @returns a new Vector2
  67088. */
  67089. clone(): Vector2;
  67090. /**
  67091. * Gets a new Vector2(0, 0)
  67092. * @returns a new Vector2
  67093. */
  67094. static Zero(): Vector2;
  67095. /**
  67096. * Gets a new Vector2(1, 1)
  67097. * @returns a new Vector2
  67098. */
  67099. static One(): Vector2;
  67100. /**
  67101. * Gets a new Vector2 set from the given index element of the given array
  67102. * @param array defines the data source
  67103. * @param offset defines the offset in the data source
  67104. * @returns a new Vector2
  67105. */
  67106. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67107. /**
  67108. * Sets "result" from the given index element of the given array
  67109. * @param array defines the data source
  67110. * @param offset defines the offset in the data source
  67111. * @param result defines the target vector
  67112. */
  67113. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67114. /**
  67115. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67116. * @param value1 defines 1st point of control
  67117. * @param value2 defines 2nd point of control
  67118. * @param value3 defines 3rd point of control
  67119. * @param value4 defines 4th point of control
  67120. * @param amount defines the interpolation factor
  67121. * @returns a new Vector2
  67122. */
  67123. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67124. /**
  67125. * 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".
  67126. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67127. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67128. * @param value defines the value to clamp
  67129. * @param min defines the lower limit
  67130. * @param max defines the upper limit
  67131. * @returns a new Vector2
  67132. */
  67133. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67134. /**
  67135. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67136. * @param value1 defines the 1st control point
  67137. * @param tangent1 defines the outgoing tangent
  67138. * @param value2 defines the 2nd control point
  67139. * @param tangent2 defines the incoming tangent
  67140. * @param amount defines the interpolation factor
  67141. * @returns a new Vector2
  67142. */
  67143. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67144. /**
  67145. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67146. * @param start defines the start vector
  67147. * @param end defines the end vector
  67148. * @param amount defines the interpolation factor
  67149. * @returns a new Vector2
  67150. */
  67151. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67152. /**
  67153. * Gets the dot product of the vector "left" and the vector "right"
  67154. * @param left defines first vector
  67155. * @param right defines second vector
  67156. * @returns the dot product (float)
  67157. */
  67158. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67159. /**
  67160. * Returns a new Vector2 equal to the normalized given vector
  67161. * @param vector defines the vector to normalize
  67162. * @returns a new Vector2
  67163. */
  67164. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67165. /**
  67166. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67167. * @param left defines 1st vector
  67168. * @param right defines 2nd vector
  67169. * @returns a new Vector2
  67170. */
  67171. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67172. /**
  67173. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67174. * @param left defines 1st vector
  67175. * @param right defines 2nd vector
  67176. * @returns a new Vector2
  67177. */
  67178. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67179. /**
  67180. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67181. * @param vector defines the vector to transform
  67182. * @param transformation defines the matrix to apply
  67183. * @returns a new Vector2
  67184. */
  67185. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67186. /**
  67187. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67188. * @param vector defines the vector to transform
  67189. * @param transformation defines the matrix to apply
  67190. * @param result defines the target vector
  67191. */
  67192. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67193. /**
  67194. * Determines if a given vector is included in a triangle
  67195. * @param p defines the vector to test
  67196. * @param p0 defines 1st triangle point
  67197. * @param p1 defines 2nd triangle point
  67198. * @param p2 defines 3rd triangle point
  67199. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67200. */
  67201. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67202. /**
  67203. * Gets the distance between the vectors "value1" and "value2"
  67204. * @param value1 defines first vector
  67205. * @param value2 defines second vector
  67206. * @returns the distance between vectors
  67207. */
  67208. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67209. /**
  67210. * Returns the squared distance between the vectors "value1" and "value2"
  67211. * @param value1 defines first vector
  67212. * @param value2 defines second vector
  67213. * @returns the squared distance between vectors
  67214. */
  67215. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67216. /**
  67217. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67218. * @param value1 defines first vector
  67219. * @param value2 defines second vector
  67220. * @returns a new Vector2
  67221. */
  67222. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67223. /**
  67224. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67225. * @param p defines the middle point
  67226. * @param segA defines one point of the segment
  67227. * @param segB defines the other point of the segment
  67228. * @returns the shortest distance
  67229. */
  67230. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67231. }
  67232. /**
  67233. * Classed used to store (x,y,z) vector representation
  67234. * A Vector3 is the main object used in 3D geometry
  67235. * It can represent etiher the coordinates of a point the space, either a direction
  67236. * Reminder: js uses a left handed forward facing system
  67237. */
  67238. export class Vector3 {
  67239. /**
  67240. * Defines the first coordinates (on X axis)
  67241. */
  67242. x: number;
  67243. /**
  67244. * Defines the second coordinates (on Y axis)
  67245. */
  67246. y: number;
  67247. /**
  67248. * Defines the third coordinates (on Z axis)
  67249. */
  67250. z: number;
  67251. private static _UpReadOnly;
  67252. private static _ZeroReadOnly;
  67253. /**
  67254. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67255. * @param x defines the first coordinates (on X axis)
  67256. * @param y defines the second coordinates (on Y axis)
  67257. * @param z defines the third coordinates (on Z axis)
  67258. */
  67259. constructor(
  67260. /**
  67261. * Defines the first coordinates (on X axis)
  67262. */
  67263. x?: number,
  67264. /**
  67265. * Defines the second coordinates (on Y axis)
  67266. */
  67267. y?: number,
  67268. /**
  67269. * Defines the third coordinates (on Z axis)
  67270. */
  67271. z?: number);
  67272. /**
  67273. * Creates a string representation of the Vector3
  67274. * @returns a string with the Vector3 coordinates.
  67275. */
  67276. toString(): string;
  67277. /**
  67278. * Gets the class name
  67279. * @returns the string "Vector3"
  67280. */
  67281. getClassName(): string;
  67282. /**
  67283. * Creates the Vector3 hash code
  67284. * @returns a number which tends to be unique between Vector3 instances
  67285. */
  67286. getHashCode(): number;
  67287. /**
  67288. * Creates an array containing three elements : the coordinates of the Vector3
  67289. * @returns a new array of numbers
  67290. */
  67291. asArray(): number[];
  67292. /**
  67293. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67294. * @param array defines the destination array
  67295. * @param index defines the offset in the destination array
  67296. * @returns the current Vector3
  67297. */
  67298. toArray(array: FloatArray, index?: number): Vector3;
  67299. /**
  67300. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67301. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67302. */
  67303. toQuaternion(): Quaternion;
  67304. /**
  67305. * Adds the given vector to the current Vector3
  67306. * @param otherVector defines the second operand
  67307. * @returns the current updated Vector3
  67308. */
  67309. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67310. /**
  67311. * Adds the given coordinates to the current Vector3
  67312. * @param x defines the x coordinate of the operand
  67313. * @param y defines the y coordinate of the operand
  67314. * @param z defines the z coordinate of the operand
  67315. * @returns the current updated Vector3
  67316. */
  67317. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67318. /**
  67319. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67320. * @param otherVector defines the second operand
  67321. * @returns the resulting Vector3
  67322. */
  67323. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67324. /**
  67325. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67326. * @param otherVector defines the second operand
  67327. * @param result defines the Vector3 object where to store the result
  67328. * @returns the current Vector3
  67329. */
  67330. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67331. /**
  67332. * Subtract the given vector from the current Vector3
  67333. * @param otherVector defines the second operand
  67334. * @returns the current updated Vector3
  67335. */
  67336. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67337. /**
  67338. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67339. * @param otherVector defines the second operand
  67340. * @returns the resulting Vector3
  67341. */
  67342. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67343. /**
  67344. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67345. * @param otherVector defines the second operand
  67346. * @param result defines the Vector3 object where to store the result
  67347. * @returns the current Vector3
  67348. */
  67349. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67350. /**
  67351. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67352. * @param x defines the x coordinate of the operand
  67353. * @param y defines the y coordinate of the operand
  67354. * @param z defines the z coordinate of the operand
  67355. * @returns the resulting Vector3
  67356. */
  67357. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67358. /**
  67359. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67360. * @param x defines the x coordinate of the operand
  67361. * @param y defines the y coordinate of the operand
  67362. * @param z defines the z coordinate of the operand
  67363. * @param result defines the Vector3 object where to store the result
  67364. * @returns the current Vector3
  67365. */
  67366. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67367. /**
  67368. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67369. * @returns a new Vector3
  67370. */
  67371. negate(): Vector3;
  67372. /**
  67373. * Multiplies the Vector3 coordinates by the float "scale"
  67374. * @param scale defines the multiplier factor
  67375. * @returns the current updated Vector3
  67376. */
  67377. scaleInPlace(scale: number): Vector3;
  67378. /**
  67379. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67380. * @param scale defines the multiplier factor
  67381. * @returns a new Vector3
  67382. */
  67383. scale(scale: number): Vector3;
  67384. /**
  67385. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67386. * @param scale defines the multiplier factor
  67387. * @param result defines the Vector3 object where to store the result
  67388. * @returns the current Vector3
  67389. */
  67390. scaleToRef(scale: number, result: Vector3): Vector3;
  67391. /**
  67392. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67393. * @param scale defines the scale factor
  67394. * @param result defines the Vector3 object where to store the result
  67395. * @returns the unmodified current Vector3
  67396. */
  67397. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67398. /**
  67399. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67400. * @param otherVector defines the second operand
  67401. * @returns true if both vectors are equals
  67402. */
  67403. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67404. /**
  67405. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67406. * @param otherVector defines the second operand
  67407. * @param epsilon defines the minimal distance to define values as equals
  67408. * @returns true if both vectors are distant less than epsilon
  67409. */
  67410. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67411. /**
  67412. * Returns true if the current Vector3 coordinates equals the given floats
  67413. * @param x defines the x coordinate of the operand
  67414. * @param y defines the y coordinate of the operand
  67415. * @param z defines the z coordinate of the operand
  67416. * @returns true if both vectors are equals
  67417. */
  67418. equalsToFloats(x: number, y: number, z: number): boolean;
  67419. /**
  67420. * Multiplies the current Vector3 coordinates by the given ones
  67421. * @param otherVector defines the second operand
  67422. * @returns the current updated Vector3
  67423. */
  67424. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67425. /**
  67426. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67427. * @param otherVector defines the second operand
  67428. * @returns the new Vector3
  67429. */
  67430. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67431. /**
  67432. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67433. * @param otherVector defines the second operand
  67434. * @param result defines the Vector3 object where to store the result
  67435. * @returns the current Vector3
  67436. */
  67437. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67438. /**
  67439. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67440. * @param x defines the x coordinate of the operand
  67441. * @param y defines the y coordinate of the operand
  67442. * @param z defines the z coordinate of the operand
  67443. * @returns the new Vector3
  67444. */
  67445. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67446. /**
  67447. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67448. * @param otherVector defines the second operand
  67449. * @returns the new Vector3
  67450. */
  67451. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67452. /**
  67453. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67454. * @param otherVector defines the second operand
  67455. * @param result defines the Vector3 object where to store the result
  67456. * @returns the current Vector3
  67457. */
  67458. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67459. /**
  67460. * Divides the current Vector3 coordinates by the given ones.
  67461. * @param otherVector defines the second operand
  67462. * @returns the current updated Vector3
  67463. */
  67464. divideInPlace(otherVector: Vector3): Vector3;
  67465. /**
  67466. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67467. * @param other defines the second operand
  67468. * @returns the current updated Vector3
  67469. */
  67470. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67471. /**
  67472. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67473. * @param other defines the second operand
  67474. * @returns the current updated Vector3
  67475. */
  67476. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67477. /**
  67478. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67479. * @param x defines the x coordinate of the operand
  67480. * @param y defines the y coordinate of the operand
  67481. * @param z defines the z coordinate of the operand
  67482. * @returns the current updated Vector3
  67483. */
  67484. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67485. /**
  67486. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67487. * @param x defines the x coordinate of the operand
  67488. * @param y defines the y coordinate of the operand
  67489. * @param z defines the z coordinate of the operand
  67490. * @returns the current updated Vector3
  67491. */
  67492. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67493. /**
  67494. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67495. * Check if is non uniform within a certain amount of decimal places to account for this
  67496. * @param epsilon the amount the values can differ
  67497. * @returns if the the vector is non uniform to a certain number of decimal places
  67498. */
  67499. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67500. /**
  67501. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67502. */
  67503. readonly isNonUniform: boolean;
  67504. /**
  67505. * Gets a new Vector3 from current Vector3 floored values
  67506. * @returns a new Vector3
  67507. */
  67508. floor(): Vector3;
  67509. /**
  67510. * Gets a new Vector3 from current Vector3 floored values
  67511. * @returns a new Vector3
  67512. */
  67513. fract(): Vector3;
  67514. /**
  67515. * Gets the length of the Vector3
  67516. * @returns the length of the Vector3
  67517. */
  67518. length(): number;
  67519. /**
  67520. * Gets the squared length of the Vector3
  67521. * @returns squared length of the Vector3
  67522. */
  67523. lengthSquared(): number;
  67524. /**
  67525. * Normalize the current Vector3.
  67526. * Please note that this is an in place operation.
  67527. * @returns the current updated Vector3
  67528. */
  67529. normalize(): Vector3;
  67530. /**
  67531. * Reorders the x y z properties of the vector in place
  67532. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67533. * @returns the current updated vector
  67534. */
  67535. reorderInPlace(order: string): this;
  67536. /**
  67537. * Rotates the vector around 0,0,0 by a quaternion
  67538. * @param quaternion the rotation quaternion
  67539. * @param result vector to store the result
  67540. * @returns the resulting vector
  67541. */
  67542. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67543. /**
  67544. * Rotates a vector around a given point
  67545. * @param quaternion the rotation quaternion
  67546. * @param point the point to rotate around
  67547. * @param result vector to store the result
  67548. * @returns the resulting vector
  67549. */
  67550. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67551. /**
  67552. * Normalize the current Vector3 with the given input length.
  67553. * Please note that this is an in place operation.
  67554. * @param len the length of the vector
  67555. * @returns the current updated Vector3
  67556. */
  67557. normalizeFromLength(len: number): Vector3;
  67558. /**
  67559. * Normalize the current Vector3 to a new vector
  67560. * @returns the new Vector3
  67561. */
  67562. normalizeToNew(): Vector3;
  67563. /**
  67564. * Normalize the current Vector3 to the reference
  67565. * @param reference define the Vector3 to update
  67566. * @returns the updated Vector3
  67567. */
  67568. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67569. /**
  67570. * Creates a new Vector3 copied from the current Vector3
  67571. * @returns the new Vector3
  67572. */
  67573. clone(): Vector3;
  67574. /**
  67575. * Copies the given vector coordinates to the current Vector3 ones
  67576. * @param source defines the source Vector3
  67577. * @returns the current updated Vector3
  67578. */
  67579. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67580. /**
  67581. * Copies the given floats to the current Vector3 coordinates
  67582. * @param x defines the x coordinate of the operand
  67583. * @param y defines the y coordinate of the operand
  67584. * @param z defines the z coordinate of the operand
  67585. * @returns the current updated Vector3
  67586. */
  67587. copyFromFloats(x: number, y: number, z: number): Vector3;
  67588. /**
  67589. * Copies the given floats to the current Vector3 coordinates
  67590. * @param x defines the x coordinate of the operand
  67591. * @param y defines the y coordinate of the operand
  67592. * @param z defines the z coordinate of the operand
  67593. * @returns the current updated Vector3
  67594. */
  67595. set(x: number, y: number, z: number): Vector3;
  67596. /**
  67597. * Copies the given float to the current Vector3 coordinates
  67598. * @param v defines the x, y and z coordinates of the operand
  67599. * @returns the current updated Vector3
  67600. */
  67601. setAll(v: number): Vector3;
  67602. /**
  67603. * Get the clip factor between two vectors
  67604. * @param vector0 defines the first operand
  67605. * @param vector1 defines the second operand
  67606. * @param axis defines the axis to use
  67607. * @param size defines the size along the axis
  67608. * @returns the clip factor
  67609. */
  67610. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67611. /**
  67612. * Get angle between two vectors
  67613. * @param vector0 angle between vector0 and vector1
  67614. * @param vector1 angle between vector0 and vector1
  67615. * @param normal direction of the normal
  67616. * @return the angle between vector0 and vector1
  67617. */
  67618. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67619. /**
  67620. * Returns a new Vector3 set from the index "offset" of the given array
  67621. * @param array defines the source array
  67622. * @param offset defines the offset in the source array
  67623. * @returns the new Vector3
  67624. */
  67625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67626. /**
  67627. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67628. * This function is deprecated. Use FromArray instead
  67629. * @param array defines the source array
  67630. * @param offset defines the offset in the source array
  67631. * @returns the new Vector3
  67632. */
  67633. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67634. /**
  67635. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67636. * @param array defines the source array
  67637. * @param offset defines the offset in the source array
  67638. * @param result defines the Vector3 where to store the result
  67639. */
  67640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67641. /**
  67642. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67643. * This function is deprecated. Use FromArrayToRef instead.
  67644. * @param array defines the source array
  67645. * @param offset defines the offset in the source array
  67646. * @param result defines the Vector3 where to store the result
  67647. */
  67648. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67649. /**
  67650. * Sets the given vector "result" with the given floats.
  67651. * @param x defines the x coordinate of the source
  67652. * @param y defines the y coordinate of the source
  67653. * @param z defines the z coordinate of the source
  67654. * @param result defines the Vector3 where to store the result
  67655. */
  67656. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67657. /**
  67658. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67659. * @returns a new empty Vector3
  67660. */
  67661. static Zero(): Vector3;
  67662. /**
  67663. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67664. * @returns a new unit Vector3
  67665. */
  67666. static One(): Vector3;
  67667. /**
  67668. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67669. * @returns a new up Vector3
  67670. */
  67671. static Up(): Vector3;
  67672. /**
  67673. * Gets a up Vector3 that must not be updated
  67674. */
  67675. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67676. /**
  67677. * Gets a zero Vector3 that must not be updated
  67678. */
  67679. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67680. /**
  67681. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67682. * @returns a new down Vector3
  67683. */
  67684. static Down(): Vector3;
  67685. /**
  67686. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67687. * @returns a new forward Vector3
  67688. */
  67689. static Forward(): Vector3;
  67690. /**
  67691. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67692. * @returns a new forward Vector3
  67693. */
  67694. static Backward(): Vector3;
  67695. /**
  67696. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67697. * @returns a new right Vector3
  67698. */
  67699. static Right(): Vector3;
  67700. /**
  67701. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67702. * @returns a new left Vector3
  67703. */
  67704. static Left(): Vector3;
  67705. /**
  67706. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67707. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67708. * @param vector defines the Vector3 to transform
  67709. * @param transformation defines the transformation matrix
  67710. * @returns the transformed Vector3
  67711. */
  67712. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67713. /**
  67714. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67715. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67716. * @param vector defines the Vector3 to transform
  67717. * @param transformation defines the transformation matrix
  67718. * @param result defines the Vector3 where to store the result
  67719. */
  67720. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67721. /**
  67722. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67723. * This method computes tranformed coordinates only, not transformed direction vectors
  67724. * @param x define the x coordinate of the source vector
  67725. * @param y define the y coordinate of the source vector
  67726. * @param z define the z coordinate of the source vector
  67727. * @param transformation defines the transformation matrix
  67728. * @param result defines the Vector3 where to store the result
  67729. */
  67730. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67731. /**
  67732. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67733. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67734. * @param vector defines the Vector3 to transform
  67735. * @param transformation defines the transformation matrix
  67736. * @returns the new Vector3
  67737. */
  67738. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67739. /**
  67740. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67741. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67742. * @param vector defines the Vector3 to transform
  67743. * @param transformation defines the transformation matrix
  67744. * @param result defines the Vector3 where to store the result
  67745. */
  67746. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67747. /**
  67748. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67750. * @param x define the x coordinate of the source vector
  67751. * @param y define the y coordinate of the source vector
  67752. * @param z define the z coordinate of the source vector
  67753. * @param transformation defines the transformation matrix
  67754. * @param result defines the Vector3 where to store the result
  67755. */
  67756. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67757. /**
  67758. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67759. * @param value1 defines the first control point
  67760. * @param value2 defines the second control point
  67761. * @param value3 defines the third control point
  67762. * @param value4 defines the fourth control point
  67763. * @param amount defines the amount on the spline to use
  67764. * @returns the new Vector3
  67765. */
  67766. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67767. /**
  67768. * 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"
  67769. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67770. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67771. * @param value defines the current value
  67772. * @param min defines the lower range value
  67773. * @param max defines the upper range value
  67774. * @returns the new Vector3
  67775. */
  67776. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67777. /**
  67778. * 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"
  67779. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67780. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67781. * @param value defines the current value
  67782. * @param min defines the lower range value
  67783. * @param max defines the upper range value
  67784. * @param result defines the Vector3 where to store the result
  67785. */
  67786. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67787. /**
  67788. * Checks if a given vector is inside a specific range
  67789. * @param v defines the vector to test
  67790. * @param min defines the minimum range
  67791. * @param max defines the maximum range
  67792. */
  67793. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67794. /**
  67795. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67796. * @param value1 defines the first control point
  67797. * @param tangent1 defines the first tangent vector
  67798. * @param value2 defines the second control point
  67799. * @param tangent2 defines the second tangent vector
  67800. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67801. * @returns the new Vector3
  67802. */
  67803. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67804. /**
  67805. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67806. * @param start defines the start value
  67807. * @param end defines the end value
  67808. * @param amount max defines amount between both (between 0 and 1)
  67809. * @returns the new Vector3
  67810. */
  67811. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67812. /**
  67813. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67814. * @param start defines the start value
  67815. * @param end defines the end value
  67816. * @param amount max defines amount between both (between 0 and 1)
  67817. * @param result defines the Vector3 where to store the result
  67818. */
  67819. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67820. /**
  67821. * Returns the dot product (float) between the vectors "left" and "right"
  67822. * @param left defines the left operand
  67823. * @param right defines the right operand
  67824. * @returns the dot product
  67825. */
  67826. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67827. /**
  67828. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67829. * The cross product is then orthogonal to both "left" and "right"
  67830. * @param left defines the left operand
  67831. * @param right defines the right operand
  67832. * @returns the cross product
  67833. */
  67834. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67835. /**
  67836. * Sets the given vector "result" with the cross product of "left" and "right"
  67837. * The cross product is then orthogonal to both "left" and "right"
  67838. * @param left defines the left operand
  67839. * @param right defines the right operand
  67840. * @param result defines the Vector3 where to store the result
  67841. */
  67842. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67843. /**
  67844. * Returns a new Vector3 as the normalization of the given vector
  67845. * @param vector defines the Vector3 to normalize
  67846. * @returns the new Vector3
  67847. */
  67848. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67849. /**
  67850. * Sets the given vector "result" with the normalization of the given first vector
  67851. * @param vector defines the Vector3 to normalize
  67852. * @param result defines the Vector3 where to store the result
  67853. */
  67854. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67855. /**
  67856. * Project a Vector3 onto screen space
  67857. * @param vector defines the Vector3 to project
  67858. * @param world defines the world matrix to use
  67859. * @param transform defines the transform (view x projection) matrix to use
  67860. * @param viewport defines the screen viewport to use
  67861. * @returns the new Vector3
  67862. */
  67863. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67864. /** @hidden */
  67865. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67866. /**
  67867. * Unproject from screen space to object space
  67868. * @param source defines the screen space Vector3 to use
  67869. * @param viewportWidth defines the current width of the viewport
  67870. * @param viewportHeight defines the current height of the viewport
  67871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67872. * @param transform defines the transform (view x projection) matrix to use
  67873. * @returns the new Vector3
  67874. */
  67875. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67876. /**
  67877. * Unproject from screen space to object space
  67878. * @param source defines the screen space Vector3 to use
  67879. * @param viewportWidth defines the current width of the viewport
  67880. * @param viewportHeight defines the current height of the viewport
  67881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67882. * @param view defines the view matrix to use
  67883. * @param projection defines the projection matrix to use
  67884. * @returns the new Vector3
  67885. */
  67886. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67887. /**
  67888. * Unproject from screen space to object space
  67889. * @param source defines the screen space Vector3 to use
  67890. * @param viewportWidth defines the current width of the viewport
  67891. * @param viewportHeight defines the current height of the viewport
  67892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67893. * @param view defines the view matrix to use
  67894. * @param projection defines the projection matrix to use
  67895. * @param result defines the Vector3 where to store the result
  67896. */
  67897. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67898. /**
  67899. * Unproject from screen space to object space
  67900. * @param sourceX defines the screen space x coordinate to use
  67901. * @param sourceY defines the screen space y coordinate to use
  67902. * @param sourceZ defines the screen space z coordinate to use
  67903. * @param viewportWidth defines the current width of the viewport
  67904. * @param viewportHeight defines the current height of the viewport
  67905. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67906. * @param view defines the view matrix to use
  67907. * @param projection defines the projection matrix to use
  67908. * @param result defines the Vector3 where to store the result
  67909. */
  67910. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67911. /**
  67912. * Gets the minimal coordinate values between two Vector3
  67913. * @param left defines the first operand
  67914. * @param right defines the second operand
  67915. * @returns the new Vector3
  67916. */
  67917. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67918. /**
  67919. * Gets the maximal coordinate values between two Vector3
  67920. * @param left defines the first operand
  67921. * @param right defines the second operand
  67922. * @returns the new Vector3
  67923. */
  67924. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67925. /**
  67926. * Returns the distance between the vectors "value1" and "value2"
  67927. * @param value1 defines the first operand
  67928. * @param value2 defines the second operand
  67929. * @returns the distance
  67930. */
  67931. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67932. /**
  67933. * Returns the squared distance between the vectors "value1" and "value2"
  67934. * @param value1 defines the first operand
  67935. * @param value2 defines the second operand
  67936. * @returns the squared distance
  67937. */
  67938. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67939. /**
  67940. * Returns a new Vector3 located at the center between "value1" and "value2"
  67941. * @param value1 defines the first operand
  67942. * @param value2 defines the second operand
  67943. * @returns the new Vector3
  67944. */
  67945. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67946. /**
  67947. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67948. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67949. * to something in order to rotate it from its local system to the given target system
  67950. * Note: axis1, axis2 and axis3 are normalized during this operation
  67951. * @param axis1 defines the first axis
  67952. * @param axis2 defines the second axis
  67953. * @param axis3 defines the third axis
  67954. * @returns a new Vector3
  67955. */
  67956. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67957. /**
  67958. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67959. * @param axis1 defines the first axis
  67960. * @param axis2 defines the second axis
  67961. * @param axis3 defines the third axis
  67962. * @param ref defines the Vector3 where to store the result
  67963. */
  67964. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67965. }
  67966. /**
  67967. * Vector4 class created for EulerAngle class conversion to Quaternion
  67968. */
  67969. export class Vector4 {
  67970. /** x value of the vector */
  67971. x: number;
  67972. /** y value of the vector */
  67973. y: number;
  67974. /** z value of the vector */
  67975. z: number;
  67976. /** w value of the vector */
  67977. w: number;
  67978. /**
  67979. * Creates a Vector4 object from the given floats.
  67980. * @param x x value of the vector
  67981. * @param y y value of the vector
  67982. * @param z z value of the vector
  67983. * @param w w value of the vector
  67984. */
  67985. constructor(
  67986. /** x value of the vector */
  67987. x: number,
  67988. /** y value of the vector */
  67989. y: number,
  67990. /** z value of the vector */
  67991. z: number,
  67992. /** w value of the vector */
  67993. w: number);
  67994. /**
  67995. * Returns the string with the Vector4 coordinates.
  67996. * @returns a string containing all the vector values
  67997. */
  67998. toString(): string;
  67999. /**
  68000. * Returns the string "Vector4".
  68001. * @returns "Vector4"
  68002. */
  68003. getClassName(): string;
  68004. /**
  68005. * Returns the Vector4 hash code.
  68006. * @returns a unique hash code
  68007. */
  68008. getHashCode(): number;
  68009. /**
  68010. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68011. * @returns the resulting array
  68012. */
  68013. asArray(): number[];
  68014. /**
  68015. * Populates the given array from the given index with the Vector4 coordinates.
  68016. * @param array array to populate
  68017. * @param index index of the array to start at (default: 0)
  68018. * @returns the Vector4.
  68019. */
  68020. toArray(array: FloatArray, index?: number): Vector4;
  68021. /**
  68022. * Adds the given vector to the current Vector4.
  68023. * @param otherVector the vector to add
  68024. * @returns the updated Vector4.
  68025. */
  68026. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68027. /**
  68028. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68029. * @param otherVector the vector to add
  68030. * @returns the resulting vector
  68031. */
  68032. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68033. /**
  68034. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68035. * @param otherVector the vector to add
  68036. * @param result the vector to store the result
  68037. * @returns the current Vector4.
  68038. */
  68039. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68040. /**
  68041. * Subtract in place the given vector from the current Vector4.
  68042. * @param otherVector the vector to subtract
  68043. * @returns the updated Vector4.
  68044. */
  68045. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68046. /**
  68047. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68048. * @param otherVector the vector to add
  68049. * @returns the new vector with the result
  68050. */
  68051. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68052. /**
  68053. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68054. * @param otherVector the vector to subtract
  68055. * @param result the vector to store the result
  68056. * @returns the current Vector4.
  68057. */
  68058. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68059. /**
  68060. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68061. */
  68062. /**
  68063. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68064. * @param x value to subtract
  68065. * @param y value to subtract
  68066. * @param z value to subtract
  68067. * @param w value to subtract
  68068. * @returns new vector containing the result
  68069. */
  68070. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68071. /**
  68072. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68073. * @param x value to subtract
  68074. * @param y value to subtract
  68075. * @param z value to subtract
  68076. * @param w value to subtract
  68077. * @param result the vector to store the result in
  68078. * @returns the current Vector4.
  68079. */
  68080. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68081. /**
  68082. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68083. * @returns a new vector with the negated values
  68084. */
  68085. negate(): Vector4;
  68086. /**
  68087. * Multiplies the current Vector4 coordinates by scale (float).
  68088. * @param scale the number to scale with
  68089. * @returns the updated Vector4.
  68090. */
  68091. scaleInPlace(scale: number): Vector4;
  68092. /**
  68093. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68094. * @param scale the number to scale with
  68095. * @returns a new vector with the result
  68096. */
  68097. scale(scale: number): Vector4;
  68098. /**
  68099. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68100. * @param scale the number to scale with
  68101. * @param result a vector to store the result in
  68102. * @returns the current Vector4.
  68103. */
  68104. scaleToRef(scale: number, result: Vector4): Vector4;
  68105. /**
  68106. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68107. * @param scale defines the scale factor
  68108. * @param result defines the Vector4 object where to store the result
  68109. * @returns the unmodified current Vector4
  68110. */
  68111. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68112. /**
  68113. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68114. * @param otherVector the vector to compare against
  68115. * @returns true if they are equal
  68116. */
  68117. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68118. /**
  68119. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68120. * @param otherVector vector to compare against
  68121. * @param epsilon (Default: very small number)
  68122. * @returns true if they are equal
  68123. */
  68124. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68125. /**
  68126. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68127. * @param x x value to compare against
  68128. * @param y y value to compare against
  68129. * @param z z value to compare against
  68130. * @param w w value to compare against
  68131. * @returns true if equal
  68132. */
  68133. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68134. /**
  68135. * Multiplies in place the current Vector4 by the given one.
  68136. * @param otherVector vector to multiple with
  68137. * @returns the updated Vector4.
  68138. */
  68139. multiplyInPlace(otherVector: Vector4): Vector4;
  68140. /**
  68141. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68142. * @param otherVector vector to multiple with
  68143. * @returns resulting new vector
  68144. */
  68145. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68146. /**
  68147. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68148. * @param otherVector vector to multiple with
  68149. * @param result vector to store the result
  68150. * @returns the current Vector4.
  68151. */
  68152. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68153. /**
  68154. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68155. * @param x x value multiply with
  68156. * @param y y value multiply with
  68157. * @param z z value multiply with
  68158. * @param w w value multiply with
  68159. * @returns resulting new vector
  68160. */
  68161. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68162. /**
  68163. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68164. * @param otherVector vector to devide with
  68165. * @returns resulting new vector
  68166. */
  68167. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68168. /**
  68169. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68170. * @param otherVector vector to devide with
  68171. * @param result vector to store the result
  68172. * @returns the current Vector4.
  68173. */
  68174. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68175. /**
  68176. * Divides the current Vector3 coordinates by the given ones.
  68177. * @param otherVector vector to devide with
  68178. * @returns the updated Vector3.
  68179. */
  68180. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68181. /**
  68182. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68183. * @param other defines the second operand
  68184. * @returns the current updated Vector4
  68185. */
  68186. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68187. /**
  68188. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68189. * @param other defines the second operand
  68190. * @returns the current updated Vector4
  68191. */
  68192. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68193. /**
  68194. * Gets a new Vector4 from current Vector4 floored values
  68195. * @returns a new Vector4
  68196. */
  68197. floor(): Vector4;
  68198. /**
  68199. * Gets a new Vector4 from current Vector3 floored values
  68200. * @returns a new Vector4
  68201. */
  68202. fract(): Vector4;
  68203. /**
  68204. * Returns the Vector4 length (float).
  68205. * @returns the length
  68206. */
  68207. length(): number;
  68208. /**
  68209. * Returns the Vector4 squared length (float).
  68210. * @returns the length squared
  68211. */
  68212. lengthSquared(): number;
  68213. /**
  68214. * Normalizes in place the Vector4.
  68215. * @returns the updated Vector4.
  68216. */
  68217. normalize(): Vector4;
  68218. /**
  68219. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68220. * @returns this converted to a new vector3
  68221. */
  68222. toVector3(): Vector3;
  68223. /**
  68224. * Returns a new Vector4 copied from the current one.
  68225. * @returns the new cloned vector
  68226. */
  68227. clone(): Vector4;
  68228. /**
  68229. * Updates the current Vector4 with the given one coordinates.
  68230. * @param source the source vector to copy from
  68231. * @returns the updated Vector4.
  68232. */
  68233. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68234. /**
  68235. * Updates the current Vector4 coordinates with the given floats.
  68236. * @param x float to copy from
  68237. * @param y float to copy from
  68238. * @param z float to copy from
  68239. * @param w float to copy from
  68240. * @returns the updated Vector4.
  68241. */
  68242. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68243. /**
  68244. * Updates the current Vector4 coordinates with the given floats.
  68245. * @param x float to set from
  68246. * @param y float to set from
  68247. * @param z float to set from
  68248. * @param w float to set from
  68249. * @returns the updated Vector4.
  68250. */
  68251. set(x: number, y: number, z: number, w: number): Vector4;
  68252. /**
  68253. * Copies the given float to the current Vector3 coordinates
  68254. * @param v defines the x, y, z and w coordinates of the operand
  68255. * @returns the current updated Vector3
  68256. */
  68257. setAll(v: number): Vector4;
  68258. /**
  68259. * Returns a new Vector4 set from the starting index of the given array.
  68260. * @param array the array to pull values from
  68261. * @param offset the offset into the array to start at
  68262. * @returns the new vector
  68263. */
  68264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68265. /**
  68266. * Updates the given vector "result" from the starting index of the given array.
  68267. * @param array the array to pull values from
  68268. * @param offset the offset into the array to start at
  68269. * @param result the vector to store the result in
  68270. */
  68271. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68272. /**
  68273. * Updates the given vector "result" from the starting index of the given Float32Array.
  68274. * @param array the array to pull values from
  68275. * @param offset the offset into the array to start at
  68276. * @param result the vector to store the result in
  68277. */
  68278. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68279. /**
  68280. * Updates the given vector "result" coordinates from the given floats.
  68281. * @param x float to set from
  68282. * @param y float to set from
  68283. * @param z float to set from
  68284. * @param w float to set from
  68285. * @param result the vector to the floats in
  68286. */
  68287. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68288. /**
  68289. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68290. * @returns the new vector
  68291. */
  68292. static Zero(): Vector4;
  68293. /**
  68294. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68295. * @returns the new vector
  68296. */
  68297. static One(): Vector4;
  68298. /**
  68299. * Returns a new normalized Vector4 from the given one.
  68300. * @param vector the vector to normalize
  68301. * @returns the vector
  68302. */
  68303. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68304. /**
  68305. * Updates the given vector "result" from the normalization of the given one.
  68306. * @param vector the vector to normalize
  68307. * @param result the vector to store the result in
  68308. */
  68309. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68310. /**
  68311. * Returns a vector with the minimum values from the left and right vectors
  68312. * @param left left vector to minimize
  68313. * @param right right vector to minimize
  68314. * @returns a new vector with the minimum of the left and right vector values
  68315. */
  68316. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68317. /**
  68318. * Returns a vector with the maximum values from the left and right vectors
  68319. * @param left left vector to maximize
  68320. * @param right right vector to maximize
  68321. * @returns a new vector with the maximum of the left and right vector values
  68322. */
  68323. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68324. /**
  68325. * Returns the distance (float) between the vectors "value1" and "value2".
  68326. * @param value1 value to calulate the distance between
  68327. * @param value2 value to calulate the distance between
  68328. * @return the distance between the two vectors
  68329. */
  68330. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68331. /**
  68332. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68333. * @param value1 value to calulate the distance between
  68334. * @param value2 value to calulate the distance between
  68335. * @return the distance between the two vectors squared
  68336. */
  68337. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68338. /**
  68339. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68340. * @param value1 value to calulate the center between
  68341. * @param value2 value to calulate the center between
  68342. * @return the center between the two vectors
  68343. */
  68344. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68345. /**
  68346. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68347. * This methods computes transformed normalized direction vectors only.
  68348. * @param vector the vector to transform
  68349. * @param transformation the transformation matrix to apply
  68350. * @returns the new vector
  68351. */
  68352. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68353. /**
  68354. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68355. * This methods computes transformed normalized direction vectors only.
  68356. * @param vector the vector to transform
  68357. * @param transformation the transformation matrix to apply
  68358. * @param result the vector to store the result in
  68359. */
  68360. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68361. /**
  68362. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68363. * This methods computes transformed normalized direction vectors only.
  68364. * @param x value to transform
  68365. * @param y value to transform
  68366. * @param z value to transform
  68367. * @param w value to transform
  68368. * @param transformation the transformation matrix to apply
  68369. * @param result the vector to store the results in
  68370. */
  68371. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68372. /**
  68373. * Creates a new Vector4 from a Vector3
  68374. * @param source defines the source data
  68375. * @param w defines the 4th component (default is 0)
  68376. * @returns a new Vector4
  68377. */
  68378. static FromVector3(source: Vector3, w?: number): Vector4;
  68379. }
  68380. /**
  68381. * Class used to store quaternion data
  68382. * @see https://en.wikipedia.org/wiki/Quaternion
  68383. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68384. */
  68385. export class Quaternion {
  68386. /** defines the first component (0 by default) */
  68387. x: number;
  68388. /** defines the second component (0 by default) */
  68389. y: number;
  68390. /** defines the third component (0 by default) */
  68391. z: number;
  68392. /** defines the fourth component (1.0 by default) */
  68393. w: number;
  68394. /**
  68395. * Creates a new Quaternion from the given floats
  68396. * @param x defines the first component (0 by default)
  68397. * @param y defines the second component (0 by default)
  68398. * @param z defines the third component (0 by default)
  68399. * @param w defines the fourth component (1.0 by default)
  68400. */
  68401. constructor(
  68402. /** defines the first component (0 by default) */
  68403. x?: number,
  68404. /** defines the second component (0 by default) */
  68405. y?: number,
  68406. /** defines the third component (0 by default) */
  68407. z?: number,
  68408. /** defines the fourth component (1.0 by default) */
  68409. w?: number);
  68410. /**
  68411. * Gets a string representation for the current quaternion
  68412. * @returns a string with the Quaternion coordinates
  68413. */
  68414. toString(): string;
  68415. /**
  68416. * Gets the class name of the quaternion
  68417. * @returns the string "Quaternion"
  68418. */
  68419. getClassName(): string;
  68420. /**
  68421. * Gets a hash code for this quaternion
  68422. * @returns the quaternion hash code
  68423. */
  68424. getHashCode(): number;
  68425. /**
  68426. * Copy the quaternion to an array
  68427. * @returns a new array populated with 4 elements from the quaternion coordinates
  68428. */
  68429. asArray(): number[];
  68430. /**
  68431. * Check if two quaternions are equals
  68432. * @param otherQuaternion defines the second operand
  68433. * @return true if the current quaternion and the given one coordinates are strictly equals
  68434. */
  68435. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68436. /**
  68437. * Clone the current quaternion
  68438. * @returns a new quaternion copied from the current one
  68439. */
  68440. clone(): Quaternion;
  68441. /**
  68442. * Copy a quaternion to the current one
  68443. * @param other defines the other quaternion
  68444. * @returns the updated current quaternion
  68445. */
  68446. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68447. /**
  68448. * Updates the current quaternion with the given float coordinates
  68449. * @param x defines the x coordinate
  68450. * @param y defines the y coordinate
  68451. * @param z defines the z coordinate
  68452. * @param w defines the w coordinate
  68453. * @returns the updated current quaternion
  68454. */
  68455. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68456. /**
  68457. * Updates the current quaternion from the given float coordinates
  68458. * @param x defines the x coordinate
  68459. * @param y defines the y coordinate
  68460. * @param z defines the z coordinate
  68461. * @param w defines the w coordinate
  68462. * @returns the updated current quaternion
  68463. */
  68464. set(x: number, y: number, z: number, w: number): Quaternion;
  68465. /**
  68466. * Adds two quaternions
  68467. * @param other defines the second operand
  68468. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68469. */
  68470. add(other: DeepImmutable<Quaternion>): Quaternion;
  68471. /**
  68472. * Add a quaternion to the current one
  68473. * @param other defines the quaternion to add
  68474. * @returns the current quaternion
  68475. */
  68476. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68477. /**
  68478. * Subtract two quaternions
  68479. * @param other defines the second operand
  68480. * @returns a new quaternion as the subtraction result of the given one from the current one
  68481. */
  68482. subtract(other: Quaternion): Quaternion;
  68483. /**
  68484. * Multiplies the current quaternion by a scale factor
  68485. * @param value defines the scale factor
  68486. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68487. */
  68488. scale(value: number): Quaternion;
  68489. /**
  68490. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68491. * @param scale defines the scale factor
  68492. * @param result defines the Quaternion object where to store the result
  68493. * @returns the unmodified current quaternion
  68494. */
  68495. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68496. /**
  68497. * Multiplies in place the current quaternion by a scale factor
  68498. * @param value defines the scale factor
  68499. * @returns the current modified quaternion
  68500. */
  68501. scaleInPlace(value: number): Quaternion;
  68502. /**
  68503. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68504. * @param scale defines the scale factor
  68505. * @param result defines the Quaternion object where to store the result
  68506. * @returns the unmodified current quaternion
  68507. */
  68508. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68509. /**
  68510. * Multiplies two quaternions
  68511. * @param q1 defines the second operand
  68512. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68513. */
  68514. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68515. /**
  68516. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68517. * @param q1 defines the second operand
  68518. * @param result defines the target quaternion
  68519. * @returns the current quaternion
  68520. */
  68521. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68522. /**
  68523. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68524. * @param q1 defines the second operand
  68525. * @returns the currentupdated quaternion
  68526. */
  68527. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68528. /**
  68529. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68530. * @param ref defines the target quaternion
  68531. * @returns the current quaternion
  68532. */
  68533. conjugateToRef(ref: Quaternion): Quaternion;
  68534. /**
  68535. * Conjugates in place (1-q) the current quaternion
  68536. * @returns the current updated quaternion
  68537. */
  68538. conjugateInPlace(): Quaternion;
  68539. /**
  68540. * Conjugates in place (1-q) the current quaternion
  68541. * @returns a new quaternion
  68542. */
  68543. conjugate(): Quaternion;
  68544. /**
  68545. * Gets length of current quaternion
  68546. * @returns the quaternion length (float)
  68547. */
  68548. length(): number;
  68549. /**
  68550. * Normalize in place the current quaternion
  68551. * @returns the current updated quaternion
  68552. */
  68553. normalize(): Quaternion;
  68554. /**
  68555. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68556. * @param order is a reserved parameter and is ignore for now
  68557. * @returns a new Vector3 containing the Euler angles
  68558. */
  68559. toEulerAngles(order?: string): Vector3;
  68560. /**
  68561. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68562. * @param result defines the vector which will be filled with the Euler angles
  68563. * @param order is a reserved parameter and is ignore for now
  68564. * @returns the current unchanged quaternion
  68565. */
  68566. toEulerAnglesToRef(result: Vector3): Quaternion;
  68567. /**
  68568. * Updates the given rotation matrix with the current quaternion values
  68569. * @param result defines the target matrix
  68570. * @returns the current unchanged quaternion
  68571. */
  68572. toRotationMatrix(result: Matrix): Quaternion;
  68573. /**
  68574. * Updates the current quaternion from the given rotation matrix values
  68575. * @param matrix defines the source matrix
  68576. * @returns the current updated quaternion
  68577. */
  68578. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68579. /**
  68580. * Creates a new quaternion from a rotation matrix
  68581. * @param matrix defines the source matrix
  68582. * @returns a new quaternion created from the given rotation matrix values
  68583. */
  68584. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68585. /**
  68586. * Updates the given quaternion with the given rotation matrix values
  68587. * @param matrix defines the source matrix
  68588. * @param result defines the target quaternion
  68589. */
  68590. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68591. /**
  68592. * Returns the dot product (float) between the quaternions "left" and "right"
  68593. * @param left defines the left operand
  68594. * @param right defines the right operand
  68595. * @returns the dot product
  68596. */
  68597. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68598. /**
  68599. * Checks if the two quaternions are close to each other
  68600. * @param quat0 defines the first quaternion to check
  68601. * @param quat1 defines the second quaternion to check
  68602. * @returns true if the two quaternions are close to each other
  68603. */
  68604. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68605. /**
  68606. * Creates an empty quaternion
  68607. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68608. */
  68609. static Zero(): Quaternion;
  68610. /**
  68611. * Inverse a given quaternion
  68612. * @param q defines the source quaternion
  68613. * @returns a new quaternion as the inverted current quaternion
  68614. */
  68615. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68616. /**
  68617. * Inverse a given quaternion
  68618. * @param q defines the source quaternion
  68619. * @param result the quaternion the result will be stored in
  68620. * @returns the result quaternion
  68621. */
  68622. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68623. /**
  68624. * Creates an identity quaternion
  68625. * @returns the identity quaternion
  68626. */
  68627. static Identity(): Quaternion;
  68628. /**
  68629. * Gets a boolean indicating if the given quaternion is identity
  68630. * @param quaternion defines the quaternion to check
  68631. * @returns true if the quaternion is identity
  68632. */
  68633. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68634. /**
  68635. * Creates a quaternion from a rotation around an axis
  68636. * @param axis defines the axis to use
  68637. * @param angle defines the angle to use
  68638. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68639. */
  68640. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68641. /**
  68642. * Creates a rotation around an axis and stores it into the given quaternion
  68643. * @param axis defines the axis to use
  68644. * @param angle defines the angle to use
  68645. * @param result defines the target quaternion
  68646. * @returns the target quaternion
  68647. */
  68648. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68649. /**
  68650. * Creates a new quaternion from data stored into an array
  68651. * @param array defines the data source
  68652. * @param offset defines the offset in the source array where the data starts
  68653. * @returns a new quaternion
  68654. */
  68655. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68656. /**
  68657. * Create a quaternion from Euler rotation angles
  68658. * @param x Pitch
  68659. * @param y Yaw
  68660. * @param z Roll
  68661. * @returns the new Quaternion
  68662. */
  68663. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68664. /**
  68665. * Updates a quaternion from Euler rotation angles
  68666. * @param x Pitch
  68667. * @param y Yaw
  68668. * @param z Roll
  68669. * @param result the quaternion to store the result
  68670. * @returns the updated quaternion
  68671. */
  68672. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68673. /**
  68674. * Create a quaternion from Euler rotation vector
  68675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68676. * @returns the new Quaternion
  68677. */
  68678. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68679. /**
  68680. * Updates a quaternion from Euler rotation vector
  68681. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68682. * @param result the quaternion to store the result
  68683. * @returns the updated quaternion
  68684. */
  68685. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68686. /**
  68687. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68688. * @param yaw defines the rotation around Y axis
  68689. * @param pitch defines the rotation around X axis
  68690. * @param roll defines the rotation around Z axis
  68691. * @returns the new quaternion
  68692. */
  68693. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68694. /**
  68695. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68696. * @param yaw defines the rotation around Y axis
  68697. * @param pitch defines the rotation around X axis
  68698. * @param roll defines the rotation around Z axis
  68699. * @param result defines the target quaternion
  68700. */
  68701. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68702. /**
  68703. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68704. * @param alpha defines the rotation around first axis
  68705. * @param beta defines the rotation around second axis
  68706. * @param gamma defines the rotation around third axis
  68707. * @returns the new quaternion
  68708. */
  68709. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68710. /**
  68711. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68712. * @param alpha defines the rotation around first axis
  68713. * @param beta defines the rotation around second axis
  68714. * @param gamma defines the rotation around third axis
  68715. * @param result defines the target quaternion
  68716. */
  68717. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68718. /**
  68719. * 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)
  68720. * @param axis1 defines the first axis
  68721. * @param axis2 defines the second axis
  68722. * @param axis3 defines the third axis
  68723. * @returns the new quaternion
  68724. */
  68725. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68726. /**
  68727. * 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
  68728. * @param axis1 defines the first axis
  68729. * @param axis2 defines the second axis
  68730. * @param axis3 defines the third axis
  68731. * @param ref defines the target quaternion
  68732. */
  68733. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68734. /**
  68735. * Interpolates between two quaternions
  68736. * @param left defines first quaternion
  68737. * @param right defines second quaternion
  68738. * @param amount defines the gradient to use
  68739. * @returns the new interpolated quaternion
  68740. */
  68741. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68742. /**
  68743. * Interpolates between two quaternions and stores it into a target quaternion
  68744. * @param left defines first quaternion
  68745. * @param right defines second quaternion
  68746. * @param amount defines the gradient to use
  68747. * @param result defines the target quaternion
  68748. */
  68749. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68750. /**
  68751. * Interpolate between two quaternions using Hermite interpolation
  68752. * @param value1 defines first quaternion
  68753. * @param tangent1 defines the incoming tangent
  68754. * @param value2 defines second quaternion
  68755. * @param tangent2 defines the outgoing tangent
  68756. * @param amount defines the target quaternion
  68757. * @returns the new interpolated quaternion
  68758. */
  68759. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68760. }
  68761. /**
  68762. * Class used to store matrix data (4x4)
  68763. */
  68764. export class Matrix {
  68765. private static _updateFlagSeed;
  68766. private static _identityReadOnly;
  68767. private _isIdentity;
  68768. private _isIdentityDirty;
  68769. private _isIdentity3x2;
  68770. private _isIdentity3x2Dirty;
  68771. /**
  68772. * Gets the update flag of the matrix which is an unique number for the matrix.
  68773. * It will be incremented every time the matrix data change.
  68774. * You can use it to speed the comparison between two versions of the same matrix.
  68775. */
  68776. updateFlag: number;
  68777. private readonly _m;
  68778. /**
  68779. * Gets the internal data of the matrix
  68780. */
  68781. readonly m: DeepImmutable<Float32Array>;
  68782. /** @hidden */
  68783. _markAsUpdated(): void;
  68784. /** @hidden */
  68785. private _updateIdentityStatus;
  68786. /**
  68787. * Creates an empty matrix (filled with zeros)
  68788. */
  68789. constructor();
  68790. /**
  68791. * Check if the current matrix is identity
  68792. * @returns true is the matrix is the identity matrix
  68793. */
  68794. isIdentity(): boolean;
  68795. /**
  68796. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68797. * @returns true is the matrix is the identity matrix
  68798. */
  68799. isIdentityAs3x2(): boolean;
  68800. /**
  68801. * Gets the determinant of the matrix
  68802. * @returns the matrix determinant
  68803. */
  68804. determinant(): number;
  68805. /**
  68806. * Returns the matrix as a Float32Array
  68807. * @returns the matrix underlying array
  68808. */
  68809. toArray(): DeepImmutable<Float32Array>;
  68810. /**
  68811. * Returns the matrix as a Float32Array
  68812. * @returns the matrix underlying array.
  68813. */
  68814. asArray(): DeepImmutable<Float32Array>;
  68815. /**
  68816. * Inverts the current matrix in place
  68817. * @returns the current inverted matrix
  68818. */
  68819. invert(): Matrix;
  68820. /**
  68821. * Sets all the matrix elements to zero
  68822. * @returns the current matrix
  68823. */
  68824. reset(): Matrix;
  68825. /**
  68826. * Adds the current matrix with a second one
  68827. * @param other defines the matrix to add
  68828. * @returns a new matrix as the addition of the current matrix and the given one
  68829. */
  68830. add(other: DeepImmutable<Matrix>): Matrix;
  68831. /**
  68832. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68833. * @param other defines the matrix to add
  68834. * @param result defines the target matrix
  68835. * @returns the current matrix
  68836. */
  68837. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68838. /**
  68839. * Adds in place the given matrix to the current matrix
  68840. * @param other defines the second operand
  68841. * @returns the current updated matrix
  68842. */
  68843. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68844. /**
  68845. * Sets the given matrix to the current inverted Matrix
  68846. * @param other defines the target matrix
  68847. * @returns the unmodified current matrix
  68848. */
  68849. invertToRef(other: Matrix): Matrix;
  68850. /**
  68851. * add a value at the specified position in the current Matrix
  68852. * @param index the index of the value within the matrix. between 0 and 15.
  68853. * @param value the value to be added
  68854. * @returns the current updated matrix
  68855. */
  68856. addAtIndex(index: number, value: number): Matrix;
  68857. /**
  68858. * mutiply the specified position in the current Matrix by a value
  68859. * @param index the index of the value within the matrix. between 0 and 15.
  68860. * @param value the value to be added
  68861. * @returns the current updated matrix
  68862. */
  68863. multiplyAtIndex(index: number, value: number): Matrix;
  68864. /**
  68865. * Inserts the translation vector (using 3 floats) in the current matrix
  68866. * @param x defines the 1st component of the translation
  68867. * @param y defines the 2nd component of the translation
  68868. * @param z defines the 3rd component of the translation
  68869. * @returns the current updated matrix
  68870. */
  68871. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68872. /**
  68873. * Adds the translation vector (using 3 floats) in the current matrix
  68874. * @param x defines the 1st component of the translation
  68875. * @param y defines the 2nd component of the translation
  68876. * @param z defines the 3rd component of the translation
  68877. * @returns the current updated matrix
  68878. */
  68879. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68880. /**
  68881. * Inserts the translation vector in the current matrix
  68882. * @param vector3 defines the translation to insert
  68883. * @returns the current updated matrix
  68884. */
  68885. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68886. /**
  68887. * Gets the translation value of the current matrix
  68888. * @returns a new Vector3 as the extracted translation from the matrix
  68889. */
  68890. getTranslation(): Vector3;
  68891. /**
  68892. * Fill a Vector3 with the extracted translation from the matrix
  68893. * @param result defines the Vector3 where to store the translation
  68894. * @returns the current matrix
  68895. */
  68896. getTranslationToRef(result: Vector3): Matrix;
  68897. /**
  68898. * Remove rotation and scaling part from the matrix
  68899. * @returns the updated matrix
  68900. */
  68901. removeRotationAndScaling(): Matrix;
  68902. /**
  68903. * Multiply two matrices
  68904. * @param other defines the second operand
  68905. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68906. */
  68907. multiply(other: DeepImmutable<Matrix>): Matrix;
  68908. /**
  68909. * Copy the current matrix from the given one
  68910. * @param other defines the source matrix
  68911. * @returns the current updated matrix
  68912. */
  68913. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68914. /**
  68915. * Populates the given array from the starting index with the current matrix values
  68916. * @param array defines the target array
  68917. * @param offset defines the offset in the target array where to start storing values
  68918. * @returns the current matrix
  68919. */
  68920. copyToArray(array: Float32Array, offset?: number): Matrix;
  68921. /**
  68922. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68923. * @param other defines the second operand
  68924. * @param result defines the matrix where to store the multiplication
  68925. * @returns the current matrix
  68926. */
  68927. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68928. /**
  68929. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68930. * @param other defines the second operand
  68931. * @param result defines the array where to store the multiplication
  68932. * @param offset defines the offset in the target array where to start storing values
  68933. * @returns the current matrix
  68934. */
  68935. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68936. /**
  68937. * Check equality between this matrix and a second one
  68938. * @param value defines the second matrix to compare
  68939. * @returns true is the current matrix and the given one values are strictly equal
  68940. */
  68941. equals(value: DeepImmutable<Matrix>): boolean;
  68942. /**
  68943. * Clone the current matrix
  68944. * @returns a new matrix from the current matrix
  68945. */
  68946. clone(): Matrix;
  68947. /**
  68948. * Returns the name of the current matrix class
  68949. * @returns the string "Matrix"
  68950. */
  68951. getClassName(): string;
  68952. /**
  68953. * Gets the hash code of the current matrix
  68954. * @returns the hash code
  68955. */
  68956. getHashCode(): number;
  68957. /**
  68958. * Decomposes the current Matrix into a translation, rotation and scaling components
  68959. * @param scale defines the scale vector3 given as a reference to update
  68960. * @param rotation defines the rotation quaternion given as a reference to update
  68961. * @param translation defines the translation vector3 given as a reference to update
  68962. * @returns true if operation was successful
  68963. */
  68964. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68965. /**
  68966. * Gets specific row of the matrix
  68967. * @param index defines the number of the row to get
  68968. * @returns the index-th row of the current matrix as a new Vector4
  68969. */
  68970. getRow(index: number): Nullable<Vector4>;
  68971. /**
  68972. * Sets the index-th row of the current matrix to the vector4 values
  68973. * @param index defines the number of the row to set
  68974. * @param row defines the target vector4
  68975. * @returns the updated current matrix
  68976. */
  68977. setRow(index: number, row: Vector4): Matrix;
  68978. /**
  68979. * Compute the transpose of the matrix
  68980. * @returns the new transposed matrix
  68981. */
  68982. transpose(): Matrix;
  68983. /**
  68984. * Compute the transpose of the matrix and store it in a given matrix
  68985. * @param result defines the target matrix
  68986. * @returns the current matrix
  68987. */
  68988. transposeToRef(result: Matrix): Matrix;
  68989. /**
  68990. * Sets the index-th row of the current matrix with the given 4 x float values
  68991. * @param index defines the row index
  68992. * @param x defines the x component to set
  68993. * @param y defines the y component to set
  68994. * @param z defines the z component to set
  68995. * @param w defines the w component to set
  68996. * @returns the updated current matrix
  68997. */
  68998. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68999. /**
  69000. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69001. * @param scale defines the scale factor
  69002. * @returns a new matrix
  69003. */
  69004. scale(scale: number): Matrix;
  69005. /**
  69006. * Scale the current matrix values by a factor to a given result matrix
  69007. * @param scale defines the scale factor
  69008. * @param result defines the matrix to store the result
  69009. * @returns the current matrix
  69010. */
  69011. scaleToRef(scale: number, result: Matrix): Matrix;
  69012. /**
  69013. * Scale the current matrix values by a factor and add the result to a given matrix
  69014. * @param scale defines the scale factor
  69015. * @param result defines the Matrix to store the result
  69016. * @returns the current matrix
  69017. */
  69018. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69019. /**
  69020. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69021. * @param ref matrix to store the result
  69022. */
  69023. toNormalMatrix(ref: Matrix): void;
  69024. /**
  69025. * Gets only rotation part of the current matrix
  69026. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69027. */
  69028. getRotationMatrix(): Matrix;
  69029. /**
  69030. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69031. * @param result defines the target matrix to store data to
  69032. * @returns the current matrix
  69033. */
  69034. getRotationMatrixToRef(result: Matrix): Matrix;
  69035. /**
  69036. * Toggles model matrix from being right handed to left handed in place and vice versa
  69037. */
  69038. toggleModelMatrixHandInPlace(): void;
  69039. /**
  69040. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69041. */
  69042. toggleProjectionMatrixHandInPlace(): void;
  69043. /**
  69044. * Creates a matrix from an array
  69045. * @param array defines the source array
  69046. * @param offset defines an offset in the source array
  69047. * @returns a new Matrix set from the starting index of the given array
  69048. */
  69049. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69050. /**
  69051. * Copy the content of an array into a given matrix
  69052. * @param array defines the source array
  69053. * @param offset defines an offset in the source array
  69054. * @param result defines the target matrix
  69055. */
  69056. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69057. /**
  69058. * Stores an array into a matrix after having multiplied each component by a given factor
  69059. * @param array defines the source array
  69060. * @param offset defines the offset in the source array
  69061. * @param scale defines the scaling factor
  69062. * @param result defines the target matrix
  69063. */
  69064. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69065. /**
  69066. * Gets an identity matrix that must not be updated
  69067. */
  69068. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69069. /**
  69070. * Stores a list of values (16) inside a given matrix
  69071. * @param initialM11 defines 1st value of 1st row
  69072. * @param initialM12 defines 2nd value of 1st row
  69073. * @param initialM13 defines 3rd value of 1st row
  69074. * @param initialM14 defines 4th value of 1st row
  69075. * @param initialM21 defines 1st value of 2nd row
  69076. * @param initialM22 defines 2nd value of 2nd row
  69077. * @param initialM23 defines 3rd value of 2nd row
  69078. * @param initialM24 defines 4th value of 2nd row
  69079. * @param initialM31 defines 1st value of 3rd row
  69080. * @param initialM32 defines 2nd value of 3rd row
  69081. * @param initialM33 defines 3rd value of 3rd row
  69082. * @param initialM34 defines 4th value of 3rd row
  69083. * @param initialM41 defines 1st value of 4th row
  69084. * @param initialM42 defines 2nd value of 4th row
  69085. * @param initialM43 defines 3rd value of 4th row
  69086. * @param initialM44 defines 4th value of 4th row
  69087. * @param result defines the target matrix
  69088. */
  69089. 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;
  69090. /**
  69091. * Creates new matrix from a list of values (16)
  69092. * @param initialM11 defines 1st value of 1st row
  69093. * @param initialM12 defines 2nd value of 1st row
  69094. * @param initialM13 defines 3rd value of 1st row
  69095. * @param initialM14 defines 4th value of 1st row
  69096. * @param initialM21 defines 1st value of 2nd row
  69097. * @param initialM22 defines 2nd value of 2nd row
  69098. * @param initialM23 defines 3rd value of 2nd row
  69099. * @param initialM24 defines 4th value of 2nd row
  69100. * @param initialM31 defines 1st value of 3rd row
  69101. * @param initialM32 defines 2nd value of 3rd row
  69102. * @param initialM33 defines 3rd value of 3rd row
  69103. * @param initialM34 defines 4th value of 3rd row
  69104. * @param initialM41 defines 1st value of 4th row
  69105. * @param initialM42 defines 2nd value of 4th row
  69106. * @param initialM43 defines 3rd value of 4th row
  69107. * @param initialM44 defines 4th value of 4th row
  69108. * @returns the new matrix
  69109. */
  69110. 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;
  69111. /**
  69112. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69113. * @param scale defines the scale vector3
  69114. * @param rotation defines the rotation quaternion
  69115. * @param translation defines the translation vector3
  69116. * @returns a new matrix
  69117. */
  69118. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69119. /**
  69120. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69121. * @param scale defines the scale vector3
  69122. * @param rotation defines the rotation quaternion
  69123. * @param translation defines the translation vector3
  69124. * @param result defines the target matrix
  69125. */
  69126. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69127. /**
  69128. * Creates a new identity matrix
  69129. * @returns a new identity matrix
  69130. */
  69131. static Identity(): Matrix;
  69132. /**
  69133. * Creates a new identity matrix and stores the result in a given matrix
  69134. * @param result defines the target matrix
  69135. */
  69136. static IdentityToRef(result: Matrix): void;
  69137. /**
  69138. * Creates a new zero matrix
  69139. * @returns a new zero matrix
  69140. */
  69141. static Zero(): Matrix;
  69142. /**
  69143. * Creates a new rotation matrix for "angle" radians around the X axis
  69144. * @param angle defines the angle (in radians) to use
  69145. * @return the new matrix
  69146. */
  69147. static RotationX(angle: number): Matrix;
  69148. /**
  69149. * Creates a new matrix as the invert of a given matrix
  69150. * @param source defines the source matrix
  69151. * @returns the new matrix
  69152. */
  69153. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69154. /**
  69155. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69156. * @param angle defines the angle (in radians) to use
  69157. * @param result defines the target matrix
  69158. */
  69159. static RotationXToRef(angle: number, result: Matrix): void;
  69160. /**
  69161. * Creates a new rotation matrix for "angle" radians around the Y axis
  69162. * @param angle defines the angle (in radians) to use
  69163. * @return the new matrix
  69164. */
  69165. static RotationY(angle: number): Matrix;
  69166. /**
  69167. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69168. * @param angle defines the angle (in radians) to use
  69169. * @param result defines the target matrix
  69170. */
  69171. static RotationYToRef(angle: number, result: Matrix): void;
  69172. /**
  69173. * Creates a new rotation matrix for "angle" radians around the Z axis
  69174. * @param angle defines the angle (in radians) to use
  69175. * @return the new matrix
  69176. */
  69177. static RotationZ(angle: number): Matrix;
  69178. /**
  69179. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69180. * @param angle defines the angle (in radians) to use
  69181. * @param result defines the target matrix
  69182. */
  69183. static RotationZToRef(angle: number, result: Matrix): void;
  69184. /**
  69185. * Creates a new rotation matrix for "angle" radians around the given axis
  69186. * @param axis defines the axis to use
  69187. * @param angle defines the angle (in radians) to use
  69188. * @return the new matrix
  69189. */
  69190. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69191. /**
  69192. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69193. * @param axis defines the axis to use
  69194. * @param angle defines the angle (in radians) to use
  69195. * @param result defines the target matrix
  69196. */
  69197. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69198. /**
  69199. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69200. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69201. * @param from defines the vector to align
  69202. * @param to defines the vector to align to
  69203. * @param result defines the target matrix
  69204. */
  69205. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69206. /**
  69207. * Creates a rotation matrix
  69208. * @param yaw defines the yaw angle in radians (Y axis)
  69209. * @param pitch defines the pitch angle in radians (X axis)
  69210. * @param roll defines the roll angle in radians (X axis)
  69211. * @returns the new rotation matrix
  69212. */
  69213. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69214. /**
  69215. * Creates a rotation matrix and stores it in a given matrix
  69216. * @param yaw defines the yaw angle in radians (Y axis)
  69217. * @param pitch defines the pitch angle in radians (X axis)
  69218. * @param roll defines the roll angle in radians (X axis)
  69219. * @param result defines the target matrix
  69220. */
  69221. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69222. /**
  69223. * Creates a scaling matrix
  69224. * @param x defines the scale factor on X axis
  69225. * @param y defines the scale factor on Y axis
  69226. * @param z defines the scale factor on Z axis
  69227. * @returns the new matrix
  69228. */
  69229. static Scaling(x: number, y: number, z: number): Matrix;
  69230. /**
  69231. * Creates a scaling matrix and stores it in a given matrix
  69232. * @param x defines the scale factor on X axis
  69233. * @param y defines the scale factor on Y axis
  69234. * @param z defines the scale factor on Z axis
  69235. * @param result defines the target matrix
  69236. */
  69237. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69238. /**
  69239. * Creates a translation matrix
  69240. * @param x defines the translation on X axis
  69241. * @param y defines the translation on Y axis
  69242. * @param z defines the translationon Z axis
  69243. * @returns the new matrix
  69244. */
  69245. static Translation(x: number, y: number, z: number): Matrix;
  69246. /**
  69247. * Creates a translation matrix and stores it in a given matrix
  69248. * @param x defines the translation on X axis
  69249. * @param y defines the translation on Y axis
  69250. * @param z defines the translationon Z axis
  69251. * @param result defines the target matrix
  69252. */
  69253. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69254. /**
  69255. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69256. * @param startValue defines the start value
  69257. * @param endValue defines the end value
  69258. * @param gradient defines the gradient factor
  69259. * @returns the new matrix
  69260. */
  69261. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69262. /**
  69263. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69264. * @param startValue defines the start value
  69265. * @param endValue defines the end value
  69266. * @param gradient defines the gradient factor
  69267. * @param result defines the Matrix object where to store data
  69268. */
  69269. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69270. /**
  69271. * Builds a new matrix whose values are computed by:
  69272. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69273. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69274. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69275. * @param startValue defines the first matrix
  69276. * @param endValue defines the second matrix
  69277. * @param gradient defines the gradient between the two matrices
  69278. * @returns the new matrix
  69279. */
  69280. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69281. /**
  69282. * Update a matrix to values which are computed by:
  69283. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69284. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69285. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69286. * @param startValue defines the first matrix
  69287. * @param endValue defines the second matrix
  69288. * @param gradient defines the gradient between the two matrices
  69289. * @param result defines the target matrix
  69290. */
  69291. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69292. /**
  69293. * 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"
  69294. * This function works in left handed mode
  69295. * @param eye defines the final position of the entity
  69296. * @param target defines where the entity should look at
  69297. * @param up defines the up vector for the entity
  69298. * @returns the new matrix
  69299. */
  69300. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69301. /**
  69302. * 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".
  69303. * This function works in left handed mode
  69304. * @param eye defines the final position of the entity
  69305. * @param target defines where the entity should look at
  69306. * @param up defines the up vector for the entity
  69307. * @param result defines the target matrix
  69308. */
  69309. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69310. /**
  69311. * 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"
  69312. * This function works in right handed mode
  69313. * @param eye defines the final position of the entity
  69314. * @param target defines where the entity should look at
  69315. * @param up defines the up vector for the entity
  69316. * @returns the new matrix
  69317. */
  69318. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69319. /**
  69320. * 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".
  69321. * This function works in right handed mode
  69322. * @param eye defines the final position of the entity
  69323. * @param target defines where the entity should look at
  69324. * @param up defines the up vector for the entity
  69325. * @param result defines the target matrix
  69326. */
  69327. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69328. /**
  69329. * Create a left-handed orthographic projection matrix
  69330. * @param width defines the viewport width
  69331. * @param height defines the viewport height
  69332. * @param znear defines the near clip plane
  69333. * @param zfar defines the far clip plane
  69334. * @returns a new matrix as a left-handed orthographic projection matrix
  69335. */
  69336. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69337. /**
  69338. * Store a left-handed orthographic projection to a given matrix
  69339. * @param width defines the viewport width
  69340. * @param height defines the viewport height
  69341. * @param znear defines the near clip plane
  69342. * @param zfar defines the far clip plane
  69343. * @param result defines the target matrix
  69344. */
  69345. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69346. /**
  69347. * Create a left-handed orthographic projection matrix
  69348. * @param left defines the viewport left coordinate
  69349. * @param right defines the viewport right coordinate
  69350. * @param bottom defines the viewport bottom coordinate
  69351. * @param top defines the viewport top coordinate
  69352. * @param znear defines the near clip plane
  69353. * @param zfar defines the far clip plane
  69354. * @returns a new matrix as a left-handed orthographic projection matrix
  69355. */
  69356. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69357. /**
  69358. * Stores a left-handed orthographic projection into a given matrix
  69359. * @param left defines the viewport left coordinate
  69360. * @param right defines the viewport right coordinate
  69361. * @param bottom defines the viewport bottom coordinate
  69362. * @param top defines the viewport top coordinate
  69363. * @param znear defines the near clip plane
  69364. * @param zfar defines the far clip plane
  69365. * @param result defines the target matrix
  69366. */
  69367. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69368. /**
  69369. * Creates a right-handed orthographic projection matrix
  69370. * @param left defines the viewport left coordinate
  69371. * @param right defines the viewport right coordinate
  69372. * @param bottom defines the viewport bottom coordinate
  69373. * @param top defines the viewport top coordinate
  69374. * @param znear defines the near clip plane
  69375. * @param zfar defines the far clip plane
  69376. * @returns a new matrix as a right-handed orthographic projection matrix
  69377. */
  69378. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69379. /**
  69380. * Stores a right-handed orthographic projection into a given matrix
  69381. * @param left defines the viewport left coordinate
  69382. * @param right defines the viewport right coordinate
  69383. * @param bottom defines the viewport bottom coordinate
  69384. * @param top defines the viewport top coordinate
  69385. * @param znear defines the near clip plane
  69386. * @param zfar defines the far clip plane
  69387. * @param result defines the target matrix
  69388. */
  69389. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69390. /**
  69391. * Creates a left-handed perspective projection matrix
  69392. * @param width defines the viewport width
  69393. * @param height defines the viewport height
  69394. * @param znear defines the near clip plane
  69395. * @param zfar defines the far clip plane
  69396. * @returns a new matrix as a left-handed perspective projection matrix
  69397. */
  69398. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69399. /**
  69400. * Creates a left-handed perspective projection matrix
  69401. * @param fov defines the horizontal field of view
  69402. * @param aspect defines the aspect ratio
  69403. * @param znear defines the near clip plane
  69404. * @param zfar defines the far clip plane
  69405. * @returns a new matrix as a left-handed perspective projection matrix
  69406. */
  69407. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69408. /**
  69409. * Stores a left-handed perspective projection into a given matrix
  69410. * @param fov defines the horizontal field of view
  69411. * @param aspect defines the aspect ratio
  69412. * @param znear defines the near clip plane
  69413. * @param zfar defines the far clip plane
  69414. * @param result defines the target matrix
  69415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69416. */
  69417. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69418. /**
  69419. * Creates a right-handed perspective projection matrix
  69420. * @param fov defines the horizontal field of view
  69421. * @param aspect defines the aspect ratio
  69422. * @param znear defines the near clip plane
  69423. * @param zfar defines the far clip plane
  69424. * @returns a new matrix as a right-handed perspective projection matrix
  69425. */
  69426. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69427. /**
  69428. * Stores a right-handed perspective projection into a given matrix
  69429. * @param fov defines the horizontal field of view
  69430. * @param aspect defines the aspect ratio
  69431. * @param znear defines the near clip plane
  69432. * @param zfar defines the far clip plane
  69433. * @param result defines the target matrix
  69434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69435. */
  69436. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69437. /**
  69438. * Stores a perspective projection for WebVR info a given matrix
  69439. * @param fov defines the field of view
  69440. * @param znear defines the near clip plane
  69441. * @param zfar defines the far clip plane
  69442. * @param result defines the target matrix
  69443. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69444. */
  69445. static PerspectiveFovWebVRToRef(fov: {
  69446. upDegrees: number;
  69447. downDegrees: number;
  69448. leftDegrees: number;
  69449. rightDegrees: number;
  69450. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69451. /**
  69452. * Computes a complete transformation matrix
  69453. * @param viewport defines the viewport to use
  69454. * @param world defines the world matrix
  69455. * @param view defines the view matrix
  69456. * @param projection defines the projection matrix
  69457. * @param zmin defines the near clip plane
  69458. * @param zmax defines the far clip plane
  69459. * @returns the transformation matrix
  69460. */
  69461. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69462. /**
  69463. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69464. * @param matrix defines the matrix to use
  69465. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69466. */
  69467. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69468. /**
  69469. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69470. * @param matrix defines the matrix to use
  69471. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69472. */
  69473. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69474. /**
  69475. * Compute the transpose of a given matrix
  69476. * @param matrix defines the matrix to transpose
  69477. * @returns the new matrix
  69478. */
  69479. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69480. /**
  69481. * Compute the transpose of a matrix and store it in a target matrix
  69482. * @param matrix defines the matrix to transpose
  69483. * @param result defines the target matrix
  69484. */
  69485. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69486. /**
  69487. * Computes a reflection matrix from a plane
  69488. * @param plane defines the reflection plane
  69489. * @returns a new matrix
  69490. */
  69491. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69492. /**
  69493. * Computes a reflection matrix from a plane
  69494. * @param plane defines the reflection plane
  69495. * @param result defines the target matrix
  69496. */
  69497. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69498. /**
  69499. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69500. * @param xaxis defines the value of the 1st axis
  69501. * @param yaxis defines the value of the 2nd axis
  69502. * @param zaxis defines the value of the 3rd axis
  69503. * @param result defines the target matrix
  69504. */
  69505. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69506. /**
  69507. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69508. * @param quat defines the quaternion to use
  69509. * @param result defines the target matrix
  69510. */
  69511. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69512. }
  69513. /**
  69514. * @hidden
  69515. */
  69516. export class TmpVectors {
  69517. static Vector2: Vector2[];
  69518. static Vector3: Vector3[];
  69519. static Vector4: Vector4[];
  69520. static Quaternion: Quaternion[];
  69521. static Matrix: Matrix[];
  69522. }
  69523. }
  69524. declare module BABYLON {
  69525. /** Defines the cross module used constants to avoid circular dependncies */
  69526. export class Constants {
  69527. /** Defines that alpha blending is disabled */
  69528. static readonly ALPHA_DISABLE: number;
  69529. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69530. static readonly ALPHA_ADD: number;
  69531. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69532. static readonly ALPHA_COMBINE: number;
  69533. /** Defines that alpha blending to DEST - SRC * DEST */
  69534. static readonly ALPHA_SUBTRACT: number;
  69535. /** Defines that alpha blending to SRC * DEST */
  69536. static readonly ALPHA_MULTIPLY: number;
  69537. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69538. static readonly ALPHA_MAXIMIZED: number;
  69539. /** Defines that alpha blending to SRC + DEST */
  69540. static readonly ALPHA_ONEONE: number;
  69541. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69542. static readonly ALPHA_PREMULTIPLIED: number;
  69543. /**
  69544. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69545. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69546. */
  69547. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69548. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69549. static readonly ALPHA_INTERPOLATE: number;
  69550. /**
  69551. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69552. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69553. */
  69554. static readonly ALPHA_SCREENMODE: number;
  69555. /** Defines that the ressource is not delayed*/
  69556. static readonly DELAYLOADSTATE_NONE: number;
  69557. /** Defines that the ressource was successfully delay loaded */
  69558. static readonly DELAYLOADSTATE_LOADED: number;
  69559. /** Defines that the ressource is currently delay loading */
  69560. static readonly DELAYLOADSTATE_LOADING: number;
  69561. /** Defines that the ressource is delayed and has not started loading */
  69562. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69563. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69564. static readonly NEVER: number;
  69565. /** 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 */
  69566. static readonly ALWAYS: number;
  69567. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69568. static readonly LESS: number;
  69569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69570. static readonly EQUAL: number;
  69571. /** 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 */
  69572. static readonly LEQUAL: number;
  69573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69574. static readonly GREATER: number;
  69575. /** 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 */
  69576. static readonly GEQUAL: number;
  69577. /** 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 */
  69578. static readonly NOTEQUAL: number;
  69579. /** Passed to stencilOperation to specify that stencil value must be kept */
  69580. static readonly KEEP: number;
  69581. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69582. static readonly REPLACE: number;
  69583. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69584. static readonly INCR: number;
  69585. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69586. static readonly DECR: number;
  69587. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69588. static readonly INVERT: number;
  69589. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69590. static readonly INCR_WRAP: number;
  69591. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69592. static readonly DECR_WRAP: number;
  69593. /** Texture is not repeating outside of 0..1 UVs */
  69594. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69595. /** Texture is repeating outside of 0..1 UVs */
  69596. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69597. /** Texture is repeating and mirrored */
  69598. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69599. /** ALPHA */
  69600. static readonly TEXTUREFORMAT_ALPHA: number;
  69601. /** LUMINANCE */
  69602. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69603. /** LUMINANCE_ALPHA */
  69604. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69605. /** RGB */
  69606. static readonly TEXTUREFORMAT_RGB: number;
  69607. /** RGBA */
  69608. static readonly TEXTUREFORMAT_RGBA: number;
  69609. /** RED */
  69610. static readonly TEXTUREFORMAT_RED: number;
  69611. /** RED (2nd reference) */
  69612. static readonly TEXTUREFORMAT_R: number;
  69613. /** RG */
  69614. static readonly TEXTUREFORMAT_RG: number;
  69615. /** RED_INTEGER */
  69616. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69617. /** RED_INTEGER (2nd reference) */
  69618. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69619. /** RG_INTEGER */
  69620. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69621. /** RGB_INTEGER */
  69622. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69623. /** RGBA_INTEGER */
  69624. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69625. /** UNSIGNED_BYTE */
  69626. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69627. /** UNSIGNED_BYTE (2nd reference) */
  69628. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69629. /** FLOAT */
  69630. static readonly TEXTURETYPE_FLOAT: number;
  69631. /** HALF_FLOAT */
  69632. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69633. /** BYTE */
  69634. static readonly TEXTURETYPE_BYTE: number;
  69635. /** SHORT */
  69636. static readonly TEXTURETYPE_SHORT: number;
  69637. /** UNSIGNED_SHORT */
  69638. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69639. /** INT */
  69640. static readonly TEXTURETYPE_INT: number;
  69641. /** UNSIGNED_INT */
  69642. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69643. /** UNSIGNED_SHORT_4_4_4_4 */
  69644. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69645. /** UNSIGNED_SHORT_5_5_5_1 */
  69646. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69647. /** UNSIGNED_SHORT_5_6_5 */
  69648. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69649. /** UNSIGNED_INT_2_10_10_10_REV */
  69650. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69651. /** UNSIGNED_INT_24_8 */
  69652. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69653. /** UNSIGNED_INT_10F_11F_11F_REV */
  69654. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69655. /** UNSIGNED_INT_5_9_9_9_REV */
  69656. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69657. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69658. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69659. /** nearest is mag = nearest and min = nearest and mip = linear */
  69660. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69661. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69662. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69663. /** Trilinear is mag = linear and min = linear and mip = linear */
  69664. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69665. /** nearest is mag = nearest and min = nearest and mip = linear */
  69666. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69667. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69668. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69669. /** Trilinear is mag = linear and min = linear and mip = linear */
  69670. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69671. /** mag = nearest and min = nearest and mip = nearest */
  69672. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69673. /** mag = nearest and min = linear and mip = nearest */
  69674. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69675. /** mag = nearest and min = linear and mip = linear */
  69676. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69677. /** mag = nearest and min = linear and mip = none */
  69678. static readonly TEXTURE_NEAREST_LINEAR: number;
  69679. /** mag = nearest and min = nearest and mip = none */
  69680. static readonly TEXTURE_NEAREST_NEAREST: number;
  69681. /** mag = linear and min = nearest and mip = nearest */
  69682. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69683. /** mag = linear and min = nearest and mip = linear */
  69684. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69685. /** mag = linear and min = linear and mip = none */
  69686. static readonly TEXTURE_LINEAR_LINEAR: number;
  69687. /** mag = linear and min = nearest and mip = none */
  69688. static readonly TEXTURE_LINEAR_NEAREST: number;
  69689. /** Explicit coordinates mode */
  69690. static readonly TEXTURE_EXPLICIT_MODE: number;
  69691. /** Spherical coordinates mode */
  69692. static readonly TEXTURE_SPHERICAL_MODE: number;
  69693. /** Planar coordinates mode */
  69694. static readonly TEXTURE_PLANAR_MODE: number;
  69695. /** Cubic coordinates mode */
  69696. static readonly TEXTURE_CUBIC_MODE: number;
  69697. /** Projection coordinates mode */
  69698. static readonly TEXTURE_PROJECTION_MODE: number;
  69699. /** Skybox coordinates mode */
  69700. static readonly TEXTURE_SKYBOX_MODE: number;
  69701. /** Inverse Cubic coordinates mode */
  69702. static readonly TEXTURE_INVCUBIC_MODE: number;
  69703. /** Equirectangular coordinates mode */
  69704. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69705. /** Equirectangular Fixed coordinates mode */
  69706. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69707. /** Equirectangular Fixed Mirrored coordinates mode */
  69708. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69709. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69710. static readonly SCALEMODE_FLOOR: number;
  69711. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69712. static readonly SCALEMODE_NEAREST: number;
  69713. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69714. static readonly SCALEMODE_CEILING: number;
  69715. /**
  69716. * The dirty texture flag value
  69717. */
  69718. static readonly MATERIAL_TextureDirtyFlag: number;
  69719. /**
  69720. * The dirty light flag value
  69721. */
  69722. static readonly MATERIAL_LightDirtyFlag: number;
  69723. /**
  69724. * The dirty fresnel flag value
  69725. */
  69726. static readonly MATERIAL_FresnelDirtyFlag: number;
  69727. /**
  69728. * The dirty attribute flag value
  69729. */
  69730. static readonly MATERIAL_AttributesDirtyFlag: number;
  69731. /**
  69732. * The dirty misc flag value
  69733. */
  69734. static readonly MATERIAL_MiscDirtyFlag: number;
  69735. /**
  69736. * The all dirty flag value
  69737. */
  69738. static readonly MATERIAL_AllDirtyFlag: number;
  69739. /**
  69740. * Returns the triangle fill mode
  69741. */
  69742. static readonly MATERIAL_TriangleFillMode: number;
  69743. /**
  69744. * Returns the wireframe mode
  69745. */
  69746. static readonly MATERIAL_WireFrameFillMode: number;
  69747. /**
  69748. * Returns the point fill mode
  69749. */
  69750. static readonly MATERIAL_PointFillMode: number;
  69751. /**
  69752. * Returns the point list draw mode
  69753. */
  69754. static readonly MATERIAL_PointListDrawMode: number;
  69755. /**
  69756. * Returns the line list draw mode
  69757. */
  69758. static readonly MATERIAL_LineListDrawMode: number;
  69759. /**
  69760. * Returns the line loop draw mode
  69761. */
  69762. static readonly MATERIAL_LineLoopDrawMode: number;
  69763. /**
  69764. * Returns the line strip draw mode
  69765. */
  69766. static readonly MATERIAL_LineStripDrawMode: number;
  69767. /**
  69768. * Returns the triangle strip draw mode
  69769. */
  69770. static readonly MATERIAL_TriangleStripDrawMode: number;
  69771. /**
  69772. * Returns the triangle fan draw mode
  69773. */
  69774. static readonly MATERIAL_TriangleFanDrawMode: number;
  69775. /**
  69776. * Stores the clock-wise side orientation
  69777. */
  69778. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69779. /**
  69780. * Stores the counter clock-wise side orientation
  69781. */
  69782. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69783. /**
  69784. * Nothing
  69785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69786. */
  69787. static readonly ACTION_NothingTrigger: number;
  69788. /**
  69789. * On pick
  69790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69791. */
  69792. static readonly ACTION_OnPickTrigger: number;
  69793. /**
  69794. * On left pick
  69795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69796. */
  69797. static readonly ACTION_OnLeftPickTrigger: number;
  69798. /**
  69799. * On right pick
  69800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69801. */
  69802. static readonly ACTION_OnRightPickTrigger: number;
  69803. /**
  69804. * On center pick
  69805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69806. */
  69807. static readonly ACTION_OnCenterPickTrigger: number;
  69808. /**
  69809. * On pick down
  69810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69811. */
  69812. static readonly ACTION_OnPickDownTrigger: number;
  69813. /**
  69814. * On double pick
  69815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69816. */
  69817. static readonly ACTION_OnDoublePickTrigger: number;
  69818. /**
  69819. * On pick up
  69820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69821. */
  69822. static readonly ACTION_OnPickUpTrigger: number;
  69823. /**
  69824. * On pick out.
  69825. * This trigger will only be raised if you also declared a OnPickDown
  69826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69827. */
  69828. static readonly ACTION_OnPickOutTrigger: number;
  69829. /**
  69830. * On long press
  69831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69832. */
  69833. static readonly ACTION_OnLongPressTrigger: number;
  69834. /**
  69835. * On pointer over
  69836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69837. */
  69838. static readonly ACTION_OnPointerOverTrigger: number;
  69839. /**
  69840. * On pointer out
  69841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69842. */
  69843. static readonly ACTION_OnPointerOutTrigger: number;
  69844. /**
  69845. * On every frame
  69846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69847. */
  69848. static readonly ACTION_OnEveryFrameTrigger: number;
  69849. /**
  69850. * On intersection enter
  69851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69852. */
  69853. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69854. /**
  69855. * On intersection exit
  69856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69857. */
  69858. static readonly ACTION_OnIntersectionExitTrigger: number;
  69859. /**
  69860. * On key down
  69861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69862. */
  69863. static readonly ACTION_OnKeyDownTrigger: number;
  69864. /**
  69865. * On key up
  69866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69867. */
  69868. static readonly ACTION_OnKeyUpTrigger: number;
  69869. /**
  69870. * Billboard mode will only apply to Y axis
  69871. */
  69872. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69873. /**
  69874. * Billboard mode will apply to all axes
  69875. */
  69876. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69877. /**
  69878. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69879. */
  69880. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69881. /**
  69882. * Gets or sets base Assets URL
  69883. */
  69884. static PARTICLES_BaseAssetsUrl: string;
  69885. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69886. * Test order :
  69887. * Is the bounding sphere outside the frustum ?
  69888. * If not, are the bounding box vertices outside the frustum ?
  69889. * It not, then the cullable object is in the frustum.
  69890. */
  69891. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69892. /** Culling strategy : Bounding Sphere Only.
  69893. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69894. * It's also less accurate than the standard because some not visible objects can still be selected.
  69895. * Test : is the bounding sphere outside the frustum ?
  69896. * If not, then the cullable object is in the frustum.
  69897. */
  69898. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69899. /** Culling strategy : Optimistic Inclusion.
  69900. * This in an inclusion test first, then the standard exclusion test.
  69901. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69902. * 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.
  69903. * Anyway, it's as accurate as the standard strategy.
  69904. * Test :
  69905. * Is the cullable object bounding sphere center in the frustum ?
  69906. * If not, apply the default culling strategy.
  69907. */
  69908. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69909. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69910. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69911. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69912. * 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.
  69913. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69914. * Test :
  69915. * Is the cullable object bounding sphere center in the frustum ?
  69916. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69917. */
  69918. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69919. /**
  69920. * No logging while loading
  69921. */
  69922. static readonly SCENELOADER_NO_LOGGING: number;
  69923. /**
  69924. * Minimal logging while loading
  69925. */
  69926. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69927. /**
  69928. * Summary logging while loading
  69929. */
  69930. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69931. /**
  69932. * Detailled logging while loading
  69933. */
  69934. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69935. }
  69936. }
  69937. declare module BABYLON {
  69938. /**
  69939. * Class used to store and describe the pipeline context associated with an effect
  69940. */
  69941. export interface IPipelineContext {
  69942. /**
  69943. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69944. */
  69945. isAsync: boolean;
  69946. /**
  69947. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69948. */
  69949. isReady: boolean;
  69950. /** @hidden */
  69951. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69952. }
  69953. }
  69954. declare module BABYLON {
  69955. /** @hidden */
  69956. export interface IShaderProcessor {
  69957. attributeProcessor?: (attribute: string) => string;
  69958. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69959. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69960. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69961. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69962. lineProcessor?: (line: string, isFragment: boolean) => string;
  69963. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69964. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69965. }
  69966. }
  69967. declare module BABYLON {
  69968. /** @hidden */
  69969. export interface ProcessingOptions {
  69970. defines: string[];
  69971. indexParameters: any;
  69972. isFragment: boolean;
  69973. shouldUseHighPrecisionShader: boolean;
  69974. supportsUniformBuffers: boolean;
  69975. shadersRepository: string;
  69976. includesShadersStore: {
  69977. [key: string]: string;
  69978. };
  69979. processor?: IShaderProcessor;
  69980. version: string;
  69981. platformName: string;
  69982. lookForClosingBracketForUniformBuffer?: boolean;
  69983. }
  69984. }
  69985. declare module BABYLON {
  69986. /**
  69987. * Helper to manipulate strings
  69988. */
  69989. export class StringTools {
  69990. /**
  69991. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69992. * @param str Source string
  69993. * @param suffix Suffix to search for in the source string
  69994. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69995. */
  69996. static EndsWith(str: string, suffix: string): boolean;
  69997. /**
  69998. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69999. * @param str Source string
  70000. * @param suffix Suffix to search for in the source string
  70001. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70002. */
  70003. static StartsWith(str: string, suffix: string): boolean;
  70004. }
  70005. }
  70006. declare module BABYLON {
  70007. /** @hidden */
  70008. export class ShaderCodeNode {
  70009. line: string;
  70010. children: ShaderCodeNode[];
  70011. additionalDefineKey?: string;
  70012. additionalDefineValue?: string;
  70013. isValid(preprocessors: {
  70014. [key: string]: string;
  70015. }): boolean;
  70016. process(preprocessors: {
  70017. [key: string]: string;
  70018. }, options: ProcessingOptions): string;
  70019. }
  70020. }
  70021. declare module BABYLON {
  70022. /** @hidden */
  70023. export class ShaderCodeCursor {
  70024. private _lines;
  70025. lineIndex: number;
  70026. readonly currentLine: string;
  70027. readonly canRead: boolean;
  70028. lines: string[];
  70029. }
  70030. }
  70031. declare module BABYLON {
  70032. /** @hidden */
  70033. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70034. process(preprocessors: {
  70035. [key: string]: string;
  70036. }, options: ProcessingOptions): string;
  70037. }
  70038. }
  70039. declare module BABYLON {
  70040. /** @hidden */
  70041. export class ShaderDefineExpression {
  70042. isTrue(preprocessors: {
  70043. [key: string]: string;
  70044. }): boolean;
  70045. }
  70046. }
  70047. declare module BABYLON {
  70048. /** @hidden */
  70049. export class ShaderCodeTestNode extends ShaderCodeNode {
  70050. testExpression: ShaderDefineExpression;
  70051. isValid(preprocessors: {
  70052. [key: string]: string;
  70053. }): boolean;
  70054. }
  70055. }
  70056. declare module BABYLON {
  70057. /** @hidden */
  70058. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70059. define: string;
  70060. not: boolean;
  70061. constructor(define: string, not?: boolean);
  70062. isTrue(preprocessors: {
  70063. [key: string]: string;
  70064. }): boolean;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. /** @hidden */
  70069. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70070. leftOperand: ShaderDefineExpression;
  70071. rightOperand: ShaderDefineExpression;
  70072. isTrue(preprocessors: {
  70073. [key: string]: string;
  70074. }): boolean;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /** @hidden */
  70079. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70080. leftOperand: ShaderDefineExpression;
  70081. rightOperand: ShaderDefineExpression;
  70082. isTrue(preprocessors: {
  70083. [key: string]: string;
  70084. }): boolean;
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /** @hidden */
  70089. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70090. define: string;
  70091. operand: string;
  70092. testValue: string;
  70093. constructor(define: string, operand: string, testValue: string);
  70094. isTrue(preprocessors: {
  70095. [key: string]: string;
  70096. }): boolean;
  70097. }
  70098. }
  70099. declare module BABYLON {
  70100. /**
  70101. * @ignore
  70102. * Application error to support additional information when loading a file
  70103. */
  70104. export class LoadFileError extends Error {
  70105. /** defines the optional web request */
  70106. request?: WebRequest | undefined;
  70107. private static _setPrototypeOf;
  70108. /**
  70109. * Creates a new LoadFileError
  70110. * @param message defines the message of the error
  70111. * @param request defines the optional web request
  70112. */
  70113. constructor(message: string,
  70114. /** defines the optional web request */
  70115. request?: WebRequest | undefined);
  70116. }
  70117. }
  70118. declare module BABYLON {
  70119. /**
  70120. * Class used to enable access to offline support
  70121. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70122. */
  70123. export interface IOfflineProvider {
  70124. /**
  70125. * Gets a boolean indicating if scene must be saved in the database
  70126. */
  70127. enableSceneOffline: boolean;
  70128. /**
  70129. * Gets a boolean indicating if textures must be saved in the database
  70130. */
  70131. enableTexturesOffline: boolean;
  70132. /**
  70133. * Open the offline support and make it available
  70134. * @param successCallback defines the callback to call on success
  70135. * @param errorCallback defines the callback to call on error
  70136. */
  70137. open(successCallback: () => void, errorCallback: () => void): void;
  70138. /**
  70139. * Loads an image from the offline support
  70140. * @param url defines the url to load from
  70141. * @param image defines the target DOM image
  70142. */
  70143. loadImage(url: string, image: HTMLImageElement): void;
  70144. /**
  70145. * Loads a file from offline support
  70146. * @param url defines the URL to load from
  70147. * @param sceneLoaded defines a callback to call on success
  70148. * @param progressCallBack defines a callback to call when progress changed
  70149. * @param errorCallback defines a callback to call on error
  70150. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70151. */
  70152. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70153. }
  70154. }
  70155. declare module BABYLON {
  70156. /**
  70157. * Class used to help managing file picking and drag'n'drop
  70158. * File Storage
  70159. */
  70160. export class FilesInputStore {
  70161. /**
  70162. * List of files ready to be loaded
  70163. */
  70164. static FilesToLoad: {
  70165. [key: string]: File;
  70166. };
  70167. }
  70168. }
  70169. declare module BABYLON {
  70170. /**
  70171. * Class used to define a retry strategy when error happens while loading assets
  70172. */
  70173. export class RetryStrategy {
  70174. /**
  70175. * Function used to defines an exponential back off strategy
  70176. * @param maxRetries defines the maximum number of retries (3 by default)
  70177. * @param baseInterval defines the interval between retries
  70178. * @returns the strategy function to use
  70179. */
  70180. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70181. }
  70182. }
  70183. declare module BABYLON {
  70184. /**
  70185. * @hidden
  70186. */
  70187. export class FileTools {
  70188. /**
  70189. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70190. */
  70191. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70192. /**
  70193. * Gets or sets the base URL to use to load assets
  70194. */
  70195. static BaseUrl: string;
  70196. /**
  70197. * Default behaviour for cors in the application.
  70198. * It can be a string if the expected behavior is identical in the entire app.
  70199. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70200. */
  70201. static CorsBehavior: string | ((url: string | string[]) => string);
  70202. /**
  70203. * Gets or sets a function used to pre-process url before using them to load assets
  70204. */
  70205. static PreprocessUrl: (url: string) => string;
  70206. /**
  70207. * Removes unwanted characters from an url
  70208. * @param url defines the url to clean
  70209. * @returns the cleaned url
  70210. */
  70211. private static _CleanUrl;
  70212. /**
  70213. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70214. * @param url define the url we are trying
  70215. * @param element define the dom element where to configure the cors policy
  70216. */
  70217. static SetCorsBehavior(url: string | string[], element: {
  70218. crossOrigin: string | null;
  70219. }): void;
  70220. /**
  70221. * Loads an image as an HTMLImageElement.
  70222. * @param input url string, ArrayBuffer, or Blob to load
  70223. * @param onLoad callback called when the image successfully loads
  70224. * @param onError callback called when the image fails to load
  70225. * @param offlineProvider offline provider for caching
  70226. * @returns the HTMLImageElement of the loaded image
  70227. */
  70228. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70229. /**
  70230. * Loads a file
  70231. * @param fileToLoad defines the file to load
  70232. * @param callback defines the callback to call when data is loaded
  70233. * @param progressCallBack defines the callback to call during loading process
  70234. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70235. * @returns a file request object
  70236. */
  70237. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70238. /**
  70239. * Loads a file
  70240. * @param url url string, ArrayBuffer, or Blob to load
  70241. * @param onSuccess callback called when the file successfully loads
  70242. * @param onProgress callback called while file is loading (if the server supports this mode)
  70243. * @param offlineProvider defines the offline provider for caching
  70244. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70245. * @param onError callback called when the file fails to load
  70246. * @returns a file request object
  70247. */
  70248. 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;
  70249. /**
  70250. * Checks if the loaded document was accessed via `file:`-Protocol.
  70251. * @returns boolean
  70252. */
  70253. static IsFileURL(): boolean;
  70254. }
  70255. }
  70256. declare module BABYLON {
  70257. /** @hidden */
  70258. export class ShaderProcessor {
  70259. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70260. private static _ProcessPrecision;
  70261. private static _ExtractOperation;
  70262. private static _BuildSubExpression;
  70263. private static _BuildExpression;
  70264. private static _MoveCursorWithinIf;
  70265. private static _MoveCursor;
  70266. private static _EvaluatePreProcessors;
  70267. private static _PreparePreProcessors;
  70268. private static _ProcessShaderConversion;
  70269. private static _ProcessIncludes;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /**
  70274. * Class used to hold a RBG color
  70275. */
  70276. export class Color3 {
  70277. /**
  70278. * Defines the red component (between 0 and 1, default is 0)
  70279. */
  70280. r: number;
  70281. /**
  70282. * Defines the green component (between 0 and 1, default is 0)
  70283. */
  70284. g: number;
  70285. /**
  70286. * Defines the blue component (between 0 and 1, default is 0)
  70287. */
  70288. b: number;
  70289. /**
  70290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70291. * @param r defines the red component (between 0 and 1, default is 0)
  70292. * @param g defines the green component (between 0 and 1, default is 0)
  70293. * @param b defines the blue component (between 0 and 1, default is 0)
  70294. */
  70295. constructor(
  70296. /**
  70297. * Defines the red component (between 0 and 1, default is 0)
  70298. */
  70299. r?: number,
  70300. /**
  70301. * Defines the green component (between 0 and 1, default is 0)
  70302. */
  70303. g?: number,
  70304. /**
  70305. * Defines the blue component (between 0 and 1, default is 0)
  70306. */
  70307. b?: number);
  70308. /**
  70309. * Creates a string with the Color3 current values
  70310. * @returns the string representation of the Color3 object
  70311. */
  70312. toString(): string;
  70313. /**
  70314. * Returns the string "Color3"
  70315. * @returns "Color3"
  70316. */
  70317. getClassName(): string;
  70318. /**
  70319. * Compute the Color3 hash code
  70320. * @returns an unique number that can be used to hash Color3 objects
  70321. */
  70322. getHashCode(): number;
  70323. /**
  70324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70325. * @param array defines the array where to store the r,g,b components
  70326. * @param index defines an optional index in the target array to define where to start storing values
  70327. * @returns the current Color3 object
  70328. */
  70329. toArray(array: FloatArray, index?: number): Color3;
  70330. /**
  70331. * Returns a new Color4 object from the current Color3 and the given alpha
  70332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70333. * @returns a new Color4 object
  70334. */
  70335. toColor4(alpha?: number): Color4;
  70336. /**
  70337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70338. * @returns the new array
  70339. */
  70340. asArray(): number[];
  70341. /**
  70342. * Returns the luminance value
  70343. * @returns a float value
  70344. */
  70345. toLuminance(): number;
  70346. /**
  70347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70348. * @param otherColor defines the second operand
  70349. * @returns the new Color3 object
  70350. */
  70351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70352. /**
  70353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70354. * @param otherColor defines the second operand
  70355. * @param result defines the Color3 object where to store the result
  70356. * @returns the current Color3
  70357. */
  70358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70359. /**
  70360. * Determines equality between Color3 objects
  70361. * @param otherColor defines the second operand
  70362. * @returns true if the rgb values are equal to the given ones
  70363. */
  70364. equals(otherColor: DeepImmutable<Color3>): boolean;
  70365. /**
  70366. * Determines equality between the current Color3 object and a set of r,b,g values
  70367. * @param r defines the red component to check
  70368. * @param g defines the green component to check
  70369. * @param b defines the blue component to check
  70370. * @returns true if the rgb values are equal to the given ones
  70371. */
  70372. equalsFloats(r: number, g: number, b: number): boolean;
  70373. /**
  70374. * Multiplies in place each rgb value by scale
  70375. * @param scale defines the scaling factor
  70376. * @returns the updated Color3
  70377. */
  70378. scale(scale: number): Color3;
  70379. /**
  70380. * Multiplies the rgb values by scale and stores the result into "result"
  70381. * @param scale defines the scaling factor
  70382. * @param result defines the Color3 object where to store the result
  70383. * @returns the unmodified current Color3
  70384. */
  70385. scaleToRef(scale: number, result: Color3): Color3;
  70386. /**
  70387. * Scale the current Color3 values by a factor and add the result to a given Color3
  70388. * @param scale defines the scale factor
  70389. * @param result defines color to store the result into
  70390. * @returns the unmodified current Color3
  70391. */
  70392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70393. /**
  70394. * Clamps the rgb values by the min and max values and stores the result into "result"
  70395. * @param min defines minimum clamping value (default is 0)
  70396. * @param max defines maximum clamping value (default is 1)
  70397. * @param result defines color to store the result into
  70398. * @returns the original Color3
  70399. */
  70400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70401. /**
  70402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70403. * @param otherColor defines the second operand
  70404. * @returns the new Color3
  70405. */
  70406. add(otherColor: DeepImmutable<Color3>): Color3;
  70407. /**
  70408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70409. * @param otherColor defines the second operand
  70410. * @param result defines Color3 object to store the result into
  70411. * @returns the unmodified current Color3
  70412. */
  70413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70414. /**
  70415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70416. * @param otherColor defines the second operand
  70417. * @returns the new Color3
  70418. */
  70419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70420. /**
  70421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70422. * @param otherColor defines the second operand
  70423. * @param result defines Color3 object to store the result into
  70424. * @returns the unmodified current Color3
  70425. */
  70426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70427. /**
  70428. * Copy the current object
  70429. * @returns a new Color3 copied the current one
  70430. */
  70431. clone(): Color3;
  70432. /**
  70433. * Copies the rgb values from the source in the current Color3
  70434. * @param source defines the source Color3 object
  70435. * @returns the updated Color3 object
  70436. */
  70437. copyFrom(source: DeepImmutable<Color3>): Color3;
  70438. /**
  70439. * Updates the Color3 rgb values from the given floats
  70440. * @param r defines the red component to read from
  70441. * @param g defines the green component to read from
  70442. * @param b defines the blue component to read from
  70443. * @returns the current Color3 object
  70444. */
  70445. copyFromFloats(r: number, g: number, b: number): Color3;
  70446. /**
  70447. * Updates the Color3 rgb values from the given floats
  70448. * @param r defines the red component to read from
  70449. * @param g defines the green component to read from
  70450. * @param b defines the blue component to read from
  70451. * @returns the current Color3 object
  70452. */
  70453. set(r: number, g: number, b: number): Color3;
  70454. /**
  70455. * Compute the Color3 hexadecimal code as a string
  70456. * @returns a string containing the hexadecimal representation of the Color3 object
  70457. */
  70458. toHexString(): string;
  70459. /**
  70460. * Computes a new Color3 converted from the current one to linear space
  70461. * @returns a new Color3 object
  70462. */
  70463. toLinearSpace(): Color3;
  70464. /**
  70465. * Converts current color in rgb space to HSV values
  70466. * @returns a new color3 representing the HSV values
  70467. */
  70468. toHSV(): Color3;
  70469. /**
  70470. * Converts current color in rgb space to HSV values
  70471. * @param result defines the Color3 where to store the HSV values
  70472. */
  70473. toHSVToRef(result: Color3): void;
  70474. /**
  70475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70476. * @param convertedColor defines the Color3 object where to store the linear space version
  70477. * @returns the unmodified Color3
  70478. */
  70479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70480. /**
  70481. * Computes a new Color3 converted from the current one to gamma space
  70482. * @returns a new Color3 object
  70483. */
  70484. toGammaSpace(): Color3;
  70485. /**
  70486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70487. * @param convertedColor defines the Color3 object where to store the gamma space version
  70488. * @returns the unmodified Color3
  70489. */
  70490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70491. private static _BlackReadOnly;
  70492. /**
  70493. * Convert Hue, saturation and value to a Color3 (RGB)
  70494. * @param hue defines the hue
  70495. * @param saturation defines the saturation
  70496. * @param value defines the value
  70497. * @param result defines the Color3 where to store the RGB values
  70498. */
  70499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70500. /**
  70501. * Creates a new Color3 from the string containing valid hexadecimal values
  70502. * @param hex defines a string containing valid hexadecimal values
  70503. * @returns a new Color3 object
  70504. */
  70505. static FromHexString(hex: string): Color3;
  70506. /**
  70507. * Creates a new Color3 from the starting index of the given array
  70508. * @param array defines the source array
  70509. * @param offset defines an offset in the source array
  70510. * @returns a new Color3 object
  70511. */
  70512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70513. /**
  70514. * Creates a new Color3 from integer values (< 256)
  70515. * @param r defines the red component to read from (value between 0 and 255)
  70516. * @param g defines the green component to read from (value between 0 and 255)
  70517. * @param b defines the blue component to read from (value between 0 and 255)
  70518. * @returns a new Color3 object
  70519. */
  70520. static FromInts(r: number, g: number, b: number): Color3;
  70521. /**
  70522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70523. * @param start defines the start Color3 value
  70524. * @param end defines the end Color3 value
  70525. * @param amount defines the gradient value between start and end
  70526. * @returns a new Color3 object
  70527. */
  70528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70529. /**
  70530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70531. * @param left defines the start value
  70532. * @param right defines the end value
  70533. * @param amount defines the gradient factor
  70534. * @param result defines the Color3 object where to store the result
  70535. */
  70536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70537. /**
  70538. * Returns a Color3 value containing a red color
  70539. * @returns a new Color3 object
  70540. */
  70541. static Red(): Color3;
  70542. /**
  70543. * Returns a Color3 value containing a green color
  70544. * @returns a new Color3 object
  70545. */
  70546. static Green(): Color3;
  70547. /**
  70548. * Returns a Color3 value containing a blue color
  70549. * @returns a new Color3 object
  70550. */
  70551. static Blue(): Color3;
  70552. /**
  70553. * Returns a Color3 value containing a black color
  70554. * @returns a new Color3 object
  70555. */
  70556. static Black(): Color3;
  70557. /**
  70558. * Gets a Color3 value containing a black color that must not be updated
  70559. */
  70560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70561. /**
  70562. * Returns a Color3 value containing a white color
  70563. * @returns a new Color3 object
  70564. */
  70565. static White(): Color3;
  70566. /**
  70567. * Returns a Color3 value containing a purple color
  70568. * @returns a new Color3 object
  70569. */
  70570. static Purple(): Color3;
  70571. /**
  70572. * Returns a Color3 value containing a magenta color
  70573. * @returns a new Color3 object
  70574. */
  70575. static Magenta(): Color3;
  70576. /**
  70577. * Returns a Color3 value containing a yellow color
  70578. * @returns a new Color3 object
  70579. */
  70580. static Yellow(): Color3;
  70581. /**
  70582. * Returns a Color3 value containing a gray color
  70583. * @returns a new Color3 object
  70584. */
  70585. static Gray(): Color3;
  70586. /**
  70587. * Returns a Color3 value containing a teal color
  70588. * @returns a new Color3 object
  70589. */
  70590. static Teal(): Color3;
  70591. /**
  70592. * Returns a Color3 value containing a random color
  70593. * @returns a new Color3 object
  70594. */
  70595. static Random(): Color3;
  70596. }
  70597. /**
  70598. * Class used to hold a RBGA color
  70599. */
  70600. export class Color4 {
  70601. /**
  70602. * Defines the red component (between 0 and 1, default is 0)
  70603. */
  70604. r: number;
  70605. /**
  70606. * Defines the green component (between 0 and 1, default is 0)
  70607. */
  70608. g: number;
  70609. /**
  70610. * Defines the blue component (between 0 and 1, default is 0)
  70611. */
  70612. b: number;
  70613. /**
  70614. * Defines the alpha component (between 0 and 1, default is 1)
  70615. */
  70616. a: number;
  70617. /**
  70618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70619. * @param r defines the red component (between 0 and 1, default is 0)
  70620. * @param g defines the green component (between 0 and 1, default is 0)
  70621. * @param b defines the blue component (between 0 and 1, default is 0)
  70622. * @param a defines the alpha component (between 0 and 1, default is 1)
  70623. */
  70624. constructor(
  70625. /**
  70626. * Defines the red component (between 0 and 1, default is 0)
  70627. */
  70628. r?: number,
  70629. /**
  70630. * Defines the green component (between 0 and 1, default is 0)
  70631. */
  70632. g?: number,
  70633. /**
  70634. * Defines the blue component (between 0 and 1, default is 0)
  70635. */
  70636. b?: number,
  70637. /**
  70638. * Defines the alpha component (between 0 and 1, default is 1)
  70639. */
  70640. a?: number);
  70641. /**
  70642. * Adds in place the given Color4 values to the current Color4 object
  70643. * @param right defines the second operand
  70644. * @returns the current updated Color4 object
  70645. */
  70646. addInPlace(right: DeepImmutable<Color4>): Color4;
  70647. /**
  70648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70649. * @returns the new array
  70650. */
  70651. asArray(): number[];
  70652. /**
  70653. * Stores from the starting index in the given array the Color4 successive values
  70654. * @param array defines the array where to store the r,g,b components
  70655. * @param index defines an optional index in the target array to define where to start storing values
  70656. * @returns the current Color4 object
  70657. */
  70658. toArray(array: number[], index?: number): Color4;
  70659. /**
  70660. * Determines equality between Color4 objects
  70661. * @param otherColor defines the second operand
  70662. * @returns true if the rgba values are equal to the given ones
  70663. */
  70664. equals(otherColor: DeepImmutable<Color4>): boolean;
  70665. /**
  70666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70667. * @param right defines the second operand
  70668. * @returns a new Color4 object
  70669. */
  70670. add(right: DeepImmutable<Color4>): Color4;
  70671. /**
  70672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70673. * @param right defines the second operand
  70674. * @returns a new Color4 object
  70675. */
  70676. subtract(right: DeepImmutable<Color4>): Color4;
  70677. /**
  70678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70679. * @param right defines the second operand
  70680. * @param result defines the Color4 object where to store the result
  70681. * @returns the current Color4 object
  70682. */
  70683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70684. /**
  70685. * Creates a new Color4 with the current Color4 values multiplied by scale
  70686. * @param scale defines the scaling factor to apply
  70687. * @returns a new Color4 object
  70688. */
  70689. scale(scale: number): Color4;
  70690. /**
  70691. * Multiplies the current Color4 values by scale and stores the result in "result"
  70692. * @param scale defines the scaling factor to apply
  70693. * @param result defines the Color4 object where to store the result
  70694. * @returns the current unmodified Color4
  70695. */
  70696. scaleToRef(scale: number, result: Color4): Color4;
  70697. /**
  70698. * Scale the current Color4 values by a factor and add the result to a given Color4
  70699. * @param scale defines the scale factor
  70700. * @param result defines the Color4 object where to store the result
  70701. * @returns the unmodified current Color4
  70702. */
  70703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70704. /**
  70705. * Clamps the rgb values by the min and max values and stores the result into "result"
  70706. * @param min defines minimum clamping value (default is 0)
  70707. * @param max defines maximum clamping value (default is 1)
  70708. * @param result defines color to store the result into.
  70709. * @returns the cuurent Color4
  70710. */
  70711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70712. /**
  70713. * Multipy an Color4 value by another and return a new Color4 object
  70714. * @param color defines the Color4 value to multiply by
  70715. * @returns a new Color4 object
  70716. */
  70717. multiply(color: Color4): Color4;
  70718. /**
  70719. * Multipy a Color4 value by another and push the result in a reference value
  70720. * @param color defines the Color4 value to multiply by
  70721. * @param result defines the Color4 to fill the result in
  70722. * @returns the result Color4
  70723. */
  70724. multiplyToRef(color: Color4, result: Color4): Color4;
  70725. /**
  70726. * Creates a string with the Color4 current values
  70727. * @returns the string representation of the Color4 object
  70728. */
  70729. toString(): string;
  70730. /**
  70731. * Returns the string "Color4"
  70732. * @returns "Color4"
  70733. */
  70734. getClassName(): string;
  70735. /**
  70736. * Compute the Color4 hash code
  70737. * @returns an unique number that can be used to hash Color4 objects
  70738. */
  70739. getHashCode(): number;
  70740. /**
  70741. * Creates a new Color4 copied from the current one
  70742. * @returns a new Color4 object
  70743. */
  70744. clone(): Color4;
  70745. /**
  70746. * Copies the given Color4 values into the current one
  70747. * @param source defines the source Color4 object
  70748. * @returns the current updated Color4 object
  70749. */
  70750. copyFrom(source: Color4): Color4;
  70751. /**
  70752. * Copies the given float values into the current one
  70753. * @param r defines the red component to read from
  70754. * @param g defines the green component to read from
  70755. * @param b defines the blue component to read from
  70756. * @param a defines the alpha component to read from
  70757. * @returns the current updated Color4 object
  70758. */
  70759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70760. /**
  70761. * Copies the given float values into the current one
  70762. * @param r defines the red component to read from
  70763. * @param g defines the green component to read from
  70764. * @param b defines the blue component to read from
  70765. * @param a defines the alpha component to read from
  70766. * @returns the current updated Color4 object
  70767. */
  70768. set(r: number, g: number, b: number, a: number): Color4;
  70769. /**
  70770. * Compute the Color4 hexadecimal code as a string
  70771. * @returns a string containing the hexadecimal representation of the Color4 object
  70772. */
  70773. toHexString(): string;
  70774. /**
  70775. * Computes a new Color4 converted from the current one to linear space
  70776. * @returns a new Color4 object
  70777. */
  70778. toLinearSpace(): Color4;
  70779. /**
  70780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70781. * @param convertedColor defines the Color4 object where to store the linear space version
  70782. * @returns the unmodified Color4
  70783. */
  70784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70785. /**
  70786. * Computes a new Color4 converted from the current one to gamma space
  70787. * @returns a new Color4 object
  70788. */
  70789. toGammaSpace(): Color4;
  70790. /**
  70791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70792. * @param convertedColor defines the Color4 object where to store the gamma space version
  70793. * @returns the unmodified Color4
  70794. */
  70795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70796. /**
  70797. * Creates a new Color4 from the string containing valid hexadecimal values
  70798. * @param hex defines a string containing valid hexadecimal values
  70799. * @returns a new Color4 object
  70800. */
  70801. static FromHexString(hex: string): Color4;
  70802. /**
  70803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70804. * @param left defines the start value
  70805. * @param right defines the end value
  70806. * @param amount defines the gradient factor
  70807. * @returns a new Color4 object
  70808. */
  70809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70810. /**
  70811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70812. * @param left defines the start value
  70813. * @param right defines the end value
  70814. * @param amount defines the gradient factor
  70815. * @param result defines the Color4 object where to store data
  70816. */
  70817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70818. /**
  70819. * Creates a new Color4 from a Color3 and an alpha value
  70820. * @param color3 defines the source Color3 to read from
  70821. * @param alpha defines the alpha component (1.0 by default)
  70822. * @returns a new Color4 object
  70823. */
  70824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70825. /**
  70826. * Creates a new Color4 from the starting index element of the given array
  70827. * @param array defines the source array to read from
  70828. * @param offset defines the offset in the source array
  70829. * @returns a new Color4 object
  70830. */
  70831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70832. /**
  70833. * Creates a new Color3 from integer values (< 256)
  70834. * @param r defines the red component to read from (value between 0 and 255)
  70835. * @param g defines the green component to read from (value between 0 and 255)
  70836. * @param b defines the blue component to read from (value between 0 and 255)
  70837. * @param a defines the alpha component to read from (value between 0 and 255)
  70838. * @returns a new Color3 object
  70839. */
  70840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70841. /**
  70842. * Check the content of a given array and convert it to an array containing RGBA data
  70843. * If the original array was already containing count * 4 values then it is returned directly
  70844. * @param colors defines the array to check
  70845. * @param count defines the number of RGBA data to expect
  70846. * @returns an array containing count * 4 values (RGBA)
  70847. */
  70848. static CheckColors4(colors: number[], count: number): number[];
  70849. }
  70850. /**
  70851. * @hidden
  70852. */
  70853. export class TmpColors {
  70854. static Color3: Color3[];
  70855. static Color4: Color4[];
  70856. }
  70857. }
  70858. declare module BABYLON {
  70859. /**
  70860. * Class representing spherical harmonics coefficients to the 3rd degree
  70861. */
  70862. export class SphericalHarmonics {
  70863. /**
  70864. * Defines whether or not the harmonics have been prescaled for rendering.
  70865. */
  70866. preScaled: boolean;
  70867. /**
  70868. * The l0,0 coefficients of the spherical harmonics
  70869. */
  70870. l00: Vector3;
  70871. /**
  70872. * The l1,-1 coefficients of the spherical harmonics
  70873. */
  70874. l1_1: Vector3;
  70875. /**
  70876. * The l1,0 coefficients of the spherical harmonics
  70877. */
  70878. l10: Vector3;
  70879. /**
  70880. * The l1,1 coefficients of the spherical harmonics
  70881. */
  70882. l11: Vector3;
  70883. /**
  70884. * The l2,-2 coefficients of the spherical harmonics
  70885. */
  70886. l2_2: Vector3;
  70887. /**
  70888. * The l2,-1 coefficients of the spherical harmonics
  70889. */
  70890. l2_1: Vector3;
  70891. /**
  70892. * The l2,0 coefficients of the spherical harmonics
  70893. */
  70894. l20: Vector3;
  70895. /**
  70896. * The l2,1 coefficients of the spherical harmonics
  70897. */
  70898. l21: Vector3;
  70899. /**
  70900. * The l2,2 coefficients of the spherical harmonics
  70901. */
  70902. l22: Vector3;
  70903. /**
  70904. * Adds a light to the spherical harmonics
  70905. * @param direction the direction of the light
  70906. * @param color the color of the light
  70907. * @param deltaSolidAngle the delta solid angle of the light
  70908. */
  70909. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70910. /**
  70911. * Scales the spherical harmonics by the given amount
  70912. * @param scale the amount to scale
  70913. */
  70914. scaleInPlace(scale: number): void;
  70915. /**
  70916. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70917. *
  70918. * ```
  70919. * E_lm = A_l * L_lm
  70920. * ```
  70921. *
  70922. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70923. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70924. * the scaling factors are given in equation 9.
  70925. */
  70926. convertIncidentRadianceToIrradiance(): void;
  70927. /**
  70928. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70929. *
  70930. * ```
  70931. * L = (1/pi) * E * rho
  70932. * ```
  70933. *
  70934. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70935. */
  70936. convertIrradianceToLambertianRadiance(): void;
  70937. /**
  70938. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70939. * required operations at run time.
  70940. *
  70941. * This is simply done by scaling back the SH with Ylm constants parameter.
  70942. * The trigonometric part being applied by the shader at run time.
  70943. */
  70944. preScaleForRendering(): void;
  70945. /**
  70946. * Constructs a spherical harmonics from an array.
  70947. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70948. * @returns the spherical harmonics
  70949. */
  70950. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70951. /**
  70952. * Gets the spherical harmonics from polynomial
  70953. * @param polynomial the spherical polynomial
  70954. * @returns the spherical harmonics
  70955. */
  70956. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70957. }
  70958. /**
  70959. * Class representing spherical polynomial coefficients to the 3rd degree
  70960. */
  70961. export class SphericalPolynomial {
  70962. private _harmonics;
  70963. /**
  70964. * The spherical harmonics used to create the polynomials.
  70965. */
  70966. readonly preScaledHarmonics: SphericalHarmonics;
  70967. /**
  70968. * The x coefficients of the spherical polynomial
  70969. */
  70970. x: Vector3;
  70971. /**
  70972. * The y coefficients of the spherical polynomial
  70973. */
  70974. y: Vector3;
  70975. /**
  70976. * The z coefficients of the spherical polynomial
  70977. */
  70978. z: Vector3;
  70979. /**
  70980. * The xx coefficients of the spherical polynomial
  70981. */
  70982. xx: Vector3;
  70983. /**
  70984. * The yy coefficients of the spherical polynomial
  70985. */
  70986. yy: Vector3;
  70987. /**
  70988. * The zz coefficients of the spherical polynomial
  70989. */
  70990. zz: Vector3;
  70991. /**
  70992. * The xy coefficients of the spherical polynomial
  70993. */
  70994. xy: Vector3;
  70995. /**
  70996. * The yz coefficients of the spherical polynomial
  70997. */
  70998. yz: Vector3;
  70999. /**
  71000. * The zx coefficients of the spherical polynomial
  71001. */
  71002. zx: Vector3;
  71003. /**
  71004. * Adds an ambient color to the spherical polynomial
  71005. * @param color the color to add
  71006. */
  71007. addAmbient(color: Color3): void;
  71008. /**
  71009. * Scales the spherical polynomial by the given amount
  71010. * @param scale the amount to scale
  71011. */
  71012. scaleInPlace(scale: number): void;
  71013. /**
  71014. * Gets the spherical polynomial from harmonics
  71015. * @param harmonics the spherical harmonics
  71016. * @returns the spherical polynomial
  71017. */
  71018. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71019. /**
  71020. * Constructs a spherical polynomial from an array.
  71021. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71022. * @returns the spherical polynomial
  71023. */
  71024. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71025. }
  71026. }
  71027. declare module BABYLON {
  71028. /**
  71029. * Define options used to create a render target texture
  71030. */
  71031. export class RenderTargetCreationOptions {
  71032. /**
  71033. * Specifies is mipmaps must be generated
  71034. */
  71035. generateMipMaps?: boolean;
  71036. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71037. generateDepthBuffer?: boolean;
  71038. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71039. generateStencilBuffer?: boolean;
  71040. /** Defines texture type (int by default) */
  71041. type?: number;
  71042. /** Defines sampling mode (trilinear by default) */
  71043. samplingMode?: number;
  71044. /** Defines format (RGBA by default) */
  71045. format?: number;
  71046. }
  71047. }
  71048. declare module BABYLON {
  71049. /**
  71050. * @hidden
  71051. **/
  71052. export class _AlphaState {
  71053. private _isAlphaBlendDirty;
  71054. private _isBlendFunctionParametersDirty;
  71055. private _isBlendEquationParametersDirty;
  71056. private _isBlendConstantsDirty;
  71057. private _alphaBlend;
  71058. private _blendFunctionParameters;
  71059. private _blendEquationParameters;
  71060. private _blendConstants;
  71061. /**
  71062. * Initializes the state.
  71063. */
  71064. constructor();
  71065. readonly isDirty: boolean;
  71066. alphaBlend: boolean;
  71067. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71068. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71069. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71070. reset(): void;
  71071. apply(gl: WebGLRenderingContext): void;
  71072. }
  71073. }
  71074. declare module BABYLON {
  71075. /**
  71076. * @hidden
  71077. **/
  71078. export class _DepthCullingState {
  71079. private _isDepthTestDirty;
  71080. private _isDepthMaskDirty;
  71081. private _isDepthFuncDirty;
  71082. private _isCullFaceDirty;
  71083. private _isCullDirty;
  71084. private _isZOffsetDirty;
  71085. private _isFrontFaceDirty;
  71086. private _depthTest;
  71087. private _depthMask;
  71088. private _depthFunc;
  71089. private _cull;
  71090. private _cullFace;
  71091. private _zOffset;
  71092. private _frontFace;
  71093. /**
  71094. * Initializes the state.
  71095. */
  71096. constructor();
  71097. readonly isDirty: boolean;
  71098. zOffset: number;
  71099. cullFace: Nullable<number>;
  71100. cull: Nullable<boolean>;
  71101. depthFunc: Nullable<number>;
  71102. depthMask: boolean;
  71103. depthTest: boolean;
  71104. frontFace: Nullable<number>;
  71105. reset(): void;
  71106. apply(gl: WebGLRenderingContext): void;
  71107. }
  71108. }
  71109. declare module BABYLON {
  71110. /**
  71111. * @hidden
  71112. **/
  71113. export class _StencilState {
  71114. /** 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 */
  71115. static readonly ALWAYS: number;
  71116. /** Passed to stencilOperation to specify that stencil value must be kept */
  71117. static readonly KEEP: number;
  71118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71119. static readonly REPLACE: number;
  71120. private _isStencilTestDirty;
  71121. private _isStencilMaskDirty;
  71122. private _isStencilFuncDirty;
  71123. private _isStencilOpDirty;
  71124. private _stencilTest;
  71125. private _stencilMask;
  71126. private _stencilFunc;
  71127. private _stencilFuncRef;
  71128. private _stencilFuncMask;
  71129. private _stencilOpStencilFail;
  71130. private _stencilOpDepthFail;
  71131. private _stencilOpStencilDepthPass;
  71132. readonly isDirty: boolean;
  71133. stencilFunc: number;
  71134. stencilFuncRef: number;
  71135. stencilFuncMask: number;
  71136. stencilOpStencilFail: number;
  71137. stencilOpDepthFail: number;
  71138. stencilOpStencilDepthPass: number;
  71139. stencilMask: number;
  71140. stencilTest: boolean;
  71141. constructor();
  71142. reset(): void;
  71143. apply(gl: WebGLRenderingContext): void;
  71144. }
  71145. }
  71146. declare module BABYLON {
  71147. /**
  71148. * @hidden
  71149. **/
  71150. export class _TimeToken {
  71151. _startTimeQuery: Nullable<WebGLQuery>;
  71152. _endTimeQuery: Nullable<WebGLQuery>;
  71153. _timeElapsedQuery: Nullable<WebGLQuery>;
  71154. _timeElapsedQueryEnded: boolean;
  71155. }
  71156. }
  71157. declare module BABYLON {
  71158. /**
  71159. * Class used to evalaute queries containing `and` and `or` operators
  71160. */
  71161. export class AndOrNotEvaluator {
  71162. /**
  71163. * Evaluate a query
  71164. * @param query defines the query to evaluate
  71165. * @param evaluateCallback defines the callback used to filter result
  71166. * @returns true if the query matches
  71167. */
  71168. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71169. private static _HandleParenthesisContent;
  71170. private static _SimplifyNegation;
  71171. }
  71172. }
  71173. declare module BABYLON {
  71174. /**
  71175. * Class used to store custom tags
  71176. */
  71177. export class Tags {
  71178. /**
  71179. * Adds support for tags on the given object
  71180. * @param obj defines the object to use
  71181. */
  71182. static EnableFor(obj: any): void;
  71183. /**
  71184. * Removes tags support
  71185. * @param obj defines the object to use
  71186. */
  71187. static DisableFor(obj: any): void;
  71188. /**
  71189. * Gets a boolean indicating if the given object has tags
  71190. * @param obj defines the object to use
  71191. * @returns a boolean
  71192. */
  71193. static HasTags(obj: any): boolean;
  71194. /**
  71195. * Gets the tags available on a given object
  71196. * @param obj defines the object to use
  71197. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71198. * @returns the tags
  71199. */
  71200. static GetTags(obj: any, asString?: boolean): any;
  71201. /**
  71202. * Adds tags to an object
  71203. * @param obj defines the object to use
  71204. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71205. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71206. */
  71207. static AddTagsTo(obj: any, tagsString: string): void;
  71208. /**
  71209. * @hidden
  71210. */
  71211. static _AddTagTo(obj: any, tag: string): void;
  71212. /**
  71213. * Removes specific tags from a specific object
  71214. * @param obj defines the object to use
  71215. * @param tagsString defines the tags to remove
  71216. */
  71217. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71218. /**
  71219. * @hidden
  71220. */
  71221. static _RemoveTagFrom(obj: any, tag: string): void;
  71222. /**
  71223. * Defines if tags hosted on an object match a given query
  71224. * @param obj defines the object to use
  71225. * @param tagsQuery defines the tag query
  71226. * @returns a boolean
  71227. */
  71228. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71229. }
  71230. }
  71231. declare module BABYLON {
  71232. /**
  71233. * Defines potential orientation for back face culling
  71234. */
  71235. export enum Orientation {
  71236. /**
  71237. * Clockwise
  71238. */
  71239. CW = 0,
  71240. /** Counter clockwise */
  71241. CCW = 1
  71242. }
  71243. /** Class used to represent a Bezier curve */
  71244. export class BezierCurve {
  71245. /**
  71246. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71247. * @param t defines the time
  71248. * @param x1 defines the left coordinate on X axis
  71249. * @param y1 defines the left coordinate on Y axis
  71250. * @param x2 defines the right coordinate on X axis
  71251. * @param y2 defines the right coordinate on Y axis
  71252. * @returns the interpolated value
  71253. */
  71254. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71255. }
  71256. /**
  71257. * Defines angle representation
  71258. */
  71259. export class Angle {
  71260. private _radians;
  71261. /**
  71262. * Creates an Angle object of "radians" radians (float).
  71263. * @param radians the angle in radians
  71264. */
  71265. constructor(radians: number);
  71266. /**
  71267. * Get value in degrees
  71268. * @returns the Angle value in degrees (float)
  71269. */
  71270. degrees(): number;
  71271. /**
  71272. * Get value in radians
  71273. * @returns the Angle value in radians (float)
  71274. */
  71275. radians(): number;
  71276. /**
  71277. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71278. * @param a defines first vector
  71279. * @param b defines second vector
  71280. * @returns a new Angle
  71281. */
  71282. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71283. /**
  71284. * Gets a new Angle object from the given float in radians
  71285. * @param radians defines the angle value in radians
  71286. * @returns a new Angle
  71287. */
  71288. static FromRadians(radians: number): Angle;
  71289. /**
  71290. * Gets a new Angle object from the given float in degrees
  71291. * @param degrees defines the angle value in degrees
  71292. * @returns a new Angle
  71293. */
  71294. static FromDegrees(degrees: number): Angle;
  71295. }
  71296. /**
  71297. * This represents an arc in a 2d space.
  71298. */
  71299. export class Arc2 {
  71300. /** Defines the start point of the arc */
  71301. startPoint: Vector2;
  71302. /** Defines the mid point of the arc */
  71303. midPoint: Vector2;
  71304. /** Defines the end point of the arc */
  71305. endPoint: Vector2;
  71306. /**
  71307. * Defines the center point of the arc.
  71308. */
  71309. centerPoint: Vector2;
  71310. /**
  71311. * Defines the radius of the arc.
  71312. */
  71313. radius: number;
  71314. /**
  71315. * Defines the angle of the arc (from mid point to end point).
  71316. */
  71317. angle: Angle;
  71318. /**
  71319. * Defines the start angle of the arc (from start point to middle point).
  71320. */
  71321. startAngle: Angle;
  71322. /**
  71323. * Defines the orientation of the arc (clock wise/counter clock wise).
  71324. */
  71325. orientation: Orientation;
  71326. /**
  71327. * Creates an Arc object from the three given points : start, middle and end.
  71328. * @param startPoint Defines the start point of the arc
  71329. * @param midPoint Defines the midlle point of the arc
  71330. * @param endPoint Defines the end point of the arc
  71331. */
  71332. constructor(
  71333. /** Defines the start point of the arc */
  71334. startPoint: Vector2,
  71335. /** Defines the mid point of the arc */
  71336. midPoint: Vector2,
  71337. /** Defines the end point of the arc */
  71338. endPoint: Vector2);
  71339. }
  71340. /**
  71341. * Represents a 2D path made up of multiple 2D points
  71342. */
  71343. export class Path2 {
  71344. private _points;
  71345. private _length;
  71346. /**
  71347. * If the path start and end point are the same
  71348. */
  71349. closed: boolean;
  71350. /**
  71351. * Creates a Path2 object from the starting 2D coordinates x and y.
  71352. * @param x the starting points x value
  71353. * @param y the starting points y value
  71354. */
  71355. constructor(x: number, y: number);
  71356. /**
  71357. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71358. * @param x the added points x value
  71359. * @param y the added points y value
  71360. * @returns the updated Path2.
  71361. */
  71362. addLineTo(x: number, y: number): Path2;
  71363. /**
  71364. * 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.
  71365. * @param midX middle point x value
  71366. * @param midY middle point y value
  71367. * @param endX end point x value
  71368. * @param endY end point y value
  71369. * @param numberOfSegments (default: 36)
  71370. * @returns the updated Path2.
  71371. */
  71372. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71373. /**
  71374. * Closes the Path2.
  71375. * @returns the Path2.
  71376. */
  71377. close(): Path2;
  71378. /**
  71379. * Gets the sum of the distance between each sequential point in the path
  71380. * @returns the Path2 total length (float).
  71381. */
  71382. length(): number;
  71383. /**
  71384. * Gets the points which construct the path
  71385. * @returns the Path2 internal array of points.
  71386. */
  71387. getPoints(): Vector2[];
  71388. /**
  71389. * Retreives the point at the distance aways from the starting point
  71390. * @param normalizedLengthPosition the length along the path to retreive the point from
  71391. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71392. */
  71393. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71394. /**
  71395. * Creates a new path starting from an x and y position
  71396. * @param x starting x value
  71397. * @param y starting y value
  71398. * @returns a new Path2 starting at the coordinates (x, y).
  71399. */
  71400. static StartingAt(x: number, y: number): Path2;
  71401. }
  71402. /**
  71403. * Represents a 3D path made up of multiple 3D points
  71404. */
  71405. export class Path3D {
  71406. /**
  71407. * an array of Vector3, the curve axis of the Path3D
  71408. */
  71409. path: Vector3[];
  71410. private _curve;
  71411. private _distances;
  71412. private _tangents;
  71413. private _normals;
  71414. private _binormals;
  71415. private _raw;
  71416. /**
  71417. * new Path3D(path, normal, raw)
  71418. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71419. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71420. * @param path an array of Vector3, the curve axis of the Path3D
  71421. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71422. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71423. */
  71424. constructor(
  71425. /**
  71426. * an array of Vector3, the curve axis of the Path3D
  71427. */
  71428. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71429. /**
  71430. * Returns the Path3D array of successive Vector3 designing its curve.
  71431. * @returns the Path3D array of successive Vector3 designing its curve.
  71432. */
  71433. getCurve(): Vector3[];
  71434. /**
  71435. * Returns an array populated with tangent vectors on each Path3D curve point.
  71436. * @returns an array populated with tangent vectors on each Path3D curve point.
  71437. */
  71438. getTangents(): Vector3[];
  71439. /**
  71440. * Returns an array populated with normal vectors on each Path3D curve point.
  71441. * @returns an array populated with normal vectors on each Path3D curve point.
  71442. */
  71443. getNormals(): Vector3[];
  71444. /**
  71445. * Returns an array populated with binormal vectors on each Path3D curve point.
  71446. * @returns an array populated with binormal vectors on each Path3D curve point.
  71447. */
  71448. getBinormals(): Vector3[];
  71449. /**
  71450. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71451. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71452. */
  71453. getDistances(): number[];
  71454. /**
  71455. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71456. * @param path path which all values are copied into the curves points
  71457. * @param firstNormal which should be projected onto the curve
  71458. * @returns the same object updated.
  71459. */
  71460. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71461. private _compute;
  71462. private _getFirstNonNullVector;
  71463. private _getLastNonNullVector;
  71464. private _normalVector;
  71465. }
  71466. /**
  71467. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71468. * A Curve3 is designed from a series of successive Vector3.
  71469. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71470. */
  71471. export class Curve3 {
  71472. private _points;
  71473. private _length;
  71474. /**
  71475. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71476. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71477. * @param v1 (Vector3) the control point
  71478. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71479. * @param nbPoints (integer) the wanted number of points in the curve
  71480. * @returns the created Curve3
  71481. */
  71482. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71483. /**
  71484. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71485. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71486. * @param v1 (Vector3) the first control point
  71487. * @param v2 (Vector3) the second control point
  71488. * @param v3 (Vector3) the end point of the Cubic Bezier
  71489. * @param nbPoints (integer) the wanted number of points in the curve
  71490. * @returns the created Curve3
  71491. */
  71492. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71493. /**
  71494. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71495. * @param p1 (Vector3) the origin point of the Hermite Spline
  71496. * @param t1 (Vector3) the tangent vector at the origin point
  71497. * @param p2 (Vector3) the end point of the Hermite Spline
  71498. * @param t2 (Vector3) the tangent vector at the end point
  71499. * @param nbPoints (integer) the wanted number of points in the curve
  71500. * @returns the created Curve3
  71501. */
  71502. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71503. /**
  71504. * Returns a Curve3 object along a CatmullRom Spline curve :
  71505. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71506. * @param nbPoints (integer) the wanted number of points between each curve control points
  71507. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71508. * @returns the created Curve3
  71509. */
  71510. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71511. /**
  71512. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71513. * A Curve3 is designed from a series of successive Vector3.
  71514. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71515. * @param points points which make up the curve
  71516. */
  71517. constructor(points: Vector3[]);
  71518. /**
  71519. * @returns the Curve3 stored array of successive Vector3
  71520. */
  71521. getPoints(): Vector3[];
  71522. /**
  71523. * @returns the computed length (float) of the curve.
  71524. */
  71525. length(): number;
  71526. /**
  71527. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71528. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71529. * curveA and curveB keep unchanged.
  71530. * @param curve the curve to continue from this curve
  71531. * @returns the newly constructed curve
  71532. */
  71533. continue(curve: DeepImmutable<Curve3>): Curve3;
  71534. private _computeLength;
  71535. }
  71536. }
  71537. declare module BABYLON {
  71538. /**
  71539. * This represents the main contract an easing function should follow.
  71540. * Easing functions are used throughout the animation system.
  71541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71542. */
  71543. export interface IEasingFunction {
  71544. /**
  71545. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71546. * of the easing function.
  71547. * The link below provides some of the most common examples of easing functions.
  71548. * @see https://easings.net/
  71549. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71550. * @returns the corresponding value on the curve defined by the easing function
  71551. */
  71552. ease(gradient: number): number;
  71553. }
  71554. /**
  71555. * Base class used for every default easing function.
  71556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71557. */
  71558. export class EasingFunction implements IEasingFunction {
  71559. /**
  71560. * Interpolation follows the mathematical formula associated with the easing function.
  71561. */
  71562. static readonly EASINGMODE_EASEIN: number;
  71563. /**
  71564. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71565. */
  71566. static readonly EASINGMODE_EASEOUT: number;
  71567. /**
  71568. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71569. */
  71570. static readonly EASINGMODE_EASEINOUT: number;
  71571. private _easingMode;
  71572. /**
  71573. * Sets the easing mode of the current function.
  71574. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71575. */
  71576. setEasingMode(easingMode: number): void;
  71577. /**
  71578. * Gets the current easing mode.
  71579. * @returns the easing mode
  71580. */
  71581. getEasingMode(): number;
  71582. /**
  71583. * @hidden
  71584. */
  71585. easeInCore(gradient: number): number;
  71586. /**
  71587. * Given an input gradient between 0 and 1, this returns the corresponding value
  71588. * of the easing function.
  71589. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71590. * @returns the corresponding value on the curve defined by the easing function
  71591. */
  71592. ease(gradient: number): number;
  71593. }
  71594. /**
  71595. * Easing function with a circle shape (see link below).
  71596. * @see https://easings.net/#easeInCirc
  71597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71598. */
  71599. export class CircleEase extends EasingFunction implements IEasingFunction {
  71600. /** @hidden */
  71601. easeInCore(gradient: number): number;
  71602. }
  71603. /**
  71604. * Easing function with a ease back shape (see link below).
  71605. * @see https://easings.net/#easeInBack
  71606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71607. */
  71608. export class BackEase extends EasingFunction implements IEasingFunction {
  71609. /** Defines the amplitude of the function */
  71610. amplitude: number;
  71611. /**
  71612. * Instantiates a back ease easing
  71613. * @see https://easings.net/#easeInBack
  71614. * @param amplitude Defines the amplitude of the function
  71615. */
  71616. constructor(
  71617. /** Defines the amplitude of the function */
  71618. amplitude?: number);
  71619. /** @hidden */
  71620. easeInCore(gradient: number): number;
  71621. }
  71622. /**
  71623. * Easing function with a bouncing shape (see link below).
  71624. * @see https://easings.net/#easeInBounce
  71625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71626. */
  71627. export class BounceEase extends EasingFunction implements IEasingFunction {
  71628. /** Defines the number of bounces */
  71629. bounces: number;
  71630. /** Defines the amplitude of the bounce */
  71631. bounciness: number;
  71632. /**
  71633. * Instantiates a bounce easing
  71634. * @see https://easings.net/#easeInBounce
  71635. * @param bounces Defines the number of bounces
  71636. * @param bounciness Defines the amplitude of the bounce
  71637. */
  71638. constructor(
  71639. /** Defines the number of bounces */
  71640. bounces?: number,
  71641. /** Defines the amplitude of the bounce */
  71642. bounciness?: number);
  71643. /** @hidden */
  71644. easeInCore(gradient: number): number;
  71645. }
  71646. /**
  71647. * Easing function with a power of 3 shape (see link below).
  71648. * @see https://easings.net/#easeInCubic
  71649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71650. */
  71651. export class CubicEase extends EasingFunction implements IEasingFunction {
  71652. /** @hidden */
  71653. easeInCore(gradient: number): number;
  71654. }
  71655. /**
  71656. * Easing function with an elastic shape (see link below).
  71657. * @see https://easings.net/#easeInElastic
  71658. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71659. */
  71660. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71661. /** Defines the number of oscillations*/
  71662. oscillations: number;
  71663. /** Defines the amplitude of the oscillations*/
  71664. springiness: number;
  71665. /**
  71666. * Instantiates an elastic easing function
  71667. * @see https://easings.net/#easeInElastic
  71668. * @param oscillations Defines the number of oscillations
  71669. * @param springiness Defines the amplitude of the oscillations
  71670. */
  71671. constructor(
  71672. /** Defines the number of oscillations*/
  71673. oscillations?: number,
  71674. /** Defines the amplitude of the oscillations*/
  71675. springiness?: number);
  71676. /** @hidden */
  71677. easeInCore(gradient: number): number;
  71678. }
  71679. /**
  71680. * Easing function with an exponential shape (see link below).
  71681. * @see https://easings.net/#easeInExpo
  71682. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71683. */
  71684. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71685. /** Defines the exponent of the function */
  71686. exponent: number;
  71687. /**
  71688. * Instantiates an exponential easing function
  71689. * @see https://easings.net/#easeInExpo
  71690. * @param exponent Defines the exponent of the function
  71691. */
  71692. constructor(
  71693. /** Defines the exponent of the function */
  71694. exponent?: number);
  71695. /** @hidden */
  71696. easeInCore(gradient: number): number;
  71697. }
  71698. /**
  71699. * Easing function with a power shape (see link below).
  71700. * @see https://easings.net/#easeInQuad
  71701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71702. */
  71703. export class PowerEase extends EasingFunction implements IEasingFunction {
  71704. /** Defines the power of the function */
  71705. power: number;
  71706. /**
  71707. * Instantiates an power base easing function
  71708. * @see https://easings.net/#easeInQuad
  71709. * @param power Defines the power of the function
  71710. */
  71711. constructor(
  71712. /** Defines the power of the function */
  71713. power?: number);
  71714. /** @hidden */
  71715. easeInCore(gradient: number): number;
  71716. }
  71717. /**
  71718. * Easing function with a power of 2 shape (see link below).
  71719. * @see https://easings.net/#easeInQuad
  71720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71721. */
  71722. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71723. /** @hidden */
  71724. easeInCore(gradient: number): number;
  71725. }
  71726. /**
  71727. * Easing function with a power of 4 shape (see link below).
  71728. * @see https://easings.net/#easeInQuart
  71729. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71730. */
  71731. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71732. /** @hidden */
  71733. easeInCore(gradient: number): number;
  71734. }
  71735. /**
  71736. * Easing function with a power of 5 shape (see link below).
  71737. * @see https://easings.net/#easeInQuint
  71738. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71739. */
  71740. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71741. /** @hidden */
  71742. easeInCore(gradient: number): number;
  71743. }
  71744. /**
  71745. * Easing function with a sin shape (see link below).
  71746. * @see https://easings.net/#easeInSine
  71747. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71748. */
  71749. export class SineEase extends EasingFunction implements IEasingFunction {
  71750. /** @hidden */
  71751. easeInCore(gradient: number): number;
  71752. }
  71753. /**
  71754. * Easing function with a bezier shape (see link below).
  71755. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71757. */
  71758. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71759. /** Defines the x component of the start tangent in the bezier curve */
  71760. x1: number;
  71761. /** Defines the y component of the start tangent in the bezier curve */
  71762. y1: number;
  71763. /** Defines the x component of the end tangent in the bezier curve */
  71764. x2: number;
  71765. /** Defines the y component of the end tangent in the bezier curve */
  71766. y2: number;
  71767. /**
  71768. * Instantiates a bezier function
  71769. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71770. * @param x1 Defines the x component of the start tangent in the bezier curve
  71771. * @param y1 Defines the y component of the start tangent in the bezier curve
  71772. * @param x2 Defines the x component of the end tangent in the bezier curve
  71773. * @param y2 Defines the y component of the end tangent in the bezier curve
  71774. */
  71775. constructor(
  71776. /** Defines the x component of the start tangent in the bezier curve */
  71777. x1?: number,
  71778. /** Defines the y component of the start tangent in the bezier curve */
  71779. y1?: number,
  71780. /** Defines the x component of the end tangent in the bezier curve */
  71781. x2?: number,
  71782. /** Defines the y component of the end tangent in the bezier curve */
  71783. y2?: number);
  71784. /** @hidden */
  71785. easeInCore(gradient: number): number;
  71786. }
  71787. }
  71788. declare module BABYLON {
  71789. /**
  71790. * Defines an interface which represents an animation key frame
  71791. */
  71792. export interface IAnimationKey {
  71793. /**
  71794. * Frame of the key frame
  71795. */
  71796. frame: number;
  71797. /**
  71798. * Value at the specifies key frame
  71799. */
  71800. value: any;
  71801. /**
  71802. * The input tangent for the cubic hermite spline
  71803. */
  71804. inTangent?: any;
  71805. /**
  71806. * The output tangent for the cubic hermite spline
  71807. */
  71808. outTangent?: any;
  71809. /**
  71810. * The animation interpolation type
  71811. */
  71812. interpolation?: AnimationKeyInterpolation;
  71813. }
  71814. /**
  71815. * Enum for the animation key frame interpolation type
  71816. */
  71817. export enum AnimationKeyInterpolation {
  71818. /**
  71819. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71820. */
  71821. STEP = 1
  71822. }
  71823. }
  71824. declare module BABYLON {
  71825. /**
  71826. * Represents the range of an animation
  71827. */
  71828. export class AnimationRange {
  71829. /**The name of the animation range**/
  71830. name: string;
  71831. /**The starting frame of the animation */
  71832. from: number;
  71833. /**The ending frame of the animation*/
  71834. to: number;
  71835. /**
  71836. * Initializes the range of an animation
  71837. * @param name The name of the animation range
  71838. * @param from The starting frame of the animation
  71839. * @param to The ending frame of the animation
  71840. */
  71841. constructor(
  71842. /**The name of the animation range**/
  71843. name: string,
  71844. /**The starting frame of the animation */
  71845. from: number,
  71846. /**The ending frame of the animation*/
  71847. to: number);
  71848. /**
  71849. * Makes a copy of the animation range
  71850. * @returns A copy of the animation range
  71851. */
  71852. clone(): AnimationRange;
  71853. }
  71854. }
  71855. declare module BABYLON {
  71856. /**
  71857. * Composed of a frame, and an action function
  71858. */
  71859. export class AnimationEvent {
  71860. /** The frame for which the event is triggered **/
  71861. frame: number;
  71862. /** The event to perform when triggered **/
  71863. action: (currentFrame: number) => void;
  71864. /** Specifies if the event should be triggered only once**/
  71865. onlyOnce?: boolean | undefined;
  71866. /**
  71867. * Specifies if the animation event is done
  71868. */
  71869. isDone: boolean;
  71870. /**
  71871. * Initializes the animation event
  71872. * @param frame The frame for which the event is triggered
  71873. * @param action The event to perform when triggered
  71874. * @param onlyOnce Specifies if the event should be triggered only once
  71875. */
  71876. constructor(
  71877. /** The frame for which the event is triggered **/
  71878. frame: number,
  71879. /** The event to perform when triggered **/
  71880. action: (currentFrame: number) => void,
  71881. /** Specifies if the event should be triggered only once**/
  71882. onlyOnce?: boolean | undefined);
  71883. /** @hidden */
  71884. _clone(): AnimationEvent;
  71885. }
  71886. }
  71887. declare module BABYLON {
  71888. /**
  71889. * Interface used to define a behavior
  71890. */
  71891. export interface Behavior<T> {
  71892. /** gets or sets behavior's name */
  71893. name: string;
  71894. /**
  71895. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71896. */
  71897. init(): void;
  71898. /**
  71899. * Called when the behavior is attached to a target
  71900. * @param target defines the target where the behavior is attached to
  71901. */
  71902. attach(target: T): void;
  71903. /**
  71904. * Called when the behavior is detached from its target
  71905. */
  71906. detach(): void;
  71907. }
  71908. /**
  71909. * Interface implemented by classes supporting behaviors
  71910. */
  71911. export interface IBehaviorAware<T> {
  71912. /**
  71913. * Attach a behavior
  71914. * @param behavior defines the behavior to attach
  71915. * @returns the current host
  71916. */
  71917. addBehavior(behavior: Behavior<T>): T;
  71918. /**
  71919. * Remove a behavior from the current object
  71920. * @param behavior defines the behavior to detach
  71921. * @returns the current host
  71922. */
  71923. removeBehavior(behavior: Behavior<T>): T;
  71924. /**
  71925. * Gets a behavior using its name to search
  71926. * @param name defines the name to search
  71927. * @returns the behavior or null if not found
  71928. */
  71929. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71930. }
  71931. }
  71932. declare module BABYLON {
  71933. /**
  71934. * Defines an array and its length.
  71935. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71936. */
  71937. export interface ISmartArrayLike<T> {
  71938. /**
  71939. * The data of the array.
  71940. */
  71941. data: Array<T>;
  71942. /**
  71943. * The active length of the array.
  71944. */
  71945. length: number;
  71946. }
  71947. /**
  71948. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71949. */
  71950. export class SmartArray<T> implements ISmartArrayLike<T> {
  71951. /**
  71952. * The full set of data from the array.
  71953. */
  71954. data: Array<T>;
  71955. /**
  71956. * The active length of the array.
  71957. */
  71958. length: number;
  71959. protected _id: number;
  71960. /**
  71961. * Instantiates a Smart Array.
  71962. * @param capacity defines the default capacity of the array.
  71963. */
  71964. constructor(capacity: number);
  71965. /**
  71966. * Pushes a value at the end of the active data.
  71967. * @param value defines the object to push in the array.
  71968. */
  71969. push(value: T): void;
  71970. /**
  71971. * Iterates over the active data and apply the lambda to them.
  71972. * @param func defines the action to apply on each value.
  71973. */
  71974. forEach(func: (content: T) => void): void;
  71975. /**
  71976. * Sorts the full sets of data.
  71977. * @param compareFn defines the comparison function to apply.
  71978. */
  71979. sort(compareFn: (a: T, b: T) => number): void;
  71980. /**
  71981. * Resets the active data to an empty array.
  71982. */
  71983. reset(): void;
  71984. /**
  71985. * Releases all the data from the array as well as the array.
  71986. */
  71987. dispose(): void;
  71988. /**
  71989. * Concats the active data with a given array.
  71990. * @param array defines the data to concatenate with.
  71991. */
  71992. concat(array: any): void;
  71993. /**
  71994. * Returns the position of a value in the active data.
  71995. * @param value defines the value to find the index for
  71996. * @returns the index if found in the active data otherwise -1
  71997. */
  71998. indexOf(value: T): number;
  71999. /**
  72000. * Returns whether an element is part of the active data.
  72001. * @param value defines the value to look for
  72002. * @returns true if found in the active data otherwise false
  72003. */
  72004. contains(value: T): boolean;
  72005. private static _GlobalId;
  72006. }
  72007. /**
  72008. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72009. * The data in this array can only be present once
  72010. */
  72011. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72012. private _duplicateId;
  72013. /**
  72014. * Pushes a value at the end of the active data.
  72015. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72016. * @param value defines the object to push in the array.
  72017. */
  72018. push(value: T): void;
  72019. /**
  72020. * Pushes a value at the end of the active data.
  72021. * If the data is already present, it won t be added again
  72022. * @param value defines the object to push in the array.
  72023. * @returns true if added false if it was already present
  72024. */
  72025. pushNoDuplicate(value: T): boolean;
  72026. /**
  72027. * Resets the active data to an empty array.
  72028. */
  72029. reset(): void;
  72030. /**
  72031. * Concats the active data with a given array.
  72032. * This ensures no dupplicate will be present in the result.
  72033. * @param array defines the data to concatenate with.
  72034. */
  72035. concatWithNoDuplicate(array: any): void;
  72036. }
  72037. }
  72038. declare module BABYLON {
  72039. /**
  72040. * @ignore
  72041. * This is a list of all the different input types that are available in the application.
  72042. * Fo instance: ArcRotateCameraGamepadInput...
  72043. */
  72044. export var CameraInputTypes: {};
  72045. /**
  72046. * This is the contract to implement in order to create a new input class.
  72047. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72048. */
  72049. export interface ICameraInput<TCamera extends Camera> {
  72050. /**
  72051. * Defines the camera the input is attached to.
  72052. */
  72053. camera: Nullable<TCamera>;
  72054. /**
  72055. * Gets the class name of the current intput.
  72056. * @returns the class name
  72057. */
  72058. getClassName(): string;
  72059. /**
  72060. * Get the friendly name associated with the input class.
  72061. * @returns the input friendly name
  72062. */
  72063. getSimpleName(): string;
  72064. /**
  72065. * Attach the input controls to a specific dom element to get the input from.
  72066. * @param element Defines the element the controls should be listened from
  72067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72068. */
  72069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72070. /**
  72071. * Detach the current controls from the specified dom element.
  72072. * @param element Defines the element to stop listening the inputs from
  72073. */
  72074. detachControl(element: Nullable<HTMLElement>): void;
  72075. /**
  72076. * Update the current camera state depending on the inputs that have been used this frame.
  72077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72078. */
  72079. checkInputs?: () => void;
  72080. }
  72081. /**
  72082. * Represents a map of input types to input instance or input index to input instance.
  72083. */
  72084. export interface CameraInputsMap<TCamera extends Camera> {
  72085. /**
  72086. * Accessor to the input by input type.
  72087. */
  72088. [name: string]: ICameraInput<TCamera>;
  72089. /**
  72090. * Accessor to the input by input index.
  72091. */
  72092. [idx: number]: ICameraInput<TCamera>;
  72093. }
  72094. /**
  72095. * This represents the input manager used within a camera.
  72096. * It helps dealing with all the different kind of input attached to a camera.
  72097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72098. */
  72099. export class CameraInputsManager<TCamera extends Camera> {
  72100. /**
  72101. * Defines the list of inputs attahed to the camera.
  72102. */
  72103. attached: CameraInputsMap<TCamera>;
  72104. /**
  72105. * Defines the dom element the camera is collecting inputs from.
  72106. * This is null if the controls have not been attached.
  72107. */
  72108. attachedElement: Nullable<HTMLElement>;
  72109. /**
  72110. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72111. */
  72112. noPreventDefault: boolean;
  72113. /**
  72114. * Defined the camera the input manager belongs to.
  72115. */
  72116. camera: TCamera;
  72117. /**
  72118. * Update the current camera state depending on the inputs that have been used this frame.
  72119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72120. */
  72121. checkInputs: () => void;
  72122. /**
  72123. * Instantiate a new Camera Input Manager.
  72124. * @param camera Defines the camera the input manager blongs to
  72125. */
  72126. constructor(camera: TCamera);
  72127. /**
  72128. * Add an input method to a camera
  72129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72130. * @param input camera input method
  72131. */
  72132. add(input: ICameraInput<TCamera>): void;
  72133. /**
  72134. * Remove a specific input method from a camera
  72135. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72136. * @param inputToRemove camera input method
  72137. */
  72138. remove(inputToRemove: ICameraInput<TCamera>): void;
  72139. /**
  72140. * Remove a specific input type from a camera
  72141. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72142. * @param inputType the type of the input to remove
  72143. */
  72144. removeByType(inputType: string): void;
  72145. private _addCheckInputs;
  72146. /**
  72147. * Attach the input controls to the currently attached dom element to listen the events from.
  72148. * @param input Defines the input to attach
  72149. */
  72150. attachInput(input: ICameraInput<TCamera>): void;
  72151. /**
  72152. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72153. * @param element Defines the dom element to collect the events from
  72154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72155. */
  72156. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72157. /**
  72158. * Detach the current manager inputs controls from a specific dom element.
  72159. * @param element Defines the dom element to collect the events from
  72160. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72161. */
  72162. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72163. /**
  72164. * Rebuild the dynamic inputCheck function from the current list of
  72165. * defined inputs in the manager.
  72166. */
  72167. rebuildInputCheck(): void;
  72168. /**
  72169. * Remove all attached input methods from a camera
  72170. */
  72171. clear(): void;
  72172. /**
  72173. * Serialize the current input manager attached to a camera.
  72174. * This ensures than once parsed,
  72175. * the input associated to the camera will be identical to the current ones
  72176. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72177. */
  72178. serialize(serializedCamera: any): void;
  72179. /**
  72180. * Parses an input manager serialized JSON to restore the previous list of inputs
  72181. * and states associated to a camera.
  72182. * @param parsedCamera Defines the JSON to parse
  72183. */
  72184. parse(parsedCamera: any): void;
  72185. }
  72186. }
  72187. declare module BABYLON {
  72188. /**
  72189. * @hidden
  72190. */
  72191. export class IntersectionInfo {
  72192. bu: Nullable<number>;
  72193. bv: Nullable<number>;
  72194. distance: number;
  72195. faceId: number;
  72196. subMeshId: number;
  72197. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72198. }
  72199. }
  72200. declare module BABYLON {
  72201. /**
  72202. * Represens a plane by the equation ax + by + cz + d = 0
  72203. */
  72204. export class Plane {
  72205. private static _TmpMatrix;
  72206. /**
  72207. * Normal of the plane (a,b,c)
  72208. */
  72209. normal: Vector3;
  72210. /**
  72211. * d component of the plane
  72212. */
  72213. d: number;
  72214. /**
  72215. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72216. * @param a a component of the plane
  72217. * @param b b component of the plane
  72218. * @param c c component of the plane
  72219. * @param d d component of the plane
  72220. */
  72221. constructor(a: number, b: number, c: number, d: number);
  72222. /**
  72223. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72224. */
  72225. asArray(): number[];
  72226. /**
  72227. * @returns a new plane copied from the current Plane.
  72228. */
  72229. clone(): Plane;
  72230. /**
  72231. * @returns the string "Plane".
  72232. */
  72233. getClassName(): string;
  72234. /**
  72235. * @returns the Plane hash code.
  72236. */
  72237. getHashCode(): number;
  72238. /**
  72239. * Normalize the current Plane in place.
  72240. * @returns the updated Plane.
  72241. */
  72242. normalize(): Plane;
  72243. /**
  72244. * Applies a transformation the plane and returns the result
  72245. * @param transformation the transformation matrix to be applied to the plane
  72246. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72247. */
  72248. transform(transformation: DeepImmutable<Matrix>): Plane;
  72249. /**
  72250. * Calcualtte the dot product between the point and the plane normal
  72251. * @param point point to calculate the dot product with
  72252. * @returns the dot product (float) of the point coordinates and the plane normal.
  72253. */
  72254. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72255. /**
  72256. * Updates the current Plane from the plane defined by the three given points.
  72257. * @param point1 one of the points used to contruct the plane
  72258. * @param point2 one of the points used to contruct the plane
  72259. * @param point3 one of the points used to contruct the plane
  72260. * @returns the updated Plane.
  72261. */
  72262. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72263. /**
  72264. * Checks if the plane is facing a given direction
  72265. * @param direction the direction to check if the plane is facing
  72266. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72267. * @returns True is the vector "direction" is the same side than the plane normal.
  72268. */
  72269. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72270. /**
  72271. * Calculates the distance to a point
  72272. * @param point point to calculate distance to
  72273. * @returns the signed distance (float) from the given point to the Plane.
  72274. */
  72275. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72276. /**
  72277. * Creates a plane from an array
  72278. * @param array the array to create a plane from
  72279. * @returns a new Plane from the given array.
  72280. */
  72281. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72282. /**
  72283. * Creates a plane from three points
  72284. * @param point1 point used to create the plane
  72285. * @param point2 point used to create the plane
  72286. * @param point3 point used to create the plane
  72287. * @returns a new Plane defined by the three given points.
  72288. */
  72289. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72290. /**
  72291. * Creates a plane from an origin point and a normal
  72292. * @param origin origin of the plane to be constructed
  72293. * @param normal normal of the plane to be constructed
  72294. * @returns a new Plane the normal vector to this plane at the given origin point.
  72295. * Note : the vector "normal" is updated because normalized.
  72296. */
  72297. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72298. /**
  72299. * Calculates the distance from a plane and a point
  72300. * @param origin origin of the plane to be constructed
  72301. * @param normal normal of the plane to be constructed
  72302. * @param point point to calculate distance to
  72303. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72304. */
  72305. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72306. }
  72307. }
  72308. declare module BABYLON {
  72309. /**
  72310. * Class used to store bounding sphere information
  72311. */
  72312. export class BoundingSphere {
  72313. /**
  72314. * Gets the center of the bounding sphere in local space
  72315. */
  72316. readonly center: Vector3;
  72317. /**
  72318. * Radius of the bounding sphere in local space
  72319. */
  72320. radius: number;
  72321. /**
  72322. * Gets the center of the bounding sphere in world space
  72323. */
  72324. readonly centerWorld: Vector3;
  72325. /**
  72326. * Radius of the bounding sphere in world space
  72327. */
  72328. radiusWorld: number;
  72329. /**
  72330. * Gets the minimum vector in local space
  72331. */
  72332. readonly minimum: Vector3;
  72333. /**
  72334. * Gets the maximum vector in local space
  72335. */
  72336. readonly maximum: Vector3;
  72337. private _worldMatrix;
  72338. private static readonly TmpVector3;
  72339. /**
  72340. * Creates a new bounding sphere
  72341. * @param min defines the minimum vector (in local space)
  72342. * @param max defines the maximum vector (in local space)
  72343. * @param worldMatrix defines the new world matrix
  72344. */
  72345. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72346. /**
  72347. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72348. * @param min defines the new minimum vector (in local space)
  72349. * @param max defines the new maximum vector (in local space)
  72350. * @param worldMatrix defines the new world matrix
  72351. */
  72352. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72353. /**
  72354. * Scale the current bounding sphere by applying a scale factor
  72355. * @param factor defines the scale factor to apply
  72356. * @returns the current bounding box
  72357. */
  72358. scale(factor: number): BoundingSphere;
  72359. /**
  72360. * Gets the world matrix of the bounding box
  72361. * @returns a matrix
  72362. */
  72363. getWorldMatrix(): DeepImmutable<Matrix>;
  72364. /** @hidden */
  72365. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72366. /**
  72367. * Tests if the bounding sphere is intersecting the frustum planes
  72368. * @param frustumPlanes defines the frustum planes to test
  72369. * @returns true if there is an intersection
  72370. */
  72371. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72372. /**
  72373. * Tests if the bounding sphere center is in between the frustum planes.
  72374. * Used for optimistic fast inclusion.
  72375. * @param frustumPlanes defines the frustum planes to test
  72376. * @returns true if the sphere center is in between the frustum planes
  72377. */
  72378. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72379. /**
  72380. * Tests if a point is inside the bounding sphere
  72381. * @param point defines the point to test
  72382. * @returns true if the point is inside the bounding sphere
  72383. */
  72384. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72385. /**
  72386. * Checks if two sphere intersct
  72387. * @param sphere0 sphere 0
  72388. * @param sphere1 sphere 1
  72389. * @returns true if the speres intersect
  72390. */
  72391. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72392. }
  72393. }
  72394. declare module BABYLON {
  72395. /**
  72396. * Class used to store bounding box information
  72397. */
  72398. export class BoundingBox implements ICullable {
  72399. /**
  72400. * Gets the 8 vectors representing the bounding box in local space
  72401. */
  72402. readonly vectors: Vector3[];
  72403. /**
  72404. * Gets the center of the bounding box in local space
  72405. */
  72406. readonly center: Vector3;
  72407. /**
  72408. * Gets the center of the bounding box in world space
  72409. */
  72410. readonly centerWorld: Vector3;
  72411. /**
  72412. * Gets the extend size in local space
  72413. */
  72414. readonly extendSize: Vector3;
  72415. /**
  72416. * Gets the extend size in world space
  72417. */
  72418. readonly extendSizeWorld: Vector3;
  72419. /**
  72420. * Gets the OBB (object bounding box) directions
  72421. */
  72422. readonly directions: Vector3[];
  72423. /**
  72424. * Gets the 8 vectors representing the bounding box in world space
  72425. */
  72426. readonly vectorsWorld: Vector3[];
  72427. /**
  72428. * Gets the minimum vector in world space
  72429. */
  72430. readonly minimumWorld: Vector3;
  72431. /**
  72432. * Gets the maximum vector in world space
  72433. */
  72434. readonly maximumWorld: Vector3;
  72435. /**
  72436. * Gets the minimum vector in local space
  72437. */
  72438. readonly minimum: Vector3;
  72439. /**
  72440. * Gets the maximum vector in local space
  72441. */
  72442. readonly maximum: Vector3;
  72443. private _worldMatrix;
  72444. private static readonly TmpVector3;
  72445. /**
  72446. * @hidden
  72447. */
  72448. _tag: number;
  72449. /**
  72450. * Creates a new bounding box
  72451. * @param min defines the minimum vector (in local space)
  72452. * @param max defines the maximum vector (in local space)
  72453. * @param worldMatrix defines the new world matrix
  72454. */
  72455. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72456. /**
  72457. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72458. * @param min defines the new minimum vector (in local space)
  72459. * @param max defines the new maximum vector (in local space)
  72460. * @param worldMatrix defines the new world matrix
  72461. */
  72462. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72463. /**
  72464. * Scale the current bounding box by applying a scale factor
  72465. * @param factor defines the scale factor to apply
  72466. * @returns the current bounding box
  72467. */
  72468. scale(factor: number): BoundingBox;
  72469. /**
  72470. * Gets the world matrix of the bounding box
  72471. * @returns a matrix
  72472. */
  72473. getWorldMatrix(): DeepImmutable<Matrix>;
  72474. /** @hidden */
  72475. _update(world: DeepImmutable<Matrix>): void;
  72476. /**
  72477. * Tests if the bounding box is intersecting the frustum planes
  72478. * @param frustumPlanes defines the frustum planes to test
  72479. * @returns true if there is an intersection
  72480. */
  72481. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72482. /**
  72483. * Tests if the bounding box is entirely inside the frustum planes
  72484. * @param frustumPlanes defines the frustum planes to test
  72485. * @returns true if there is an inclusion
  72486. */
  72487. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72488. /**
  72489. * Tests if a point is inside the bounding box
  72490. * @param point defines the point to test
  72491. * @returns true if the point is inside the bounding box
  72492. */
  72493. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72494. /**
  72495. * Tests if the bounding box intersects with a bounding sphere
  72496. * @param sphere defines the sphere to test
  72497. * @returns true if there is an intersection
  72498. */
  72499. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72500. /**
  72501. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72502. * @param min defines the min vector to use
  72503. * @param max defines the max vector to use
  72504. * @returns true if there is an intersection
  72505. */
  72506. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72507. /**
  72508. * Tests if two bounding boxes are intersections
  72509. * @param box0 defines the first box to test
  72510. * @param box1 defines the second box to test
  72511. * @returns true if there is an intersection
  72512. */
  72513. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72514. /**
  72515. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72516. * @param minPoint defines the minimum vector of the bounding box
  72517. * @param maxPoint defines the maximum vector of the bounding box
  72518. * @param sphereCenter defines the sphere center
  72519. * @param sphereRadius defines the sphere radius
  72520. * @returns true if there is an intersection
  72521. */
  72522. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72523. /**
  72524. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72525. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72526. * @param frustumPlanes defines the frustum planes to test
  72527. * @return true if there is an inclusion
  72528. */
  72529. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72530. /**
  72531. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72532. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72533. * @param frustumPlanes defines the frustum planes to test
  72534. * @return true if there is an intersection
  72535. */
  72536. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72537. }
  72538. }
  72539. declare module BABYLON {
  72540. /** @hidden */
  72541. export class Collider {
  72542. /** Define if a collision was found */
  72543. collisionFound: boolean;
  72544. /**
  72545. * Define last intersection point in local space
  72546. */
  72547. intersectionPoint: Vector3;
  72548. /**
  72549. * Define last collided mesh
  72550. */
  72551. collidedMesh: Nullable<AbstractMesh>;
  72552. private _collisionPoint;
  72553. private _planeIntersectionPoint;
  72554. private _tempVector;
  72555. private _tempVector2;
  72556. private _tempVector3;
  72557. private _tempVector4;
  72558. private _edge;
  72559. private _baseToVertex;
  72560. private _destinationPoint;
  72561. private _slidePlaneNormal;
  72562. private _displacementVector;
  72563. /** @hidden */
  72564. _radius: Vector3;
  72565. /** @hidden */
  72566. _retry: number;
  72567. private _velocity;
  72568. private _basePoint;
  72569. private _epsilon;
  72570. /** @hidden */
  72571. _velocityWorldLength: number;
  72572. /** @hidden */
  72573. _basePointWorld: Vector3;
  72574. private _velocityWorld;
  72575. private _normalizedVelocity;
  72576. /** @hidden */
  72577. _initialVelocity: Vector3;
  72578. /** @hidden */
  72579. _initialPosition: Vector3;
  72580. private _nearestDistance;
  72581. private _collisionMask;
  72582. collisionMask: number;
  72583. /**
  72584. * Gets the plane normal used to compute the sliding response (in local space)
  72585. */
  72586. readonly slidePlaneNormal: Vector3;
  72587. /** @hidden */
  72588. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72589. /** @hidden */
  72590. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72591. /** @hidden */
  72592. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72593. /** @hidden */
  72594. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72595. /** @hidden */
  72596. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72597. /** @hidden */
  72598. _getResponse(pos: Vector3, vel: Vector3): void;
  72599. }
  72600. }
  72601. declare module BABYLON {
  72602. /**
  72603. * Interface for cullable objects
  72604. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72605. */
  72606. export interface ICullable {
  72607. /**
  72608. * Checks if the object or part of the object is in the frustum
  72609. * @param frustumPlanes Camera near/planes
  72610. * @returns true if the object is in frustum otherwise false
  72611. */
  72612. isInFrustum(frustumPlanes: Plane[]): boolean;
  72613. /**
  72614. * Checks if a cullable object (mesh...) is in the camera frustum
  72615. * Unlike isInFrustum this cheks the full bounding box
  72616. * @param frustumPlanes Camera near/planes
  72617. * @returns true if the object is in frustum otherwise false
  72618. */
  72619. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72620. }
  72621. /**
  72622. * Info for a bounding data of a mesh
  72623. */
  72624. export class BoundingInfo implements ICullable {
  72625. /**
  72626. * Bounding box for the mesh
  72627. */
  72628. readonly boundingBox: BoundingBox;
  72629. /**
  72630. * Bounding sphere for the mesh
  72631. */
  72632. readonly boundingSphere: BoundingSphere;
  72633. private _isLocked;
  72634. private static readonly TmpVector3;
  72635. /**
  72636. * Constructs bounding info
  72637. * @param minimum min vector of the bounding box/sphere
  72638. * @param maximum max vector of the bounding box/sphere
  72639. * @param worldMatrix defines the new world matrix
  72640. */
  72641. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72642. /**
  72643. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72644. * @param min defines the new minimum vector (in local space)
  72645. * @param max defines the new maximum vector (in local space)
  72646. * @param worldMatrix defines the new world matrix
  72647. */
  72648. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72649. /**
  72650. * min vector of the bounding box/sphere
  72651. */
  72652. readonly minimum: Vector3;
  72653. /**
  72654. * max vector of the bounding box/sphere
  72655. */
  72656. readonly maximum: Vector3;
  72657. /**
  72658. * If the info is locked and won't be updated to avoid perf overhead
  72659. */
  72660. isLocked: boolean;
  72661. /**
  72662. * Updates the bounding sphere and box
  72663. * @param world world matrix to be used to update
  72664. */
  72665. update(world: DeepImmutable<Matrix>): void;
  72666. /**
  72667. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72668. * @param center New center of the bounding info
  72669. * @param extend New extend of the bounding info
  72670. * @returns the current bounding info
  72671. */
  72672. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72673. /**
  72674. * Scale the current bounding info by applying a scale factor
  72675. * @param factor defines the scale factor to apply
  72676. * @returns the current bounding info
  72677. */
  72678. scale(factor: number): BoundingInfo;
  72679. /**
  72680. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72681. * @param frustumPlanes defines the frustum to test
  72682. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72683. * @returns true if the bounding info is in the frustum planes
  72684. */
  72685. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72686. /**
  72687. * Gets the world distance between the min and max points of the bounding box
  72688. */
  72689. readonly diagonalLength: number;
  72690. /**
  72691. * Checks if a cullable object (mesh...) is in the camera frustum
  72692. * Unlike isInFrustum this cheks the full bounding box
  72693. * @param frustumPlanes Camera near/planes
  72694. * @returns true if the object is in frustum otherwise false
  72695. */
  72696. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72697. /** @hidden */
  72698. _checkCollision(collider: Collider): boolean;
  72699. /**
  72700. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72701. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72702. * @param point the point to check intersection with
  72703. * @returns if the point intersects
  72704. */
  72705. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72706. /**
  72707. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72708. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72709. * @param boundingInfo the bounding info to check intersection with
  72710. * @param precise if the intersection should be done using OBB
  72711. * @returns if the bounding info intersects
  72712. */
  72713. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /**
  72718. * Extracts minimum and maximum values from a list of indexed positions
  72719. * @param positions defines the positions to use
  72720. * @param indices defines the indices to the positions
  72721. * @param indexStart defines the start index
  72722. * @param indexCount defines the end index
  72723. * @param bias defines bias value to add to the result
  72724. * @return minimum and maximum values
  72725. */
  72726. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72727. minimum: Vector3;
  72728. maximum: Vector3;
  72729. };
  72730. /**
  72731. * Extracts minimum and maximum values from a list of positions
  72732. * @param positions defines the positions to use
  72733. * @param start defines the start index in the positions array
  72734. * @param count defines the number of positions to handle
  72735. * @param bias defines bias value to add to the result
  72736. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72737. * @return minimum and maximum values
  72738. */
  72739. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72740. minimum: Vector3;
  72741. maximum: Vector3;
  72742. };
  72743. }
  72744. declare module BABYLON {
  72745. /**
  72746. * Enum that determines the text-wrapping mode to use.
  72747. */
  72748. export enum InspectableType {
  72749. /**
  72750. * Checkbox for booleans
  72751. */
  72752. Checkbox = 0,
  72753. /**
  72754. * Sliders for numbers
  72755. */
  72756. Slider = 1,
  72757. /**
  72758. * Vector3
  72759. */
  72760. Vector3 = 2,
  72761. /**
  72762. * Quaternions
  72763. */
  72764. Quaternion = 3,
  72765. /**
  72766. * Color3
  72767. */
  72768. Color3 = 4,
  72769. /**
  72770. * String
  72771. */
  72772. String = 5
  72773. }
  72774. /**
  72775. * Interface used to define custom inspectable properties.
  72776. * This interface is used by the inspector to display custom property grids
  72777. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72778. */
  72779. export interface IInspectable {
  72780. /**
  72781. * Gets the label to display
  72782. */
  72783. label: string;
  72784. /**
  72785. * Gets the name of the property to edit
  72786. */
  72787. propertyName: string;
  72788. /**
  72789. * Gets the type of the editor to use
  72790. */
  72791. type: InspectableType;
  72792. /**
  72793. * Gets the minimum value of the property when using in "slider" mode
  72794. */
  72795. min?: number;
  72796. /**
  72797. * Gets the maximum value of the property when using in "slider" mode
  72798. */
  72799. max?: number;
  72800. /**
  72801. * Gets the setp to use when using in "slider" mode
  72802. */
  72803. step?: number;
  72804. }
  72805. }
  72806. declare module BABYLON {
  72807. /**
  72808. * Class used to provide helper for timing
  72809. */
  72810. export class TimingTools {
  72811. /**
  72812. * Polyfill for setImmediate
  72813. * @param action defines the action to execute after the current execution block
  72814. */
  72815. static SetImmediate(action: () => void): void;
  72816. }
  72817. }
  72818. declare module BABYLON {
  72819. /**
  72820. * Class used to enable instatition of objects by class name
  72821. */
  72822. export class InstantiationTools {
  72823. /**
  72824. * Use this object to register external classes like custom textures or material
  72825. * to allow the laoders to instantiate them
  72826. */
  72827. static RegisteredExternalClasses: {
  72828. [key: string]: Object;
  72829. };
  72830. /**
  72831. * Tries to instantiate a new object from a given class name
  72832. * @param className defines the class name to instantiate
  72833. * @returns the new object or null if the system was not able to do the instantiation
  72834. */
  72835. static Instantiate(className: string): any;
  72836. }
  72837. }
  72838. declare module BABYLON {
  72839. /**
  72840. * This represents the required contract to create a new type of texture loader.
  72841. */
  72842. export interface IInternalTextureLoader {
  72843. /**
  72844. * Defines wether the loader supports cascade loading the different faces.
  72845. */
  72846. supportCascades: boolean;
  72847. /**
  72848. * This returns if the loader support the current file information.
  72849. * @param extension defines the file extension of the file being loaded
  72850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72851. * @param fallback defines the fallback internal texture if any
  72852. * @param isBase64 defines whether the texture is encoded as a base64
  72853. * @param isBuffer defines whether the texture data are stored as a buffer
  72854. * @returns true if the loader can load the specified file
  72855. */
  72856. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72857. /**
  72858. * Transform the url before loading if required.
  72859. * @param rootUrl the url of the texture
  72860. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72861. * @returns the transformed texture
  72862. */
  72863. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72864. /**
  72865. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72866. * @param rootUrl the url of the texture
  72867. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72868. * @returns the fallback texture
  72869. */
  72870. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72871. /**
  72872. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72873. * @param data contains the texture data
  72874. * @param texture defines the BabylonJS internal texture
  72875. * @param createPolynomials will be true if polynomials have been requested
  72876. * @param onLoad defines the callback to trigger once the texture is ready
  72877. * @param onError defines the callback to trigger in case of error
  72878. */
  72879. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72880. /**
  72881. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72882. * @param data contains the texture data
  72883. * @param texture defines the BabylonJS internal texture
  72884. * @param callback defines the method to call once ready to upload
  72885. */
  72886. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72887. }
  72888. }
  72889. declare module BABYLON {
  72890. interface Engine {
  72891. /**
  72892. * Creates a depth stencil cube texture.
  72893. * This is only available in WebGL 2.
  72894. * @param size The size of face edge in the cube texture.
  72895. * @param options The options defining the cube texture.
  72896. * @returns The cube texture
  72897. */
  72898. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72899. /**
  72900. * Creates a cube texture
  72901. * @param rootUrl defines the url where the files to load is located
  72902. * @param scene defines the current scene
  72903. * @param files defines the list of files to load (1 per face)
  72904. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72905. * @param onLoad defines an optional callback raised when the texture is loaded
  72906. * @param onError defines an optional callback raised if there is an issue to load the texture
  72907. * @param format defines the format of the data
  72908. * @param forcedExtension defines the extension to use to pick the right loader
  72909. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72910. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72911. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72912. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72913. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72914. * @returns the cube texture as an InternalTexture
  72915. */
  72916. 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;
  72917. /**
  72918. * Creates a cube texture
  72919. * @param rootUrl defines the url where the files to load is located
  72920. * @param scene defines the current scene
  72921. * @param files defines the list of files to load (1 per face)
  72922. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72923. * @param onLoad defines an optional callback raised when the texture is loaded
  72924. * @param onError defines an optional callback raised if there is an issue to load the texture
  72925. * @param format defines the format of the data
  72926. * @param forcedExtension defines the extension to use to pick the right loader
  72927. * @returns the cube texture as an InternalTexture
  72928. */
  72929. 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;
  72930. /**
  72931. * Creates a cube texture
  72932. * @param rootUrl defines the url where the files to load is located
  72933. * @param scene defines the current scene
  72934. * @param files defines the list of files to load (1 per face)
  72935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72936. * @param onLoad defines an optional callback raised when the texture is loaded
  72937. * @param onError defines an optional callback raised if there is an issue to load the texture
  72938. * @param format defines the format of the data
  72939. * @param forcedExtension defines the extension to use to pick the right loader
  72940. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72941. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72942. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72943. * @returns the cube texture as an InternalTexture
  72944. */
  72945. 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;
  72946. /** @hidden */
  72947. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72948. /** @hidden */
  72949. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72950. /** @hidden */
  72951. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72952. /** @hidden */
  72953. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72954. }
  72955. }
  72956. declare module BABYLON {
  72957. /**
  72958. * Class for creating a cube texture
  72959. */
  72960. export class CubeTexture extends BaseTexture {
  72961. private _delayedOnLoad;
  72962. /**
  72963. * The url of the texture
  72964. */
  72965. url: string;
  72966. /**
  72967. * Gets or sets the center of the bounding box associated with the cube texture.
  72968. * It must define where the camera used to render the texture was set
  72969. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72970. */
  72971. boundingBoxPosition: Vector3;
  72972. private _boundingBoxSize;
  72973. /**
  72974. * Gets or sets the size of the bounding box associated with the cube texture
  72975. * When defined, the cubemap will switch to local mode
  72976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72977. * @example https://www.babylonjs-playground.com/#RNASML
  72978. */
  72979. /**
  72980. * Returns the bounding box size
  72981. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72982. */
  72983. boundingBoxSize: Vector3;
  72984. protected _rotationY: number;
  72985. /**
  72986. * Sets texture matrix rotation angle around Y axis in radians.
  72987. */
  72988. /**
  72989. * Gets texture matrix rotation angle around Y axis radians.
  72990. */
  72991. rotationY: number;
  72992. /**
  72993. * Are mip maps generated for this texture or not.
  72994. */
  72995. readonly noMipmap: boolean;
  72996. private _noMipmap;
  72997. private _files;
  72998. private _extensions;
  72999. private _textureMatrix;
  73000. private _format;
  73001. private _createPolynomials;
  73002. /** @hidden */
  73003. _prefiltered: boolean;
  73004. /**
  73005. * Creates a cube texture from an array of image urls
  73006. * @param files defines an array of image urls
  73007. * @param scene defines the hosting scene
  73008. * @param noMipmap specifies if mip maps are not used
  73009. * @returns a cube texture
  73010. */
  73011. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73012. /**
  73013. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73014. * @param url defines the url of the prefiltered texture
  73015. * @param scene defines the scene the texture is attached to
  73016. * @param forcedExtension defines the extension of the file if different from the url
  73017. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73018. * @return the prefiltered texture
  73019. */
  73020. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73021. /**
  73022. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73023. * as prefiltered data.
  73024. * @param rootUrl defines the url of the texture or the root name of the six images
  73025. * @param scene defines the scene the texture is attached to
  73026. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73027. * @param noMipmap defines if mipmaps should be created or not
  73028. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73029. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73030. * @param onError defines a callback triggered in case of error during load
  73031. * @param format defines the internal format to use for the texture once loaded
  73032. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73033. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73034. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73037. * @return the cube texture
  73038. */
  73039. 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);
  73040. /**
  73041. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73042. */
  73043. readonly isPrefiltered: boolean;
  73044. /**
  73045. * Get the current class name of the texture useful for serialization or dynamic coding.
  73046. * @returns "CubeTexture"
  73047. */
  73048. getClassName(): string;
  73049. /**
  73050. * Update the url (and optional buffer) of this texture if url was null during construction.
  73051. * @param url the url of the texture
  73052. * @param forcedExtension defines the extension to use
  73053. * @param onLoad callback called when the texture is loaded (defaults to null)
  73054. */
  73055. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73056. /**
  73057. * Delays loading of the cube texture
  73058. * @param forcedExtension defines the extension to use
  73059. */
  73060. delayLoad(forcedExtension?: string): void;
  73061. /**
  73062. * Returns the reflection texture matrix
  73063. * @returns the reflection texture matrix
  73064. */
  73065. getReflectionTextureMatrix(): Matrix;
  73066. /**
  73067. * Sets the reflection texture matrix
  73068. * @param value Reflection texture matrix
  73069. */
  73070. setReflectionTextureMatrix(value: Matrix): void;
  73071. /**
  73072. * Parses text to create a cube texture
  73073. * @param parsedTexture define the serialized text to read from
  73074. * @param scene defines the hosting scene
  73075. * @param rootUrl defines the root url of the cube texture
  73076. * @returns a cube texture
  73077. */
  73078. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73079. /**
  73080. * Makes a clone, or deep copy, of the cube texture
  73081. * @returns a new cube texture
  73082. */
  73083. clone(): CubeTexture;
  73084. }
  73085. }
  73086. declare module BABYLON {
  73087. /**
  73088. * Manages the defines for the Material
  73089. */
  73090. export class MaterialDefines {
  73091. /** @hidden */
  73092. protected _keys: string[];
  73093. private _isDirty;
  73094. /** @hidden */
  73095. _renderId: number;
  73096. /** @hidden */
  73097. _areLightsDirty: boolean;
  73098. /** @hidden */
  73099. _areLightsDisposed: boolean;
  73100. /** @hidden */
  73101. _areAttributesDirty: boolean;
  73102. /** @hidden */
  73103. _areTexturesDirty: boolean;
  73104. /** @hidden */
  73105. _areFresnelDirty: boolean;
  73106. /** @hidden */
  73107. _areMiscDirty: boolean;
  73108. /** @hidden */
  73109. _areImageProcessingDirty: boolean;
  73110. /** @hidden */
  73111. _normals: boolean;
  73112. /** @hidden */
  73113. _uvs: boolean;
  73114. /** @hidden */
  73115. _needNormals: boolean;
  73116. /** @hidden */
  73117. _needUVs: boolean;
  73118. [id: string]: any;
  73119. /**
  73120. * Specifies if the material needs to be re-calculated
  73121. */
  73122. readonly isDirty: boolean;
  73123. /**
  73124. * Marks the material to indicate that it has been re-calculated
  73125. */
  73126. markAsProcessed(): void;
  73127. /**
  73128. * Marks the material to indicate that it needs to be re-calculated
  73129. */
  73130. markAsUnprocessed(): void;
  73131. /**
  73132. * Marks the material to indicate all of its defines need to be re-calculated
  73133. */
  73134. markAllAsDirty(): void;
  73135. /**
  73136. * Marks the material to indicate that image processing needs to be re-calculated
  73137. */
  73138. markAsImageProcessingDirty(): void;
  73139. /**
  73140. * Marks the material to indicate the lights need to be re-calculated
  73141. * @param disposed Defines whether the light is dirty due to dispose or not
  73142. */
  73143. markAsLightDirty(disposed?: boolean): void;
  73144. /**
  73145. * Marks the attribute state as changed
  73146. */
  73147. markAsAttributesDirty(): void;
  73148. /**
  73149. * Marks the texture state as changed
  73150. */
  73151. markAsTexturesDirty(): void;
  73152. /**
  73153. * Marks the fresnel state as changed
  73154. */
  73155. markAsFresnelDirty(): void;
  73156. /**
  73157. * Marks the misc state as changed
  73158. */
  73159. markAsMiscDirty(): void;
  73160. /**
  73161. * Rebuilds the material defines
  73162. */
  73163. rebuild(): void;
  73164. /**
  73165. * Specifies if two material defines are equal
  73166. * @param other - A material define instance to compare to
  73167. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73168. */
  73169. isEqual(other: MaterialDefines): boolean;
  73170. /**
  73171. * Clones this instance's defines to another instance
  73172. * @param other - material defines to clone values to
  73173. */
  73174. cloneTo(other: MaterialDefines): void;
  73175. /**
  73176. * Resets the material define values
  73177. */
  73178. reset(): void;
  73179. /**
  73180. * Converts the material define values to a string
  73181. * @returns - String of material define information
  73182. */
  73183. toString(): string;
  73184. }
  73185. }
  73186. declare module BABYLON {
  73187. /**
  73188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73190. * 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;
  73191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73192. */
  73193. export class ColorCurves {
  73194. private _dirty;
  73195. private _tempColor;
  73196. private _globalCurve;
  73197. private _highlightsCurve;
  73198. private _midtonesCurve;
  73199. private _shadowsCurve;
  73200. private _positiveCurve;
  73201. private _negativeCurve;
  73202. private _globalHue;
  73203. private _globalDensity;
  73204. private _globalSaturation;
  73205. private _globalExposure;
  73206. /**
  73207. * Gets the global Hue value.
  73208. * 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).
  73209. */
  73210. /**
  73211. * Sets the global Hue value.
  73212. * 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).
  73213. */
  73214. globalHue: number;
  73215. /**
  73216. * Gets the global Density value.
  73217. * 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.
  73218. * Values less than zero provide a filter of opposite hue.
  73219. */
  73220. /**
  73221. * Sets the global Density value.
  73222. * 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.
  73223. * Values less than zero provide a filter of opposite hue.
  73224. */
  73225. globalDensity: number;
  73226. /**
  73227. * Gets the global Saturation value.
  73228. * 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.
  73229. */
  73230. /**
  73231. * Sets the global Saturation value.
  73232. * 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.
  73233. */
  73234. globalSaturation: number;
  73235. /**
  73236. * Gets the global Exposure value.
  73237. * 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.
  73238. */
  73239. /**
  73240. * Sets the global Exposure value.
  73241. * 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.
  73242. */
  73243. globalExposure: number;
  73244. private _highlightsHue;
  73245. private _highlightsDensity;
  73246. private _highlightsSaturation;
  73247. private _highlightsExposure;
  73248. /**
  73249. * Gets the highlights Hue value.
  73250. * 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).
  73251. */
  73252. /**
  73253. * Sets the highlights Hue value.
  73254. * 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).
  73255. */
  73256. highlightsHue: number;
  73257. /**
  73258. * Gets the highlights Density value.
  73259. * 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.
  73260. * Values less than zero provide a filter of opposite hue.
  73261. */
  73262. /**
  73263. * Sets the highlights Density value.
  73264. * 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.
  73265. * Values less than zero provide a filter of opposite hue.
  73266. */
  73267. highlightsDensity: number;
  73268. /**
  73269. * Gets the highlights Saturation value.
  73270. * 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.
  73271. */
  73272. /**
  73273. * Sets the highlights Saturation value.
  73274. * 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.
  73275. */
  73276. highlightsSaturation: number;
  73277. /**
  73278. * Gets the highlights Exposure value.
  73279. * 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.
  73280. */
  73281. /**
  73282. * Sets the highlights Exposure value.
  73283. * 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.
  73284. */
  73285. highlightsExposure: number;
  73286. private _midtonesHue;
  73287. private _midtonesDensity;
  73288. private _midtonesSaturation;
  73289. private _midtonesExposure;
  73290. /**
  73291. * Gets the midtones Hue value.
  73292. * 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).
  73293. */
  73294. /**
  73295. * Sets the midtones Hue value.
  73296. * 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).
  73297. */
  73298. midtonesHue: number;
  73299. /**
  73300. * Gets the midtones Density value.
  73301. * 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.
  73302. * Values less than zero provide a filter of opposite hue.
  73303. */
  73304. /**
  73305. * Sets the midtones Density value.
  73306. * 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.
  73307. * Values less than zero provide a filter of opposite hue.
  73308. */
  73309. midtonesDensity: number;
  73310. /**
  73311. * Gets the midtones Saturation value.
  73312. * 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.
  73313. */
  73314. /**
  73315. * Sets the midtones Saturation value.
  73316. * 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.
  73317. */
  73318. midtonesSaturation: number;
  73319. /**
  73320. * Gets the midtones Exposure value.
  73321. * 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.
  73322. */
  73323. /**
  73324. * Sets the midtones Exposure value.
  73325. * 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.
  73326. */
  73327. midtonesExposure: number;
  73328. private _shadowsHue;
  73329. private _shadowsDensity;
  73330. private _shadowsSaturation;
  73331. private _shadowsExposure;
  73332. /**
  73333. * Gets the shadows Hue value.
  73334. * 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).
  73335. */
  73336. /**
  73337. * Sets the shadows Hue value.
  73338. * 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).
  73339. */
  73340. shadowsHue: number;
  73341. /**
  73342. * Gets the shadows Density value.
  73343. * 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.
  73344. * Values less than zero provide a filter of opposite hue.
  73345. */
  73346. /**
  73347. * Sets the shadows Density value.
  73348. * 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.
  73349. * Values less than zero provide a filter of opposite hue.
  73350. */
  73351. shadowsDensity: number;
  73352. /**
  73353. * Gets the shadows Saturation value.
  73354. * 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.
  73355. */
  73356. /**
  73357. * Sets the shadows Saturation value.
  73358. * 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.
  73359. */
  73360. shadowsSaturation: number;
  73361. /**
  73362. * Gets the shadows Exposure value.
  73363. * 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.
  73364. */
  73365. /**
  73366. * Sets the shadows Exposure value.
  73367. * 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.
  73368. */
  73369. shadowsExposure: number;
  73370. /**
  73371. * Returns the class name
  73372. * @returns The class name
  73373. */
  73374. getClassName(): string;
  73375. /**
  73376. * Binds the color curves to the shader.
  73377. * @param colorCurves The color curve to bind
  73378. * @param effect The effect to bind to
  73379. * @param positiveUniform The positive uniform shader parameter
  73380. * @param neutralUniform The neutral uniform shader parameter
  73381. * @param negativeUniform The negative uniform shader parameter
  73382. */
  73383. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73384. /**
  73385. * Prepare the list of uniforms associated with the ColorCurves effects.
  73386. * @param uniformsList The list of uniforms used in the effect
  73387. */
  73388. static PrepareUniforms(uniformsList: string[]): void;
  73389. /**
  73390. * Returns color grading data based on a hue, density, saturation and exposure value.
  73391. * @param filterHue The hue of the color filter.
  73392. * @param filterDensity The density of the color filter.
  73393. * @param saturation The saturation.
  73394. * @param exposure The exposure.
  73395. * @param result The result data container.
  73396. */
  73397. private getColorGradingDataToRef;
  73398. /**
  73399. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73400. * @param value The input slider value in range [-100,100].
  73401. * @returns Adjusted value.
  73402. */
  73403. private static applyColorGradingSliderNonlinear;
  73404. /**
  73405. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73406. * @param hue The hue (H) input.
  73407. * @param saturation The saturation (S) input.
  73408. * @param brightness The brightness (B) input.
  73409. * @result An RGBA color represented as Vector4.
  73410. */
  73411. private static fromHSBToRef;
  73412. /**
  73413. * Returns a value clamped between min and max
  73414. * @param value The value to clamp
  73415. * @param min The minimum of value
  73416. * @param max The maximum of value
  73417. * @returns The clamped value.
  73418. */
  73419. private static clamp;
  73420. /**
  73421. * Clones the current color curve instance.
  73422. * @return The cloned curves
  73423. */
  73424. clone(): ColorCurves;
  73425. /**
  73426. * Serializes the current color curve instance to a json representation.
  73427. * @return a JSON representation
  73428. */
  73429. serialize(): any;
  73430. /**
  73431. * Parses the color curve from a json representation.
  73432. * @param source the JSON source to parse
  73433. * @return The parsed curves
  73434. */
  73435. static Parse(source: any): ColorCurves;
  73436. }
  73437. }
  73438. declare module BABYLON {
  73439. /**
  73440. * Interface to follow in your material defines to integrate easily the
  73441. * Image proccessing functions.
  73442. * @hidden
  73443. */
  73444. export interface IImageProcessingConfigurationDefines {
  73445. IMAGEPROCESSING: boolean;
  73446. VIGNETTE: boolean;
  73447. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73448. VIGNETTEBLENDMODEOPAQUE: boolean;
  73449. TONEMAPPING: boolean;
  73450. TONEMAPPING_ACES: boolean;
  73451. CONTRAST: boolean;
  73452. EXPOSURE: boolean;
  73453. COLORCURVES: boolean;
  73454. COLORGRADING: boolean;
  73455. COLORGRADING3D: boolean;
  73456. SAMPLER3DGREENDEPTH: boolean;
  73457. SAMPLER3DBGRMAP: boolean;
  73458. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73459. }
  73460. /**
  73461. * @hidden
  73462. */
  73463. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73464. IMAGEPROCESSING: boolean;
  73465. VIGNETTE: boolean;
  73466. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73467. VIGNETTEBLENDMODEOPAQUE: boolean;
  73468. TONEMAPPING: boolean;
  73469. TONEMAPPING_ACES: boolean;
  73470. CONTRAST: boolean;
  73471. COLORCURVES: boolean;
  73472. COLORGRADING: boolean;
  73473. COLORGRADING3D: boolean;
  73474. SAMPLER3DGREENDEPTH: boolean;
  73475. SAMPLER3DBGRMAP: boolean;
  73476. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73477. EXPOSURE: boolean;
  73478. constructor();
  73479. }
  73480. /**
  73481. * This groups together the common properties used for image processing either in direct forward pass
  73482. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73483. * or not.
  73484. */
  73485. export class ImageProcessingConfiguration {
  73486. /**
  73487. * Default tone mapping applied in BabylonJS.
  73488. */
  73489. static readonly TONEMAPPING_STANDARD: number;
  73490. /**
  73491. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73492. * to other engines rendering to increase portability.
  73493. */
  73494. static readonly TONEMAPPING_ACES: number;
  73495. /**
  73496. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73497. */
  73498. colorCurves: Nullable<ColorCurves>;
  73499. private _colorCurvesEnabled;
  73500. /**
  73501. * Gets wether the color curves effect is enabled.
  73502. */
  73503. /**
  73504. * Sets wether the color curves effect is enabled.
  73505. */
  73506. colorCurvesEnabled: boolean;
  73507. private _colorGradingTexture;
  73508. /**
  73509. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73510. */
  73511. /**
  73512. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73513. */
  73514. colorGradingTexture: Nullable<BaseTexture>;
  73515. private _colorGradingEnabled;
  73516. /**
  73517. * Gets wether the color grading effect is enabled.
  73518. */
  73519. /**
  73520. * Sets wether the color grading effect is enabled.
  73521. */
  73522. colorGradingEnabled: boolean;
  73523. private _colorGradingWithGreenDepth;
  73524. /**
  73525. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73526. */
  73527. /**
  73528. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73529. */
  73530. colorGradingWithGreenDepth: boolean;
  73531. private _colorGradingBGR;
  73532. /**
  73533. * Gets wether the color grading texture contains BGR values.
  73534. */
  73535. /**
  73536. * Sets wether the color grading texture contains BGR values.
  73537. */
  73538. colorGradingBGR: boolean;
  73539. /** @hidden */
  73540. _exposure: number;
  73541. /**
  73542. * Gets the Exposure used in the effect.
  73543. */
  73544. /**
  73545. * Sets the Exposure used in the effect.
  73546. */
  73547. exposure: number;
  73548. private _toneMappingEnabled;
  73549. /**
  73550. * Gets wether the tone mapping effect is enabled.
  73551. */
  73552. /**
  73553. * Sets wether the tone mapping effect is enabled.
  73554. */
  73555. toneMappingEnabled: boolean;
  73556. private _toneMappingType;
  73557. /**
  73558. * Gets the type of tone mapping effect.
  73559. */
  73560. /**
  73561. * Sets the type of tone mapping effect used in BabylonJS.
  73562. */
  73563. toneMappingType: number;
  73564. protected _contrast: number;
  73565. /**
  73566. * Gets the contrast used in the effect.
  73567. */
  73568. /**
  73569. * Sets the contrast used in the effect.
  73570. */
  73571. contrast: number;
  73572. /**
  73573. * Vignette stretch size.
  73574. */
  73575. vignetteStretch: number;
  73576. /**
  73577. * Vignette centre X Offset.
  73578. */
  73579. vignetteCentreX: number;
  73580. /**
  73581. * Vignette centre Y Offset.
  73582. */
  73583. vignetteCentreY: number;
  73584. /**
  73585. * Vignette weight or intensity of the vignette effect.
  73586. */
  73587. vignetteWeight: number;
  73588. /**
  73589. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73590. * if vignetteEnabled is set to true.
  73591. */
  73592. vignetteColor: Color4;
  73593. /**
  73594. * Camera field of view used by the Vignette effect.
  73595. */
  73596. vignetteCameraFov: number;
  73597. private _vignetteBlendMode;
  73598. /**
  73599. * Gets the vignette blend mode allowing different kind of effect.
  73600. */
  73601. /**
  73602. * Sets the vignette blend mode allowing different kind of effect.
  73603. */
  73604. vignetteBlendMode: number;
  73605. private _vignetteEnabled;
  73606. /**
  73607. * Gets wether the vignette effect is enabled.
  73608. */
  73609. /**
  73610. * Sets wether the vignette effect is enabled.
  73611. */
  73612. vignetteEnabled: boolean;
  73613. private _applyByPostProcess;
  73614. /**
  73615. * Gets wether the image processing is applied through a post process or not.
  73616. */
  73617. /**
  73618. * Sets wether the image processing is applied through a post process or not.
  73619. */
  73620. applyByPostProcess: boolean;
  73621. private _isEnabled;
  73622. /**
  73623. * Gets wether the image processing is enabled or not.
  73624. */
  73625. /**
  73626. * Sets wether the image processing is enabled or not.
  73627. */
  73628. isEnabled: boolean;
  73629. /**
  73630. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73631. */
  73632. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73633. /**
  73634. * Method called each time the image processing information changes requires to recompile the effect.
  73635. */
  73636. protected _updateParameters(): void;
  73637. /**
  73638. * Gets the current class name.
  73639. * @return "ImageProcessingConfiguration"
  73640. */
  73641. getClassName(): string;
  73642. /**
  73643. * Prepare the list of uniforms associated with the Image Processing effects.
  73644. * @param uniforms The list of uniforms used in the effect
  73645. * @param defines the list of defines currently in use
  73646. */
  73647. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73648. /**
  73649. * Prepare the list of samplers associated with the Image Processing effects.
  73650. * @param samplersList The list of uniforms used in the effect
  73651. * @param defines the list of defines currently in use
  73652. */
  73653. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73654. /**
  73655. * Prepare the list of defines associated to the shader.
  73656. * @param defines the list of defines to complete
  73657. * @param forPostProcess Define if we are currently in post process mode or not
  73658. */
  73659. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73660. /**
  73661. * Returns true if all the image processing information are ready.
  73662. * @returns True if ready, otherwise, false
  73663. */
  73664. isReady(): boolean;
  73665. /**
  73666. * Binds the image processing to the shader.
  73667. * @param effect The effect to bind to
  73668. * @param aspectRatio Define the current aspect ratio of the effect
  73669. */
  73670. bind(effect: Effect, aspectRatio?: number): void;
  73671. /**
  73672. * Clones the current image processing instance.
  73673. * @return The cloned image processing
  73674. */
  73675. clone(): ImageProcessingConfiguration;
  73676. /**
  73677. * Serializes the current image processing instance to a json representation.
  73678. * @return a JSON representation
  73679. */
  73680. serialize(): any;
  73681. /**
  73682. * Parses the image processing from a json representation.
  73683. * @param source the JSON source to parse
  73684. * @return The parsed image processing
  73685. */
  73686. static Parse(source: any): ImageProcessingConfiguration;
  73687. private static _VIGNETTEMODE_MULTIPLY;
  73688. private static _VIGNETTEMODE_OPAQUE;
  73689. /**
  73690. * Used to apply the vignette as a mix with the pixel color.
  73691. */
  73692. static readonly VIGNETTEMODE_MULTIPLY: number;
  73693. /**
  73694. * Used to apply the vignette as a replacement of the pixel color.
  73695. */
  73696. static readonly VIGNETTEMODE_OPAQUE: number;
  73697. }
  73698. }
  73699. declare module BABYLON {
  73700. /** @hidden */
  73701. export var postprocessVertexShader: {
  73702. name: string;
  73703. shader: string;
  73704. };
  73705. }
  73706. declare module BABYLON {
  73707. /** Defines supported spaces */
  73708. export enum Space {
  73709. /** Local (object) space */
  73710. LOCAL = 0,
  73711. /** World space */
  73712. WORLD = 1,
  73713. /** Bone space */
  73714. BONE = 2
  73715. }
  73716. /** Defines the 3 main axes */
  73717. export class Axis {
  73718. /** X axis */
  73719. static X: Vector3;
  73720. /** Y axis */
  73721. static Y: Vector3;
  73722. /** Z axis */
  73723. static Z: Vector3;
  73724. }
  73725. }
  73726. declare module BABYLON {
  73727. /**
  73728. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73729. * This is the base of the follow, arc rotate cameras and Free camera
  73730. * @see http://doc.babylonjs.com/features/cameras
  73731. */
  73732. export class TargetCamera extends Camera {
  73733. private static _RigCamTransformMatrix;
  73734. private static _TargetTransformMatrix;
  73735. private static _TargetFocalPoint;
  73736. /**
  73737. * Define the current direction the camera is moving to
  73738. */
  73739. cameraDirection: Vector3;
  73740. /**
  73741. * Define the current rotation the camera is rotating to
  73742. */
  73743. cameraRotation: Vector2;
  73744. /**
  73745. * When set, the up vector of the camera will be updated by the rotation of the camera
  73746. */
  73747. updateUpVectorFromRotation: boolean;
  73748. private _tmpQuaternion;
  73749. /**
  73750. * Define the current rotation of the camera
  73751. */
  73752. rotation: Vector3;
  73753. /**
  73754. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73755. */
  73756. rotationQuaternion: Quaternion;
  73757. /**
  73758. * Define the current speed of the camera
  73759. */
  73760. speed: number;
  73761. /**
  73762. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73763. * around all axis.
  73764. */
  73765. noRotationConstraint: boolean;
  73766. /**
  73767. * Define the current target of the camera as an object or a position.
  73768. */
  73769. lockedTarget: any;
  73770. /** @hidden */
  73771. _currentTarget: Vector3;
  73772. /** @hidden */
  73773. _initialFocalDistance: number;
  73774. /** @hidden */
  73775. _viewMatrix: Matrix;
  73776. /** @hidden */
  73777. _camMatrix: Matrix;
  73778. /** @hidden */
  73779. _cameraTransformMatrix: Matrix;
  73780. /** @hidden */
  73781. _cameraRotationMatrix: Matrix;
  73782. /** @hidden */
  73783. _referencePoint: Vector3;
  73784. /** @hidden */
  73785. _transformedReferencePoint: Vector3;
  73786. protected _globalCurrentTarget: Vector3;
  73787. protected _globalCurrentUpVector: Vector3;
  73788. /** @hidden */
  73789. _reset: () => void;
  73790. private _defaultUp;
  73791. /**
  73792. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73793. * This is the base of the follow, arc rotate cameras and Free camera
  73794. * @see http://doc.babylonjs.com/features/cameras
  73795. * @param name Defines the name of the camera in the scene
  73796. * @param position Defines the start position of the camera in the scene
  73797. * @param scene Defines the scene the camera belongs to
  73798. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73799. */
  73800. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73801. /**
  73802. * Gets the position in front of the camera at a given distance.
  73803. * @param distance The distance from the camera we want the position to be
  73804. * @returns the position
  73805. */
  73806. getFrontPosition(distance: number): Vector3;
  73807. /** @hidden */
  73808. _getLockedTargetPosition(): Nullable<Vector3>;
  73809. private _storedPosition;
  73810. private _storedRotation;
  73811. private _storedRotationQuaternion;
  73812. /**
  73813. * Store current camera state of the camera (fov, position, rotation, etc..)
  73814. * @returns the camera
  73815. */
  73816. storeState(): Camera;
  73817. /**
  73818. * Restored camera state. You must call storeState() first
  73819. * @returns whether it was successful or not
  73820. * @hidden
  73821. */
  73822. _restoreStateValues(): boolean;
  73823. /** @hidden */
  73824. _initCache(): void;
  73825. /** @hidden */
  73826. _updateCache(ignoreParentClass?: boolean): void;
  73827. /** @hidden */
  73828. _isSynchronizedViewMatrix(): boolean;
  73829. /** @hidden */
  73830. _computeLocalCameraSpeed(): number;
  73831. /**
  73832. * Defines the target the camera should look at.
  73833. * @param target Defines the new target as a Vector or a mesh
  73834. */
  73835. setTarget(target: Vector3): void;
  73836. /**
  73837. * Return the current target position of the camera. This value is expressed in local space.
  73838. * @returns the target position
  73839. */
  73840. getTarget(): Vector3;
  73841. /** @hidden */
  73842. _decideIfNeedsToMove(): boolean;
  73843. /** @hidden */
  73844. _updatePosition(): void;
  73845. /** @hidden */
  73846. _checkInputs(): void;
  73847. protected _updateCameraRotationMatrix(): void;
  73848. /**
  73849. * 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)
  73850. * @returns the current camera
  73851. */
  73852. private _rotateUpVectorWithCameraRotationMatrix;
  73853. private _cachedRotationZ;
  73854. private _cachedQuaternionRotationZ;
  73855. /** @hidden */
  73856. _getViewMatrix(): Matrix;
  73857. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73858. /**
  73859. * @hidden
  73860. */
  73861. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73862. /**
  73863. * @hidden
  73864. */
  73865. _updateRigCameras(): void;
  73866. private _getRigCamPositionAndTarget;
  73867. /**
  73868. * Gets the current object class name.
  73869. * @return the class name
  73870. */
  73871. getClassName(): string;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /**
  73876. * Gather the list of keyboard event types as constants.
  73877. */
  73878. export class KeyboardEventTypes {
  73879. /**
  73880. * The keydown event is fired when a key becomes active (pressed).
  73881. */
  73882. static readonly KEYDOWN: number;
  73883. /**
  73884. * The keyup event is fired when a key has been released.
  73885. */
  73886. static readonly KEYUP: number;
  73887. }
  73888. /**
  73889. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73890. */
  73891. export class KeyboardInfo {
  73892. /**
  73893. * Defines the type of event (KeyboardEventTypes)
  73894. */
  73895. type: number;
  73896. /**
  73897. * Defines the related dom event
  73898. */
  73899. event: KeyboardEvent;
  73900. /**
  73901. * Instantiates a new keyboard info.
  73902. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73903. * @param type Defines the type of event (KeyboardEventTypes)
  73904. * @param event Defines the related dom event
  73905. */
  73906. constructor(
  73907. /**
  73908. * Defines the type of event (KeyboardEventTypes)
  73909. */
  73910. type: number,
  73911. /**
  73912. * Defines the related dom event
  73913. */
  73914. event: KeyboardEvent);
  73915. }
  73916. /**
  73917. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73918. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73919. */
  73920. export class KeyboardInfoPre extends KeyboardInfo {
  73921. /**
  73922. * Defines the type of event (KeyboardEventTypes)
  73923. */
  73924. type: number;
  73925. /**
  73926. * Defines the related dom event
  73927. */
  73928. event: KeyboardEvent;
  73929. /**
  73930. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73931. */
  73932. skipOnPointerObservable: boolean;
  73933. /**
  73934. * Instantiates a new keyboard pre info.
  73935. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73936. * @param type Defines the type of event (KeyboardEventTypes)
  73937. * @param event Defines the related dom event
  73938. */
  73939. constructor(
  73940. /**
  73941. * Defines the type of event (KeyboardEventTypes)
  73942. */
  73943. type: number,
  73944. /**
  73945. * Defines the related dom event
  73946. */
  73947. event: KeyboardEvent);
  73948. }
  73949. }
  73950. declare module BABYLON {
  73951. /**
  73952. * Manage the keyboard inputs to control the movement of a free camera.
  73953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73954. */
  73955. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73956. /**
  73957. * Defines the camera the input is attached to.
  73958. */
  73959. camera: FreeCamera;
  73960. /**
  73961. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73962. */
  73963. keysUp: number[];
  73964. /**
  73965. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73966. */
  73967. keysDown: number[];
  73968. /**
  73969. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73970. */
  73971. keysLeft: number[];
  73972. /**
  73973. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73974. */
  73975. keysRight: number[];
  73976. private _keys;
  73977. private _onCanvasBlurObserver;
  73978. private _onKeyboardObserver;
  73979. private _engine;
  73980. private _scene;
  73981. /**
  73982. * Attach the input controls to a specific dom element to get the input from.
  73983. * @param element Defines the element the controls should be listened from
  73984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73985. */
  73986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73987. /**
  73988. * Detach the current controls from the specified dom element.
  73989. * @param element Defines the element to stop listening the inputs from
  73990. */
  73991. detachControl(element: Nullable<HTMLElement>): void;
  73992. /**
  73993. * Update the current camera state depending on the inputs that have been used this frame.
  73994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73995. */
  73996. checkInputs(): void;
  73997. /**
  73998. * Gets the class name of the current intput.
  73999. * @returns the class name
  74000. */
  74001. getClassName(): string;
  74002. /** @hidden */
  74003. _onLostFocus(): void;
  74004. /**
  74005. * Get the friendly name associated with the input class.
  74006. * @returns the input friendly name
  74007. */
  74008. getSimpleName(): string;
  74009. }
  74010. }
  74011. declare module BABYLON {
  74012. /**
  74013. * Interface describing all the common properties and methods a shadow light needs to implement.
  74014. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74015. * as well as binding the different shadow properties to the effects.
  74016. */
  74017. export interface IShadowLight extends Light {
  74018. /**
  74019. * The light id in the scene (used in scene.findLighById for instance)
  74020. */
  74021. id: string;
  74022. /**
  74023. * The position the shdow will be casted from.
  74024. */
  74025. position: Vector3;
  74026. /**
  74027. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74028. */
  74029. direction: Vector3;
  74030. /**
  74031. * The transformed position. Position of the light in world space taking parenting in account.
  74032. */
  74033. transformedPosition: Vector3;
  74034. /**
  74035. * The transformed direction. Direction of the light in world space taking parenting in account.
  74036. */
  74037. transformedDirection: Vector3;
  74038. /**
  74039. * The friendly name of the light in the scene.
  74040. */
  74041. name: string;
  74042. /**
  74043. * Defines the shadow projection clipping minimum z value.
  74044. */
  74045. shadowMinZ: number;
  74046. /**
  74047. * Defines the shadow projection clipping maximum z value.
  74048. */
  74049. shadowMaxZ: number;
  74050. /**
  74051. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74052. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74053. */
  74054. computeTransformedInformation(): boolean;
  74055. /**
  74056. * Gets the scene the light belongs to.
  74057. * @returns The scene
  74058. */
  74059. getScene(): Scene;
  74060. /**
  74061. * Callback defining a custom Projection Matrix Builder.
  74062. * This can be used to override the default projection matrix computation.
  74063. */
  74064. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74065. /**
  74066. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74067. * @param matrix The materix to updated with the projection information
  74068. * @param viewMatrix The transform matrix of the light
  74069. * @param renderList The list of mesh to render in the map
  74070. * @returns The current light
  74071. */
  74072. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74073. /**
  74074. * Gets the current depth scale used in ESM.
  74075. * @returns The scale
  74076. */
  74077. getDepthScale(): number;
  74078. /**
  74079. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74080. * @returns true if a cube texture needs to be use
  74081. */
  74082. needCube(): boolean;
  74083. /**
  74084. * Detects if the projection matrix requires to be recomputed this frame.
  74085. * @returns true if it requires to be recomputed otherwise, false.
  74086. */
  74087. needProjectionMatrixCompute(): boolean;
  74088. /**
  74089. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74090. */
  74091. forceProjectionMatrixCompute(): void;
  74092. /**
  74093. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74094. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74095. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74096. */
  74097. getShadowDirection(faceIndex?: number): Vector3;
  74098. /**
  74099. * Gets the minZ used for shadow according to both the scene and the light.
  74100. * @param activeCamera The camera we are returning the min for
  74101. * @returns the depth min z
  74102. */
  74103. getDepthMinZ(activeCamera: Camera): number;
  74104. /**
  74105. * Gets the maxZ used for shadow according to both the scene and the light.
  74106. * @param activeCamera The camera we are returning the max for
  74107. * @returns the depth max z
  74108. */
  74109. getDepthMaxZ(activeCamera: Camera): number;
  74110. }
  74111. /**
  74112. * Base implementation IShadowLight
  74113. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74114. */
  74115. export abstract class ShadowLight extends Light implements IShadowLight {
  74116. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74117. protected _position: Vector3;
  74118. protected _setPosition(value: Vector3): void;
  74119. /**
  74120. * Sets the position the shadow will be casted from. Also use as the light position for both
  74121. * point and spot lights.
  74122. */
  74123. /**
  74124. * Sets the position the shadow will be casted from. Also use as the light position for both
  74125. * point and spot lights.
  74126. */
  74127. position: Vector3;
  74128. protected _direction: Vector3;
  74129. protected _setDirection(value: Vector3): void;
  74130. /**
  74131. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74132. * Also use as the light direction on spot and directional lights.
  74133. */
  74134. /**
  74135. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74136. * Also use as the light direction on spot and directional lights.
  74137. */
  74138. direction: Vector3;
  74139. private _shadowMinZ;
  74140. /**
  74141. * Gets the shadow projection clipping minimum z value.
  74142. */
  74143. /**
  74144. * Sets the shadow projection clipping minimum z value.
  74145. */
  74146. shadowMinZ: number;
  74147. private _shadowMaxZ;
  74148. /**
  74149. * Sets the shadow projection clipping maximum z value.
  74150. */
  74151. /**
  74152. * Gets the shadow projection clipping maximum z value.
  74153. */
  74154. shadowMaxZ: number;
  74155. /**
  74156. * Callback defining a custom Projection Matrix Builder.
  74157. * This can be used to override the default projection matrix computation.
  74158. */
  74159. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74160. /**
  74161. * The transformed position. Position of the light in world space taking parenting in account.
  74162. */
  74163. transformedPosition: Vector3;
  74164. /**
  74165. * The transformed direction. Direction of the light in world space taking parenting in account.
  74166. */
  74167. transformedDirection: Vector3;
  74168. private _needProjectionMatrixCompute;
  74169. /**
  74170. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74171. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74172. */
  74173. computeTransformedInformation(): boolean;
  74174. /**
  74175. * Return the depth scale used for the shadow map.
  74176. * @returns the depth scale.
  74177. */
  74178. getDepthScale(): number;
  74179. /**
  74180. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74181. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74182. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74183. */
  74184. getShadowDirection(faceIndex?: number): Vector3;
  74185. /**
  74186. * Returns the ShadowLight absolute position in the World.
  74187. * @returns the position vector in world space
  74188. */
  74189. getAbsolutePosition(): Vector3;
  74190. /**
  74191. * Sets the ShadowLight direction toward the passed target.
  74192. * @param target The point to target in local space
  74193. * @returns the updated ShadowLight direction
  74194. */
  74195. setDirectionToTarget(target: Vector3): Vector3;
  74196. /**
  74197. * Returns the light rotation in euler definition.
  74198. * @returns the x y z rotation in local space.
  74199. */
  74200. getRotation(): Vector3;
  74201. /**
  74202. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74203. * @returns true if a cube texture needs to be use
  74204. */
  74205. needCube(): boolean;
  74206. /**
  74207. * Detects if the projection matrix requires to be recomputed this frame.
  74208. * @returns true if it requires to be recomputed otherwise, false.
  74209. */
  74210. needProjectionMatrixCompute(): boolean;
  74211. /**
  74212. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74213. */
  74214. forceProjectionMatrixCompute(): void;
  74215. /** @hidden */
  74216. _initCache(): void;
  74217. /** @hidden */
  74218. _isSynchronized(): boolean;
  74219. /**
  74220. * Computes the world matrix of the node
  74221. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74222. * @returns the world matrix
  74223. */
  74224. computeWorldMatrix(force?: boolean): Matrix;
  74225. /**
  74226. * Gets the minZ used for shadow according to both the scene and the light.
  74227. * @param activeCamera The camera we are returning the min for
  74228. * @returns the depth min z
  74229. */
  74230. getDepthMinZ(activeCamera: Camera): number;
  74231. /**
  74232. * Gets the maxZ used for shadow according to both the scene and the light.
  74233. * @param activeCamera The camera we are returning the max for
  74234. * @returns the depth max z
  74235. */
  74236. getDepthMaxZ(activeCamera: Camera): number;
  74237. /**
  74238. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74239. * @param matrix The materix to updated with the projection information
  74240. * @param viewMatrix The transform matrix of the light
  74241. * @param renderList The list of mesh to render in the map
  74242. * @returns The current light
  74243. */
  74244. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74245. }
  74246. }
  74247. declare module BABYLON {
  74248. /**
  74249. * "Static Class" containing the most commonly used helper while dealing with material for
  74250. * rendering purpose.
  74251. *
  74252. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74253. *
  74254. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74255. */
  74256. export class MaterialHelper {
  74257. /**
  74258. * Bind the current view position to an effect.
  74259. * @param effect The effect to be bound
  74260. * @param scene The scene the eyes position is used from
  74261. */
  74262. static BindEyePosition(effect: Effect, scene: Scene): void;
  74263. /**
  74264. * Helps preparing the defines values about the UVs in used in the effect.
  74265. * UVs are shared as much as we can accross channels in the shaders.
  74266. * @param texture The texture we are preparing the UVs for
  74267. * @param defines The defines to update
  74268. * @param key The channel key "diffuse", "specular"... used in the shader
  74269. */
  74270. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74271. /**
  74272. * Binds a texture matrix value to its corrsponding uniform
  74273. * @param texture The texture to bind the matrix for
  74274. * @param uniformBuffer The uniform buffer receivin the data
  74275. * @param key The channel key "diffuse", "specular"... used in the shader
  74276. */
  74277. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74278. /**
  74279. * Gets the current status of the fog (should it be enabled?)
  74280. * @param mesh defines the mesh to evaluate for fog support
  74281. * @param scene defines the hosting scene
  74282. * @returns true if fog must be enabled
  74283. */
  74284. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74285. /**
  74286. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74287. * @param mesh defines the current mesh
  74288. * @param scene defines the current scene
  74289. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74290. * @param pointsCloud defines if point cloud rendering has to be turned on
  74291. * @param fogEnabled defines if fog has to be turned on
  74292. * @param alphaTest defines if alpha testing has to be turned on
  74293. * @param defines defines the current list of defines
  74294. */
  74295. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74296. /**
  74297. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74298. * @param scene defines the current scene
  74299. * @param engine defines the current engine
  74300. * @param defines specifies the list of active defines
  74301. * @param useInstances defines if instances have to be turned on
  74302. * @param useClipPlane defines if clip plane have to be turned on
  74303. */
  74304. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74305. /**
  74306. * Prepares the defines for bones
  74307. * @param mesh The mesh containing the geometry data we will draw
  74308. * @param defines The defines to update
  74309. */
  74310. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74311. /**
  74312. * Prepares the defines for morph targets
  74313. * @param mesh The mesh containing the geometry data we will draw
  74314. * @param defines The defines to update
  74315. */
  74316. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74317. /**
  74318. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74319. * @param mesh The mesh containing the geometry data we will draw
  74320. * @param defines The defines to update
  74321. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74322. * @param useBones Precise whether bones should be used or not (override mesh info)
  74323. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74324. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74325. * @returns false if defines are considered not dirty and have not been checked
  74326. */
  74327. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74328. /**
  74329. * Prepares the defines related to multiview
  74330. * @param scene The scene we are intending to draw
  74331. * @param defines The defines to update
  74332. */
  74333. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74334. /**
  74335. * Prepares the defines related to the light information passed in parameter
  74336. * @param scene The scene we are intending to draw
  74337. * @param mesh The mesh the effect is compiling for
  74338. * @param light The light the effect is compiling for
  74339. * @param lightIndex The index of the light
  74340. * @param defines The defines to update
  74341. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74342. * @param state Defines the current state regarding what is needed (normals, etc...)
  74343. */
  74344. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74345. needNormals: boolean;
  74346. needRebuild: boolean;
  74347. shadowEnabled: boolean;
  74348. specularEnabled: boolean;
  74349. lightmapMode: boolean;
  74350. }): void;
  74351. /**
  74352. * Prepares the defines related to the light information passed in parameter
  74353. * @param scene The scene we are intending to draw
  74354. * @param mesh The mesh the effect is compiling for
  74355. * @param defines The defines to update
  74356. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74357. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74358. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74359. * @returns true if normals will be required for the rest of the effect
  74360. */
  74361. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74362. /**
  74363. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74364. * @param lightIndex defines the light index
  74365. * @param uniformsList The uniform list
  74366. * @param samplersList The sampler list
  74367. * @param projectedLightTexture defines if projected texture must be used
  74368. * @param uniformBuffersList defines an optional list of uniform buffers
  74369. */
  74370. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74371. /**
  74372. * Prepares the uniforms and samplers list to be used in the effect
  74373. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74374. * @param samplersList The sampler list
  74375. * @param defines The defines helping in the list generation
  74376. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74377. */
  74378. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74379. /**
  74380. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74381. * @param defines The defines to update while falling back
  74382. * @param fallbacks The authorized effect fallbacks
  74383. * @param maxSimultaneousLights The maximum number of lights allowed
  74384. * @param rank the current rank of the Effect
  74385. * @returns The newly affected rank
  74386. */
  74387. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74388. private static _TmpMorphInfluencers;
  74389. /**
  74390. * Prepares the list of attributes required for morph targets according to the effect defines.
  74391. * @param attribs The current list of supported attribs
  74392. * @param mesh The mesh to prepare the morph targets attributes for
  74393. * @param influencers The number of influencers
  74394. */
  74395. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74396. /**
  74397. * Prepares the list of attributes required for morph targets according to the effect defines.
  74398. * @param attribs The current list of supported attribs
  74399. * @param mesh The mesh to prepare the morph targets attributes for
  74400. * @param defines The current Defines of the effect
  74401. */
  74402. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74403. /**
  74404. * Prepares the list of attributes required for bones according to the effect defines.
  74405. * @param attribs The current list of supported attribs
  74406. * @param mesh The mesh to prepare the bones attributes for
  74407. * @param defines The current Defines of the effect
  74408. * @param fallbacks The current efffect fallback strategy
  74409. */
  74410. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74411. /**
  74412. * Check and prepare the list of attributes required for instances according to the effect defines.
  74413. * @param attribs The current list of supported attribs
  74414. * @param defines The current MaterialDefines of the effect
  74415. */
  74416. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74417. /**
  74418. * Add the list of attributes required for instances to the attribs array.
  74419. * @param attribs The current list of supported attribs
  74420. */
  74421. static PushAttributesForInstances(attribs: string[]): void;
  74422. /**
  74423. * Binds the light shadow information to the effect for the given mesh.
  74424. * @param light The light containing the generator
  74425. * @param scene The scene the lights belongs to
  74426. * @param mesh The mesh we are binding the information to render
  74427. * @param lightIndex The light index in the effect used to render the mesh
  74428. * @param effect The effect we are binding the data to
  74429. */
  74430. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74431. /**
  74432. * Binds the light information to the effect.
  74433. * @param light The light containing the generator
  74434. * @param effect The effect we are binding the data to
  74435. * @param lightIndex The light index in the effect used to render
  74436. */
  74437. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74438. /**
  74439. * Binds the lights information from the scene to the effect for the given mesh.
  74440. * @param light Light to bind
  74441. * @param lightIndex Light index
  74442. * @param scene The scene where the light belongs to
  74443. * @param mesh The mesh we are binding the information to render
  74444. * @param effect The effect we are binding the data to
  74445. * @param useSpecular Defines if specular is supported
  74446. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74447. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74448. */
  74449. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74450. /**
  74451. * Binds the lights information from the scene to the effect for the given mesh.
  74452. * @param scene The scene the lights belongs to
  74453. * @param mesh The mesh we are binding the information to render
  74454. * @param effect The effect we are binding the data to
  74455. * @param defines The generated defines for the effect
  74456. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74457. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74458. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74459. */
  74460. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74461. private static _tempFogColor;
  74462. /**
  74463. * Binds the fog information from the scene to the effect for the given mesh.
  74464. * @param scene The scene the lights belongs to
  74465. * @param mesh The mesh we are binding the information to render
  74466. * @param effect The effect we are binding the data to
  74467. * @param linearSpace Defines if the fog effect is applied in linear space
  74468. */
  74469. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74470. /**
  74471. * Binds the bones information from the mesh to the effect.
  74472. * @param mesh The mesh we are binding the information to render
  74473. * @param effect The effect we are binding the data to
  74474. */
  74475. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74476. /**
  74477. * Binds the morph targets information from the mesh to the effect.
  74478. * @param abstractMesh The mesh we are binding the information to render
  74479. * @param effect The effect we are binding the data to
  74480. */
  74481. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74482. /**
  74483. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74484. * @param defines The generated defines used in the effect
  74485. * @param effect The effect we are binding the data to
  74486. * @param scene The scene we are willing to render with logarithmic scale for
  74487. */
  74488. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74489. /**
  74490. * Binds the clip plane information from the scene to the effect.
  74491. * @param scene The scene the clip plane information are extracted from
  74492. * @param effect The effect we are binding the data to
  74493. */
  74494. static BindClipPlane(effect: Effect, scene: Scene): void;
  74495. }
  74496. }
  74497. declare module BABYLON {
  74498. /** @hidden */
  74499. export var packingFunctions: {
  74500. name: string;
  74501. shader: string;
  74502. };
  74503. }
  74504. declare module BABYLON {
  74505. /** @hidden */
  74506. export var shadowMapPixelShader: {
  74507. name: string;
  74508. shader: string;
  74509. };
  74510. }
  74511. declare module BABYLON {
  74512. /** @hidden */
  74513. export var bonesDeclaration: {
  74514. name: string;
  74515. shader: string;
  74516. };
  74517. }
  74518. declare module BABYLON {
  74519. /** @hidden */
  74520. export var morphTargetsVertexGlobalDeclaration: {
  74521. name: string;
  74522. shader: string;
  74523. };
  74524. }
  74525. declare module BABYLON {
  74526. /** @hidden */
  74527. export var morphTargetsVertexDeclaration: {
  74528. name: string;
  74529. shader: string;
  74530. };
  74531. }
  74532. declare module BABYLON {
  74533. /** @hidden */
  74534. export var instancesDeclaration: {
  74535. name: string;
  74536. shader: string;
  74537. };
  74538. }
  74539. declare module BABYLON {
  74540. /** @hidden */
  74541. export var helperFunctions: {
  74542. name: string;
  74543. shader: string;
  74544. };
  74545. }
  74546. declare module BABYLON {
  74547. /** @hidden */
  74548. export var morphTargetsVertex: {
  74549. name: string;
  74550. shader: string;
  74551. };
  74552. }
  74553. declare module BABYLON {
  74554. /** @hidden */
  74555. export var instancesVertex: {
  74556. name: string;
  74557. shader: string;
  74558. };
  74559. }
  74560. declare module BABYLON {
  74561. /** @hidden */
  74562. export var bonesVertex: {
  74563. name: string;
  74564. shader: string;
  74565. };
  74566. }
  74567. declare module BABYLON {
  74568. /** @hidden */
  74569. export var shadowMapVertexShader: {
  74570. name: string;
  74571. shader: string;
  74572. };
  74573. }
  74574. declare module BABYLON {
  74575. /** @hidden */
  74576. export var depthBoxBlurPixelShader: {
  74577. name: string;
  74578. shader: string;
  74579. };
  74580. }
  74581. declare module BABYLON {
  74582. /**
  74583. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74584. */
  74585. export interface ICustomShaderOptions {
  74586. /**
  74587. * Gets or sets the custom shader name to use
  74588. */
  74589. shaderName: string;
  74590. /**
  74591. * The list of attribute names used in the shader
  74592. */
  74593. attributes?: string[];
  74594. /**
  74595. * The list of unifrom names used in the shader
  74596. */
  74597. uniforms?: string[];
  74598. /**
  74599. * The list of sampler names used in the shader
  74600. */
  74601. samplers?: string[];
  74602. /**
  74603. * The list of defines used in the shader
  74604. */
  74605. defines?: string[];
  74606. }
  74607. /**
  74608. * Interface to implement to create a shadow generator compatible with BJS.
  74609. */
  74610. export interface IShadowGenerator {
  74611. /**
  74612. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74613. * @returns The render target texture if present otherwise, null
  74614. */
  74615. getShadowMap(): Nullable<RenderTargetTexture>;
  74616. /**
  74617. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74618. * @returns The render target texture if the shadow map is present otherwise, null
  74619. */
  74620. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74621. /**
  74622. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74623. * @param subMesh The submesh we want to render in the shadow map
  74624. * @param useInstances Defines wether will draw in the map using instances
  74625. * @returns true if ready otherwise, false
  74626. */
  74627. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74628. /**
  74629. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74630. * @param defines Defines of the material we want to update
  74631. * @param lightIndex Index of the light in the enabled light list of the material
  74632. */
  74633. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74634. /**
  74635. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74636. * defined in the generator but impacting the effect).
  74637. * It implies the unifroms available on the materials are the standard BJS ones.
  74638. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74639. * @param effect The effect we are binfing the information for
  74640. */
  74641. bindShadowLight(lightIndex: string, effect: Effect): void;
  74642. /**
  74643. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74644. * (eq to shadow prjection matrix * light transform matrix)
  74645. * @returns The transform matrix used to create the shadow map
  74646. */
  74647. getTransformMatrix(): Matrix;
  74648. /**
  74649. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74650. * Cube and 2D textures for instance.
  74651. */
  74652. recreateShadowMap(): void;
  74653. /**
  74654. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74655. * @param onCompiled Callback triggered at the and of the effects compilation
  74656. * @param options Sets of optional options forcing the compilation with different modes
  74657. */
  74658. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74659. useInstances: boolean;
  74660. }>): void;
  74661. /**
  74662. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74663. * @param options Sets of optional options forcing the compilation with different modes
  74664. * @returns A promise that resolves when the compilation completes
  74665. */
  74666. forceCompilationAsync(options?: Partial<{
  74667. useInstances: boolean;
  74668. }>): Promise<void>;
  74669. /**
  74670. * Serializes the shadow generator setup to a json object.
  74671. * @returns The serialized JSON object
  74672. */
  74673. serialize(): any;
  74674. /**
  74675. * Disposes the Shadow map and related Textures and effects.
  74676. */
  74677. dispose(): void;
  74678. }
  74679. /**
  74680. * Default implementation IShadowGenerator.
  74681. * This is the main object responsible of generating shadows in the framework.
  74682. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74683. */
  74684. export class ShadowGenerator implements IShadowGenerator {
  74685. /**
  74686. * Shadow generator mode None: no filtering applied.
  74687. */
  74688. static readonly FILTER_NONE: number;
  74689. /**
  74690. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74691. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74692. */
  74693. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74694. /**
  74695. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74696. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74697. */
  74698. static readonly FILTER_POISSONSAMPLING: number;
  74699. /**
  74700. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74702. */
  74703. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74704. /**
  74705. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74706. * edge artifacts on steep falloff.
  74707. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74708. */
  74709. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74710. /**
  74711. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74712. * edge artifacts on steep falloff.
  74713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74714. */
  74715. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74716. /**
  74717. * Shadow generator mode PCF: Percentage Closer Filtering
  74718. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74719. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74720. */
  74721. static readonly FILTER_PCF: number;
  74722. /**
  74723. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74724. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74725. * Contact Hardening
  74726. */
  74727. static readonly FILTER_PCSS: number;
  74728. /**
  74729. * Reserved for PCF and PCSS
  74730. * Highest Quality.
  74731. *
  74732. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74733. *
  74734. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74735. */
  74736. static readonly QUALITY_HIGH: number;
  74737. /**
  74738. * Reserved for PCF and PCSS
  74739. * Good tradeoff for quality/perf cross devices
  74740. *
  74741. * Execute PCF on a 3*3 kernel.
  74742. *
  74743. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74744. */
  74745. static readonly QUALITY_MEDIUM: number;
  74746. /**
  74747. * Reserved for PCF and PCSS
  74748. * The lowest quality but the fastest.
  74749. *
  74750. * Execute PCF on a 1*1 kernel.
  74751. *
  74752. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74753. */
  74754. static readonly QUALITY_LOW: number;
  74755. /** Gets or sets the custom shader name to use */
  74756. customShaderOptions: ICustomShaderOptions;
  74757. /**
  74758. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74759. */
  74760. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74761. /**
  74762. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74763. */
  74764. onAfterShadowMapRenderObservable: Observable<Effect>;
  74765. /**
  74766. * Observable triggered before a mesh is rendered in the shadow map.
  74767. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74768. */
  74769. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74770. /**
  74771. * Observable triggered after a mesh is rendered in the shadow map.
  74772. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74773. */
  74774. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74775. private _bias;
  74776. /**
  74777. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74778. */
  74779. /**
  74780. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74781. */
  74782. bias: number;
  74783. private _normalBias;
  74784. /**
  74785. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74786. */
  74787. /**
  74788. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74789. */
  74790. normalBias: number;
  74791. private _blurBoxOffset;
  74792. /**
  74793. * Gets the blur box offset: offset applied during the blur pass.
  74794. * Only useful if useKernelBlur = false
  74795. */
  74796. /**
  74797. * Sets the blur box offset: offset applied during the blur pass.
  74798. * Only useful if useKernelBlur = false
  74799. */
  74800. blurBoxOffset: number;
  74801. private _blurScale;
  74802. /**
  74803. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74804. * 2 means half of the size.
  74805. */
  74806. /**
  74807. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74808. * 2 means half of the size.
  74809. */
  74810. blurScale: number;
  74811. private _blurKernel;
  74812. /**
  74813. * Gets the blur kernel: kernel size of the blur pass.
  74814. * Only useful if useKernelBlur = true
  74815. */
  74816. /**
  74817. * Sets the blur kernel: kernel size of the blur pass.
  74818. * Only useful if useKernelBlur = true
  74819. */
  74820. blurKernel: number;
  74821. private _useKernelBlur;
  74822. /**
  74823. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74824. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74825. */
  74826. /**
  74827. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74828. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74829. */
  74830. useKernelBlur: boolean;
  74831. private _depthScale;
  74832. /**
  74833. * Gets the depth scale used in ESM mode.
  74834. */
  74835. /**
  74836. * Sets the depth scale used in ESM mode.
  74837. * This can override the scale stored on the light.
  74838. */
  74839. depthScale: number;
  74840. private _filter;
  74841. /**
  74842. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74843. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74844. */
  74845. /**
  74846. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74847. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74848. */
  74849. filter: number;
  74850. /**
  74851. * Gets if the current filter is set to Poisson Sampling.
  74852. */
  74853. /**
  74854. * Sets the current filter to Poisson Sampling.
  74855. */
  74856. usePoissonSampling: boolean;
  74857. /**
  74858. * Gets if the current filter is set to ESM.
  74859. */
  74860. /**
  74861. * Sets the current filter is to ESM.
  74862. */
  74863. useExponentialShadowMap: boolean;
  74864. /**
  74865. * Gets if the current filter is set to filtered ESM.
  74866. */
  74867. /**
  74868. * Gets if the current filter is set to filtered ESM.
  74869. */
  74870. useBlurExponentialShadowMap: boolean;
  74871. /**
  74872. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74873. * exponential to prevent steep falloff artifacts).
  74874. */
  74875. /**
  74876. * Sets the current filter to "close ESM" (using the inverse of the
  74877. * exponential to prevent steep falloff artifacts).
  74878. */
  74879. useCloseExponentialShadowMap: boolean;
  74880. /**
  74881. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74882. * exponential to prevent steep falloff artifacts).
  74883. */
  74884. /**
  74885. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74886. * exponential to prevent steep falloff artifacts).
  74887. */
  74888. useBlurCloseExponentialShadowMap: boolean;
  74889. /**
  74890. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74891. */
  74892. /**
  74893. * Sets the current filter to "PCF" (percentage closer filtering).
  74894. */
  74895. usePercentageCloserFiltering: boolean;
  74896. private _filteringQuality;
  74897. /**
  74898. * Gets the PCF or PCSS Quality.
  74899. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74900. */
  74901. /**
  74902. * Sets the PCF or PCSS Quality.
  74903. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74904. */
  74905. filteringQuality: number;
  74906. /**
  74907. * Gets if the current filter is set to "PCSS" (contact hardening).
  74908. */
  74909. /**
  74910. * Sets the current filter to "PCSS" (contact hardening).
  74911. */
  74912. useContactHardeningShadow: boolean;
  74913. private _contactHardeningLightSizeUVRatio;
  74914. /**
  74915. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74916. * Using a ratio helps keeping shape stability independently of the map size.
  74917. *
  74918. * It does not account for the light projection as it was having too much
  74919. * instability during the light setup or during light position changes.
  74920. *
  74921. * Only valid if useContactHardeningShadow is true.
  74922. */
  74923. /**
  74924. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74925. * Using a ratio helps keeping shape stability independently of the map size.
  74926. *
  74927. * It does not account for the light projection as it was having too much
  74928. * instability during the light setup or during light position changes.
  74929. *
  74930. * Only valid if useContactHardeningShadow is true.
  74931. */
  74932. contactHardeningLightSizeUVRatio: number;
  74933. private _darkness;
  74934. /** Gets or sets the actual darkness of a shadow */
  74935. darkness: number;
  74936. /**
  74937. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74938. * 0 means strongest and 1 would means no shadow.
  74939. * @returns the darkness.
  74940. */
  74941. getDarkness(): number;
  74942. /**
  74943. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74944. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74945. * @returns the shadow generator allowing fluent coding.
  74946. */
  74947. setDarkness(darkness: number): ShadowGenerator;
  74948. private _transparencyShadow;
  74949. /** Gets or sets the ability to have transparent shadow */
  74950. transparencyShadow: boolean;
  74951. /**
  74952. * Sets the ability to have transparent shadow (boolean).
  74953. * @param transparent True if transparent else False
  74954. * @returns the shadow generator allowing fluent coding
  74955. */
  74956. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74957. private _shadowMap;
  74958. private _shadowMap2;
  74959. /**
  74960. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74961. * @returns The render target texture if present otherwise, null
  74962. */
  74963. getShadowMap(): Nullable<RenderTargetTexture>;
  74964. /**
  74965. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74966. * @returns The render target texture if the shadow map is present otherwise, null
  74967. */
  74968. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74969. /**
  74970. * Gets the class name of that object
  74971. * @returns "ShadowGenerator"
  74972. */
  74973. getClassName(): string;
  74974. /**
  74975. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74976. * @param mesh Mesh to add
  74977. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74978. * @returns the Shadow Generator itself
  74979. */
  74980. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74981. /**
  74982. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74983. * @param mesh Mesh to remove
  74984. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74985. * @returns the Shadow Generator itself
  74986. */
  74987. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74988. /**
  74989. * Controls the extent to which the shadows fade out at the edge of the frustum
  74990. * Used only by directionals and spots
  74991. */
  74992. frustumEdgeFalloff: number;
  74993. private _light;
  74994. /**
  74995. * Returns the associated light object.
  74996. * @returns the light generating the shadow
  74997. */
  74998. getLight(): IShadowLight;
  74999. /**
  75000. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75001. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75002. * It might on the other hand introduce peter panning.
  75003. */
  75004. forceBackFacesOnly: boolean;
  75005. private _scene;
  75006. private _lightDirection;
  75007. private _effect;
  75008. private _viewMatrix;
  75009. private _projectionMatrix;
  75010. private _transformMatrix;
  75011. private _cachedPosition;
  75012. private _cachedDirection;
  75013. private _cachedDefines;
  75014. private _currentRenderID;
  75015. private _boxBlurPostprocess;
  75016. private _kernelBlurXPostprocess;
  75017. private _kernelBlurYPostprocess;
  75018. private _blurPostProcesses;
  75019. private _mapSize;
  75020. private _currentFaceIndex;
  75021. private _currentFaceIndexCache;
  75022. private _textureType;
  75023. private _defaultTextureMatrix;
  75024. /** @hidden */
  75025. static _SceneComponentInitialization: (scene: Scene) => void;
  75026. /**
  75027. * Creates a ShadowGenerator object.
  75028. * A ShadowGenerator is the required tool to use the shadows.
  75029. * Each light casting shadows needs to use its own ShadowGenerator.
  75030. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75031. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75032. * @param light The light object generating the shadows.
  75033. * @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.
  75034. */
  75035. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75036. private _initializeGenerator;
  75037. private _initializeShadowMap;
  75038. private _initializeBlurRTTAndPostProcesses;
  75039. private _renderForShadowMap;
  75040. private _renderSubMeshForShadowMap;
  75041. private _applyFilterValues;
  75042. /**
  75043. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75044. * @param onCompiled Callback triggered at the and of the effects compilation
  75045. * @param options Sets of optional options forcing the compilation with different modes
  75046. */
  75047. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75048. useInstances: boolean;
  75049. }>): void;
  75050. /**
  75051. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75052. * @param options Sets of optional options forcing the compilation with different modes
  75053. * @returns A promise that resolves when the compilation completes
  75054. */
  75055. forceCompilationAsync(options?: Partial<{
  75056. useInstances: boolean;
  75057. }>): Promise<void>;
  75058. /**
  75059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75060. * @param subMesh The submesh we want to render in the shadow map
  75061. * @param useInstances Defines wether will draw in the map using instances
  75062. * @returns true if ready otherwise, false
  75063. */
  75064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75065. /**
  75066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75067. * @param defines Defines of the material we want to update
  75068. * @param lightIndex Index of the light in the enabled light list of the material
  75069. */
  75070. prepareDefines(defines: any, lightIndex: number): void;
  75071. /**
  75072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75073. * defined in the generator but impacting the effect).
  75074. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75075. * @param effect The effect we are binfing the information for
  75076. */
  75077. bindShadowLight(lightIndex: string, effect: Effect): void;
  75078. /**
  75079. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75080. * (eq to shadow prjection matrix * light transform matrix)
  75081. * @returns The transform matrix used to create the shadow map
  75082. */
  75083. getTransformMatrix(): Matrix;
  75084. /**
  75085. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75086. * Cube and 2D textures for instance.
  75087. */
  75088. recreateShadowMap(): void;
  75089. private _disposeBlurPostProcesses;
  75090. private _disposeRTTandPostProcesses;
  75091. /**
  75092. * Disposes the ShadowGenerator.
  75093. * Returns nothing.
  75094. */
  75095. dispose(): void;
  75096. /**
  75097. * Serializes the shadow generator setup to a json object.
  75098. * @returns The serialized JSON object
  75099. */
  75100. serialize(): any;
  75101. /**
  75102. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75103. * @param parsedShadowGenerator The JSON object to parse
  75104. * @param scene The scene to create the shadow map for
  75105. * @returns The parsed shadow generator
  75106. */
  75107. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75108. }
  75109. }
  75110. declare module BABYLON {
  75111. /**
  75112. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75113. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75114. * 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.
  75115. */
  75116. export abstract class Light extends Node {
  75117. /**
  75118. * Falloff Default: light is falling off following the material specification:
  75119. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75120. */
  75121. static readonly FALLOFF_DEFAULT: number;
  75122. /**
  75123. * Falloff Physical: light is falling off following the inverse squared distance law.
  75124. */
  75125. static readonly FALLOFF_PHYSICAL: number;
  75126. /**
  75127. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75128. * to enhance interoperability with other engines.
  75129. */
  75130. static readonly FALLOFF_GLTF: number;
  75131. /**
  75132. * Falloff Standard: light is falling off like in the standard material
  75133. * to enhance interoperability with other materials.
  75134. */
  75135. static readonly FALLOFF_STANDARD: number;
  75136. /**
  75137. * If every light affecting the material is in this lightmapMode,
  75138. * material.lightmapTexture adds or multiplies
  75139. * (depends on material.useLightmapAsShadowmap)
  75140. * after every other light calculations.
  75141. */
  75142. static readonly LIGHTMAP_DEFAULT: number;
  75143. /**
  75144. * material.lightmapTexture as only diffuse lighting from this light
  75145. * adds only specular lighting from this light
  75146. * adds dynamic shadows
  75147. */
  75148. static readonly LIGHTMAP_SPECULAR: number;
  75149. /**
  75150. * material.lightmapTexture as only lighting
  75151. * no light calculation from this light
  75152. * only adds dynamic shadows from this light
  75153. */
  75154. static readonly LIGHTMAP_SHADOWSONLY: number;
  75155. /**
  75156. * Each light type uses the default quantity according to its type:
  75157. * point/spot lights use luminous intensity
  75158. * directional lights use illuminance
  75159. */
  75160. static readonly INTENSITYMODE_AUTOMATIC: number;
  75161. /**
  75162. * lumen (lm)
  75163. */
  75164. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75165. /**
  75166. * candela (lm/sr)
  75167. */
  75168. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75169. /**
  75170. * lux (lm/m^2)
  75171. */
  75172. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75173. /**
  75174. * nit (cd/m^2)
  75175. */
  75176. static readonly INTENSITYMODE_LUMINANCE: number;
  75177. /**
  75178. * Light type const id of the point light.
  75179. */
  75180. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75181. /**
  75182. * Light type const id of the directional light.
  75183. */
  75184. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75185. /**
  75186. * Light type const id of the spot light.
  75187. */
  75188. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75189. /**
  75190. * Light type const id of the hemispheric light.
  75191. */
  75192. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75193. /**
  75194. * Diffuse gives the basic color to an object.
  75195. */
  75196. diffuse: Color3;
  75197. /**
  75198. * Specular produces a highlight color on an object.
  75199. * Note: This is note affecting PBR materials.
  75200. */
  75201. specular: Color3;
  75202. /**
  75203. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75204. * falling off base on range or angle.
  75205. * This can be set to any values in Light.FALLOFF_x.
  75206. *
  75207. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75208. * other types of materials.
  75209. */
  75210. falloffType: number;
  75211. /**
  75212. * Strength of the light.
  75213. * Note: By default it is define in the framework own unit.
  75214. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75215. */
  75216. intensity: number;
  75217. private _range;
  75218. protected _inverseSquaredRange: number;
  75219. /**
  75220. * Defines how far from the source the light is impacting in scene units.
  75221. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75222. */
  75223. /**
  75224. * Defines how far from the source the light is impacting in scene units.
  75225. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75226. */
  75227. range: number;
  75228. /**
  75229. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75230. * of light.
  75231. */
  75232. private _photometricScale;
  75233. private _intensityMode;
  75234. /**
  75235. * Gets the photometric scale used to interpret the intensity.
  75236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75237. */
  75238. /**
  75239. * Sets the photometric scale used to interpret the intensity.
  75240. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75241. */
  75242. intensityMode: number;
  75243. private _radius;
  75244. /**
  75245. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75246. */
  75247. /**
  75248. * sets the light radius used by PBR Materials to simulate soft area lights.
  75249. */
  75250. radius: number;
  75251. private _renderPriority;
  75252. /**
  75253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75254. * exceeding the number allowed of the materials.
  75255. */
  75256. renderPriority: number;
  75257. private _shadowEnabled;
  75258. /**
  75259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75260. * the current shadow generator.
  75261. */
  75262. /**
  75263. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75264. * the current shadow generator.
  75265. */
  75266. shadowEnabled: boolean;
  75267. private _includedOnlyMeshes;
  75268. /**
  75269. * Gets the only meshes impacted by this light.
  75270. */
  75271. /**
  75272. * Sets the only meshes impacted by this light.
  75273. */
  75274. includedOnlyMeshes: AbstractMesh[];
  75275. private _excludedMeshes;
  75276. /**
  75277. * Gets the meshes not impacted by this light.
  75278. */
  75279. /**
  75280. * Sets the meshes not impacted by this light.
  75281. */
  75282. excludedMeshes: AbstractMesh[];
  75283. private _excludeWithLayerMask;
  75284. /**
  75285. * Gets the layer id use to find what meshes are not impacted by the light.
  75286. * Inactive if 0
  75287. */
  75288. /**
  75289. * Sets the layer id use to find what meshes are not impacted by the light.
  75290. * Inactive if 0
  75291. */
  75292. excludeWithLayerMask: number;
  75293. private _includeOnlyWithLayerMask;
  75294. /**
  75295. * Gets the layer id use to find what meshes are impacted by the light.
  75296. * Inactive if 0
  75297. */
  75298. /**
  75299. * Sets the layer id use to find what meshes are impacted by the light.
  75300. * Inactive if 0
  75301. */
  75302. includeOnlyWithLayerMask: number;
  75303. private _lightmapMode;
  75304. /**
  75305. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75306. */
  75307. /**
  75308. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75309. */
  75310. lightmapMode: number;
  75311. /**
  75312. * Shadow generator associted to the light.
  75313. * @hidden Internal use only.
  75314. */
  75315. _shadowGenerator: Nullable<IShadowGenerator>;
  75316. /**
  75317. * @hidden Internal use only.
  75318. */
  75319. _excludedMeshesIds: string[];
  75320. /**
  75321. * @hidden Internal use only.
  75322. */
  75323. _includedOnlyMeshesIds: string[];
  75324. /**
  75325. * The current light unifom buffer.
  75326. * @hidden Internal use only.
  75327. */
  75328. _uniformBuffer: UniformBuffer;
  75329. /**
  75330. * Creates a Light object in the scene.
  75331. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75332. * @param name The firendly name of the light
  75333. * @param scene The scene the light belongs too
  75334. */
  75335. constructor(name: string, scene: Scene);
  75336. protected abstract _buildUniformLayout(): void;
  75337. /**
  75338. * Sets the passed Effect "effect" with the Light information.
  75339. * @param effect The effect to update
  75340. * @param lightIndex The index of the light in the effect to update
  75341. * @returns The light
  75342. */
  75343. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75344. /**
  75345. * Sets the passed Effect "effect" with the Light information.
  75346. * @param effect The effect to update
  75347. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75348. * @returns The light
  75349. */
  75350. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75351. /**
  75352. * Returns the string "Light".
  75353. * @returns the class name
  75354. */
  75355. getClassName(): string;
  75356. /** @hidden */
  75357. readonly _isLight: boolean;
  75358. /**
  75359. * Converts the light information to a readable string for debug purpose.
  75360. * @param fullDetails Supports for multiple levels of logging within scene loading
  75361. * @returns the human readable light info
  75362. */
  75363. toString(fullDetails?: boolean): string;
  75364. /** @hidden */
  75365. protected _syncParentEnabledState(): void;
  75366. /**
  75367. * Set the enabled state of this node.
  75368. * @param value - the new enabled state
  75369. */
  75370. setEnabled(value: boolean): void;
  75371. /**
  75372. * Returns the Light associated shadow generator if any.
  75373. * @return the associated shadow generator.
  75374. */
  75375. getShadowGenerator(): Nullable<IShadowGenerator>;
  75376. /**
  75377. * Returns a Vector3, the absolute light position in the World.
  75378. * @returns the world space position of the light
  75379. */
  75380. getAbsolutePosition(): Vector3;
  75381. /**
  75382. * Specifies if the light will affect the passed mesh.
  75383. * @param mesh The mesh to test against the light
  75384. * @return true the mesh is affected otherwise, false.
  75385. */
  75386. canAffectMesh(mesh: AbstractMesh): boolean;
  75387. /**
  75388. * Sort function to order lights for rendering.
  75389. * @param a First Light object to compare to second.
  75390. * @param b Second Light object to compare first.
  75391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75392. */
  75393. static CompareLightsPriority(a: Light, b: Light): number;
  75394. /**
  75395. * Releases resources associated with this node.
  75396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75398. */
  75399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75400. /**
  75401. * Returns the light type ID (integer).
  75402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75403. */
  75404. getTypeID(): number;
  75405. /**
  75406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75407. * @returns the scaled intensity in intensity mode unit
  75408. */
  75409. getScaledIntensity(): number;
  75410. /**
  75411. * Returns a new Light object, named "name", from the current one.
  75412. * @param name The name of the cloned light
  75413. * @returns the new created light
  75414. */
  75415. clone(name: string): Nullable<Light>;
  75416. /**
  75417. * Serializes the current light into a Serialization object.
  75418. * @returns the serialized object.
  75419. */
  75420. serialize(): any;
  75421. /**
  75422. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75423. * This new light is named "name" and added to the passed scene.
  75424. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75425. * @param name The friendly name of the light
  75426. * @param scene The scene the new light will belong to
  75427. * @returns the constructor function
  75428. */
  75429. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75430. /**
  75431. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75432. * @param parsedLight The JSON representation of the light
  75433. * @param scene The scene to create the parsed light in
  75434. * @returns the created light after parsing
  75435. */
  75436. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75437. private _hookArrayForExcluded;
  75438. private _hookArrayForIncludedOnly;
  75439. private _resyncMeshes;
  75440. /**
  75441. * Forces the meshes to update their light related information in their rendering used effects
  75442. * @hidden Internal Use Only
  75443. */
  75444. _markMeshesAsLightDirty(): void;
  75445. /**
  75446. * Recomputes the cached photometric scale if needed.
  75447. */
  75448. private _computePhotometricScale;
  75449. /**
  75450. * Returns the Photometric Scale according to the light type and intensity mode.
  75451. */
  75452. private _getPhotometricScale;
  75453. /**
  75454. * Reorder the light in the scene according to their defined priority.
  75455. * @hidden Internal Use Only
  75456. */
  75457. _reorderLightsInScene(): void;
  75458. /**
  75459. * Prepares the list of defines specific to the light type.
  75460. * @param defines the list of defines
  75461. * @param lightIndex defines the index of the light for the effect
  75462. */
  75463. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75464. }
  75465. }
  75466. declare module BABYLON {
  75467. /**
  75468. * Interface used to define Action
  75469. */
  75470. export interface IAction {
  75471. /**
  75472. * Trigger for the action
  75473. */
  75474. trigger: number;
  75475. /** Options of the trigger */
  75476. triggerOptions: any;
  75477. /**
  75478. * Gets the trigger parameters
  75479. * @returns the trigger parameters
  75480. */
  75481. getTriggerParameter(): any;
  75482. /**
  75483. * Internal only - executes current action event
  75484. * @hidden
  75485. */
  75486. _executeCurrent(evt?: ActionEvent): void;
  75487. /**
  75488. * Serialize placeholder for child classes
  75489. * @param parent of child
  75490. * @returns the serialized object
  75491. */
  75492. serialize(parent: any): any;
  75493. /**
  75494. * Internal only
  75495. * @hidden
  75496. */
  75497. _prepare(): void;
  75498. /**
  75499. * Internal only - manager for action
  75500. * @hidden
  75501. */
  75502. _actionManager: AbstractActionManager;
  75503. /**
  75504. * Adds action to chain of actions, may be a DoNothingAction
  75505. * @param action defines the next action to execute
  75506. * @returns The action passed in
  75507. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75508. */
  75509. then(action: IAction): IAction;
  75510. }
  75511. /**
  75512. * The action to be carried out following a trigger
  75513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75514. */
  75515. export class Action implements IAction {
  75516. /** the trigger, with or without parameters, for the action */
  75517. triggerOptions: any;
  75518. /**
  75519. * Trigger for the action
  75520. */
  75521. trigger: number;
  75522. /**
  75523. * Internal only - manager for action
  75524. * @hidden
  75525. */
  75526. _actionManager: ActionManager;
  75527. private _nextActiveAction;
  75528. private _child;
  75529. private _condition?;
  75530. private _triggerParameter;
  75531. /**
  75532. * An event triggered prior to action being executed.
  75533. */
  75534. onBeforeExecuteObservable: Observable<Action>;
  75535. /**
  75536. * Creates a new Action
  75537. * @param triggerOptions the trigger, with or without parameters, for the action
  75538. * @param condition an optional determinant of action
  75539. */
  75540. constructor(
  75541. /** the trigger, with or without parameters, for the action */
  75542. triggerOptions: any, condition?: Condition);
  75543. /**
  75544. * Internal only
  75545. * @hidden
  75546. */
  75547. _prepare(): void;
  75548. /**
  75549. * Gets the trigger parameters
  75550. * @returns the trigger parameters
  75551. */
  75552. getTriggerParameter(): any;
  75553. /**
  75554. * Internal only - executes current action event
  75555. * @hidden
  75556. */
  75557. _executeCurrent(evt?: ActionEvent): void;
  75558. /**
  75559. * Execute placeholder for child classes
  75560. * @param evt optional action event
  75561. */
  75562. execute(evt?: ActionEvent): void;
  75563. /**
  75564. * Skips to next active action
  75565. */
  75566. skipToNextActiveAction(): void;
  75567. /**
  75568. * Adds action to chain of actions, may be a DoNothingAction
  75569. * @param action defines the next action to execute
  75570. * @returns The action passed in
  75571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75572. */
  75573. then(action: Action): Action;
  75574. /**
  75575. * Internal only
  75576. * @hidden
  75577. */
  75578. _getProperty(propertyPath: string): string;
  75579. /**
  75580. * Internal only
  75581. * @hidden
  75582. */
  75583. _getEffectiveTarget(target: any, propertyPath: string): any;
  75584. /**
  75585. * Serialize placeholder for child classes
  75586. * @param parent of child
  75587. * @returns the serialized object
  75588. */
  75589. serialize(parent: any): any;
  75590. /**
  75591. * Internal only called by serialize
  75592. * @hidden
  75593. */
  75594. protected _serialize(serializedAction: any, parent?: any): any;
  75595. /**
  75596. * Internal only
  75597. * @hidden
  75598. */
  75599. static _SerializeValueAsString: (value: any) => string;
  75600. /**
  75601. * Internal only
  75602. * @hidden
  75603. */
  75604. static _GetTargetProperty: (target: Node | Scene) => {
  75605. name: string;
  75606. targetType: string;
  75607. value: string;
  75608. };
  75609. }
  75610. }
  75611. declare module BABYLON {
  75612. /**
  75613. * A Condition applied to an Action
  75614. */
  75615. export class Condition {
  75616. /**
  75617. * Internal only - manager for action
  75618. * @hidden
  75619. */
  75620. _actionManager: ActionManager;
  75621. /**
  75622. * Internal only
  75623. * @hidden
  75624. */
  75625. _evaluationId: number;
  75626. /**
  75627. * Internal only
  75628. * @hidden
  75629. */
  75630. _currentResult: boolean;
  75631. /**
  75632. * Creates a new Condition
  75633. * @param actionManager the manager of the action the condition is applied to
  75634. */
  75635. constructor(actionManager: ActionManager);
  75636. /**
  75637. * Check if the current condition is valid
  75638. * @returns a boolean
  75639. */
  75640. isValid(): boolean;
  75641. /**
  75642. * Internal only
  75643. * @hidden
  75644. */
  75645. _getProperty(propertyPath: string): string;
  75646. /**
  75647. * Internal only
  75648. * @hidden
  75649. */
  75650. _getEffectiveTarget(target: any, propertyPath: string): any;
  75651. /**
  75652. * Serialize placeholder for child classes
  75653. * @returns the serialized object
  75654. */
  75655. serialize(): any;
  75656. /**
  75657. * Internal only
  75658. * @hidden
  75659. */
  75660. protected _serialize(serializedCondition: any): any;
  75661. }
  75662. /**
  75663. * Defines specific conditional operators as extensions of Condition
  75664. */
  75665. export class ValueCondition extends Condition {
  75666. /** path to specify the property of the target the conditional operator uses */
  75667. propertyPath: string;
  75668. /** the value compared by the conditional operator against the current value of the property */
  75669. value: any;
  75670. /** the conditional operator, default ValueCondition.IsEqual */
  75671. operator: number;
  75672. /**
  75673. * Internal only
  75674. * @hidden
  75675. */
  75676. private static _IsEqual;
  75677. /**
  75678. * Internal only
  75679. * @hidden
  75680. */
  75681. private static _IsDifferent;
  75682. /**
  75683. * Internal only
  75684. * @hidden
  75685. */
  75686. private static _IsGreater;
  75687. /**
  75688. * Internal only
  75689. * @hidden
  75690. */
  75691. private static _IsLesser;
  75692. /**
  75693. * returns the number for IsEqual
  75694. */
  75695. static readonly IsEqual: number;
  75696. /**
  75697. * Returns the number for IsDifferent
  75698. */
  75699. static readonly IsDifferent: number;
  75700. /**
  75701. * Returns the number for IsGreater
  75702. */
  75703. static readonly IsGreater: number;
  75704. /**
  75705. * Returns the number for IsLesser
  75706. */
  75707. static readonly IsLesser: number;
  75708. /**
  75709. * Internal only The action manager for the condition
  75710. * @hidden
  75711. */
  75712. _actionManager: ActionManager;
  75713. /**
  75714. * Internal only
  75715. * @hidden
  75716. */
  75717. private _target;
  75718. /**
  75719. * Internal only
  75720. * @hidden
  75721. */
  75722. private _effectiveTarget;
  75723. /**
  75724. * Internal only
  75725. * @hidden
  75726. */
  75727. private _property;
  75728. /**
  75729. * Creates a new ValueCondition
  75730. * @param actionManager manager for the action the condition applies to
  75731. * @param target for the action
  75732. * @param propertyPath path to specify the property of the target the conditional operator uses
  75733. * @param value the value compared by the conditional operator against the current value of the property
  75734. * @param operator the conditional operator, default ValueCondition.IsEqual
  75735. */
  75736. constructor(actionManager: ActionManager, target: any,
  75737. /** path to specify the property of the target the conditional operator uses */
  75738. propertyPath: string,
  75739. /** the value compared by the conditional operator against the current value of the property */
  75740. value: any,
  75741. /** the conditional operator, default ValueCondition.IsEqual */
  75742. operator?: number);
  75743. /**
  75744. * Compares the given value with the property value for the specified conditional operator
  75745. * @returns the result of the comparison
  75746. */
  75747. isValid(): boolean;
  75748. /**
  75749. * Serialize the ValueCondition into a JSON compatible object
  75750. * @returns serialization object
  75751. */
  75752. serialize(): any;
  75753. /**
  75754. * Gets the name of the conditional operator for the ValueCondition
  75755. * @param operator the conditional operator
  75756. * @returns the name
  75757. */
  75758. static GetOperatorName(operator: number): string;
  75759. }
  75760. /**
  75761. * Defines a predicate condition as an extension of Condition
  75762. */
  75763. export class PredicateCondition extends Condition {
  75764. /** defines the predicate function used to validate the condition */
  75765. predicate: () => boolean;
  75766. /**
  75767. * Internal only - manager for action
  75768. * @hidden
  75769. */
  75770. _actionManager: ActionManager;
  75771. /**
  75772. * Creates a new PredicateCondition
  75773. * @param actionManager manager for the action the condition applies to
  75774. * @param predicate defines the predicate function used to validate the condition
  75775. */
  75776. constructor(actionManager: ActionManager,
  75777. /** defines the predicate function used to validate the condition */
  75778. predicate: () => boolean);
  75779. /**
  75780. * @returns the validity of the predicate condition
  75781. */
  75782. isValid(): boolean;
  75783. }
  75784. /**
  75785. * Defines a state condition as an extension of Condition
  75786. */
  75787. export class StateCondition extends Condition {
  75788. /** Value to compare with target state */
  75789. value: string;
  75790. /**
  75791. * Internal only - manager for action
  75792. * @hidden
  75793. */
  75794. _actionManager: ActionManager;
  75795. /**
  75796. * Internal only
  75797. * @hidden
  75798. */
  75799. private _target;
  75800. /**
  75801. * Creates a new StateCondition
  75802. * @param actionManager manager for the action the condition applies to
  75803. * @param target of the condition
  75804. * @param value to compare with target state
  75805. */
  75806. constructor(actionManager: ActionManager, target: any,
  75807. /** Value to compare with target state */
  75808. value: string);
  75809. /**
  75810. * Gets a boolean indicating if the current condition is met
  75811. * @returns the validity of the state
  75812. */
  75813. isValid(): boolean;
  75814. /**
  75815. * Serialize the StateCondition into a JSON compatible object
  75816. * @returns serialization object
  75817. */
  75818. serialize(): any;
  75819. }
  75820. }
  75821. declare module BABYLON {
  75822. /**
  75823. * This defines an action responsible to toggle a boolean once triggered.
  75824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75825. */
  75826. export class SwitchBooleanAction extends Action {
  75827. /**
  75828. * The path to the boolean property in the target object
  75829. */
  75830. propertyPath: string;
  75831. private _target;
  75832. private _effectiveTarget;
  75833. private _property;
  75834. /**
  75835. * Instantiate the action
  75836. * @param triggerOptions defines the trigger options
  75837. * @param target defines the object containing the boolean
  75838. * @param propertyPath defines the path to the boolean property in the target object
  75839. * @param condition defines the trigger related conditions
  75840. */
  75841. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75842. /** @hidden */
  75843. _prepare(): void;
  75844. /**
  75845. * Execute the action toggle the boolean value.
  75846. */
  75847. execute(): void;
  75848. /**
  75849. * Serializes the actions and its related information.
  75850. * @param parent defines the object to serialize in
  75851. * @returns the serialized object
  75852. */
  75853. serialize(parent: any): any;
  75854. }
  75855. /**
  75856. * This defines an action responsible to set a the state field of the target
  75857. * to a desired value once triggered.
  75858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75859. */
  75860. export class SetStateAction extends Action {
  75861. /**
  75862. * The value to store in the state field.
  75863. */
  75864. value: string;
  75865. private _target;
  75866. /**
  75867. * Instantiate the action
  75868. * @param triggerOptions defines the trigger options
  75869. * @param target defines the object containing the state property
  75870. * @param value defines the value to store in the state field
  75871. * @param condition defines the trigger related conditions
  75872. */
  75873. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75874. /**
  75875. * Execute the action and store the value on the target state property.
  75876. */
  75877. execute(): void;
  75878. /**
  75879. * Serializes the actions and its related information.
  75880. * @param parent defines the object to serialize in
  75881. * @returns the serialized object
  75882. */
  75883. serialize(parent: any): any;
  75884. }
  75885. /**
  75886. * This defines an action responsible to set a property of the target
  75887. * to a desired value once triggered.
  75888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75889. */
  75890. export class SetValueAction extends Action {
  75891. /**
  75892. * The path of the property to set in the target.
  75893. */
  75894. propertyPath: string;
  75895. /**
  75896. * The value to set in the property
  75897. */
  75898. value: any;
  75899. private _target;
  75900. private _effectiveTarget;
  75901. private _property;
  75902. /**
  75903. * Instantiate the action
  75904. * @param triggerOptions defines the trigger options
  75905. * @param target defines the object containing the property
  75906. * @param propertyPath defines the path of the property to set in the target
  75907. * @param value defines the value to set in the property
  75908. * @param condition defines the trigger related conditions
  75909. */
  75910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75911. /** @hidden */
  75912. _prepare(): void;
  75913. /**
  75914. * Execute the action and set the targetted property to the desired value.
  75915. */
  75916. execute(): void;
  75917. /**
  75918. * Serializes the actions and its related information.
  75919. * @param parent defines the object to serialize in
  75920. * @returns the serialized object
  75921. */
  75922. serialize(parent: any): any;
  75923. }
  75924. /**
  75925. * This defines an action responsible to increment the target value
  75926. * to a desired value once triggered.
  75927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75928. */
  75929. export class IncrementValueAction extends Action {
  75930. /**
  75931. * The path of the property to increment in the target.
  75932. */
  75933. propertyPath: string;
  75934. /**
  75935. * The value we should increment the property by.
  75936. */
  75937. value: any;
  75938. private _target;
  75939. private _effectiveTarget;
  75940. private _property;
  75941. /**
  75942. * Instantiate the action
  75943. * @param triggerOptions defines the trigger options
  75944. * @param target defines the object containing the property
  75945. * @param propertyPath defines the path of the property to increment in the target
  75946. * @param value defines the value value we should increment the property by
  75947. * @param condition defines the trigger related conditions
  75948. */
  75949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75950. /** @hidden */
  75951. _prepare(): void;
  75952. /**
  75953. * Execute the action and increment the target of the value amount.
  75954. */
  75955. execute(): void;
  75956. /**
  75957. * Serializes the actions and its related information.
  75958. * @param parent defines the object to serialize in
  75959. * @returns the serialized object
  75960. */
  75961. serialize(parent: any): any;
  75962. }
  75963. /**
  75964. * This defines an action responsible to start an animation once triggered.
  75965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75966. */
  75967. export class PlayAnimationAction extends Action {
  75968. /**
  75969. * Where the animation should start (animation frame)
  75970. */
  75971. from: number;
  75972. /**
  75973. * Where the animation should stop (animation frame)
  75974. */
  75975. to: number;
  75976. /**
  75977. * Define if the animation should loop or stop after the first play.
  75978. */
  75979. loop?: boolean;
  75980. private _target;
  75981. /**
  75982. * Instantiate the action
  75983. * @param triggerOptions defines the trigger options
  75984. * @param target defines the target animation or animation name
  75985. * @param from defines from where the animation should start (animation frame)
  75986. * @param end defines where the animation should stop (animation frame)
  75987. * @param loop defines if the animation should loop or stop after the first play
  75988. * @param condition defines the trigger related conditions
  75989. */
  75990. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75991. /** @hidden */
  75992. _prepare(): void;
  75993. /**
  75994. * Execute the action and play the animation.
  75995. */
  75996. execute(): void;
  75997. /**
  75998. * Serializes the actions and its related information.
  75999. * @param parent defines the object to serialize in
  76000. * @returns the serialized object
  76001. */
  76002. serialize(parent: any): any;
  76003. }
  76004. /**
  76005. * This defines an action responsible to stop an animation once triggered.
  76006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76007. */
  76008. export class StopAnimationAction extends Action {
  76009. private _target;
  76010. /**
  76011. * Instantiate the action
  76012. * @param triggerOptions defines the trigger options
  76013. * @param target defines the target animation or animation name
  76014. * @param condition defines the trigger related conditions
  76015. */
  76016. constructor(triggerOptions: any, target: any, condition?: Condition);
  76017. /** @hidden */
  76018. _prepare(): void;
  76019. /**
  76020. * Execute the action and stop the animation.
  76021. */
  76022. execute(): void;
  76023. /**
  76024. * Serializes the actions and its related information.
  76025. * @param parent defines the object to serialize in
  76026. * @returns the serialized object
  76027. */
  76028. serialize(parent: any): any;
  76029. }
  76030. /**
  76031. * This defines an action responsible that does nothing once triggered.
  76032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76033. */
  76034. export class DoNothingAction extends Action {
  76035. /**
  76036. * Instantiate the action
  76037. * @param triggerOptions defines the trigger options
  76038. * @param condition defines the trigger related conditions
  76039. */
  76040. constructor(triggerOptions?: any, condition?: Condition);
  76041. /**
  76042. * Execute the action and do nothing.
  76043. */
  76044. execute(): void;
  76045. /**
  76046. * Serializes the actions and its related information.
  76047. * @param parent defines the object to serialize in
  76048. * @returns the serialized object
  76049. */
  76050. serialize(parent: any): any;
  76051. }
  76052. /**
  76053. * This defines an action responsible to trigger several actions once triggered.
  76054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76055. */
  76056. export class CombineAction extends Action {
  76057. /**
  76058. * The list of aggregated animations to run.
  76059. */
  76060. children: Action[];
  76061. /**
  76062. * Instantiate the action
  76063. * @param triggerOptions defines the trigger options
  76064. * @param children defines the list of aggregated animations to run
  76065. * @param condition defines the trigger related conditions
  76066. */
  76067. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76068. /** @hidden */
  76069. _prepare(): void;
  76070. /**
  76071. * Execute the action and executes all the aggregated actions.
  76072. */
  76073. execute(evt: ActionEvent): void;
  76074. /**
  76075. * Serializes the actions and its related information.
  76076. * @param parent defines the object to serialize in
  76077. * @returns the serialized object
  76078. */
  76079. serialize(parent: any): any;
  76080. }
  76081. /**
  76082. * This defines an action responsible to run code (external event) once triggered.
  76083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76084. */
  76085. export class ExecuteCodeAction extends Action {
  76086. /**
  76087. * The callback function to run.
  76088. */
  76089. func: (evt: ActionEvent) => void;
  76090. /**
  76091. * Instantiate the action
  76092. * @param triggerOptions defines the trigger options
  76093. * @param func defines the callback function to run
  76094. * @param condition defines the trigger related conditions
  76095. */
  76096. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76097. /**
  76098. * Execute the action and run the attached code.
  76099. */
  76100. execute(evt: ActionEvent): void;
  76101. }
  76102. /**
  76103. * This defines an action responsible to set the parent property of the target once triggered.
  76104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76105. */
  76106. export class SetParentAction extends Action {
  76107. private _parent;
  76108. private _target;
  76109. /**
  76110. * Instantiate the action
  76111. * @param triggerOptions defines the trigger options
  76112. * @param target defines the target containing the parent property
  76113. * @param parent defines from where the animation should start (animation frame)
  76114. * @param condition defines the trigger related conditions
  76115. */
  76116. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76117. /** @hidden */
  76118. _prepare(): void;
  76119. /**
  76120. * Execute the action and set the parent property.
  76121. */
  76122. execute(): void;
  76123. /**
  76124. * Serializes the actions and its related information.
  76125. * @param parent defines the object to serialize in
  76126. * @returns the serialized object
  76127. */
  76128. serialize(parent: any): any;
  76129. }
  76130. }
  76131. declare module BABYLON {
  76132. /**
  76133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76136. */
  76137. export class ActionManager extends AbstractActionManager {
  76138. /**
  76139. * Nothing
  76140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76141. */
  76142. static readonly NothingTrigger: number;
  76143. /**
  76144. * On pick
  76145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76146. */
  76147. static readonly OnPickTrigger: number;
  76148. /**
  76149. * On left pick
  76150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76151. */
  76152. static readonly OnLeftPickTrigger: number;
  76153. /**
  76154. * On right pick
  76155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76156. */
  76157. static readonly OnRightPickTrigger: number;
  76158. /**
  76159. * On center pick
  76160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76161. */
  76162. static readonly OnCenterPickTrigger: number;
  76163. /**
  76164. * On pick down
  76165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76166. */
  76167. static readonly OnPickDownTrigger: number;
  76168. /**
  76169. * On double pick
  76170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76171. */
  76172. static readonly OnDoublePickTrigger: number;
  76173. /**
  76174. * On pick up
  76175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76176. */
  76177. static readonly OnPickUpTrigger: number;
  76178. /**
  76179. * On pick out.
  76180. * This trigger will only be raised if you also declared a OnPickDown
  76181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76182. */
  76183. static readonly OnPickOutTrigger: number;
  76184. /**
  76185. * On long press
  76186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76187. */
  76188. static readonly OnLongPressTrigger: number;
  76189. /**
  76190. * On pointer over
  76191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76192. */
  76193. static readonly OnPointerOverTrigger: number;
  76194. /**
  76195. * On pointer out
  76196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76197. */
  76198. static readonly OnPointerOutTrigger: number;
  76199. /**
  76200. * On every frame
  76201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76202. */
  76203. static readonly OnEveryFrameTrigger: number;
  76204. /**
  76205. * On intersection enter
  76206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76207. */
  76208. static readonly OnIntersectionEnterTrigger: number;
  76209. /**
  76210. * On intersection exit
  76211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76212. */
  76213. static readonly OnIntersectionExitTrigger: number;
  76214. /**
  76215. * On key down
  76216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76217. */
  76218. static readonly OnKeyDownTrigger: number;
  76219. /**
  76220. * On key up
  76221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76222. */
  76223. static readonly OnKeyUpTrigger: number;
  76224. private _scene;
  76225. /**
  76226. * Creates a new action manager
  76227. * @param scene defines the hosting scene
  76228. */
  76229. constructor(scene: Scene);
  76230. /**
  76231. * Releases all associated resources
  76232. */
  76233. dispose(): void;
  76234. /**
  76235. * Gets hosting scene
  76236. * @returns the hosting scene
  76237. */
  76238. getScene(): Scene;
  76239. /**
  76240. * Does this action manager handles actions of any of the given triggers
  76241. * @param triggers defines the triggers to be tested
  76242. * @return a boolean indicating whether one (or more) of the triggers is handled
  76243. */
  76244. hasSpecificTriggers(triggers: number[]): boolean;
  76245. /**
  76246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76247. * speed.
  76248. * @param triggerA defines the trigger to be tested
  76249. * @param triggerB defines the trigger to be tested
  76250. * @return a boolean indicating whether one (or more) of the triggers is handled
  76251. */
  76252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76253. /**
  76254. * Does this action manager handles actions of a given trigger
  76255. * @param trigger defines the trigger to be tested
  76256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76257. * @return whether the trigger is handled
  76258. */
  76259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76260. /**
  76261. * Does this action manager has pointer triggers
  76262. */
  76263. readonly hasPointerTriggers: boolean;
  76264. /**
  76265. * Does this action manager has pick triggers
  76266. */
  76267. readonly hasPickTriggers: boolean;
  76268. /**
  76269. * Registers an action to this action manager
  76270. * @param action defines the action to be registered
  76271. * @return the action amended (prepared) after registration
  76272. */
  76273. registerAction(action: IAction): Nullable<IAction>;
  76274. /**
  76275. * Unregisters an action to this action manager
  76276. * @param action defines the action to be unregistered
  76277. * @return a boolean indicating whether the action has been unregistered
  76278. */
  76279. unregisterAction(action: IAction): Boolean;
  76280. /**
  76281. * Process a specific trigger
  76282. * @param trigger defines the trigger to process
  76283. * @param evt defines the event details to be processed
  76284. */
  76285. processTrigger(trigger: number, evt?: IActionEvent): void;
  76286. /** @hidden */
  76287. _getEffectiveTarget(target: any, propertyPath: string): any;
  76288. /** @hidden */
  76289. _getProperty(propertyPath: string): string;
  76290. /**
  76291. * Serialize this manager to a JSON object
  76292. * @param name defines the property name to store this manager
  76293. * @returns a JSON representation of this manager
  76294. */
  76295. serialize(name: string): any;
  76296. /**
  76297. * Creates a new ActionManager from a JSON data
  76298. * @param parsedActions defines the JSON data to read from
  76299. * @param object defines the hosting mesh
  76300. * @param scene defines the hosting scene
  76301. */
  76302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76303. /**
  76304. * Get a trigger name by index
  76305. * @param trigger defines the trigger index
  76306. * @returns a trigger name
  76307. */
  76308. static GetTriggerName(trigger: number): string;
  76309. }
  76310. }
  76311. declare module BABYLON {
  76312. /**
  76313. * Class representing a ray with position and direction
  76314. */
  76315. export class Ray {
  76316. /** origin point */
  76317. origin: Vector3;
  76318. /** direction */
  76319. direction: Vector3;
  76320. /** length of the ray */
  76321. length: number;
  76322. private static readonly TmpVector3;
  76323. private _tmpRay;
  76324. /**
  76325. * Creates a new ray
  76326. * @param origin origin point
  76327. * @param direction direction
  76328. * @param length length of the ray
  76329. */
  76330. constructor(
  76331. /** origin point */
  76332. origin: Vector3,
  76333. /** direction */
  76334. direction: Vector3,
  76335. /** length of the ray */
  76336. length?: number);
  76337. /**
  76338. * Checks if the ray intersects a box
  76339. * @param minimum bound of the box
  76340. * @param maximum bound of the box
  76341. * @param intersectionTreshold extra extend to be added to the box in all direction
  76342. * @returns if the box was hit
  76343. */
  76344. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76345. /**
  76346. * Checks if the ray intersects a box
  76347. * @param box the bounding box to check
  76348. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76349. * @returns if the box was hit
  76350. */
  76351. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76352. /**
  76353. * If the ray hits a sphere
  76354. * @param sphere the bounding sphere to check
  76355. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76356. * @returns true if it hits the sphere
  76357. */
  76358. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76359. /**
  76360. * If the ray hits a triange
  76361. * @param vertex0 triangle vertex
  76362. * @param vertex1 triangle vertex
  76363. * @param vertex2 triangle vertex
  76364. * @returns intersection information if hit
  76365. */
  76366. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76367. /**
  76368. * Checks if ray intersects a plane
  76369. * @param plane the plane to check
  76370. * @returns the distance away it was hit
  76371. */
  76372. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76373. /**
  76374. * Calculate the intercept of a ray on a given axis
  76375. * @param axis to check 'x' | 'y' | 'z'
  76376. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76377. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76378. */
  76379. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76380. /**
  76381. * Checks if ray intersects a mesh
  76382. * @param mesh the mesh to check
  76383. * @param fastCheck if only the bounding box should checked
  76384. * @returns picking info of the intersecton
  76385. */
  76386. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76387. /**
  76388. * Checks if ray intersects a mesh
  76389. * @param meshes the meshes to check
  76390. * @param fastCheck if only the bounding box should checked
  76391. * @param results array to store result in
  76392. * @returns Array of picking infos
  76393. */
  76394. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76395. private _comparePickingInfo;
  76396. private static smallnum;
  76397. private static rayl;
  76398. /**
  76399. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76400. * @param sega the first point of the segment to test the intersection against
  76401. * @param segb the second point of the segment to test the intersection against
  76402. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76403. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76404. */
  76405. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76406. /**
  76407. * Update the ray from viewport position
  76408. * @param x position
  76409. * @param y y position
  76410. * @param viewportWidth viewport width
  76411. * @param viewportHeight viewport height
  76412. * @param world world matrix
  76413. * @param view view matrix
  76414. * @param projection projection matrix
  76415. * @returns this ray updated
  76416. */
  76417. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76418. /**
  76419. * Creates a ray with origin and direction of 0,0,0
  76420. * @returns the new ray
  76421. */
  76422. static Zero(): Ray;
  76423. /**
  76424. * Creates a new ray from screen space and viewport
  76425. * @param x position
  76426. * @param y y position
  76427. * @param viewportWidth viewport width
  76428. * @param viewportHeight viewport height
  76429. * @param world world matrix
  76430. * @param view view matrix
  76431. * @param projection projection matrix
  76432. * @returns new ray
  76433. */
  76434. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76435. /**
  76436. * 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
  76437. * transformed to the given world matrix.
  76438. * @param origin The origin point
  76439. * @param end The end point
  76440. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76441. * @returns the new ray
  76442. */
  76443. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76444. /**
  76445. * Transforms a ray by a matrix
  76446. * @param ray ray to transform
  76447. * @param matrix matrix to apply
  76448. * @returns the resulting new ray
  76449. */
  76450. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76451. /**
  76452. * Transforms a ray by a matrix
  76453. * @param ray ray to transform
  76454. * @param matrix matrix to apply
  76455. * @param result ray to store result in
  76456. */
  76457. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76458. /**
  76459. * Unproject a ray from screen space to object space
  76460. * @param sourceX defines the screen space x coordinate to use
  76461. * @param sourceY defines the screen space y coordinate to use
  76462. * @param viewportWidth defines the current width of the viewport
  76463. * @param viewportHeight defines the current height of the viewport
  76464. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76465. * @param view defines the view matrix to use
  76466. * @param projection defines the projection matrix to use
  76467. */
  76468. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76469. }
  76470. /**
  76471. * Type used to define predicate used to select faces when a mesh intersection is detected
  76472. */
  76473. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76474. interface Scene {
  76475. /** @hidden */
  76476. _tempPickingRay: Nullable<Ray>;
  76477. /** @hidden */
  76478. _cachedRayForTransform: Ray;
  76479. /** @hidden */
  76480. _pickWithRayInverseMatrix: Matrix;
  76481. /** @hidden */
  76482. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76483. /** @hidden */
  76484. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76485. }
  76486. }
  76487. declare module BABYLON {
  76488. /**
  76489. * Groups all the scene component constants in one place to ease maintenance.
  76490. * @hidden
  76491. */
  76492. export class SceneComponentConstants {
  76493. static readonly NAME_EFFECTLAYER: string;
  76494. static readonly NAME_LAYER: string;
  76495. static readonly NAME_LENSFLARESYSTEM: string;
  76496. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76497. static readonly NAME_PARTICLESYSTEM: string;
  76498. static readonly NAME_GAMEPAD: string;
  76499. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76500. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76501. static readonly NAME_DEPTHRENDERER: string;
  76502. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76503. static readonly NAME_SPRITE: string;
  76504. static readonly NAME_OUTLINERENDERER: string;
  76505. static readonly NAME_PROCEDURALTEXTURE: string;
  76506. static readonly NAME_SHADOWGENERATOR: string;
  76507. static readonly NAME_OCTREE: string;
  76508. static readonly NAME_PHYSICSENGINE: string;
  76509. static readonly NAME_AUDIO: string;
  76510. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76511. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76512. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76513. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76514. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76515. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76516. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76517. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76518. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76519. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76520. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76521. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76522. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76523. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76524. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76525. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76526. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76527. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76528. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76529. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76530. static readonly STEP_AFTERRENDER_AUDIO: number;
  76531. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76532. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76533. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76534. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76535. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76536. static readonly STEP_POINTERMOVE_SPRITE: number;
  76537. static readonly STEP_POINTERDOWN_SPRITE: number;
  76538. static readonly STEP_POINTERUP_SPRITE: number;
  76539. }
  76540. /**
  76541. * This represents a scene component.
  76542. *
  76543. * This is used to decouple the dependency the scene is having on the different workloads like
  76544. * layers, post processes...
  76545. */
  76546. export interface ISceneComponent {
  76547. /**
  76548. * The name of the component. Each component must have a unique name.
  76549. */
  76550. name: string;
  76551. /**
  76552. * The scene the component belongs to.
  76553. */
  76554. scene: Scene;
  76555. /**
  76556. * Register the component to one instance of a scene.
  76557. */
  76558. register(): void;
  76559. /**
  76560. * Rebuilds the elements related to this component in case of
  76561. * context lost for instance.
  76562. */
  76563. rebuild(): void;
  76564. /**
  76565. * Disposes the component and the associated ressources.
  76566. */
  76567. dispose(): void;
  76568. }
  76569. /**
  76570. * This represents a SERIALIZABLE scene component.
  76571. *
  76572. * This extends Scene Component to add Serialization methods on top.
  76573. */
  76574. export interface ISceneSerializableComponent extends ISceneComponent {
  76575. /**
  76576. * Adds all the elements from the container to the scene
  76577. * @param container the container holding the elements
  76578. */
  76579. addFromContainer(container: AbstractScene): void;
  76580. /**
  76581. * Removes all the elements in the container from the scene
  76582. * @param container contains the elements to remove
  76583. * @param dispose if the removed element should be disposed (default: false)
  76584. */
  76585. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76586. /**
  76587. * Serializes the component data to the specified json object
  76588. * @param serializationObject The object to serialize to
  76589. */
  76590. serialize(serializationObject: any): void;
  76591. }
  76592. /**
  76593. * Strong typing of a Mesh related stage step action
  76594. */
  76595. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76596. /**
  76597. * Strong typing of a Evaluate Sub Mesh related stage step action
  76598. */
  76599. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76600. /**
  76601. * Strong typing of a Active Mesh related stage step action
  76602. */
  76603. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76604. /**
  76605. * Strong typing of a Camera related stage step action
  76606. */
  76607. export type CameraStageAction = (camera: Camera) => void;
  76608. /**
  76609. * Strong typing of a Camera Frame buffer related stage step action
  76610. */
  76611. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76612. /**
  76613. * Strong typing of a Render Target related stage step action
  76614. */
  76615. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76616. /**
  76617. * Strong typing of a RenderingGroup related stage step action
  76618. */
  76619. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76620. /**
  76621. * Strong typing of a Mesh Render related stage step action
  76622. */
  76623. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76624. /**
  76625. * Strong typing of a simple stage step action
  76626. */
  76627. export type SimpleStageAction = () => void;
  76628. /**
  76629. * Strong typing of a render target action.
  76630. */
  76631. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76632. /**
  76633. * Strong typing of a pointer move action.
  76634. */
  76635. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76636. /**
  76637. * Strong typing of a pointer up/down action.
  76638. */
  76639. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76640. /**
  76641. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76642. * @hidden
  76643. */
  76644. export class Stage<T extends Function> extends Array<{
  76645. index: number;
  76646. component: ISceneComponent;
  76647. action: T;
  76648. }> {
  76649. /**
  76650. * Hide ctor from the rest of the world.
  76651. * @param items The items to add.
  76652. */
  76653. private constructor();
  76654. /**
  76655. * Creates a new Stage.
  76656. * @returns A new instance of a Stage
  76657. */
  76658. static Create<T extends Function>(): Stage<T>;
  76659. /**
  76660. * Registers a step in an ordered way in the targeted stage.
  76661. * @param index Defines the position to register the step in
  76662. * @param component Defines the component attached to the step
  76663. * @param action Defines the action to launch during the step
  76664. */
  76665. registerStep(index: number, component: ISceneComponent, action: T): void;
  76666. /**
  76667. * Clears all the steps from the stage.
  76668. */
  76669. clear(): void;
  76670. }
  76671. }
  76672. declare module BABYLON {
  76673. interface Scene {
  76674. /** @hidden */
  76675. _pointerOverSprite: Nullable<Sprite>;
  76676. /** @hidden */
  76677. _pickedDownSprite: Nullable<Sprite>;
  76678. /** @hidden */
  76679. _tempSpritePickingRay: Nullable<Ray>;
  76680. /**
  76681. * All of the sprite managers added to this scene
  76682. * @see http://doc.babylonjs.com/babylon101/sprites
  76683. */
  76684. spriteManagers: Array<ISpriteManager>;
  76685. /**
  76686. * An event triggered when sprites rendering is about to start
  76687. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76688. */
  76689. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76690. /**
  76691. * An event triggered when sprites rendering is done
  76692. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76693. */
  76694. onAfterSpritesRenderingObservable: Observable<Scene>;
  76695. /** @hidden */
  76696. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76697. /** Launch a ray to try to pick a sprite in the scene
  76698. * @param x position on screen
  76699. * @param y position on screen
  76700. * @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
  76701. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76702. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76703. * @returns a PickingInfo
  76704. */
  76705. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76706. /** Use the given ray to pick a sprite in the scene
  76707. * @param ray The ray (in world space) to use to pick meshes
  76708. * @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
  76709. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76710. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76711. * @returns a PickingInfo
  76712. */
  76713. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76714. /** @hidden */
  76715. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76716. /** Launch a ray to try to pick sprites in the scene
  76717. * @param x position on screen
  76718. * @param y position on screen
  76719. * @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
  76720. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76721. * @returns a PickingInfo array
  76722. */
  76723. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76724. /** Use the given ray to pick sprites in the scene
  76725. * @param ray The ray (in world space) to use to pick meshes
  76726. * @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
  76727. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76728. * @returns a PickingInfo array
  76729. */
  76730. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76731. /**
  76732. * Force the sprite under the pointer
  76733. * @param sprite defines the sprite to use
  76734. */
  76735. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76736. /**
  76737. * Gets the sprite under the pointer
  76738. * @returns a Sprite or null if no sprite is under the pointer
  76739. */
  76740. getPointerOverSprite(): Nullable<Sprite>;
  76741. }
  76742. /**
  76743. * Defines the sprite scene component responsible to manage sprites
  76744. * in a given scene.
  76745. */
  76746. export class SpriteSceneComponent implements ISceneComponent {
  76747. /**
  76748. * The component name helpfull to identify the component in the list of scene components.
  76749. */
  76750. readonly name: string;
  76751. /**
  76752. * The scene the component belongs to.
  76753. */
  76754. scene: Scene;
  76755. /** @hidden */
  76756. private _spritePredicate;
  76757. /**
  76758. * Creates a new instance of the component for the given scene
  76759. * @param scene Defines the scene to register the component in
  76760. */
  76761. constructor(scene: Scene);
  76762. /**
  76763. * Registers the component in a given scene
  76764. */
  76765. register(): void;
  76766. /**
  76767. * Rebuilds the elements related to this component in case of
  76768. * context lost for instance.
  76769. */
  76770. rebuild(): void;
  76771. /**
  76772. * Disposes the component and the associated ressources.
  76773. */
  76774. dispose(): void;
  76775. private _pickSpriteButKeepRay;
  76776. private _pointerMove;
  76777. private _pointerDown;
  76778. private _pointerUp;
  76779. }
  76780. }
  76781. declare module BABYLON {
  76782. /** @hidden */
  76783. export var fogFragmentDeclaration: {
  76784. name: string;
  76785. shader: string;
  76786. };
  76787. }
  76788. declare module BABYLON {
  76789. /** @hidden */
  76790. export var fogFragment: {
  76791. name: string;
  76792. shader: string;
  76793. };
  76794. }
  76795. declare module BABYLON {
  76796. /** @hidden */
  76797. export var spritesPixelShader: {
  76798. name: string;
  76799. shader: string;
  76800. };
  76801. }
  76802. declare module BABYLON {
  76803. /** @hidden */
  76804. export var fogVertexDeclaration: {
  76805. name: string;
  76806. shader: string;
  76807. };
  76808. }
  76809. declare module BABYLON {
  76810. /** @hidden */
  76811. export var spritesVertexShader: {
  76812. name: string;
  76813. shader: string;
  76814. };
  76815. }
  76816. declare module BABYLON {
  76817. /**
  76818. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76819. */
  76820. export interface ISpriteManager extends IDisposable {
  76821. /**
  76822. * Restricts the camera to viewing objects with the same layerMask.
  76823. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76824. */
  76825. layerMask: number;
  76826. /**
  76827. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76828. */
  76829. isPickable: boolean;
  76830. /**
  76831. * Specifies the rendering group id for this mesh (0 by default)
  76832. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76833. */
  76834. renderingGroupId: number;
  76835. /**
  76836. * Defines the list of sprites managed by the manager.
  76837. */
  76838. sprites: Array<Sprite>;
  76839. /**
  76840. * Tests the intersection of a sprite with a specific ray.
  76841. * @param ray The ray we are sending to test the collision
  76842. * @param camera The camera space we are sending rays in
  76843. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76844. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76845. * @returns picking info or null.
  76846. */
  76847. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76848. /**
  76849. * Intersects the sprites with a ray
  76850. * @param ray defines the ray to intersect with
  76851. * @param camera defines the current active camera
  76852. * @param predicate defines a predicate used to select candidate sprites
  76853. * @returns null if no hit or a PickingInfo array
  76854. */
  76855. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76856. /**
  76857. * Renders the list of sprites on screen.
  76858. */
  76859. render(): void;
  76860. }
  76861. /**
  76862. * Class used to manage multiple sprites on the same spritesheet
  76863. * @see http://doc.babylonjs.com/babylon101/sprites
  76864. */
  76865. export class SpriteManager implements ISpriteManager {
  76866. /** defines the manager's name */
  76867. name: string;
  76868. /** Gets the list of sprites */
  76869. sprites: Sprite[];
  76870. /** Gets or sets the rendering group id (0 by default) */
  76871. renderingGroupId: number;
  76872. /** Gets or sets camera layer mask */
  76873. layerMask: number;
  76874. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76875. fogEnabled: boolean;
  76876. /** Gets or sets a boolean indicating if the sprites are pickable */
  76877. isPickable: boolean;
  76878. /** Defines the default width of a cell in the spritesheet */
  76879. cellWidth: number;
  76880. /** Defines the default height of a cell in the spritesheet */
  76881. cellHeight: number;
  76882. /** Associative array from JSON sprite data file */
  76883. private _cellData;
  76884. /** Array of sprite names from JSON sprite data file */
  76885. private _spriteMap;
  76886. /** True when packed cell data from JSON file is ready*/
  76887. private _packedAndReady;
  76888. /**
  76889. * An event triggered when the manager is disposed.
  76890. */
  76891. onDisposeObservable: Observable<SpriteManager>;
  76892. private _onDisposeObserver;
  76893. /**
  76894. * Callback called when the manager is disposed
  76895. */
  76896. onDispose: () => void;
  76897. private _capacity;
  76898. private _fromPacked;
  76899. private _spriteTexture;
  76900. private _epsilon;
  76901. private _scene;
  76902. private _vertexData;
  76903. private _buffer;
  76904. private _vertexBuffers;
  76905. private _indexBuffer;
  76906. private _effectBase;
  76907. private _effectFog;
  76908. /**
  76909. * Gets or sets the spritesheet texture
  76910. */
  76911. texture: Texture;
  76912. /**
  76913. * Creates a new sprite manager
  76914. * @param name defines the manager's name
  76915. * @param imgUrl defines the sprite sheet url
  76916. * @param capacity defines the maximum allowed number of sprites
  76917. * @param cellSize defines the size of a sprite cell
  76918. * @param scene defines the hosting scene
  76919. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76920. * @param samplingMode defines the smapling mode to use with spritesheet
  76921. * @param fromPacked set to false; do not alter
  76922. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76923. */
  76924. constructor(
  76925. /** defines the manager's name */
  76926. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76927. private _makePacked;
  76928. private _appendSpriteVertex;
  76929. /**
  76930. * Intersects the sprites with a ray
  76931. * @param ray defines the ray to intersect with
  76932. * @param camera defines the current active camera
  76933. * @param predicate defines a predicate used to select candidate sprites
  76934. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76935. * @returns null if no hit or a PickingInfo
  76936. */
  76937. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76938. /**
  76939. * Intersects the sprites with a ray
  76940. * @param ray defines the ray to intersect with
  76941. * @param camera defines the current active camera
  76942. * @param predicate defines a predicate used to select candidate sprites
  76943. * @returns null if no hit or a PickingInfo array
  76944. */
  76945. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76946. /**
  76947. * Render all child sprites
  76948. */
  76949. render(): void;
  76950. /**
  76951. * Release associated resources
  76952. */
  76953. dispose(): void;
  76954. }
  76955. }
  76956. declare module BABYLON {
  76957. /**
  76958. * Class used to represent a sprite
  76959. * @see http://doc.babylonjs.com/babylon101/sprites
  76960. */
  76961. export class Sprite {
  76962. /** defines the name */
  76963. name: string;
  76964. /** Gets or sets the current world position */
  76965. position: Vector3;
  76966. /** Gets or sets the main color */
  76967. color: Color4;
  76968. /** Gets or sets the width */
  76969. width: number;
  76970. /** Gets or sets the height */
  76971. height: number;
  76972. /** Gets or sets rotation angle */
  76973. angle: number;
  76974. /** Gets or sets the cell index in the sprite sheet */
  76975. cellIndex: number;
  76976. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76977. cellRef: string;
  76978. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76979. invertU: number;
  76980. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76981. invertV: number;
  76982. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76983. disposeWhenFinishedAnimating: boolean;
  76984. /** Gets the list of attached animations */
  76985. animations: Animation[];
  76986. /** Gets or sets a boolean indicating if the sprite can be picked */
  76987. isPickable: boolean;
  76988. /**
  76989. * Gets or sets the associated action manager
  76990. */
  76991. actionManager: Nullable<ActionManager>;
  76992. private _animationStarted;
  76993. private _loopAnimation;
  76994. private _fromIndex;
  76995. private _toIndex;
  76996. private _delay;
  76997. private _direction;
  76998. private _manager;
  76999. private _time;
  77000. private _onAnimationEnd;
  77001. /**
  77002. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77003. */
  77004. isVisible: boolean;
  77005. /**
  77006. * Gets or sets the sprite size
  77007. */
  77008. size: number;
  77009. /**
  77010. * Creates a new Sprite
  77011. * @param name defines the name
  77012. * @param manager defines the manager
  77013. */
  77014. constructor(
  77015. /** defines the name */
  77016. name: string, manager: ISpriteManager);
  77017. /**
  77018. * Starts an animation
  77019. * @param from defines the initial key
  77020. * @param to defines the end key
  77021. * @param loop defines if the animation must loop
  77022. * @param delay defines the start delay (in ms)
  77023. * @param onAnimationEnd defines a callback to call when animation ends
  77024. */
  77025. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77026. /** Stops current animation (if any) */
  77027. stopAnimation(): void;
  77028. /** @hidden */
  77029. _animate(deltaTime: number): void;
  77030. /** Release associated resources */
  77031. dispose(): void;
  77032. }
  77033. }
  77034. declare module BABYLON {
  77035. /**
  77036. * Information about the result of picking within a scene
  77037. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77038. */
  77039. export class PickingInfo {
  77040. /** @hidden */
  77041. _pickingUnavailable: boolean;
  77042. /**
  77043. * If the pick collided with an object
  77044. */
  77045. hit: boolean;
  77046. /**
  77047. * Distance away where the pick collided
  77048. */
  77049. distance: number;
  77050. /**
  77051. * The location of pick collision
  77052. */
  77053. pickedPoint: Nullable<Vector3>;
  77054. /**
  77055. * The mesh corresponding the the pick collision
  77056. */
  77057. pickedMesh: Nullable<AbstractMesh>;
  77058. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77059. bu: number;
  77060. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77061. bv: number;
  77062. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77063. faceId: number;
  77064. /** Id of the the submesh that was picked */
  77065. subMeshId: number;
  77066. /** If a sprite was picked, this will be the sprite the pick collided with */
  77067. pickedSprite: Nullable<Sprite>;
  77068. /**
  77069. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77070. */
  77071. originMesh: Nullable<AbstractMesh>;
  77072. /**
  77073. * The ray that was used to perform the picking.
  77074. */
  77075. ray: Nullable<Ray>;
  77076. /**
  77077. * Gets the normal correspodning to the face the pick collided with
  77078. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77079. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77080. * @returns The normal correspodning to the face the pick collided with
  77081. */
  77082. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77083. /**
  77084. * Gets the texture coordinates of where the pick occured
  77085. * @returns the vector containing the coordnates of the texture
  77086. */
  77087. getTextureCoordinates(): Nullable<Vector2>;
  77088. }
  77089. }
  77090. declare module BABYLON {
  77091. /**
  77092. * Gather the list of pointer event types as constants.
  77093. */
  77094. export class PointerEventTypes {
  77095. /**
  77096. * 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.
  77097. */
  77098. static readonly POINTERDOWN: number;
  77099. /**
  77100. * The pointerup event is fired when a pointer is no longer active.
  77101. */
  77102. static readonly POINTERUP: number;
  77103. /**
  77104. * The pointermove event is fired when a pointer changes coordinates.
  77105. */
  77106. static readonly POINTERMOVE: number;
  77107. /**
  77108. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77109. */
  77110. static readonly POINTERWHEEL: number;
  77111. /**
  77112. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77113. */
  77114. static readonly POINTERPICK: number;
  77115. /**
  77116. * The pointertap event is fired when a the object has been touched and released without drag.
  77117. */
  77118. static readonly POINTERTAP: number;
  77119. /**
  77120. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77121. */
  77122. static readonly POINTERDOUBLETAP: number;
  77123. }
  77124. /**
  77125. * Base class of pointer info types.
  77126. */
  77127. export class PointerInfoBase {
  77128. /**
  77129. * Defines the type of event (PointerEventTypes)
  77130. */
  77131. type: number;
  77132. /**
  77133. * Defines the related dom event
  77134. */
  77135. event: PointerEvent | MouseWheelEvent;
  77136. /**
  77137. * Instantiates the base class of pointers info.
  77138. * @param type Defines the type of event (PointerEventTypes)
  77139. * @param event Defines the related dom event
  77140. */
  77141. constructor(
  77142. /**
  77143. * Defines the type of event (PointerEventTypes)
  77144. */
  77145. type: number,
  77146. /**
  77147. * Defines the related dom event
  77148. */
  77149. event: PointerEvent | MouseWheelEvent);
  77150. }
  77151. /**
  77152. * This class is used to store pointer related info for the onPrePointerObservable event.
  77153. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77154. */
  77155. export class PointerInfoPre extends PointerInfoBase {
  77156. /**
  77157. * Ray from a pointer if availible (eg. 6dof controller)
  77158. */
  77159. ray: Nullable<Ray>;
  77160. /**
  77161. * Defines the local position of the pointer on the canvas.
  77162. */
  77163. localPosition: Vector2;
  77164. /**
  77165. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77166. */
  77167. skipOnPointerObservable: boolean;
  77168. /**
  77169. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77170. * @param type Defines the type of event (PointerEventTypes)
  77171. * @param event Defines the related dom event
  77172. * @param localX Defines the local x coordinates of the pointer when the event occured
  77173. * @param localY Defines the local y coordinates of the pointer when the event occured
  77174. */
  77175. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77176. }
  77177. /**
  77178. * This type contains all the data related to a pointer event in Babylon.js.
  77179. * 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.
  77180. */
  77181. export class PointerInfo extends PointerInfoBase {
  77182. /**
  77183. * Defines the picking info associated to the info (if any)\
  77184. */
  77185. pickInfo: Nullable<PickingInfo>;
  77186. /**
  77187. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77188. * @param type Defines the type of event (PointerEventTypes)
  77189. * @param event Defines the related dom event
  77190. * @param pickInfo Defines the picking info associated to the info (if any)\
  77191. */
  77192. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77193. /**
  77194. * Defines the picking info associated to the info (if any)\
  77195. */
  77196. pickInfo: Nullable<PickingInfo>);
  77197. }
  77198. /**
  77199. * Data relating to a touch event on the screen.
  77200. */
  77201. export interface PointerTouch {
  77202. /**
  77203. * X coordinate of touch.
  77204. */
  77205. x: number;
  77206. /**
  77207. * Y coordinate of touch.
  77208. */
  77209. y: number;
  77210. /**
  77211. * Id of touch. Unique for each finger.
  77212. */
  77213. pointerId: number;
  77214. /**
  77215. * Event type passed from DOM.
  77216. */
  77217. type: any;
  77218. }
  77219. }
  77220. declare module BABYLON {
  77221. /**
  77222. * Manage the mouse inputs to control the movement of a free camera.
  77223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77224. */
  77225. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77226. /**
  77227. * Define if touch is enabled in the mouse input
  77228. */
  77229. touchEnabled: boolean;
  77230. /**
  77231. * Defines the camera the input is attached to.
  77232. */
  77233. camera: FreeCamera;
  77234. /**
  77235. * Defines the buttons associated with the input to handle camera move.
  77236. */
  77237. buttons: number[];
  77238. /**
  77239. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77240. */
  77241. angularSensibility: number;
  77242. private _pointerInput;
  77243. private _onMouseMove;
  77244. private _observer;
  77245. private previousPosition;
  77246. /**
  77247. * Observable for when a pointer move event occurs containing the move offset
  77248. */
  77249. onPointerMovedObservable: Observable<{
  77250. offsetX: number;
  77251. offsetY: number;
  77252. }>;
  77253. /**
  77254. * @hidden
  77255. * If the camera should be rotated automatically based on pointer movement
  77256. */
  77257. _allowCameraRotation: boolean;
  77258. /**
  77259. * Manage the mouse inputs to control the movement of a free camera.
  77260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77261. * @param touchEnabled Defines if touch is enabled or not
  77262. */
  77263. constructor(
  77264. /**
  77265. * Define if touch is enabled in the mouse input
  77266. */
  77267. touchEnabled?: boolean);
  77268. /**
  77269. * Attach the input controls to a specific dom element to get the input from.
  77270. * @param element Defines the element the controls should be listened from
  77271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77272. */
  77273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77274. /**
  77275. * Called on JS contextmenu event.
  77276. * Override this method to provide functionality.
  77277. */
  77278. protected onContextMenu(evt: PointerEvent): void;
  77279. /**
  77280. * Detach the current controls from the specified dom element.
  77281. * @param element Defines the element to stop listening the inputs from
  77282. */
  77283. detachControl(element: Nullable<HTMLElement>): void;
  77284. /**
  77285. * Gets the class name of the current intput.
  77286. * @returns the class name
  77287. */
  77288. getClassName(): string;
  77289. /**
  77290. * Get the friendly name associated with the input class.
  77291. * @returns the input friendly name
  77292. */
  77293. getSimpleName(): string;
  77294. }
  77295. }
  77296. declare module BABYLON {
  77297. /**
  77298. * Manage the touch inputs to control the movement of a free camera.
  77299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77300. */
  77301. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77302. /**
  77303. * Defines the camera the input is attached to.
  77304. */
  77305. camera: FreeCamera;
  77306. /**
  77307. * Defines the touch sensibility for rotation.
  77308. * The higher the faster.
  77309. */
  77310. touchAngularSensibility: number;
  77311. /**
  77312. * Defines the touch sensibility for move.
  77313. * The higher the faster.
  77314. */
  77315. touchMoveSensibility: number;
  77316. private _offsetX;
  77317. private _offsetY;
  77318. private _pointerPressed;
  77319. private _pointerInput;
  77320. private _observer;
  77321. private _onLostFocus;
  77322. /**
  77323. * Attach the input controls to a specific dom element to get the input from.
  77324. * @param element Defines the element the controls should be listened from
  77325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77326. */
  77327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77328. /**
  77329. * Detach the current controls from the specified dom element.
  77330. * @param element Defines the element to stop listening the inputs from
  77331. */
  77332. detachControl(element: Nullable<HTMLElement>): void;
  77333. /**
  77334. * Update the current camera state depending on the inputs that have been used this frame.
  77335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77336. */
  77337. checkInputs(): void;
  77338. /**
  77339. * Gets the class name of the current intput.
  77340. * @returns the class name
  77341. */
  77342. getClassName(): string;
  77343. /**
  77344. * Get the friendly name associated with the input class.
  77345. * @returns the input friendly name
  77346. */
  77347. getSimpleName(): string;
  77348. }
  77349. }
  77350. declare module BABYLON {
  77351. /**
  77352. * Default Inputs manager for the FreeCamera.
  77353. * It groups all the default supported inputs for ease of use.
  77354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77355. */
  77356. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77357. /**
  77358. * @hidden
  77359. */
  77360. _mouseInput: Nullable<FreeCameraMouseInput>;
  77361. /**
  77362. * Instantiates a new FreeCameraInputsManager.
  77363. * @param camera Defines the camera the inputs belong to
  77364. */
  77365. constructor(camera: FreeCamera);
  77366. /**
  77367. * Add keyboard input support to the input manager.
  77368. * @returns the current input manager
  77369. */
  77370. addKeyboard(): FreeCameraInputsManager;
  77371. /**
  77372. * Add mouse input support to the input manager.
  77373. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77374. * @returns the current input manager
  77375. */
  77376. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77377. /**
  77378. * Removes the mouse input support from the manager
  77379. * @returns the current input manager
  77380. */
  77381. removeMouse(): FreeCameraInputsManager;
  77382. /**
  77383. * Add touch input support to the input manager.
  77384. * @returns the current input manager
  77385. */
  77386. addTouch(): FreeCameraInputsManager;
  77387. /**
  77388. * Remove all attached input methods from a camera
  77389. */
  77390. clear(): void;
  77391. }
  77392. }
  77393. declare module BABYLON {
  77394. /**
  77395. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77396. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77398. */
  77399. export class FreeCamera extends TargetCamera {
  77400. /**
  77401. * Define the collision ellipsoid of the camera.
  77402. * This is helpful to simulate a camera body like the player body around the camera
  77403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77404. */
  77405. ellipsoid: Vector3;
  77406. /**
  77407. * Define an offset for the position of the ellipsoid around the camera.
  77408. * This can be helpful to determine the center of the body near the gravity center of the body
  77409. * instead of its head.
  77410. */
  77411. ellipsoidOffset: Vector3;
  77412. /**
  77413. * Enable or disable collisions of the camera with the rest of the scene objects.
  77414. */
  77415. checkCollisions: boolean;
  77416. /**
  77417. * Enable or disable gravity on the camera.
  77418. */
  77419. applyGravity: boolean;
  77420. /**
  77421. * Define the input manager associated to the camera.
  77422. */
  77423. inputs: FreeCameraInputsManager;
  77424. /**
  77425. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77426. * Higher values reduce sensitivity.
  77427. */
  77428. /**
  77429. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77430. * Higher values reduce sensitivity.
  77431. */
  77432. angularSensibility: number;
  77433. /**
  77434. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77435. */
  77436. keysUp: number[];
  77437. /**
  77438. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77439. */
  77440. keysDown: number[];
  77441. /**
  77442. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77443. */
  77444. keysLeft: number[];
  77445. /**
  77446. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77447. */
  77448. keysRight: number[];
  77449. /**
  77450. * Event raised when the camera collide with a mesh in the scene.
  77451. */
  77452. onCollide: (collidedMesh: AbstractMesh) => void;
  77453. private _collider;
  77454. private _needMoveForGravity;
  77455. private _oldPosition;
  77456. private _diffPosition;
  77457. private _newPosition;
  77458. /** @hidden */
  77459. _localDirection: Vector3;
  77460. /** @hidden */
  77461. _transformedDirection: Vector3;
  77462. /**
  77463. * Instantiates a Free Camera.
  77464. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77465. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77467. * @param name Define the name of the camera in the scene
  77468. * @param position Define the start position of the camera in the scene
  77469. * @param scene Define the scene the camera belongs to
  77470. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77471. */
  77472. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77473. /**
  77474. * Attached controls to the current camera.
  77475. * @param element Defines the element the controls should be listened from
  77476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77477. */
  77478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77479. /**
  77480. * Detach the current controls from the camera.
  77481. * The camera will stop reacting to inputs.
  77482. * @param element Defines the element to stop listening the inputs from
  77483. */
  77484. detachControl(element: HTMLElement): void;
  77485. private _collisionMask;
  77486. /**
  77487. * Define a collision mask to limit the list of object the camera can collide with
  77488. */
  77489. collisionMask: number;
  77490. /** @hidden */
  77491. _collideWithWorld(displacement: Vector3): void;
  77492. private _onCollisionPositionChange;
  77493. /** @hidden */
  77494. _checkInputs(): void;
  77495. /** @hidden */
  77496. _decideIfNeedsToMove(): boolean;
  77497. /** @hidden */
  77498. _updatePosition(): void;
  77499. /**
  77500. * Destroy the camera and release the current resources hold by it.
  77501. */
  77502. dispose(): void;
  77503. /**
  77504. * Gets the current object class name.
  77505. * @return the class name
  77506. */
  77507. getClassName(): string;
  77508. }
  77509. }
  77510. declare module BABYLON {
  77511. /**
  77512. * Represents a gamepad control stick position
  77513. */
  77514. export class StickValues {
  77515. /**
  77516. * The x component of the control stick
  77517. */
  77518. x: number;
  77519. /**
  77520. * The y component of the control stick
  77521. */
  77522. y: number;
  77523. /**
  77524. * Initializes the gamepad x and y control stick values
  77525. * @param x The x component of the gamepad control stick value
  77526. * @param y The y component of the gamepad control stick value
  77527. */
  77528. constructor(
  77529. /**
  77530. * The x component of the control stick
  77531. */
  77532. x: number,
  77533. /**
  77534. * The y component of the control stick
  77535. */
  77536. y: number);
  77537. }
  77538. /**
  77539. * An interface which manages callbacks for gamepad button changes
  77540. */
  77541. export interface GamepadButtonChanges {
  77542. /**
  77543. * Called when a gamepad has been changed
  77544. */
  77545. changed: boolean;
  77546. /**
  77547. * Called when a gamepad press event has been triggered
  77548. */
  77549. pressChanged: boolean;
  77550. /**
  77551. * Called when a touch event has been triggered
  77552. */
  77553. touchChanged: boolean;
  77554. /**
  77555. * Called when a value has changed
  77556. */
  77557. valueChanged: boolean;
  77558. }
  77559. /**
  77560. * Represents a gamepad
  77561. */
  77562. export class Gamepad {
  77563. /**
  77564. * The id of the gamepad
  77565. */
  77566. id: string;
  77567. /**
  77568. * The index of the gamepad
  77569. */
  77570. index: number;
  77571. /**
  77572. * The browser gamepad
  77573. */
  77574. browserGamepad: any;
  77575. /**
  77576. * Specifies what type of gamepad this represents
  77577. */
  77578. type: number;
  77579. private _leftStick;
  77580. private _rightStick;
  77581. /** @hidden */
  77582. _isConnected: boolean;
  77583. private _leftStickAxisX;
  77584. private _leftStickAxisY;
  77585. private _rightStickAxisX;
  77586. private _rightStickAxisY;
  77587. /**
  77588. * Triggered when the left control stick has been changed
  77589. */
  77590. private _onleftstickchanged;
  77591. /**
  77592. * Triggered when the right control stick has been changed
  77593. */
  77594. private _onrightstickchanged;
  77595. /**
  77596. * Represents a gamepad controller
  77597. */
  77598. static GAMEPAD: number;
  77599. /**
  77600. * Represents a generic controller
  77601. */
  77602. static GENERIC: number;
  77603. /**
  77604. * Represents an XBox controller
  77605. */
  77606. static XBOX: number;
  77607. /**
  77608. * Represents a pose-enabled controller
  77609. */
  77610. static POSE_ENABLED: number;
  77611. /**
  77612. * Represents an Dual Shock controller
  77613. */
  77614. static DUALSHOCK: number;
  77615. /**
  77616. * Specifies whether the left control stick should be Y-inverted
  77617. */
  77618. protected _invertLeftStickY: boolean;
  77619. /**
  77620. * Specifies if the gamepad has been connected
  77621. */
  77622. readonly isConnected: boolean;
  77623. /**
  77624. * Initializes the gamepad
  77625. * @param id The id of the gamepad
  77626. * @param index The index of the gamepad
  77627. * @param browserGamepad The browser gamepad
  77628. * @param leftStickX The x component of the left joystick
  77629. * @param leftStickY The y component of the left joystick
  77630. * @param rightStickX The x component of the right joystick
  77631. * @param rightStickY The y component of the right joystick
  77632. */
  77633. constructor(
  77634. /**
  77635. * The id of the gamepad
  77636. */
  77637. id: string,
  77638. /**
  77639. * The index of the gamepad
  77640. */
  77641. index: number,
  77642. /**
  77643. * The browser gamepad
  77644. */
  77645. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77646. /**
  77647. * Callback triggered when the left joystick has changed
  77648. * @param callback
  77649. */
  77650. onleftstickchanged(callback: (values: StickValues) => void): void;
  77651. /**
  77652. * Callback triggered when the right joystick has changed
  77653. * @param callback
  77654. */
  77655. onrightstickchanged(callback: (values: StickValues) => void): void;
  77656. /**
  77657. * Gets the left joystick
  77658. */
  77659. /**
  77660. * Sets the left joystick values
  77661. */
  77662. leftStick: StickValues;
  77663. /**
  77664. * Gets the right joystick
  77665. */
  77666. /**
  77667. * Sets the right joystick value
  77668. */
  77669. rightStick: StickValues;
  77670. /**
  77671. * Updates the gamepad joystick positions
  77672. */
  77673. update(): void;
  77674. /**
  77675. * Disposes the gamepad
  77676. */
  77677. dispose(): void;
  77678. }
  77679. /**
  77680. * Represents a generic gamepad
  77681. */
  77682. export class GenericPad extends Gamepad {
  77683. private _buttons;
  77684. private _onbuttondown;
  77685. private _onbuttonup;
  77686. /**
  77687. * Observable triggered when a button has been pressed
  77688. */
  77689. onButtonDownObservable: Observable<number>;
  77690. /**
  77691. * Observable triggered when a button has been released
  77692. */
  77693. onButtonUpObservable: Observable<number>;
  77694. /**
  77695. * Callback triggered when a button has been pressed
  77696. * @param callback Called when a button has been pressed
  77697. */
  77698. onbuttondown(callback: (buttonPressed: number) => void): void;
  77699. /**
  77700. * Callback triggered when a button has been released
  77701. * @param callback Called when a button has been released
  77702. */
  77703. onbuttonup(callback: (buttonReleased: number) => void): void;
  77704. /**
  77705. * Initializes the generic gamepad
  77706. * @param id The id of the generic gamepad
  77707. * @param index The index of the generic gamepad
  77708. * @param browserGamepad The browser gamepad
  77709. */
  77710. constructor(id: string, index: number, browserGamepad: any);
  77711. private _setButtonValue;
  77712. /**
  77713. * Updates the generic gamepad
  77714. */
  77715. update(): void;
  77716. /**
  77717. * Disposes the generic gamepad
  77718. */
  77719. dispose(): void;
  77720. }
  77721. }
  77722. declare module BABYLON {
  77723. interface Engine {
  77724. /**
  77725. * Creates a raw texture
  77726. * @param data defines the data to store in the texture
  77727. * @param width defines the width of the texture
  77728. * @param height defines the height of the texture
  77729. * @param format defines the format of the data
  77730. * @param generateMipMaps defines if the engine should generate the mip levels
  77731. * @param invertY defines if data must be stored with Y axis inverted
  77732. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77733. * @param compression defines the compression used (null by default)
  77734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77735. * @returns the raw texture inside an InternalTexture
  77736. */
  77737. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77738. /**
  77739. * Update a raw texture
  77740. * @param texture defines the texture to update
  77741. * @param data defines the data to store in the texture
  77742. * @param format defines the format of the data
  77743. * @param invertY defines if data must be stored with Y axis inverted
  77744. */
  77745. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77746. /**
  77747. * Update a raw texture
  77748. * @param texture defines the texture to update
  77749. * @param data defines the data to store in the texture
  77750. * @param format defines the format of the data
  77751. * @param invertY defines if data must be stored with Y axis inverted
  77752. * @param compression defines the compression used (null by default)
  77753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77754. */
  77755. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77756. /**
  77757. * Creates a new raw cube texture
  77758. * @param data defines the array of data to use to create each face
  77759. * @param size defines the size of the textures
  77760. * @param format defines the format of the data
  77761. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77762. * @param generateMipMaps defines if the engine should generate the mip levels
  77763. * @param invertY defines if data must be stored with Y axis inverted
  77764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77765. * @param compression defines the compression used (null by default)
  77766. * @returns the cube texture as an InternalTexture
  77767. */
  77768. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77769. /**
  77770. * Update a raw cube texture
  77771. * @param texture defines the texture to udpdate
  77772. * @param data defines the data to store
  77773. * @param format defines the data format
  77774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77775. * @param invertY defines if data must be stored with Y axis inverted
  77776. */
  77777. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77778. /**
  77779. * Update a raw cube texture
  77780. * @param texture defines the texture to udpdate
  77781. * @param data defines the data to store
  77782. * @param format defines the data format
  77783. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77784. * @param invertY defines if data must be stored with Y axis inverted
  77785. * @param compression defines the compression used (null by default)
  77786. */
  77787. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77788. /**
  77789. * Update a raw cube texture
  77790. * @param texture defines the texture to udpdate
  77791. * @param data defines the data to store
  77792. * @param format defines the data format
  77793. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77794. * @param invertY defines if data must be stored with Y axis inverted
  77795. * @param compression defines the compression used (null by default)
  77796. * @param level defines which level of the texture to update
  77797. */
  77798. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77799. /**
  77800. * Creates a new raw cube texture from a specified url
  77801. * @param url defines the url where the data is located
  77802. * @param scene defines the current scene
  77803. * @param size defines the size of the textures
  77804. * @param format defines the format of the data
  77805. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77806. * @param noMipmap defines if the engine should avoid generating the mip levels
  77807. * @param callback defines a callback used to extract texture data from loaded data
  77808. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77809. * @param onLoad defines a callback called when texture is loaded
  77810. * @param onError defines a callback called if there is an error
  77811. * @returns the cube texture as an InternalTexture
  77812. */
  77813. 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;
  77814. /**
  77815. * Creates a new raw cube texture from a specified url
  77816. * @param url defines the url where the data is located
  77817. * @param scene defines the current scene
  77818. * @param size defines the size of the textures
  77819. * @param format defines the format of the data
  77820. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77821. * @param noMipmap defines if the engine should avoid generating the mip levels
  77822. * @param callback defines a callback used to extract texture data from loaded data
  77823. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77824. * @param onLoad defines a callback called when texture is loaded
  77825. * @param onError defines a callback called if there is an error
  77826. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77827. * @param invertY defines if data must be stored with Y axis inverted
  77828. * @returns the cube texture as an InternalTexture
  77829. */
  77830. 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;
  77831. /**
  77832. * Creates a new raw 3D texture
  77833. * @param data defines the data used to create the texture
  77834. * @param width defines the width of the texture
  77835. * @param height defines the height of the texture
  77836. * @param depth defines the depth of the texture
  77837. * @param format defines the format of the texture
  77838. * @param generateMipMaps defines if the engine must generate mip levels
  77839. * @param invertY defines if data must be stored with Y axis inverted
  77840. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77841. * @param compression defines the compressed used (can be null)
  77842. * @param textureType defines the compressed used (can be null)
  77843. * @returns a new raw 3D texture (stored in an InternalTexture)
  77844. */
  77845. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77846. /**
  77847. * Update a raw 3D texture
  77848. * @param texture defines the texture to update
  77849. * @param data defines the data to store
  77850. * @param format defines the data format
  77851. * @param invertY defines if data must be stored with Y axis inverted
  77852. */
  77853. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77854. /**
  77855. * Update a raw 3D texture
  77856. * @param texture defines the texture to update
  77857. * @param data defines the data to store
  77858. * @param format defines the data format
  77859. * @param invertY defines if data must be stored with Y axis inverted
  77860. * @param compression defines the used compression (can be null)
  77861. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77862. */
  77863. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77864. }
  77865. }
  77866. declare module BABYLON {
  77867. /**
  77868. * Raw texture can help creating a texture directly from an array of data.
  77869. * This can be super useful if you either get the data from an uncompressed source or
  77870. * if you wish to create your texture pixel by pixel.
  77871. */
  77872. export class RawTexture extends Texture {
  77873. /**
  77874. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77875. */
  77876. format: number;
  77877. private _engine;
  77878. /**
  77879. * Instantiates a new RawTexture.
  77880. * Raw texture can help creating a texture directly from an array of data.
  77881. * This can be super useful if you either get the data from an uncompressed source or
  77882. * if you wish to create your texture pixel by pixel.
  77883. * @param data define the array of data to use to create the texture
  77884. * @param width define the width of the texture
  77885. * @param height define the height of the texture
  77886. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77887. * @param scene define the scene the texture belongs to
  77888. * @param generateMipMaps define whether mip maps should be generated or not
  77889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77892. */
  77893. constructor(data: ArrayBufferView, width: number, height: number,
  77894. /**
  77895. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77896. */
  77897. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77898. /**
  77899. * Updates the texture underlying data.
  77900. * @param data Define the new data of the texture
  77901. */
  77902. update(data: ArrayBufferView): void;
  77903. /**
  77904. * Creates a luminance texture from some data.
  77905. * @param data Define the texture data
  77906. * @param width Define the width of the texture
  77907. * @param height Define the height of the texture
  77908. * @param scene Define the scene the texture belongs to
  77909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77912. * @returns the luminance texture
  77913. */
  77914. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77915. /**
  77916. * Creates a luminance alpha texture from some data.
  77917. * @param data Define the texture data
  77918. * @param width Define the width of the texture
  77919. * @param height Define the height of the texture
  77920. * @param scene Define the scene the texture belongs to
  77921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77924. * @returns the luminance alpha texture
  77925. */
  77926. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77927. /**
  77928. * Creates an alpha texture from some data.
  77929. * @param data Define the texture data
  77930. * @param width Define the width of the texture
  77931. * @param height Define the height of the texture
  77932. * @param scene Define the scene the texture belongs to
  77933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77936. * @returns the alpha texture
  77937. */
  77938. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77939. /**
  77940. * Creates a RGB texture from some data.
  77941. * @param data Define the texture data
  77942. * @param width Define the width of the texture
  77943. * @param height Define the height of the texture
  77944. * @param scene Define the scene the texture belongs to
  77945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77949. * @returns the RGB alpha texture
  77950. */
  77951. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77952. /**
  77953. * Creates a RGBA texture from some data.
  77954. * @param data Define the texture data
  77955. * @param width Define the width of the texture
  77956. * @param height Define the height of the texture
  77957. * @param scene Define the scene the texture belongs to
  77958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77962. * @returns the RGBA texture
  77963. */
  77964. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77965. /**
  77966. * Creates a R texture from some data.
  77967. * @param data Define the texture data
  77968. * @param width Define the width of the texture
  77969. * @param height Define the height of the texture
  77970. * @param scene Define the scene the texture belongs to
  77971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77975. * @returns the R texture
  77976. */
  77977. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77978. }
  77979. }
  77980. declare module BABYLON {
  77981. /**
  77982. * Interface for the size containing width and height
  77983. */
  77984. export interface ISize {
  77985. /**
  77986. * Width
  77987. */
  77988. width: number;
  77989. /**
  77990. * Heighht
  77991. */
  77992. height: number;
  77993. }
  77994. /**
  77995. * Size containing widht and height
  77996. */
  77997. export class Size implements ISize {
  77998. /**
  77999. * Width
  78000. */
  78001. width: number;
  78002. /**
  78003. * Height
  78004. */
  78005. height: number;
  78006. /**
  78007. * Creates a Size object from the given width and height (floats).
  78008. * @param width width of the new size
  78009. * @param height height of the new size
  78010. */
  78011. constructor(width: number, height: number);
  78012. /**
  78013. * Returns a string with the Size width and height
  78014. * @returns a string with the Size width and height
  78015. */
  78016. toString(): string;
  78017. /**
  78018. * "Size"
  78019. * @returns the string "Size"
  78020. */
  78021. getClassName(): string;
  78022. /**
  78023. * Returns the Size hash code.
  78024. * @returns a hash code for a unique width and height
  78025. */
  78026. getHashCode(): number;
  78027. /**
  78028. * Updates the current size from the given one.
  78029. * @param src the given size
  78030. */
  78031. copyFrom(src: Size): void;
  78032. /**
  78033. * Updates in place the current Size from the given floats.
  78034. * @param width width of the new size
  78035. * @param height height of the new size
  78036. * @returns the updated Size.
  78037. */
  78038. copyFromFloats(width: number, height: number): Size;
  78039. /**
  78040. * Updates in place the current Size from the given floats.
  78041. * @param width width to set
  78042. * @param height height to set
  78043. * @returns the updated Size.
  78044. */
  78045. set(width: number, height: number): Size;
  78046. /**
  78047. * Multiplies the width and height by numbers
  78048. * @param w factor to multiple the width by
  78049. * @param h factor to multiple the height by
  78050. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78051. */
  78052. multiplyByFloats(w: number, h: number): Size;
  78053. /**
  78054. * Clones the size
  78055. * @returns a new Size copied from the given one.
  78056. */
  78057. clone(): Size;
  78058. /**
  78059. * True if the current Size and the given one width and height are strictly equal.
  78060. * @param other the other size to compare against
  78061. * @returns True if the current Size and the given one width and height are strictly equal.
  78062. */
  78063. equals(other: Size): boolean;
  78064. /**
  78065. * The surface of the Size : width * height (float).
  78066. */
  78067. readonly surface: number;
  78068. /**
  78069. * Create a new size of zero
  78070. * @returns a new Size set to (0.0, 0.0)
  78071. */
  78072. static Zero(): Size;
  78073. /**
  78074. * Sums the width and height of two sizes
  78075. * @param otherSize size to add to this size
  78076. * @returns a new Size set as the addition result of the current Size and the given one.
  78077. */
  78078. add(otherSize: Size): Size;
  78079. /**
  78080. * Subtracts the width and height of two
  78081. * @param otherSize size to subtract to this size
  78082. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78083. */
  78084. subtract(otherSize: Size): Size;
  78085. /**
  78086. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78087. * @param start starting size to lerp between
  78088. * @param end end size to lerp between
  78089. * @param amount amount to lerp between the start and end values
  78090. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78091. */
  78092. static Lerp(start: Size, end: Size, amount: number): Size;
  78093. }
  78094. }
  78095. declare module BABYLON {
  78096. /**
  78097. * Defines a runtime animation
  78098. */
  78099. export class RuntimeAnimation {
  78100. private _events;
  78101. /**
  78102. * The current frame of the runtime animation
  78103. */
  78104. private _currentFrame;
  78105. /**
  78106. * The animation used by the runtime animation
  78107. */
  78108. private _animation;
  78109. /**
  78110. * The target of the runtime animation
  78111. */
  78112. private _target;
  78113. /**
  78114. * The initiating animatable
  78115. */
  78116. private _host;
  78117. /**
  78118. * The original value of the runtime animation
  78119. */
  78120. private _originalValue;
  78121. /**
  78122. * The original blend value of the runtime animation
  78123. */
  78124. private _originalBlendValue;
  78125. /**
  78126. * The offsets cache of the runtime animation
  78127. */
  78128. private _offsetsCache;
  78129. /**
  78130. * The high limits cache of the runtime animation
  78131. */
  78132. private _highLimitsCache;
  78133. /**
  78134. * Specifies if the runtime animation has been stopped
  78135. */
  78136. private _stopped;
  78137. /**
  78138. * The blending factor of the runtime animation
  78139. */
  78140. private _blendingFactor;
  78141. /**
  78142. * The BabylonJS scene
  78143. */
  78144. private _scene;
  78145. /**
  78146. * The current value of the runtime animation
  78147. */
  78148. private _currentValue;
  78149. /** @hidden */
  78150. _animationState: _IAnimationState;
  78151. /**
  78152. * The active target of the runtime animation
  78153. */
  78154. private _activeTargets;
  78155. private _currentActiveTarget;
  78156. private _directTarget;
  78157. /**
  78158. * The target path of the runtime animation
  78159. */
  78160. private _targetPath;
  78161. /**
  78162. * The weight of the runtime animation
  78163. */
  78164. private _weight;
  78165. /**
  78166. * The ratio offset of the runtime animation
  78167. */
  78168. private _ratioOffset;
  78169. /**
  78170. * The previous delay of the runtime animation
  78171. */
  78172. private _previousDelay;
  78173. /**
  78174. * The previous ratio of the runtime animation
  78175. */
  78176. private _previousRatio;
  78177. private _enableBlending;
  78178. private _keys;
  78179. private _minFrame;
  78180. private _maxFrame;
  78181. private _minValue;
  78182. private _maxValue;
  78183. private _targetIsArray;
  78184. /**
  78185. * Gets the current frame of the runtime animation
  78186. */
  78187. readonly currentFrame: number;
  78188. /**
  78189. * Gets the weight of the runtime animation
  78190. */
  78191. readonly weight: number;
  78192. /**
  78193. * Gets the current value of the runtime animation
  78194. */
  78195. readonly currentValue: any;
  78196. /**
  78197. * Gets the target path of the runtime animation
  78198. */
  78199. readonly targetPath: string;
  78200. /**
  78201. * Gets the actual target of the runtime animation
  78202. */
  78203. readonly target: any;
  78204. /** @hidden */
  78205. _onLoop: () => void;
  78206. /**
  78207. * Create a new RuntimeAnimation object
  78208. * @param target defines the target of the animation
  78209. * @param animation defines the source animation object
  78210. * @param scene defines the hosting scene
  78211. * @param host defines the initiating Animatable
  78212. */
  78213. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78214. private _preparePath;
  78215. /**
  78216. * Gets the animation from the runtime animation
  78217. */
  78218. readonly animation: Animation;
  78219. /**
  78220. * Resets the runtime animation to the beginning
  78221. * @param restoreOriginal defines whether to restore the target property to the original value
  78222. */
  78223. reset(restoreOriginal?: boolean): void;
  78224. /**
  78225. * Specifies if the runtime animation is stopped
  78226. * @returns Boolean specifying if the runtime animation is stopped
  78227. */
  78228. isStopped(): boolean;
  78229. /**
  78230. * Disposes of the runtime animation
  78231. */
  78232. dispose(): void;
  78233. /**
  78234. * Apply the interpolated value to the target
  78235. * @param currentValue defines the value computed by the animation
  78236. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78237. */
  78238. setValue(currentValue: any, weight: number): void;
  78239. private _getOriginalValues;
  78240. private _setValue;
  78241. /**
  78242. * Gets the loop pmode of the runtime animation
  78243. * @returns Loop Mode
  78244. */
  78245. private _getCorrectLoopMode;
  78246. /**
  78247. * Move the current animation to a given frame
  78248. * @param frame defines the frame to move to
  78249. */
  78250. goToFrame(frame: number): void;
  78251. /**
  78252. * @hidden Internal use only
  78253. */
  78254. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78255. /**
  78256. * Execute the current animation
  78257. * @param delay defines the delay to add to the current frame
  78258. * @param from defines the lower bound of the animation range
  78259. * @param to defines the upper bound of the animation range
  78260. * @param loop defines if the current animation must loop
  78261. * @param speedRatio defines the current speed ratio
  78262. * @param weight defines the weight of the animation (default is -1 so no weight)
  78263. * @param onLoop optional callback called when animation loops
  78264. * @returns a boolean indicating if the animation is running
  78265. */
  78266. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. /**
  78271. * Class used to store an actual running animation
  78272. */
  78273. export class Animatable {
  78274. /** defines the target object */
  78275. target: any;
  78276. /** defines the starting frame number (default is 0) */
  78277. fromFrame: number;
  78278. /** defines the ending frame number (default is 100) */
  78279. toFrame: number;
  78280. /** defines if the animation must loop (default is false) */
  78281. loopAnimation: boolean;
  78282. /** defines a callback to call when animation ends if it is not looping */
  78283. onAnimationEnd?: (() => void) | null | undefined;
  78284. /** defines a callback to call when animation loops */
  78285. onAnimationLoop?: (() => void) | null | undefined;
  78286. private _localDelayOffset;
  78287. private _pausedDelay;
  78288. private _runtimeAnimations;
  78289. private _paused;
  78290. private _scene;
  78291. private _speedRatio;
  78292. private _weight;
  78293. private _syncRoot;
  78294. /**
  78295. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78296. * This will only apply for non looping animation (default is true)
  78297. */
  78298. disposeOnEnd: boolean;
  78299. /**
  78300. * Gets a boolean indicating if the animation has started
  78301. */
  78302. animationStarted: boolean;
  78303. /**
  78304. * Observer raised when the animation ends
  78305. */
  78306. onAnimationEndObservable: Observable<Animatable>;
  78307. /**
  78308. * Observer raised when the animation loops
  78309. */
  78310. onAnimationLoopObservable: Observable<Animatable>;
  78311. /**
  78312. * Gets the root Animatable used to synchronize and normalize animations
  78313. */
  78314. readonly syncRoot: Nullable<Animatable>;
  78315. /**
  78316. * Gets the current frame of the first RuntimeAnimation
  78317. * Used to synchronize Animatables
  78318. */
  78319. readonly masterFrame: number;
  78320. /**
  78321. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78322. */
  78323. weight: number;
  78324. /**
  78325. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78326. */
  78327. speedRatio: number;
  78328. /**
  78329. * Creates a new Animatable
  78330. * @param scene defines the hosting scene
  78331. * @param target defines the target object
  78332. * @param fromFrame defines the starting frame number (default is 0)
  78333. * @param toFrame defines the ending frame number (default is 100)
  78334. * @param loopAnimation defines if the animation must loop (default is false)
  78335. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78336. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78337. * @param animations defines a group of animation to add to the new Animatable
  78338. * @param onAnimationLoop defines a callback to call when animation loops
  78339. */
  78340. constructor(scene: Scene,
  78341. /** defines the target object */
  78342. target: any,
  78343. /** defines the starting frame number (default is 0) */
  78344. fromFrame?: number,
  78345. /** defines the ending frame number (default is 100) */
  78346. toFrame?: number,
  78347. /** defines if the animation must loop (default is false) */
  78348. loopAnimation?: boolean, speedRatio?: number,
  78349. /** defines a callback to call when animation ends if it is not looping */
  78350. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78351. /** defines a callback to call when animation loops */
  78352. onAnimationLoop?: (() => void) | null | undefined);
  78353. /**
  78354. * Synchronize and normalize current Animatable with a source Animatable
  78355. * This is useful when using animation weights and when animations are not of the same length
  78356. * @param root defines the root Animatable to synchronize with
  78357. * @returns the current Animatable
  78358. */
  78359. syncWith(root: Animatable): Animatable;
  78360. /**
  78361. * Gets the list of runtime animations
  78362. * @returns an array of RuntimeAnimation
  78363. */
  78364. getAnimations(): RuntimeAnimation[];
  78365. /**
  78366. * Adds more animations to the current animatable
  78367. * @param target defines the target of the animations
  78368. * @param animations defines the new animations to add
  78369. */
  78370. appendAnimations(target: any, animations: Animation[]): void;
  78371. /**
  78372. * Gets the source animation for a specific property
  78373. * @param property defines the propertyu to look for
  78374. * @returns null or the source animation for the given property
  78375. */
  78376. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78377. /**
  78378. * Gets the runtime animation for a specific property
  78379. * @param property defines the propertyu to look for
  78380. * @returns null or the runtime animation for the given property
  78381. */
  78382. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78383. /**
  78384. * Resets the animatable to its original state
  78385. */
  78386. reset(): void;
  78387. /**
  78388. * Allows the animatable to blend with current running animations
  78389. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78390. * @param blendingSpeed defines the blending speed to use
  78391. */
  78392. enableBlending(blendingSpeed: number): void;
  78393. /**
  78394. * Disable animation blending
  78395. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78396. */
  78397. disableBlending(): void;
  78398. /**
  78399. * Jump directly to a given frame
  78400. * @param frame defines the frame to jump to
  78401. */
  78402. goToFrame(frame: number): void;
  78403. /**
  78404. * Pause the animation
  78405. */
  78406. pause(): void;
  78407. /**
  78408. * Restart the animation
  78409. */
  78410. restart(): void;
  78411. private _raiseOnAnimationEnd;
  78412. /**
  78413. * Stop and delete the current animation
  78414. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78415. * @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)
  78416. */
  78417. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78418. /**
  78419. * Wait asynchronously for the animation to end
  78420. * @returns a promise which will be fullfilled when the animation ends
  78421. */
  78422. waitAsync(): Promise<Animatable>;
  78423. /** @hidden */
  78424. _animate(delay: number): boolean;
  78425. }
  78426. interface Scene {
  78427. /** @hidden */
  78428. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78429. /** @hidden */
  78430. _processLateAnimationBindingsForMatrices(holder: {
  78431. totalWeight: number;
  78432. animations: RuntimeAnimation[];
  78433. originalValue: Matrix;
  78434. }): any;
  78435. /** @hidden */
  78436. _processLateAnimationBindingsForQuaternions(holder: {
  78437. totalWeight: number;
  78438. animations: RuntimeAnimation[];
  78439. originalValue: Quaternion;
  78440. }, refQuaternion: Quaternion): Quaternion;
  78441. /** @hidden */
  78442. _processLateAnimationBindings(): void;
  78443. /**
  78444. * Will start the animation sequence of a given target
  78445. * @param target defines the target
  78446. * @param from defines from which frame should animation start
  78447. * @param to defines until which frame should animation run.
  78448. * @param weight defines the weight to apply to the animation (1.0 by default)
  78449. * @param loop defines if the animation loops
  78450. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78451. * @param onAnimationEnd defines the function to be executed when the animation ends
  78452. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78453. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78454. * @param onAnimationLoop defines the callback to call when an animation loops
  78455. * @returns the animatable object created for this animation
  78456. */
  78457. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78458. /**
  78459. * Will start the animation sequence of a given target
  78460. * @param target defines the target
  78461. * @param from defines from which frame should animation start
  78462. * @param to defines until which frame should animation run.
  78463. * @param loop defines if the animation loops
  78464. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78465. * @param onAnimationEnd defines the function to be executed when the animation ends
  78466. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78467. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78468. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78469. * @param onAnimationLoop defines the callback to call when an animation loops
  78470. * @returns the animatable object created for this animation
  78471. */
  78472. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78473. /**
  78474. * Will start the animation sequence of a given target and its hierarchy
  78475. * @param target defines the target
  78476. * @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.
  78477. * @param from defines from which frame should animation start
  78478. * @param to defines until which frame should animation run.
  78479. * @param loop defines if the animation loops
  78480. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78481. * @param onAnimationEnd defines the function to be executed when the animation ends
  78482. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78483. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78484. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78485. * @param onAnimationLoop defines the callback to call when an animation loops
  78486. * @returns the list of created animatables
  78487. */
  78488. 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[];
  78489. /**
  78490. * Begin a new animation on a given node
  78491. * @param target defines the target where the animation will take place
  78492. * @param animations defines the list of animations to start
  78493. * @param from defines the initial value
  78494. * @param to defines the final value
  78495. * @param loop defines if you want animation to loop (off by default)
  78496. * @param speedRatio defines the speed ratio to apply to all animations
  78497. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78498. * @param onAnimationLoop defines the callback to call when an animation loops
  78499. * @returns the list of created animatables
  78500. */
  78501. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78502. /**
  78503. * Begin a new animation on a given node and its hierarchy
  78504. * @param target defines the root node where the animation will take place
  78505. * @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.
  78506. * @param animations defines the list of animations to start
  78507. * @param from defines the initial value
  78508. * @param to defines the final value
  78509. * @param loop defines if you want animation to loop (off by default)
  78510. * @param speedRatio defines the speed ratio to apply to all animations
  78511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78512. * @param onAnimationLoop defines the callback to call when an animation loops
  78513. * @returns the list of animatables created for all nodes
  78514. */
  78515. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78516. /**
  78517. * Gets the animatable associated with a specific target
  78518. * @param target defines the target of the animatable
  78519. * @returns the required animatable if found
  78520. */
  78521. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78522. /**
  78523. * Gets all animatables associated with a given target
  78524. * @param target defines the target to look animatables for
  78525. * @returns an array of Animatables
  78526. */
  78527. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78528. /**
  78529. * Stops and removes all animations that have been applied to the scene
  78530. */
  78531. stopAllAnimations(): void;
  78532. }
  78533. interface Bone {
  78534. /**
  78535. * Copy an animation range from another bone
  78536. * @param source defines the source bone
  78537. * @param rangeName defines the range name to copy
  78538. * @param frameOffset defines the frame offset
  78539. * @param rescaleAsRequired defines if rescaling must be applied if required
  78540. * @param skelDimensionsRatio defines the scaling ratio
  78541. * @returns true if operation was successful
  78542. */
  78543. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78544. }
  78545. }
  78546. declare module BABYLON {
  78547. /**
  78548. * Class used to override all child animations of a given target
  78549. */
  78550. export class AnimationPropertiesOverride {
  78551. /**
  78552. * Gets or sets a value indicating if animation blending must be used
  78553. */
  78554. enableBlending: boolean;
  78555. /**
  78556. * Gets or sets the blending speed to use when enableBlending is true
  78557. */
  78558. blendingSpeed: number;
  78559. /**
  78560. * Gets or sets the default loop mode to use
  78561. */
  78562. loopMode: number;
  78563. }
  78564. }
  78565. declare module BABYLON {
  78566. /**
  78567. * Class used to handle skinning animations
  78568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78569. */
  78570. export class Skeleton implements IAnimatable {
  78571. /** defines the skeleton name */
  78572. name: string;
  78573. /** defines the skeleton Id */
  78574. id: string;
  78575. /**
  78576. * Defines the list of child bones
  78577. */
  78578. bones: Bone[];
  78579. /**
  78580. * Defines an estimate of the dimension of the skeleton at rest
  78581. */
  78582. dimensionsAtRest: Vector3;
  78583. /**
  78584. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78585. */
  78586. needInitialSkinMatrix: boolean;
  78587. /**
  78588. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78589. */
  78590. overrideMesh: Nullable<AbstractMesh>;
  78591. /**
  78592. * Gets the list of animations attached to this skeleton
  78593. */
  78594. animations: Array<Animation>;
  78595. private _scene;
  78596. private _isDirty;
  78597. private _transformMatrices;
  78598. private _transformMatrixTexture;
  78599. private _meshesWithPoseMatrix;
  78600. private _animatables;
  78601. private _identity;
  78602. private _synchronizedWithMesh;
  78603. private _ranges;
  78604. private _lastAbsoluteTransformsUpdateId;
  78605. private _canUseTextureForBones;
  78606. private _uniqueId;
  78607. /** @hidden */
  78608. _numBonesWithLinkedTransformNode: number;
  78609. /** @hidden */
  78610. _hasWaitingData: Nullable<boolean>;
  78611. /**
  78612. * Specifies if the skeleton should be serialized
  78613. */
  78614. doNotSerialize: boolean;
  78615. private _useTextureToStoreBoneMatrices;
  78616. /**
  78617. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78618. * Please note that this option is not available if the hardware does not support it
  78619. */
  78620. useTextureToStoreBoneMatrices: boolean;
  78621. private _animationPropertiesOverride;
  78622. /**
  78623. * Gets or sets the animation properties override
  78624. */
  78625. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78626. /**
  78627. * List of inspectable custom properties (used by the Inspector)
  78628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78629. */
  78630. inspectableCustomProperties: IInspectable[];
  78631. /**
  78632. * An observable triggered before computing the skeleton's matrices
  78633. */
  78634. onBeforeComputeObservable: Observable<Skeleton>;
  78635. /**
  78636. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78637. */
  78638. readonly isUsingTextureForMatrices: boolean;
  78639. /**
  78640. * Gets the unique ID of this skeleton
  78641. */
  78642. readonly uniqueId: number;
  78643. /**
  78644. * Creates a new skeleton
  78645. * @param name defines the skeleton name
  78646. * @param id defines the skeleton Id
  78647. * @param scene defines the hosting scene
  78648. */
  78649. constructor(
  78650. /** defines the skeleton name */
  78651. name: string,
  78652. /** defines the skeleton Id */
  78653. id: string, scene: Scene);
  78654. /**
  78655. * Gets the current object class name.
  78656. * @return the class name
  78657. */
  78658. getClassName(): string;
  78659. /**
  78660. * Returns an array containing the root bones
  78661. * @returns an array containing the root bones
  78662. */
  78663. getChildren(): Array<Bone>;
  78664. /**
  78665. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78666. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78667. * @returns a Float32Array containing matrices data
  78668. */
  78669. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78670. /**
  78671. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78673. * @returns a raw texture containing the data
  78674. */
  78675. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78676. /**
  78677. * Gets the current hosting scene
  78678. * @returns a scene object
  78679. */
  78680. getScene(): Scene;
  78681. /**
  78682. * Gets a string representing the current skeleton data
  78683. * @param fullDetails defines a boolean indicating if we want a verbose version
  78684. * @returns a string representing the current skeleton data
  78685. */
  78686. toString(fullDetails?: boolean): string;
  78687. /**
  78688. * Get bone's index searching by name
  78689. * @param name defines bone's name to search for
  78690. * @return the indice of the bone. Returns -1 if not found
  78691. */
  78692. getBoneIndexByName(name: string): number;
  78693. /**
  78694. * Creater a new animation range
  78695. * @param name defines the name of the range
  78696. * @param from defines the start key
  78697. * @param to defines the end key
  78698. */
  78699. createAnimationRange(name: string, from: number, to: number): void;
  78700. /**
  78701. * Delete a specific animation range
  78702. * @param name defines the name of the range
  78703. * @param deleteFrames defines if frames must be removed as well
  78704. */
  78705. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78706. /**
  78707. * Gets a specific animation range
  78708. * @param name defines the name of the range to look for
  78709. * @returns the requested animation range or null if not found
  78710. */
  78711. getAnimationRange(name: string): Nullable<AnimationRange>;
  78712. /**
  78713. * Gets the list of all animation ranges defined on this skeleton
  78714. * @returns an array
  78715. */
  78716. getAnimationRanges(): Nullable<AnimationRange>[];
  78717. /**
  78718. * Copy animation range from a source skeleton.
  78719. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78720. * @param source defines the source skeleton
  78721. * @param name defines the name of the range to copy
  78722. * @param rescaleAsRequired defines if rescaling must be applied if required
  78723. * @returns true if operation was successful
  78724. */
  78725. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78726. /**
  78727. * Forces the skeleton to go to rest pose
  78728. */
  78729. returnToRest(): void;
  78730. private _getHighestAnimationFrame;
  78731. /**
  78732. * Begin a specific animation range
  78733. * @param name defines the name of the range to start
  78734. * @param loop defines if looping must be turned on (false by default)
  78735. * @param speedRatio defines the speed ratio to apply (1 by default)
  78736. * @param onAnimationEnd defines a callback which will be called when animation will end
  78737. * @returns a new animatable
  78738. */
  78739. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78740. /** @hidden */
  78741. _markAsDirty(): void;
  78742. /** @hidden */
  78743. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78744. /** @hidden */
  78745. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78746. private _computeTransformMatrices;
  78747. /**
  78748. * Build all resources required to render a skeleton
  78749. */
  78750. prepare(): void;
  78751. /**
  78752. * Gets the list of animatables currently running for this skeleton
  78753. * @returns an array of animatables
  78754. */
  78755. getAnimatables(): IAnimatable[];
  78756. /**
  78757. * Clone the current skeleton
  78758. * @param name defines the name of the new skeleton
  78759. * @param id defines the id of the new skeleton
  78760. * @returns the new skeleton
  78761. */
  78762. clone(name: string, id: string): Skeleton;
  78763. /**
  78764. * Enable animation blending for this skeleton
  78765. * @param blendingSpeed defines the blending speed to apply
  78766. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78767. */
  78768. enableBlending(blendingSpeed?: number): void;
  78769. /**
  78770. * Releases all resources associated with the current skeleton
  78771. */
  78772. dispose(): void;
  78773. /**
  78774. * Serialize the skeleton in a JSON object
  78775. * @returns a JSON object
  78776. */
  78777. serialize(): any;
  78778. /**
  78779. * Creates a new skeleton from serialized data
  78780. * @param parsedSkeleton defines the serialized data
  78781. * @param scene defines the hosting scene
  78782. * @returns a new skeleton
  78783. */
  78784. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78785. /**
  78786. * Compute all node absolute transforms
  78787. * @param forceUpdate defines if computation must be done even if cache is up to date
  78788. */
  78789. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78790. /**
  78791. * Gets the root pose matrix
  78792. * @returns a matrix
  78793. */
  78794. getPoseMatrix(): Nullable<Matrix>;
  78795. /**
  78796. * Sorts bones per internal index
  78797. */
  78798. sortBones(): void;
  78799. private _sortBones;
  78800. }
  78801. }
  78802. declare module BABYLON {
  78803. /**
  78804. * Class used to store bone information
  78805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78806. */
  78807. export class Bone extends Node {
  78808. /**
  78809. * defines the bone name
  78810. */
  78811. name: string;
  78812. private static _tmpVecs;
  78813. private static _tmpQuat;
  78814. private static _tmpMats;
  78815. /**
  78816. * Gets the list of child bones
  78817. */
  78818. children: Bone[];
  78819. /** Gets the animations associated with this bone */
  78820. animations: Animation[];
  78821. /**
  78822. * Gets or sets bone length
  78823. */
  78824. length: number;
  78825. /**
  78826. * @hidden Internal only
  78827. * Set this value to map this bone to a different index in the transform matrices
  78828. * Set this value to -1 to exclude the bone from the transform matrices
  78829. */
  78830. _index: Nullable<number>;
  78831. private _skeleton;
  78832. private _localMatrix;
  78833. private _restPose;
  78834. private _baseMatrix;
  78835. private _absoluteTransform;
  78836. private _invertedAbsoluteTransform;
  78837. private _parent;
  78838. private _scalingDeterminant;
  78839. private _worldTransform;
  78840. private _localScaling;
  78841. private _localRotation;
  78842. private _localPosition;
  78843. private _needToDecompose;
  78844. private _needToCompose;
  78845. /** @hidden */
  78846. _linkedTransformNode: Nullable<TransformNode>;
  78847. /** @hidden */
  78848. _waitingTransformNodeId: Nullable<string>;
  78849. /** @hidden */
  78850. /** @hidden */
  78851. _matrix: Matrix;
  78852. /**
  78853. * Create a new bone
  78854. * @param name defines the bone name
  78855. * @param skeleton defines the parent skeleton
  78856. * @param parentBone defines the parent (can be null if the bone is the root)
  78857. * @param localMatrix defines the local matrix
  78858. * @param restPose defines the rest pose matrix
  78859. * @param baseMatrix defines the base matrix
  78860. * @param index defines index of the bone in the hiearchy
  78861. */
  78862. constructor(
  78863. /**
  78864. * defines the bone name
  78865. */
  78866. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78867. /**
  78868. * Gets the current object class name.
  78869. * @return the class name
  78870. */
  78871. getClassName(): string;
  78872. /**
  78873. * Gets the parent skeleton
  78874. * @returns a skeleton
  78875. */
  78876. getSkeleton(): Skeleton;
  78877. /**
  78878. * Gets parent bone
  78879. * @returns a bone or null if the bone is the root of the bone hierarchy
  78880. */
  78881. getParent(): Nullable<Bone>;
  78882. /**
  78883. * Returns an array containing the root bones
  78884. * @returns an array containing the root bones
  78885. */
  78886. getChildren(): Array<Bone>;
  78887. /**
  78888. * Sets the parent bone
  78889. * @param parent defines the parent (can be null if the bone is the root)
  78890. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78891. */
  78892. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78893. /**
  78894. * Gets the local matrix
  78895. * @returns a matrix
  78896. */
  78897. getLocalMatrix(): Matrix;
  78898. /**
  78899. * Gets the base matrix (initial matrix which remains unchanged)
  78900. * @returns a matrix
  78901. */
  78902. getBaseMatrix(): Matrix;
  78903. /**
  78904. * Gets the rest pose matrix
  78905. * @returns a matrix
  78906. */
  78907. getRestPose(): Matrix;
  78908. /**
  78909. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78910. */
  78911. getWorldMatrix(): Matrix;
  78912. /**
  78913. * Sets the local matrix to rest pose matrix
  78914. */
  78915. returnToRest(): void;
  78916. /**
  78917. * Gets the inverse of the absolute transform matrix.
  78918. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78919. * @returns a matrix
  78920. */
  78921. getInvertedAbsoluteTransform(): Matrix;
  78922. /**
  78923. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78924. * @returns a matrix
  78925. */
  78926. getAbsoluteTransform(): Matrix;
  78927. /**
  78928. * Links with the given transform node.
  78929. * The local matrix of this bone is copied from the transform node every frame.
  78930. * @param transformNode defines the transform node to link to
  78931. */
  78932. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78933. /**
  78934. * Gets the node used to drive the bone's transformation
  78935. * @returns a transform node or null
  78936. */
  78937. getTransformNode(): Nullable<TransformNode>;
  78938. /** Gets or sets current position (in local space) */
  78939. position: Vector3;
  78940. /** Gets or sets current rotation (in local space) */
  78941. rotation: Vector3;
  78942. /** Gets or sets current rotation quaternion (in local space) */
  78943. rotationQuaternion: Quaternion;
  78944. /** Gets or sets current scaling (in local space) */
  78945. scaling: Vector3;
  78946. /**
  78947. * Gets the animation properties override
  78948. */
  78949. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78950. private _decompose;
  78951. private _compose;
  78952. /**
  78953. * Update the base and local matrices
  78954. * @param matrix defines the new base or local matrix
  78955. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78956. * @param updateLocalMatrix defines if the local matrix should be updated
  78957. */
  78958. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78959. /** @hidden */
  78960. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78961. /**
  78962. * Flag the bone as dirty (Forcing it to update everything)
  78963. */
  78964. markAsDirty(): void;
  78965. /** @hidden */
  78966. _markAsDirtyAndCompose(): void;
  78967. private _markAsDirtyAndDecompose;
  78968. /**
  78969. * Translate the bone in local or world space
  78970. * @param vec The amount to translate the bone
  78971. * @param space The space that the translation is in
  78972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78973. */
  78974. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78975. /**
  78976. * Set the postion of the bone in local or world space
  78977. * @param position The position to set the bone
  78978. * @param space The space that the position is in
  78979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78980. */
  78981. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78982. /**
  78983. * Set the absolute position of the bone (world space)
  78984. * @param position The position to set the bone
  78985. * @param mesh The mesh that this bone is attached to
  78986. */
  78987. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78988. /**
  78989. * Scale the bone on the x, y and z axes (in local space)
  78990. * @param x The amount to scale the bone on the x axis
  78991. * @param y The amount to scale the bone on the y axis
  78992. * @param z The amount to scale the bone on the z axis
  78993. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78994. */
  78995. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78996. /**
  78997. * Set the bone scaling in local space
  78998. * @param scale defines the scaling vector
  78999. */
  79000. setScale(scale: Vector3): void;
  79001. /**
  79002. * Gets the current scaling in local space
  79003. * @returns the current scaling vector
  79004. */
  79005. getScale(): Vector3;
  79006. /**
  79007. * Gets the current scaling in local space and stores it in a target vector
  79008. * @param result defines the target vector
  79009. */
  79010. getScaleToRef(result: Vector3): void;
  79011. /**
  79012. * Set the yaw, pitch, and roll of the bone in local or world space
  79013. * @param yaw The rotation of the bone on the y axis
  79014. * @param pitch The rotation of the bone on the x axis
  79015. * @param roll The rotation of the bone on the z axis
  79016. * @param space The space that the axes of rotation are in
  79017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79018. */
  79019. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79020. /**
  79021. * Add a rotation to the bone on an axis in local or world space
  79022. * @param axis The axis to rotate the bone on
  79023. * @param amount The amount to rotate the bone
  79024. * @param space The space that the axis is in
  79025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79026. */
  79027. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79028. /**
  79029. * Set the rotation of the bone to a particular axis angle in local or world space
  79030. * @param axis The axis to rotate the bone on
  79031. * @param angle The angle that the bone should be rotated to
  79032. * @param space The space that the axis is in
  79033. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79034. */
  79035. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79036. /**
  79037. * Set the euler rotation of the bone in local of world space
  79038. * @param rotation The euler rotation that the bone should be set to
  79039. * @param space The space that the rotation is in
  79040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79041. */
  79042. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79043. /**
  79044. * Set the quaternion rotation of the bone in local of world space
  79045. * @param quat The quaternion rotation that the bone should be set to
  79046. * @param space The space that the rotation is in
  79047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79048. */
  79049. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79050. /**
  79051. * Set the rotation matrix of the bone in local of world space
  79052. * @param rotMat The rotation matrix that the bone should be set to
  79053. * @param space The space that the rotation is in
  79054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79055. */
  79056. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79057. private _rotateWithMatrix;
  79058. private _getNegativeRotationToRef;
  79059. /**
  79060. * Get the position of the bone in local or world space
  79061. * @param space The space that the returned position is in
  79062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79063. * @returns The position of the bone
  79064. */
  79065. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79066. /**
  79067. * Copy the position of the bone to a vector3 in local or world space
  79068. * @param space The space that the returned position is in
  79069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79070. * @param result The vector3 to copy the position to
  79071. */
  79072. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79073. /**
  79074. * Get the absolute position of the bone (world space)
  79075. * @param mesh The mesh that this bone is attached to
  79076. * @returns The absolute position of the bone
  79077. */
  79078. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79079. /**
  79080. * Copy the absolute position of the bone (world space) to the result param
  79081. * @param mesh The mesh that this bone is attached to
  79082. * @param result The vector3 to copy the absolute position to
  79083. */
  79084. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79085. /**
  79086. * Compute the absolute transforms of this bone and its children
  79087. */
  79088. computeAbsoluteTransforms(): void;
  79089. /**
  79090. * Get the world direction from an axis that is in the local space of the bone
  79091. * @param localAxis The local direction that is used to compute the world direction
  79092. * @param mesh The mesh that this bone is attached to
  79093. * @returns The world direction
  79094. */
  79095. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79096. /**
  79097. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79098. * @param localAxis The local direction that is used to compute the world direction
  79099. * @param mesh The mesh that this bone is attached to
  79100. * @param result The vector3 that the world direction will be copied to
  79101. */
  79102. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79103. /**
  79104. * Get the euler rotation of the bone in local or world space
  79105. * @param space The space that the rotation should be in
  79106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79107. * @returns The euler rotation
  79108. */
  79109. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79110. /**
  79111. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79112. * @param space The space that the rotation should be in
  79113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79114. * @param result The vector3 that the rotation should be copied to
  79115. */
  79116. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79117. /**
  79118. * Get the quaternion rotation of the bone in either local or world space
  79119. * @param space The space that the rotation should be in
  79120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79121. * @returns The quaternion rotation
  79122. */
  79123. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79124. /**
  79125. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79126. * @param space The space that the rotation should be in
  79127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79128. * @param result The quaternion that the rotation should be copied to
  79129. */
  79130. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79131. /**
  79132. * Get the rotation matrix of the bone in local or world space
  79133. * @param space The space that the rotation should be in
  79134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79135. * @returns The rotation matrix
  79136. */
  79137. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79138. /**
  79139. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79140. * @param space The space that the rotation should be in
  79141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79142. * @param result The quaternion that the rotation should be copied to
  79143. */
  79144. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79145. /**
  79146. * Get the world position of a point that is in the local space of the bone
  79147. * @param position The local position
  79148. * @param mesh The mesh that this bone is attached to
  79149. * @returns The world position
  79150. */
  79151. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79152. /**
  79153. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79154. * @param position The local position
  79155. * @param mesh The mesh that this bone is attached to
  79156. * @param result The vector3 that the world position should be copied to
  79157. */
  79158. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79159. /**
  79160. * Get the local position of a point that is in world space
  79161. * @param position The world position
  79162. * @param mesh The mesh that this bone is attached to
  79163. * @returns The local position
  79164. */
  79165. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79166. /**
  79167. * Get the local position of a point that is in world space and copy it to the result param
  79168. * @param position The world position
  79169. * @param mesh The mesh that this bone is attached to
  79170. * @param result The vector3 that the local position should be copied to
  79171. */
  79172. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79173. }
  79174. }
  79175. declare module BABYLON {
  79176. /**
  79177. * 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.
  79178. * @see https://doc.babylonjs.com/how_to/transformnode
  79179. */
  79180. export class TransformNode extends Node {
  79181. /**
  79182. * Object will not rotate to face the camera
  79183. */
  79184. static BILLBOARDMODE_NONE: number;
  79185. /**
  79186. * Object will rotate to face the camera but only on the x axis
  79187. */
  79188. static BILLBOARDMODE_X: number;
  79189. /**
  79190. * Object will rotate to face the camera but only on the y axis
  79191. */
  79192. static BILLBOARDMODE_Y: number;
  79193. /**
  79194. * Object will rotate to face the camera but only on the z axis
  79195. */
  79196. static BILLBOARDMODE_Z: number;
  79197. /**
  79198. * Object will rotate to face the camera
  79199. */
  79200. static BILLBOARDMODE_ALL: number;
  79201. /**
  79202. * Object will rotate to face the camera's position instead of orientation
  79203. */
  79204. static BILLBOARDMODE_USE_POSITION: number;
  79205. private _forward;
  79206. private _forwardInverted;
  79207. private _up;
  79208. private _right;
  79209. private _rightInverted;
  79210. private _position;
  79211. private _rotation;
  79212. private _rotationQuaternion;
  79213. protected _scaling: Vector3;
  79214. protected _isDirty: boolean;
  79215. private _transformToBoneReferal;
  79216. private _isAbsoluteSynced;
  79217. private _billboardMode;
  79218. /**
  79219. * Gets or sets the billboard mode. Default is 0.
  79220. *
  79221. * | Value | Type | Description |
  79222. * | --- | --- | --- |
  79223. * | 0 | BILLBOARDMODE_NONE | |
  79224. * | 1 | BILLBOARDMODE_X | |
  79225. * | 2 | BILLBOARDMODE_Y | |
  79226. * | 4 | BILLBOARDMODE_Z | |
  79227. * | 7 | BILLBOARDMODE_ALL | |
  79228. *
  79229. */
  79230. billboardMode: number;
  79231. private _preserveParentRotationForBillboard;
  79232. /**
  79233. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79234. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79235. */
  79236. preserveParentRotationForBillboard: boolean;
  79237. /**
  79238. * 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
  79239. */
  79240. scalingDeterminant: number;
  79241. private _infiniteDistance;
  79242. /**
  79243. * Gets or sets the distance of the object to max, often used by skybox
  79244. */
  79245. infiniteDistance: boolean;
  79246. /**
  79247. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79248. * By default the system will update normals to compensate
  79249. */
  79250. ignoreNonUniformScaling: boolean;
  79251. /**
  79252. * 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
  79253. */
  79254. reIntegrateRotationIntoRotationQuaternion: boolean;
  79255. /** @hidden */
  79256. _poseMatrix: Nullable<Matrix>;
  79257. /** @hidden */
  79258. _localMatrix: Matrix;
  79259. private _usePivotMatrix;
  79260. private _absolutePosition;
  79261. private _absoluteScaling;
  79262. private _absoluteRotationQuaternion;
  79263. private _pivotMatrix;
  79264. private _pivotMatrixInverse;
  79265. protected _postMultiplyPivotMatrix: boolean;
  79266. protected _isWorldMatrixFrozen: boolean;
  79267. /** @hidden */
  79268. _indexInSceneTransformNodesArray: number;
  79269. /**
  79270. * An event triggered after the world matrix is updated
  79271. */
  79272. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79273. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79274. /**
  79275. * Gets a string identifying the name of the class
  79276. * @returns "TransformNode" string
  79277. */
  79278. getClassName(): string;
  79279. /**
  79280. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79281. */
  79282. position: Vector3;
  79283. /**
  79284. * 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)).
  79285. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79286. */
  79287. rotation: Vector3;
  79288. /**
  79289. * 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)).
  79290. */
  79291. scaling: Vector3;
  79292. /**
  79293. * 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).
  79294. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79295. */
  79296. rotationQuaternion: Nullable<Quaternion>;
  79297. /**
  79298. * The forward direction of that transform in world space.
  79299. */
  79300. readonly forward: Vector3;
  79301. /**
  79302. * The up direction of that transform in world space.
  79303. */
  79304. readonly up: Vector3;
  79305. /**
  79306. * The right direction of that transform in world space.
  79307. */
  79308. readonly right: Vector3;
  79309. /**
  79310. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79311. * @param matrix the matrix to copy the pose from
  79312. * @returns this TransformNode.
  79313. */
  79314. updatePoseMatrix(matrix: Matrix): TransformNode;
  79315. /**
  79316. * Returns the mesh Pose matrix.
  79317. * @returns the pose matrix
  79318. */
  79319. getPoseMatrix(): Matrix;
  79320. /** @hidden */
  79321. _isSynchronized(): boolean;
  79322. /** @hidden */
  79323. _initCache(): void;
  79324. /**
  79325. * Flag the transform node as dirty (Forcing it to update everything)
  79326. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79327. * @returns this transform node
  79328. */
  79329. markAsDirty(property: string): TransformNode;
  79330. /**
  79331. * Returns the current mesh absolute position.
  79332. * Returns a Vector3.
  79333. */
  79334. readonly absolutePosition: Vector3;
  79335. /**
  79336. * Returns the current mesh absolute scaling.
  79337. * Returns a Vector3.
  79338. */
  79339. readonly absoluteScaling: Vector3;
  79340. /**
  79341. * Returns the current mesh absolute rotation.
  79342. * Returns a Quaternion.
  79343. */
  79344. readonly absoluteRotationQuaternion: Quaternion;
  79345. /**
  79346. * Sets a new matrix to apply before all other transformation
  79347. * @param matrix defines the transform matrix
  79348. * @returns the current TransformNode
  79349. */
  79350. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79351. /**
  79352. * Sets a new pivot matrix to the current node
  79353. * @param matrix defines the new pivot matrix to use
  79354. * @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
  79355. * @returns the current TransformNode
  79356. */
  79357. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79358. /**
  79359. * Returns the mesh pivot matrix.
  79360. * Default : Identity.
  79361. * @returns the matrix
  79362. */
  79363. getPivotMatrix(): Matrix;
  79364. /**
  79365. * Instantiate (when possible) or clone that node with its hierarchy
  79366. * @param newParent defines the new parent to use for the instance (or clone)
  79367. * @returns an instance (or a clone) of the current node with its hiearchy
  79368. */
  79369. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79370. /**
  79371. * Prevents the World matrix to be computed any longer
  79372. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79373. * @returns the TransformNode.
  79374. */
  79375. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79376. /**
  79377. * Allows back the World matrix computation.
  79378. * @returns the TransformNode.
  79379. */
  79380. unfreezeWorldMatrix(): this;
  79381. /**
  79382. * True if the World matrix has been frozen.
  79383. */
  79384. readonly isWorldMatrixFrozen: boolean;
  79385. /**
  79386. * Retuns the mesh absolute position in the World.
  79387. * @returns a Vector3.
  79388. */
  79389. getAbsolutePosition(): Vector3;
  79390. /**
  79391. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79392. * @param absolutePosition the absolute position to set
  79393. * @returns the TransformNode.
  79394. */
  79395. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79396. /**
  79397. * Sets the mesh position in its local space.
  79398. * @param vector3 the position to set in localspace
  79399. * @returns the TransformNode.
  79400. */
  79401. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79402. /**
  79403. * Returns the mesh position in the local space from the current World matrix values.
  79404. * @returns a new Vector3.
  79405. */
  79406. getPositionExpressedInLocalSpace(): Vector3;
  79407. /**
  79408. * Translates the mesh along the passed Vector3 in its local space.
  79409. * @param vector3 the distance to translate in localspace
  79410. * @returns the TransformNode.
  79411. */
  79412. locallyTranslate(vector3: Vector3): TransformNode;
  79413. private static _lookAtVectorCache;
  79414. /**
  79415. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79416. * @param targetPoint the position (must be in same space as current mesh) to look at
  79417. * @param yawCor optional yaw (y-axis) correction in radians
  79418. * @param pitchCor optional pitch (x-axis) correction in radians
  79419. * @param rollCor optional roll (z-axis) correction in radians
  79420. * @param space the choosen space of the target
  79421. * @returns the TransformNode.
  79422. */
  79423. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79424. /**
  79425. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79426. * This Vector3 is expressed in the World space.
  79427. * @param localAxis axis to rotate
  79428. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79429. */
  79430. getDirection(localAxis: Vector3): Vector3;
  79431. /**
  79432. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79433. * localAxis is expressed in the mesh local space.
  79434. * result is computed in the Wordl space from the mesh World matrix.
  79435. * @param localAxis axis to rotate
  79436. * @param result the resulting transformnode
  79437. * @returns this TransformNode.
  79438. */
  79439. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79440. /**
  79441. * Sets this transform node rotation to the given local axis.
  79442. * @param localAxis the axis in local space
  79443. * @param yawCor optional yaw (y-axis) correction in radians
  79444. * @param pitchCor optional pitch (x-axis) correction in radians
  79445. * @param rollCor optional roll (z-axis) correction in radians
  79446. * @returns this TransformNode
  79447. */
  79448. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79449. /**
  79450. * Sets a new pivot point to the current node
  79451. * @param point defines the new pivot point to use
  79452. * @param space defines if the point is in world or local space (local by default)
  79453. * @returns the current TransformNode
  79454. */
  79455. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79456. /**
  79457. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79458. * @returns the pivot point
  79459. */
  79460. getPivotPoint(): Vector3;
  79461. /**
  79462. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79463. * @param result the vector3 to store the result
  79464. * @returns this TransformNode.
  79465. */
  79466. getPivotPointToRef(result: Vector3): TransformNode;
  79467. /**
  79468. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79469. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79470. */
  79471. getAbsolutePivotPoint(): Vector3;
  79472. /**
  79473. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79474. * @param result vector3 to store the result
  79475. * @returns this TransformNode.
  79476. */
  79477. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79478. /**
  79479. * Defines the passed node as the parent of the current node.
  79480. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79481. * @see https://doc.babylonjs.com/how_to/parenting
  79482. * @param node the node ot set as the parent
  79483. * @returns this TransformNode.
  79484. */
  79485. setParent(node: Nullable<Node>): TransformNode;
  79486. private _nonUniformScaling;
  79487. /**
  79488. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79489. */
  79490. readonly nonUniformScaling: boolean;
  79491. /** @hidden */
  79492. _updateNonUniformScalingState(value: boolean): boolean;
  79493. /**
  79494. * Attach the current TransformNode to another TransformNode associated with a bone
  79495. * @param bone Bone affecting the TransformNode
  79496. * @param affectedTransformNode TransformNode associated with the bone
  79497. * @returns this object
  79498. */
  79499. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79500. /**
  79501. * Detach the transform node if its associated with a bone
  79502. * @returns this object
  79503. */
  79504. detachFromBone(): TransformNode;
  79505. private static _rotationAxisCache;
  79506. /**
  79507. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79508. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79509. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79510. * The passed axis is also normalized.
  79511. * @param axis the axis to rotate around
  79512. * @param amount the amount to rotate in radians
  79513. * @param space Space to rotate in (Default: local)
  79514. * @returns the TransformNode.
  79515. */
  79516. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79517. /**
  79518. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79519. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79520. * The passed axis is also normalized. .
  79521. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79522. * @param point the point to rotate around
  79523. * @param axis the axis to rotate around
  79524. * @param amount the amount to rotate in radians
  79525. * @returns the TransformNode
  79526. */
  79527. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79528. /**
  79529. * Translates the mesh along the axis vector for the passed distance in the given space.
  79530. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79531. * @param axis the axis to translate in
  79532. * @param distance the distance to translate
  79533. * @param space Space to rotate in (Default: local)
  79534. * @returns the TransformNode.
  79535. */
  79536. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79537. /**
  79538. * Adds a rotation step to the mesh current rotation.
  79539. * x, y, z are Euler angles expressed in radians.
  79540. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79541. * This means this rotation is made in the mesh local space only.
  79542. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79543. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79544. * ```javascript
  79545. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79546. * ```
  79547. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79548. * 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.
  79549. * @param x Rotation to add
  79550. * @param y Rotation to add
  79551. * @param z Rotation to add
  79552. * @returns the TransformNode.
  79553. */
  79554. addRotation(x: number, y: number, z: number): TransformNode;
  79555. /**
  79556. * @hidden
  79557. */
  79558. protected _getEffectiveParent(): Nullable<Node>;
  79559. /**
  79560. * Computes the world matrix of the node
  79561. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79562. * @returns the world matrix
  79563. */
  79564. computeWorldMatrix(force?: boolean): Matrix;
  79565. protected _afterComputeWorldMatrix(): void;
  79566. /**
  79567. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79568. * @param func callback function to add
  79569. *
  79570. * @returns the TransformNode.
  79571. */
  79572. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79573. /**
  79574. * Removes a registered callback function.
  79575. * @param func callback function to remove
  79576. * @returns the TransformNode.
  79577. */
  79578. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79579. /**
  79580. * Gets the position of the current mesh in camera space
  79581. * @param camera defines the camera to use
  79582. * @returns a position
  79583. */
  79584. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79585. /**
  79586. * Returns the distance from the mesh to the active camera
  79587. * @param camera defines the camera to use
  79588. * @returns the distance
  79589. */
  79590. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79591. /**
  79592. * Clone the current transform node
  79593. * @param name Name of the new clone
  79594. * @param newParent New parent for the clone
  79595. * @param doNotCloneChildren Do not clone children hierarchy
  79596. * @returns the new transform node
  79597. */
  79598. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79599. /**
  79600. * Serializes the objects information.
  79601. * @param currentSerializationObject defines the object to serialize in
  79602. * @returns the serialized object
  79603. */
  79604. serialize(currentSerializationObject?: any): any;
  79605. /**
  79606. * Returns a new TransformNode object parsed from the source provided.
  79607. * @param parsedTransformNode is the source.
  79608. * @param scene the scne the object belongs to
  79609. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79610. * @returns a new TransformNode object parsed from the source provided.
  79611. */
  79612. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79613. /**
  79614. * Get all child-transformNodes of this node
  79615. * @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
  79616. * @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
  79617. * @returns an array of TransformNode
  79618. */
  79619. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79620. /**
  79621. * Releases resources associated with this transform node.
  79622. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79623. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79624. */
  79625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79626. /**
  79627. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79628. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79629. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79630. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79631. * @returns the current mesh
  79632. */
  79633. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79634. private _syncAbsoluteScalingAndRotation;
  79635. }
  79636. }
  79637. declare module BABYLON {
  79638. /**
  79639. * Defines the types of pose enabled controllers that are supported
  79640. */
  79641. export enum PoseEnabledControllerType {
  79642. /**
  79643. * HTC Vive
  79644. */
  79645. VIVE = 0,
  79646. /**
  79647. * Oculus Rift
  79648. */
  79649. OCULUS = 1,
  79650. /**
  79651. * Windows mixed reality
  79652. */
  79653. WINDOWS = 2,
  79654. /**
  79655. * Samsung gear VR
  79656. */
  79657. GEAR_VR = 3,
  79658. /**
  79659. * Google Daydream
  79660. */
  79661. DAYDREAM = 4,
  79662. /**
  79663. * Generic
  79664. */
  79665. GENERIC = 5
  79666. }
  79667. /**
  79668. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79669. */
  79670. export interface MutableGamepadButton {
  79671. /**
  79672. * Value of the button/trigger
  79673. */
  79674. value: number;
  79675. /**
  79676. * If the button/trigger is currently touched
  79677. */
  79678. touched: boolean;
  79679. /**
  79680. * If the button/trigger is currently pressed
  79681. */
  79682. pressed: boolean;
  79683. }
  79684. /**
  79685. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79686. * @hidden
  79687. */
  79688. export interface ExtendedGamepadButton extends GamepadButton {
  79689. /**
  79690. * If the button/trigger is currently pressed
  79691. */
  79692. readonly pressed: boolean;
  79693. /**
  79694. * If the button/trigger is currently touched
  79695. */
  79696. readonly touched: boolean;
  79697. /**
  79698. * Value of the button/trigger
  79699. */
  79700. readonly value: number;
  79701. }
  79702. /** @hidden */
  79703. export interface _GamePadFactory {
  79704. /**
  79705. * Returns wether or not the current gamepad can be created for this type of controller.
  79706. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79707. * @returns true if it can be created, otherwise false
  79708. */
  79709. canCreate(gamepadInfo: any): boolean;
  79710. /**
  79711. * Creates a new instance of the Gamepad.
  79712. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79713. * @returns the new gamepad instance
  79714. */
  79715. create(gamepadInfo: any): Gamepad;
  79716. }
  79717. /**
  79718. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79719. */
  79720. export class PoseEnabledControllerHelper {
  79721. /** @hidden */
  79722. static _ControllerFactories: _GamePadFactory[];
  79723. /** @hidden */
  79724. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79725. /**
  79726. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79727. * @param vrGamepad the gamepad to initialized
  79728. * @returns a vr controller of the type the gamepad identified as
  79729. */
  79730. static InitiateController(vrGamepad: any): Gamepad;
  79731. }
  79732. /**
  79733. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79734. */
  79735. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79736. /**
  79737. * If the controller is used in a webXR session
  79738. */
  79739. isXR: boolean;
  79740. private _deviceRoomPosition;
  79741. private _deviceRoomRotationQuaternion;
  79742. /**
  79743. * The device position in babylon space
  79744. */
  79745. devicePosition: Vector3;
  79746. /**
  79747. * The device rotation in babylon space
  79748. */
  79749. deviceRotationQuaternion: Quaternion;
  79750. /**
  79751. * The scale factor of the device in babylon space
  79752. */
  79753. deviceScaleFactor: number;
  79754. /**
  79755. * (Likely devicePosition should be used instead) The device position in its room space
  79756. */
  79757. position: Vector3;
  79758. /**
  79759. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79760. */
  79761. rotationQuaternion: Quaternion;
  79762. /**
  79763. * The type of controller (Eg. Windows mixed reality)
  79764. */
  79765. controllerType: PoseEnabledControllerType;
  79766. protected _calculatedPosition: Vector3;
  79767. private _calculatedRotation;
  79768. /**
  79769. * The raw pose from the device
  79770. */
  79771. rawPose: DevicePose;
  79772. private _trackPosition;
  79773. private _maxRotationDistFromHeadset;
  79774. private _draggedRoomRotation;
  79775. /**
  79776. * @hidden
  79777. */
  79778. _disableTrackPosition(fixedPosition: Vector3): void;
  79779. /**
  79780. * Internal, the mesh attached to the controller
  79781. * @hidden
  79782. */
  79783. _mesh: Nullable<AbstractMesh>;
  79784. private _poseControlledCamera;
  79785. private _leftHandSystemQuaternion;
  79786. /**
  79787. * Internal, matrix used to convert room space to babylon space
  79788. * @hidden
  79789. */
  79790. _deviceToWorld: Matrix;
  79791. /**
  79792. * Node to be used when casting a ray from the controller
  79793. * @hidden
  79794. */
  79795. _pointingPoseNode: Nullable<TransformNode>;
  79796. /**
  79797. * Name of the child mesh that can be used to cast a ray from the controller
  79798. */
  79799. static readonly POINTING_POSE: string;
  79800. /**
  79801. * Creates a new PoseEnabledController from a gamepad
  79802. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79803. */
  79804. constructor(browserGamepad: any);
  79805. private _workingMatrix;
  79806. /**
  79807. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79808. */
  79809. update(): void;
  79810. /**
  79811. * Updates only the pose device and mesh without doing any button event checking
  79812. */
  79813. protected _updatePoseAndMesh(): void;
  79814. /**
  79815. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79816. * @param poseData raw pose fromthe device
  79817. */
  79818. updateFromDevice(poseData: DevicePose): void;
  79819. /**
  79820. * @hidden
  79821. */
  79822. _meshAttachedObservable: Observable<AbstractMesh>;
  79823. /**
  79824. * Attaches a mesh to the controller
  79825. * @param mesh the mesh to be attached
  79826. */
  79827. attachToMesh(mesh: AbstractMesh): void;
  79828. /**
  79829. * Attaches the controllers mesh to a camera
  79830. * @param camera the camera the mesh should be attached to
  79831. */
  79832. attachToPoseControlledCamera(camera: TargetCamera): void;
  79833. /**
  79834. * Disposes of the controller
  79835. */
  79836. dispose(): void;
  79837. /**
  79838. * The mesh that is attached to the controller
  79839. */
  79840. readonly mesh: Nullable<AbstractMesh>;
  79841. /**
  79842. * Gets the ray of the controller in the direction the controller is pointing
  79843. * @param length the length the resulting ray should be
  79844. * @returns a ray in the direction the controller is pointing
  79845. */
  79846. getForwardRay(length?: number): Ray;
  79847. }
  79848. }
  79849. declare module BABYLON {
  79850. /**
  79851. * Defines the WebVRController object that represents controllers tracked in 3D space
  79852. */
  79853. export abstract class WebVRController extends PoseEnabledController {
  79854. /**
  79855. * Internal, the default controller model for the controller
  79856. */
  79857. protected _defaultModel: AbstractMesh;
  79858. /**
  79859. * Fired when the trigger state has changed
  79860. */
  79861. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79862. /**
  79863. * Fired when the main button state has changed
  79864. */
  79865. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79866. /**
  79867. * Fired when the secondary button state has changed
  79868. */
  79869. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79870. /**
  79871. * Fired when the pad state has changed
  79872. */
  79873. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79874. /**
  79875. * Fired when controllers stick values have changed
  79876. */
  79877. onPadValuesChangedObservable: Observable<StickValues>;
  79878. /**
  79879. * Array of button availible on the controller
  79880. */
  79881. protected _buttons: Array<MutableGamepadButton>;
  79882. private _onButtonStateChange;
  79883. /**
  79884. * Fired when a controller button's state has changed
  79885. * @param callback the callback containing the button that was modified
  79886. */
  79887. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79888. /**
  79889. * X and Y axis corresponding to the controllers joystick
  79890. */
  79891. pad: StickValues;
  79892. /**
  79893. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79894. */
  79895. hand: string;
  79896. /**
  79897. * The default controller model for the controller
  79898. */
  79899. readonly defaultModel: AbstractMesh;
  79900. /**
  79901. * Creates a new WebVRController from a gamepad
  79902. * @param vrGamepad the gamepad that the WebVRController should be created from
  79903. */
  79904. constructor(vrGamepad: any);
  79905. /**
  79906. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79907. */
  79908. update(): void;
  79909. /**
  79910. * Function to be called when a button is modified
  79911. */
  79912. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79913. /**
  79914. * Loads a mesh and attaches it to the controller
  79915. * @param scene the scene the mesh should be added to
  79916. * @param meshLoaded callback for when the mesh has been loaded
  79917. */
  79918. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79919. private _setButtonValue;
  79920. private _changes;
  79921. private _checkChanges;
  79922. /**
  79923. * Disposes of th webVRCOntroller
  79924. */
  79925. dispose(): void;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /**
  79930. * The HemisphericLight simulates the ambient environment light,
  79931. * so the passed direction is the light reflection direction, not the incoming direction.
  79932. */
  79933. export class HemisphericLight extends Light {
  79934. /**
  79935. * The groundColor is the light in the opposite direction to the one specified during creation.
  79936. * 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.
  79937. */
  79938. groundColor: Color3;
  79939. /**
  79940. * The light reflection direction, not the incoming direction.
  79941. */
  79942. direction: Vector3;
  79943. /**
  79944. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79945. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79946. * The HemisphericLight can't cast shadows.
  79947. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79948. * @param name The friendly name of the light
  79949. * @param direction The direction of the light reflection
  79950. * @param scene The scene the light belongs to
  79951. */
  79952. constructor(name: string, direction: Vector3, scene: Scene);
  79953. protected _buildUniformLayout(): void;
  79954. /**
  79955. * Returns the string "HemisphericLight".
  79956. * @return The class name
  79957. */
  79958. getClassName(): string;
  79959. /**
  79960. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79961. * Returns the updated direction.
  79962. * @param target The target the direction should point to
  79963. * @return The computed direction
  79964. */
  79965. setDirectionToTarget(target: Vector3): Vector3;
  79966. /**
  79967. * Returns the shadow generator associated to the light.
  79968. * @returns Always null for hemispheric lights because it does not support shadows.
  79969. */
  79970. getShadowGenerator(): Nullable<IShadowGenerator>;
  79971. /**
  79972. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79973. * @param effect The effect to update
  79974. * @param lightIndex The index of the light in the effect to update
  79975. * @returns The hemispheric light
  79976. */
  79977. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79978. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  79979. /**
  79980. * Computes the world matrix of the node
  79981. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79982. * @param useWasUpdatedFlag defines a reserved property
  79983. * @returns the world matrix
  79984. */
  79985. computeWorldMatrix(): Matrix;
  79986. /**
  79987. * Returns the integer 3.
  79988. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79989. */
  79990. getTypeID(): number;
  79991. /**
  79992. * Prepares the list of defines specific to the light type.
  79993. * @param defines the list of defines
  79994. * @param lightIndex defines the index of the light for the effect
  79995. */
  79996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79997. }
  79998. }
  79999. declare module BABYLON {
  80000. /** @hidden */
  80001. export var vrMultiviewToSingleviewPixelShader: {
  80002. name: string;
  80003. shader: string;
  80004. };
  80005. }
  80006. declare module BABYLON {
  80007. /**
  80008. * Renders to multiple views with a single draw call
  80009. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80010. */
  80011. export class MultiviewRenderTarget extends RenderTargetTexture {
  80012. /**
  80013. * Creates a multiview render target
  80014. * @param scene scene used with the render target
  80015. * @param size the size of the render target (used for each view)
  80016. */
  80017. constructor(scene: Scene, size?: number | {
  80018. width: number;
  80019. height: number;
  80020. } | {
  80021. ratio: number;
  80022. });
  80023. /**
  80024. * @hidden
  80025. * @param faceIndex the face index, if its a cube texture
  80026. */
  80027. _bindFrameBuffer(faceIndex?: number): void;
  80028. /**
  80029. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80030. * @returns the view count
  80031. */
  80032. getViewCount(): number;
  80033. }
  80034. }
  80035. declare module BABYLON {
  80036. /**
  80037. * Reprasents a camera frustum
  80038. */
  80039. export class Frustum {
  80040. /**
  80041. * Gets the planes representing the frustum
  80042. * @param transform matrix to be applied to the returned planes
  80043. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80044. */
  80045. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80046. /**
  80047. * Gets the near frustum plane transformed by the transform matrix
  80048. * @param transform transformation matrix to be applied to the resulting frustum plane
  80049. * @param frustumPlane the resuling frustum plane
  80050. */
  80051. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80052. /**
  80053. * Gets the far frustum plane transformed by the transform matrix
  80054. * @param transform transformation matrix to be applied to the resulting frustum plane
  80055. * @param frustumPlane the resuling frustum plane
  80056. */
  80057. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80058. /**
  80059. * Gets the left frustum plane transformed by the transform matrix
  80060. * @param transform transformation matrix to be applied to the resulting frustum plane
  80061. * @param frustumPlane the resuling frustum plane
  80062. */
  80063. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80064. /**
  80065. * Gets the right frustum plane transformed by the transform matrix
  80066. * @param transform transformation matrix to be applied to the resulting frustum plane
  80067. * @param frustumPlane the resuling frustum plane
  80068. */
  80069. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80070. /**
  80071. * Gets the top frustum plane transformed by the transform matrix
  80072. * @param transform transformation matrix to be applied to the resulting frustum plane
  80073. * @param frustumPlane the resuling frustum plane
  80074. */
  80075. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80076. /**
  80077. * Gets the bottom frustum plane transformed by the transform matrix
  80078. * @param transform transformation matrix to be applied to the resulting frustum plane
  80079. * @param frustumPlane the resuling frustum plane
  80080. */
  80081. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80082. /**
  80083. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80084. * @param transform transformation matrix to be applied to the resulting frustum planes
  80085. * @param frustumPlanes the resuling frustum planes
  80086. */
  80087. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80088. }
  80089. }
  80090. declare module BABYLON {
  80091. interface Engine {
  80092. /**
  80093. * Creates a new multiview render target
  80094. * @param width defines the width of the texture
  80095. * @param height defines the height of the texture
  80096. * @returns the created multiview texture
  80097. */
  80098. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80099. /**
  80100. * Binds a multiview framebuffer to be drawn to
  80101. * @param multiviewTexture texture to bind
  80102. */
  80103. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80104. }
  80105. interface Camera {
  80106. /**
  80107. * @hidden
  80108. * 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)
  80109. */
  80110. _useMultiviewToSingleView: boolean;
  80111. /**
  80112. * @hidden
  80113. * 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)
  80114. */
  80115. _multiviewTexture: Nullable<RenderTargetTexture>;
  80116. /**
  80117. * @hidden
  80118. * ensures the multiview texture of the camera exists and has the specified width/height
  80119. * @param width height to set on the multiview texture
  80120. * @param height width to set on the multiview texture
  80121. */
  80122. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80123. }
  80124. interface Scene {
  80125. /** @hidden */
  80126. _transformMatrixR: Matrix;
  80127. /** @hidden */
  80128. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80129. /** @hidden */
  80130. _createMultiviewUbo(): void;
  80131. /** @hidden */
  80132. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80133. /** @hidden */
  80134. _renderMultiviewToSingleView(camera: Camera): void;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /**
  80139. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80140. * This will not be used for webXR as it supports displaying texture arrays directly
  80141. */
  80142. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80143. /**
  80144. * Initializes a VRMultiviewToSingleview
  80145. * @param name name of the post process
  80146. * @param camera camera to be applied to
  80147. * @param scaleFactor scaling factor to the size of the output texture
  80148. */
  80149. constructor(name: string, camera: Camera, scaleFactor: number);
  80150. }
  80151. }
  80152. declare module BABYLON {
  80153. interface Engine {
  80154. /** @hidden */
  80155. _vrDisplay: any;
  80156. /** @hidden */
  80157. _vrSupported: boolean;
  80158. /** @hidden */
  80159. _oldSize: Size;
  80160. /** @hidden */
  80161. _oldHardwareScaleFactor: number;
  80162. /** @hidden */
  80163. _vrExclusivePointerMode: boolean;
  80164. /** @hidden */
  80165. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80166. /** @hidden */
  80167. _onVRDisplayPointerRestricted: () => void;
  80168. /** @hidden */
  80169. _onVRDisplayPointerUnrestricted: () => void;
  80170. /** @hidden */
  80171. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80172. /** @hidden */
  80173. _onVrDisplayDisconnect: Nullable<() => void>;
  80174. /** @hidden */
  80175. _onVrDisplayPresentChange: Nullable<() => void>;
  80176. /**
  80177. * Observable signaled when VR display mode changes
  80178. */
  80179. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80180. /**
  80181. * Observable signaled when VR request present is complete
  80182. */
  80183. onVRRequestPresentComplete: Observable<boolean>;
  80184. /**
  80185. * Observable signaled when VR request present starts
  80186. */
  80187. onVRRequestPresentStart: Observable<Engine>;
  80188. /**
  80189. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80190. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80191. */
  80192. isInVRExclusivePointerMode: boolean;
  80193. /**
  80194. * Gets a boolean indicating if a webVR device was detected
  80195. * @returns true if a webVR device was detected
  80196. */
  80197. isVRDevicePresent(): boolean;
  80198. /**
  80199. * Gets the current webVR device
  80200. * @returns the current webVR device (or null)
  80201. */
  80202. getVRDevice(): any;
  80203. /**
  80204. * Initializes a webVR display and starts listening to display change events
  80205. * The onVRDisplayChangedObservable will be notified upon these changes
  80206. * @returns A promise containing a VRDisplay and if vr is supported
  80207. */
  80208. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80209. /** @hidden */
  80210. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80211. /**
  80212. * Call this function to switch to webVR mode
  80213. * Will do nothing if webVR is not supported or if there is no webVR device
  80214. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80215. */
  80216. enableVR(): void;
  80217. /** @hidden */
  80218. _onVRFullScreenTriggered(): void;
  80219. }
  80220. }
  80221. declare module BABYLON {
  80222. /**
  80223. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80224. * IMPORTANT!! The data is right-hand data.
  80225. * @export
  80226. * @interface DevicePose
  80227. */
  80228. export interface DevicePose {
  80229. /**
  80230. * The position of the device, values in array are [x,y,z].
  80231. */
  80232. readonly position: Nullable<Float32Array>;
  80233. /**
  80234. * The linearVelocity of the device, values in array are [x,y,z].
  80235. */
  80236. readonly linearVelocity: Nullable<Float32Array>;
  80237. /**
  80238. * The linearAcceleration of the device, values in array are [x,y,z].
  80239. */
  80240. readonly linearAcceleration: Nullable<Float32Array>;
  80241. /**
  80242. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80243. */
  80244. readonly orientation: Nullable<Float32Array>;
  80245. /**
  80246. * The angularVelocity of the device, values in array are [x,y,z].
  80247. */
  80248. readonly angularVelocity: Nullable<Float32Array>;
  80249. /**
  80250. * The angularAcceleration of the device, values in array are [x,y,z].
  80251. */
  80252. readonly angularAcceleration: Nullable<Float32Array>;
  80253. }
  80254. /**
  80255. * Interface representing a pose controlled object in Babylon.
  80256. * A pose controlled object has both regular pose values as well as pose values
  80257. * from an external device such as a VR head mounted display
  80258. */
  80259. export interface PoseControlled {
  80260. /**
  80261. * The position of the object in babylon space.
  80262. */
  80263. position: Vector3;
  80264. /**
  80265. * The rotation quaternion of the object in babylon space.
  80266. */
  80267. rotationQuaternion: Quaternion;
  80268. /**
  80269. * The position of the device in babylon space.
  80270. */
  80271. devicePosition?: Vector3;
  80272. /**
  80273. * The rotation quaternion of the device in babylon space.
  80274. */
  80275. deviceRotationQuaternion: Quaternion;
  80276. /**
  80277. * The raw pose coming from the device.
  80278. */
  80279. rawPose: Nullable<DevicePose>;
  80280. /**
  80281. * The scale of the device to be used when translating from device space to babylon space.
  80282. */
  80283. deviceScaleFactor: number;
  80284. /**
  80285. * Updates the poseControlled values based on the input device pose.
  80286. * @param poseData the pose data to update the object with
  80287. */
  80288. updateFromDevice(poseData: DevicePose): void;
  80289. }
  80290. /**
  80291. * Set of options to customize the webVRCamera
  80292. */
  80293. export interface WebVROptions {
  80294. /**
  80295. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80296. */
  80297. trackPosition?: boolean;
  80298. /**
  80299. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80300. */
  80301. positionScale?: number;
  80302. /**
  80303. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80304. */
  80305. displayName?: string;
  80306. /**
  80307. * Should the native controller meshes be initialized. (default: true)
  80308. */
  80309. controllerMeshes?: boolean;
  80310. /**
  80311. * Creating a default HemiLight only on controllers. (default: true)
  80312. */
  80313. defaultLightingOnControllers?: boolean;
  80314. /**
  80315. * If you don't want to use the default VR button of the helper. (default: false)
  80316. */
  80317. useCustomVRButton?: boolean;
  80318. /**
  80319. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80320. */
  80321. customVRButton?: HTMLButtonElement;
  80322. /**
  80323. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80324. */
  80325. rayLength?: number;
  80326. /**
  80327. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80328. */
  80329. defaultHeight?: number;
  80330. /**
  80331. * If multiview should be used if availible (default: false)
  80332. */
  80333. useMultiview?: boolean;
  80334. }
  80335. /**
  80336. * This represents a WebVR camera.
  80337. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80338. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80339. */
  80340. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80341. private webVROptions;
  80342. /**
  80343. * @hidden
  80344. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80345. */
  80346. _vrDevice: any;
  80347. /**
  80348. * The rawPose of the vrDevice.
  80349. */
  80350. rawPose: Nullable<DevicePose>;
  80351. private _onVREnabled;
  80352. private _specsVersion;
  80353. private _attached;
  80354. private _frameData;
  80355. protected _descendants: Array<Node>;
  80356. private _deviceRoomPosition;
  80357. /** @hidden */
  80358. _deviceRoomRotationQuaternion: Quaternion;
  80359. private _standingMatrix;
  80360. /**
  80361. * Represents device position in babylon space.
  80362. */
  80363. devicePosition: Vector3;
  80364. /**
  80365. * Represents device rotation in babylon space.
  80366. */
  80367. deviceRotationQuaternion: Quaternion;
  80368. /**
  80369. * The scale of the device to be used when translating from device space to babylon space.
  80370. */
  80371. deviceScaleFactor: number;
  80372. private _deviceToWorld;
  80373. private _worldToDevice;
  80374. /**
  80375. * References to the webVR controllers for the vrDevice.
  80376. */
  80377. controllers: Array<WebVRController>;
  80378. /**
  80379. * Emits an event when a controller is attached.
  80380. */
  80381. onControllersAttachedObservable: Observable<WebVRController[]>;
  80382. /**
  80383. * Emits an event when a controller's mesh has been loaded;
  80384. */
  80385. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80386. /**
  80387. * Emits an event when the HMD's pose has been updated.
  80388. */
  80389. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80390. private _poseSet;
  80391. /**
  80392. * If the rig cameras be used as parent instead of this camera.
  80393. */
  80394. rigParenting: boolean;
  80395. private _lightOnControllers;
  80396. private _defaultHeight?;
  80397. /**
  80398. * Instantiates a WebVRFreeCamera.
  80399. * @param name The name of the WebVRFreeCamera
  80400. * @param position The starting anchor position for the camera
  80401. * @param scene The scene the camera belongs to
  80402. * @param webVROptions a set of customizable options for the webVRCamera
  80403. */
  80404. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80405. /**
  80406. * Gets the device distance from the ground in meters.
  80407. * @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.
  80408. */
  80409. deviceDistanceToRoomGround(): number;
  80410. /**
  80411. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80412. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80413. */
  80414. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80415. /**
  80416. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80417. * @returns A promise with a boolean set to if the standing matrix is supported.
  80418. */
  80419. useStandingMatrixAsync(): Promise<boolean>;
  80420. /**
  80421. * Disposes the camera
  80422. */
  80423. dispose(): void;
  80424. /**
  80425. * Gets a vrController by name.
  80426. * @param name The name of the controller to retreive
  80427. * @returns the controller matching the name specified or null if not found
  80428. */
  80429. getControllerByName(name: string): Nullable<WebVRController>;
  80430. private _leftController;
  80431. /**
  80432. * The controller corresponding to the users left hand.
  80433. */
  80434. readonly leftController: Nullable<WebVRController>;
  80435. private _rightController;
  80436. /**
  80437. * The controller corresponding to the users right hand.
  80438. */
  80439. readonly rightController: Nullable<WebVRController>;
  80440. /**
  80441. * Casts a ray forward from the vrCamera's gaze.
  80442. * @param length Length of the ray (default: 100)
  80443. * @returns the ray corresponding to the gaze
  80444. */
  80445. getForwardRay(length?: number): Ray;
  80446. /**
  80447. * @hidden
  80448. * Updates the camera based on device's frame data
  80449. */
  80450. _checkInputs(): void;
  80451. /**
  80452. * Updates the poseControlled values based on the input device pose.
  80453. * @param poseData Pose coming from the device
  80454. */
  80455. updateFromDevice(poseData: DevicePose): void;
  80456. private _htmlElementAttached;
  80457. private _detachIfAttached;
  80458. /**
  80459. * WebVR's attach control will start broadcasting frames to the device.
  80460. * Note that in certain browsers (chrome for example) this function must be called
  80461. * within a user-interaction callback. Example:
  80462. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80463. *
  80464. * @param element html element to attach the vrDevice to
  80465. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80466. */
  80467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80468. /**
  80469. * Detaches the camera from the html element and disables VR
  80470. *
  80471. * @param element html element to detach from
  80472. */
  80473. detachControl(element: HTMLElement): void;
  80474. /**
  80475. * @returns the name of this class
  80476. */
  80477. getClassName(): string;
  80478. /**
  80479. * Calls resetPose on the vrDisplay
  80480. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80481. */
  80482. resetToCurrentRotation(): void;
  80483. /**
  80484. * @hidden
  80485. * Updates the rig cameras (left and right eye)
  80486. */
  80487. _updateRigCameras(): void;
  80488. private _workingVector;
  80489. private _oneVector;
  80490. private _workingMatrix;
  80491. private updateCacheCalled;
  80492. private _correctPositionIfNotTrackPosition;
  80493. /**
  80494. * @hidden
  80495. * Updates the cached values of the camera
  80496. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80497. */
  80498. _updateCache(ignoreParentClass?: boolean): void;
  80499. /**
  80500. * @hidden
  80501. * Get current device position in babylon world
  80502. */
  80503. _computeDevicePosition(): void;
  80504. /**
  80505. * Updates the current device position and rotation in the babylon world
  80506. */
  80507. update(): void;
  80508. /**
  80509. * @hidden
  80510. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80511. * @returns an identity matrix
  80512. */
  80513. _getViewMatrix(): Matrix;
  80514. private _tmpMatrix;
  80515. /**
  80516. * This function is called by the two RIG cameras.
  80517. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80518. * @hidden
  80519. */
  80520. _getWebVRViewMatrix(): Matrix;
  80521. /** @hidden */
  80522. _getWebVRProjectionMatrix(): Matrix;
  80523. private _onGamepadConnectedObserver;
  80524. private _onGamepadDisconnectedObserver;
  80525. private _updateCacheWhenTrackingDisabledObserver;
  80526. /**
  80527. * Initializes the controllers and their meshes
  80528. */
  80529. initControllers(): void;
  80530. }
  80531. }
  80532. declare module BABYLON {
  80533. /**
  80534. * Size options for a post process
  80535. */
  80536. export type PostProcessOptions = {
  80537. width: number;
  80538. height: number;
  80539. };
  80540. /**
  80541. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80542. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80543. */
  80544. export class PostProcess {
  80545. /** Name of the PostProcess. */
  80546. name: string;
  80547. /**
  80548. * Gets or sets the unique id of the post process
  80549. */
  80550. uniqueId: number;
  80551. /**
  80552. * Width of the texture to apply the post process on
  80553. */
  80554. width: number;
  80555. /**
  80556. * Height of the texture to apply the post process on
  80557. */
  80558. height: number;
  80559. /**
  80560. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80561. * @hidden
  80562. */
  80563. _outputTexture: Nullable<InternalTexture>;
  80564. /**
  80565. * Sampling mode used by the shader
  80566. * See https://doc.babylonjs.com/classes/3.1/texture
  80567. */
  80568. renderTargetSamplingMode: number;
  80569. /**
  80570. * Clear color to use when screen clearing
  80571. */
  80572. clearColor: Color4;
  80573. /**
  80574. * If the buffer needs to be cleared before applying the post process. (default: true)
  80575. * Should be set to false if shader will overwrite all previous pixels.
  80576. */
  80577. autoClear: boolean;
  80578. /**
  80579. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80580. */
  80581. alphaMode: number;
  80582. /**
  80583. * Sets the setAlphaBlendConstants of the babylon engine
  80584. */
  80585. alphaConstants: Color4;
  80586. /**
  80587. * Animations to be used for the post processing
  80588. */
  80589. animations: Animation[];
  80590. /**
  80591. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80592. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80593. */
  80594. enablePixelPerfectMode: boolean;
  80595. /**
  80596. * Force the postprocess to be applied without taking in account viewport
  80597. */
  80598. forceFullscreenViewport: boolean;
  80599. /**
  80600. * List of inspectable custom properties (used by the Inspector)
  80601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80602. */
  80603. inspectableCustomProperties: IInspectable[];
  80604. /**
  80605. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80606. *
  80607. * | Value | Type | Description |
  80608. * | ----- | ----------------------------------- | ----------- |
  80609. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80610. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80611. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80612. *
  80613. */
  80614. scaleMode: number;
  80615. /**
  80616. * Force textures to be a power of two (default: false)
  80617. */
  80618. alwaysForcePOT: boolean;
  80619. private _samples;
  80620. /**
  80621. * Number of sample textures (default: 1)
  80622. */
  80623. samples: number;
  80624. /**
  80625. * Modify the scale of the post process to be the same as the viewport (default: false)
  80626. */
  80627. adaptScaleToCurrentViewport: boolean;
  80628. private _camera;
  80629. private _scene;
  80630. private _engine;
  80631. private _options;
  80632. private _reusable;
  80633. private _textureType;
  80634. /**
  80635. * Smart array of input and output textures for the post process.
  80636. * @hidden
  80637. */
  80638. _textures: SmartArray<InternalTexture>;
  80639. /**
  80640. * The index in _textures that corresponds to the output texture.
  80641. * @hidden
  80642. */
  80643. _currentRenderTextureInd: number;
  80644. private _effect;
  80645. private _samplers;
  80646. private _fragmentUrl;
  80647. private _vertexUrl;
  80648. private _parameters;
  80649. private _scaleRatio;
  80650. protected _indexParameters: any;
  80651. private _shareOutputWithPostProcess;
  80652. private _texelSize;
  80653. private _forcedOutputTexture;
  80654. /**
  80655. * Returns the fragment url or shader name used in the post process.
  80656. * @returns the fragment url or name in the shader store.
  80657. */
  80658. getEffectName(): string;
  80659. /**
  80660. * An event triggered when the postprocess is activated.
  80661. */
  80662. onActivateObservable: Observable<Camera>;
  80663. private _onActivateObserver;
  80664. /**
  80665. * A function that is added to the onActivateObservable
  80666. */
  80667. onActivate: Nullable<(camera: Camera) => void>;
  80668. /**
  80669. * An event triggered when the postprocess changes its size.
  80670. */
  80671. onSizeChangedObservable: Observable<PostProcess>;
  80672. private _onSizeChangedObserver;
  80673. /**
  80674. * A function that is added to the onSizeChangedObservable
  80675. */
  80676. onSizeChanged: (postProcess: PostProcess) => void;
  80677. /**
  80678. * An event triggered when the postprocess applies its effect.
  80679. */
  80680. onApplyObservable: Observable<Effect>;
  80681. private _onApplyObserver;
  80682. /**
  80683. * A function that is added to the onApplyObservable
  80684. */
  80685. onApply: (effect: Effect) => void;
  80686. /**
  80687. * An event triggered before rendering the postprocess
  80688. */
  80689. onBeforeRenderObservable: Observable<Effect>;
  80690. private _onBeforeRenderObserver;
  80691. /**
  80692. * A function that is added to the onBeforeRenderObservable
  80693. */
  80694. onBeforeRender: (effect: Effect) => void;
  80695. /**
  80696. * An event triggered after rendering the postprocess
  80697. */
  80698. onAfterRenderObservable: Observable<Effect>;
  80699. private _onAfterRenderObserver;
  80700. /**
  80701. * A function that is added to the onAfterRenderObservable
  80702. */
  80703. onAfterRender: (efect: Effect) => void;
  80704. /**
  80705. * 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
  80706. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80707. */
  80708. inputTexture: InternalTexture;
  80709. /**
  80710. * Gets the camera which post process is applied to.
  80711. * @returns The camera the post process is applied to.
  80712. */
  80713. getCamera(): Camera;
  80714. /**
  80715. * Gets the texel size of the postprocess.
  80716. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80717. */
  80718. readonly texelSize: Vector2;
  80719. /**
  80720. * Creates a new instance PostProcess
  80721. * @param name The name of the PostProcess.
  80722. * @param fragmentUrl The url of the fragment shader to be used.
  80723. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80724. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80725. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80726. * @param camera The camera to apply the render pass to.
  80727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80728. * @param engine The engine which the post process will be applied. (default: current engine)
  80729. * @param reusable If the post process can be reused on the same frame. (default: false)
  80730. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80731. * @param textureType Type of textures used when performing the post process. (default: 0)
  80732. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80733. * @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
  80734. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80735. */
  80736. constructor(
  80737. /** Name of the PostProcess. */
  80738. 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);
  80739. /**
  80740. * Gets a string idenfifying the name of the class
  80741. * @returns "PostProcess" string
  80742. */
  80743. getClassName(): string;
  80744. /**
  80745. * Gets the engine which this post process belongs to.
  80746. * @returns The engine the post process was enabled with.
  80747. */
  80748. getEngine(): Engine;
  80749. /**
  80750. * The effect that is created when initializing the post process.
  80751. * @returns The created effect corresponding the the postprocess.
  80752. */
  80753. getEffect(): Effect;
  80754. /**
  80755. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80756. * @param postProcess The post process to share the output with.
  80757. * @returns This post process.
  80758. */
  80759. shareOutputWith(postProcess: PostProcess): PostProcess;
  80760. /**
  80761. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80762. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80763. */
  80764. useOwnOutput(): void;
  80765. /**
  80766. * Updates the effect with the current post process compile time values and recompiles the shader.
  80767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80770. * @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
  80771. * @param onCompiled Called when the shader has been compiled.
  80772. * @param onError Called if there is an error when compiling a shader.
  80773. */
  80774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80775. /**
  80776. * The post process is reusable if it can be used multiple times within one frame.
  80777. * @returns If the post process is reusable
  80778. */
  80779. isReusable(): boolean;
  80780. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80781. markTextureDirty(): void;
  80782. /**
  80783. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80784. * 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.
  80785. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80786. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80787. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80788. * @returns The target texture that was bound to be written to.
  80789. */
  80790. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80791. /**
  80792. * If the post process is supported.
  80793. */
  80794. readonly isSupported: boolean;
  80795. /**
  80796. * The aspect ratio of the output texture.
  80797. */
  80798. readonly aspectRatio: number;
  80799. /**
  80800. * Get a value indicating if the post-process is ready to be used
  80801. * @returns true if the post-process is ready (shader is compiled)
  80802. */
  80803. isReady(): boolean;
  80804. /**
  80805. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80806. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80807. */
  80808. apply(): Nullable<Effect>;
  80809. private _disposeTextures;
  80810. /**
  80811. * Disposes the post process.
  80812. * @param camera The camera to dispose the post process on.
  80813. */
  80814. dispose(camera?: Camera): void;
  80815. }
  80816. }
  80817. declare module BABYLON {
  80818. /** @hidden */
  80819. export var kernelBlurVaryingDeclaration: {
  80820. name: string;
  80821. shader: string;
  80822. };
  80823. }
  80824. declare module BABYLON {
  80825. /** @hidden */
  80826. export var kernelBlurFragment: {
  80827. name: string;
  80828. shader: string;
  80829. };
  80830. }
  80831. declare module BABYLON {
  80832. /** @hidden */
  80833. export var kernelBlurFragment2: {
  80834. name: string;
  80835. shader: string;
  80836. };
  80837. }
  80838. declare module BABYLON {
  80839. /** @hidden */
  80840. export var kernelBlurPixelShader: {
  80841. name: string;
  80842. shader: string;
  80843. };
  80844. }
  80845. declare module BABYLON {
  80846. /** @hidden */
  80847. export var kernelBlurVertex: {
  80848. name: string;
  80849. shader: string;
  80850. };
  80851. }
  80852. declare module BABYLON {
  80853. /** @hidden */
  80854. export var kernelBlurVertexShader: {
  80855. name: string;
  80856. shader: string;
  80857. };
  80858. }
  80859. declare module BABYLON {
  80860. /**
  80861. * The Blur Post Process which blurs an image based on a kernel and direction.
  80862. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80863. */
  80864. export class BlurPostProcess extends PostProcess {
  80865. /** The direction in which to blur the image. */
  80866. direction: Vector2;
  80867. private blockCompilation;
  80868. protected _kernel: number;
  80869. protected _idealKernel: number;
  80870. protected _packedFloat: boolean;
  80871. private _staticDefines;
  80872. /**
  80873. * Sets the length in pixels of the blur sample region
  80874. */
  80875. /**
  80876. * Gets the length in pixels of the blur sample region
  80877. */
  80878. kernel: number;
  80879. /**
  80880. * Sets wether or not the blur needs to unpack/repack floats
  80881. */
  80882. /**
  80883. * Gets wether or not the blur is unpacking/repacking floats
  80884. */
  80885. packedFloat: boolean;
  80886. /**
  80887. * Creates a new instance BlurPostProcess
  80888. * @param name The name of the effect.
  80889. * @param direction The direction in which to blur the image.
  80890. * @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.
  80891. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80892. * @param camera The camera to apply the render pass to.
  80893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80894. * @param engine The engine which the post process will be applied. (default: current engine)
  80895. * @param reusable If the post process can be reused on the same frame. (default: false)
  80896. * @param textureType Type of textures used when performing the post process. (default: 0)
  80897. * @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)
  80898. */
  80899. constructor(name: string,
  80900. /** The direction in which to blur the image. */
  80901. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80902. /**
  80903. * Updates the effect with the current post process compile time values and recompiles the shader.
  80904. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80905. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80906. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80907. * @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
  80908. * @param onCompiled Called when the shader has been compiled.
  80909. * @param onError Called if there is an error when compiling a shader.
  80910. */
  80911. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80912. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80913. /**
  80914. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80915. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80916. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80917. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80918. * The gaps between physical kernels are compensated for in the weighting of the samples
  80919. * @param idealKernel Ideal blur kernel.
  80920. * @return Nearest best kernel.
  80921. */
  80922. protected _nearestBestKernel(idealKernel: number): number;
  80923. /**
  80924. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80925. * @param x The point on the Gaussian distribution to sample.
  80926. * @return the value of the Gaussian function at x.
  80927. */
  80928. protected _gaussianWeight(x: number): number;
  80929. /**
  80930. * Generates a string that can be used as a floating point number in GLSL.
  80931. * @param x Value to print.
  80932. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80933. * @return GLSL float string.
  80934. */
  80935. protected _glslFloat(x: number, decimalFigures?: number): string;
  80936. }
  80937. }
  80938. declare module BABYLON {
  80939. /**
  80940. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80941. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80942. * You can then easily use it as a reflectionTexture on a flat surface.
  80943. * In case the surface is not a plane, please consider relying on reflection probes.
  80944. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80945. */
  80946. export class MirrorTexture extends RenderTargetTexture {
  80947. private scene;
  80948. /**
  80949. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80950. * 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.
  80951. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80952. */
  80953. mirrorPlane: Plane;
  80954. /**
  80955. * Define the blur ratio used to blur the reflection if needed.
  80956. */
  80957. blurRatio: number;
  80958. /**
  80959. * Define the adaptive blur kernel used to blur the reflection if needed.
  80960. * This will autocompute the closest best match for the `blurKernel`
  80961. */
  80962. adaptiveBlurKernel: number;
  80963. /**
  80964. * Define the blur kernel used to blur the reflection if needed.
  80965. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80966. */
  80967. blurKernel: number;
  80968. /**
  80969. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80970. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80971. */
  80972. blurKernelX: number;
  80973. /**
  80974. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80975. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80976. */
  80977. blurKernelY: number;
  80978. private _autoComputeBlurKernel;
  80979. protected _onRatioRescale(): void;
  80980. private _updateGammaSpace;
  80981. private _imageProcessingConfigChangeObserver;
  80982. private _transformMatrix;
  80983. private _mirrorMatrix;
  80984. private _savedViewMatrix;
  80985. private _blurX;
  80986. private _blurY;
  80987. private _adaptiveBlurKernel;
  80988. private _blurKernelX;
  80989. private _blurKernelY;
  80990. private _blurRatio;
  80991. /**
  80992. * Instantiates a Mirror Texture.
  80993. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80994. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80995. * You can then easily use it as a reflectionTexture on a flat surface.
  80996. * In case the surface is not a plane, please consider relying on reflection probes.
  80997. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80998. * @param name
  80999. * @param size
  81000. * @param scene
  81001. * @param generateMipMaps
  81002. * @param type
  81003. * @param samplingMode
  81004. * @param generateDepthBuffer
  81005. */
  81006. constructor(name: string, size: number | {
  81007. width: number;
  81008. height: number;
  81009. } | {
  81010. ratio: number;
  81011. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81012. private _preparePostProcesses;
  81013. /**
  81014. * Clone the mirror texture.
  81015. * @returns the cloned texture
  81016. */
  81017. clone(): MirrorTexture;
  81018. /**
  81019. * Serialize the texture to a JSON representation you could use in Parse later on
  81020. * @returns the serialized JSON representation
  81021. */
  81022. serialize(): any;
  81023. /**
  81024. * Dispose the texture and release its associated resources.
  81025. */
  81026. dispose(): void;
  81027. }
  81028. }
  81029. declare module BABYLON {
  81030. /**
  81031. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81032. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81033. */
  81034. export class Texture extends BaseTexture {
  81035. /** @hidden */
  81036. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81037. /** @hidden */
  81038. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81039. /** @hidden */
  81040. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81041. /** nearest is mag = nearest and min = nearest and mip = linear */
  81042. static readonly NEAREST_SAMPLINGMODE: number;
  81043. /** nearest is mag = nearest and min = nearest and mip = linear */
  81044. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81045. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81046. static readonly BILINEAR_SAMPLINGMODE: number;
  81047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81048. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81049. /** Trilinear is mag = linear and min = linear and mip = linear */
  81050. static readonly TRILINEAR_SAMPLINGMODE: number;
  81051. /** Trilinear is mag = linear and min = linear and mip = linear */
  81052. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81053. /** mag = nearest and min = nearest and mip = nearest */
  81054. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81055. /** mag = nearest and min = linear and mip = nearest */
  81056. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81057. /** mag = nearest and min = linear and mip = linear */
  81058. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81059. /** mag = nearest and min = linear and mip = none */
  81060. static readonly NEAREST_LINEAR: number;
  81061. /** mag = nearest and min = nearest and mip = none */
  81062. static readonly NEAREST_NEAREST: number;
  81063. /** mag = linear and min = nearest and mip = nearest */
  81064. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81065. /** mag = linear and min = nearest and mip = linear */
  81066. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81067. /** mag = linear and min = linear and mip = none */
  81068. static readonly LINEAR_LINEAR: number;
  81069. /** mag = linear and min = nearest and mip = none */
  81070. static readonly LINEAR_NEAREST: number;
  81071. /** Explicit coordinates mode */
  81072. static readonly EXPLICIT_MODE: number;
  81073. /** Spherical coordinates mode */
  81074. static readonly SPHERICAL_MODE: number;
  81075. /** Planar coordinates mode */
  81076. static readonly PLANAR_MODE: number;
  81077. /** Cubic coordinates mode */
  81078. static readonly CUBIC_MODE: number;
  81079. /** Projection coordinates mode */
  81080. static readonly PROJECTION_MODE: number;
  81081. /** Inverse Cubic coordinates mode */
  81082. static readonly SKYBOX_MODE: number;
  81083. /** Inverse Cubic coordinates mode */
  81084. static readonly INVCUBIC_MODE: number;
  81085. /** Equirectangular coordinates mode */
  81086. static readonly EQUIRECTANGULAR_MODE: number;
  81087. /** Equirectangular Fixed coordinates mode */
  81088. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81089. /** Equirectangular Fixed Mirrored coordinates mode */
  81090. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81091. /** Texture is not repeating outside of 0..1 UVs */
  81092. static readonly CLAMP_ADDRESSMODE: number;
  81093. /** Texture is repeating outside of 0..1 UVs */
  81094. static readonly WRAP_ADDRESSMODE: number;
  81095. /** Texture is repeating and mirrored */
  81096. static readonly MIRROR_ADDRESSMODE: number;
  81097. /**
  81098. * 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
  81099. */
  81100. static UseSerializedUrlIfAny: boolean;
  81101. /**
  81102. * Define the url of the texture.
  81103. */
  81104. url: Nullable<string>;
  81105. /**
  81106. * Define an offset on the texture to offset the u coordinates of the UVs
  81107. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81108. */
  81109. uOffset: number;
  81110. /**
  81111. * Define an offset on the texture to offset the v coordinates of the UVs
  81112. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81113. */
  81114. vOffset: number;
  81115. /**
  81116. * Define an offset on the texture to scale the u coordinates of the UVs
  81117. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81118. */
  81119. uScale: number;
  81120. /**
  81121. * Define an offset on the texture to scale the v coordinates of the UVs
  81122. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81123. */
  81124. vScale: number;
  81125. /**
  81126. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81127. * @see http://doc.babylonjs.com/how_to/more_materials
  81128. */
  81129. uAng: number;
  81130. /**
  81131. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81132. * @see http://doc.babylonjs.com/how_to/more_materials
  81133. */
  81134. vAng: number;
  81135. /**
  81136. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81137. * @see http://doc.babylonjs.com/how_to/more_materials
  81138. */
  81139. wAng: number;
  81140. /**
  81141. * Defines the center of rotation (U)
  81142. */
  81143. uRotationCenter: number;
  81144. /**
  81145. * Defines the center of rotation (V)
  81146. */
  81147. vRotationCenter: number;
  81148. /**
  81149. * Defines the center of rotation (W)
  81150. */
  81151. wRotationCenter: number;
  81152. /**
  81153. * Are mip maps generated for this texture or not.
  81154. */
  81155. readonly noMipmap: boolean;
  81156. /**
  81157. * List of inspectable custom properties (used by the Inspector)
  81158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81159. */
  81160. inspectableCustomProperties: Nullable<IInspectable[]>;
  81161. private _noMipmap;
  81162. /** @hidden */
  81163. _invertY: boolean;
  81164. private _rowGenerationMatrix;
  81165. private _cachedTextureMatrix;
  81166. private _projectionModeMatrix;
  81167. private _t0;
  81168. private _t1;
  81169. private _t2;
  81170. private _cachedUOffset;
  81171. private _cachedVOffset;
  81172. private _cachedUScale;
  81173. private _cachedVScale;
  81174. private _cachedUAng;
  81175. private _cachedVAng;
  81176. private _cachedWAng;
  81177. private _cachedProjectionMatrixId;
  81178. private _cachedCoordinatesMode;
  81179. /** @hidden */
  81180. protected _initialSamplingMode: number;
  81181. /** @hidden */
  81182. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81183. private _deleteBuffer;
  81184. protected _format: Nullable<number>;
  81185. private _delayedOnLoad;
  81186. private _delayedOnError;
  81187. /**
  81188. * Observable triggered once the texture has been loaded.
  81189. */
  81190. onLoadObservable: Observable<Texture>;
  81191. protected _isBlocking: boolean;
  81192. /**
  81193. * Is the texture preventing material to render while loading.
  81194. * If false, a default texture will be used instead of the loading one during the preparation step.
  81195. */
  81196. isBlocking: boolean;
  81197. /**
  81198. * Get the current sampling mode associated with the texture.
  81199. */
  81200. readonly samplingMode: number;
  81201. /**
  81202. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81203. */
  81204. readonly invertY: boolean;
  81205. /**
  81206. * Instantiates a new texture.
  81207. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81208. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81209. * @param url define the url of the picture to load as a texture
  81210. * @param scene define the scene or engine the texture will belong to
  81211. * @param noMipmap define if the texture will require mip maps or not
  81212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81214. * @param onLoad define a callback triggered when the texture has been loaded
  81215. * @param onError define a callback triggered when an error occurred during the loading session
  81216. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81217. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81218. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81219. */
  81220. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81221. /**
  81222. * Update the url (and optional buffer) of this texture if url was null during construction.
  81223. * @param url the url of the texture
  81224. * @param buffer the buffer of the texture (defaults to null)
  81225. * @param onLoad callback called when the texture is loaded (defaults to null)
  81226. */
  81227. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81228. /**
  81229. * Finish the loading sequence of a texture flagged as delayed load.
  81230. * @hidden
  81231. */
  81232. delayLoad(): void;
  81233. private _prepareRowForTextureGeneration;
  81234. /**
  81235. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81236. * @returns the transform matrix of the texture.
  81237. */
  81238. getTextureMatrix(): Matrix;
  81239. /**
  81240. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81241. * @returns The reflection texture transform
  81242. */
  81243. getReflectionTextureMatrix(): Matrix;
  81244. /**
  81245. * Clones the texture.
  81246. * @returns the cloned texture
  81247. */
  81248. clone(): Texture;
  81249. /**
  81250. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81251. * @returns The JSON representation of the texture
  81252. */
  81253. serialize(): any;
  81254. /**
  81255. * Get the current class name of the texture useful for serialization or dynamic coding.
  81256. * @returns "Texture"
  81257. */
  81258. getClassName(): string;
  81259. /**
  81260. * Dispose the texture and release its associated resources.
  81261. */
  81262. dispose(): void;
  81263. /**
  81264. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81265. * @param parsedTexture Define the JSON representation of the texture
  81266. * @param scene Define the scene the parsed texture should be instantiated in
  81267. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81268. * @returns The parsed texture if successful
  81269. */
  81270. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81271. /**
  81272. * Creates a texture from its base 64 representation.
  81273. * @param data Define the base64 payload without the data: prefix
  81274. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81275. * @param scene Define the scene the texture should belong to
  81276. * @param noMipmap Forces the texture to not create mip map information if true
  81277. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81278. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81279. * @param onLoad define a callback triggered when the texture has been loaded
  81280. * @param onError define a callback triggered when an error occurred during the loading session
  81281. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81282. * @returns the created texture
  81283. */
  81284. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81285. /**
  81286. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81287. * @param data Define the base64 payload without the data: prefix
  81288. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81290. * @param scene Define the scene the texture should belong to
  81291. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81292. * @param noMipmap Forces the texture to not create mip map information if true
  81293. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81294. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81295. * @param onLoad define a callback triggered when the texture has been loaded
  81296. * @param onError define a callback triggered when an error occurred during the loading session
  81297. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81298. * @returns the created texture
  81299. */
  81300. 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;
  81301. }
  81302. }
  81303. declare module BABYLON {
  81304. /**
  81305. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81306. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81307. */
  81308. export class PostProcessManager {
  81309. private _scene;
  81310. private _indexBuffer;
  81311. private _vertexBuffers;
  81312. /**
  81313. * Creates a new instance PostProcess
  81314. * @param scene The scene that the post process is associated with.
  81315. */
  81316. constructor(scene: Scene);
  81317. private _prepareBuffers;
  81318. private _buildIndexBuffer;
  81319. /**
  81320. * Rebuilds the vertex buffers of the manager.
  81321. * @hidden
  81322. */
  81323. _rebuild(): void;
  81324. /**
  81325. * Prepares a frame to be run through a post process.
  81326. * @param sourceTexture The input texture to the post procesess. (default: null)
  81327. * @param postProcesses An array of post processes to be run. (default: null)
  81328. * @returns True if the post processes were able to be run.
  81329. * @hidden
  81330. */
  81331. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81332. /**
  81333. * Manually render a set of post processes to a texture.
  81334. * @param postProcesses An array of post processes to be run.
  81335. * @param targetTexture The target texture to render to.
  81336. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81337. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81338. * @param lodLevel defines which lod of the texture to render to
  81339. */
  81340. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81341. /**
  81342. * Finalize the result of the output of the postprocesses.
  81343. * @param doNotPresent If true the result will not be displayed to the screen.
  81344. * @param targetTexture The target texture to render to.
  81345. * @param faceIndex The index of the face to bind the target texture to.
  81346. * @param postProcesses The array of post processes to render.
  81347. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81348. * @hidden
  81349. */
  81350. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81351. /**
  81352. * Disposes of the post process manager.
  81353. */
  81354. dispose(): void;
  81355. }
  81356. }
  81357. declare module BABYLON {
  81358. /** Interface used by value gradients (color, factor, ...) */
  81359. export interface IValueGradient {
  81360. /**
  81361. * Gets or sets the gradient value (between 0 and 1)
  81362. */
  81363. gradient: number;
  81364. }
  81365. /** Class used to store color4 gradient */
  81366. export class ColorGradient implements IValueGradient {
  81367. /**
  81368. * Gets or sets the gradient value (between 0 and 1)
  81369. */
  81370. gradient: number;
  81371. /**
  81372. * Gets or sets first associated color
  81373. */
  81374. color1: Color4;
  81375. /**
  81376. * Gets or sets second associated color
  81377. */
  81378. color2?: Color4;
  81379. /**
  81380. * Will get a color picked randomly between color1 and color2.
  81381. * If color2 is undefined then color1 will be used
  81382. * @param result defines the target Color4 to store the result in
  81383. */
  81384. getColorToRef(result: Color4): void;
  81385. }
  81386. /** Class used to store color 3 gradient */
  81387. export class Color3Gradient implements IValueGradient {
  81388. /**
  81389. * Gets or sets the gradient value (between 0 and 1)
  81390. */
  81391. gradient: number;
  81392. /**
  81393. * Gets or sets the associated color
  81394. */
  81395. color: Color3;
  81396. }
  81397. /** Class used to store factor gradient */
  81398. export class FactorGradient implements IValueGradient {
  81399. /**
  81400. * Gets or sets the gradient value (between 0 and 1)
  81401. */
  81402. gradient: number;
  81403. /**
  81404. * Gets or sets first associated factor
  81405. */
  81406. factor1: number;
  81407. /**
  81408. * Gets or sets second associated factor
  81409. */
  81410. factor2?: number;
  81411. /**
  81412. * Will get a number picked randomly between factor1 and factor2.
  81413. * If factor2 is undefined then factor1 will be used
  81414. * @returns the picked number
  81415. */
  81416. getFactor(): number;
  81417. }
  81418. /**
  81419. * Helper used to simplify some generic gradient tasks
  81420. */
  81421. export class GradientHelper {
  81422. /**
  81423. * Gets the current gradient from an array of IValueGradient
  81424. * @param ratio defines the current ratio to get
  81425. * @param gradients defines the array of IValueGradient
  81426. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81427. */
  81428. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81429. }
  81430. }
  81431. declare module BABYLON {
  81432. interface AbstractScene {
  81433. /**
  81434. * The list of procedural textures added to the scene
  81435. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81436. */
  81437. proceduralTextures: Array<ProceduralTexture>;
  81438. }
  81439. /**
  81440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81441. * in a given scene.
  81442. */
  81443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81444. /**
  81445. * The component name helpfull to identify the component in the list of scene components.
  81446. */
  81447. readonly name: string;
  81448. /**
  81449. * The scene the component belongs to.
  81450. */
  81451. scene: Scene;
  81452. /**
  81453. * Creates a new instance of the component for the given scene
  81454. * @param scene Defines the scene to register the component in
  81455. */
  81456. constructor(scene: Scene);
  81457. /**
  81458. * Registers the component in a given scene
  81459. */
  81460. register(): void;
  81461. /**
  81462. * Rebuilds the elements related to this component in case of
  81463. * context lost for instance.
  81464. */
  81465. rebuild(): void;
  81466. /**
  81467. * Disposes the component and the associated ressources.
  81468. */
  81469. dispose(): void;
  81470. private _beforeClear;
  81471. }
  81472. }
  81473. declare module BABYLON {
  81474. interface Engine {
  81475. /**
  81476. * Creates a new render target cube texture
  81477. * @param size defines the size of the texture
  81478. * @param options defines the options used to create the texture
  81479. * @returns a new render target cube texture stored in an InternalTexture
  81480. */
  81481. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81482. }
  81483. }
  81484. declare module BABYLON {
  81485. /** @hidden */
  81486. export var proceduralVertexShader: {
  81487. name: string;
  81488. shader: string;
  81489. };
  81490. }
  81491. declare module BABYLON {
  81492. /**
  81493. * 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.
  81494. * This is the base class of any Procedural texture and contains most of the shareable code.
  81495. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81496. */
  81497. export class ProceduralTexture extends Texture {
  81498. isCube: boolean;
  81499. /**
  81500. * Define if the texture is enabled or not (disabled texture will not render)
  81501. */
  81502. isEnabled: boolean;
  81503. /**
  81504. * Define if the texture must be cleared before rendering (default is true)
  81505. */
  81506. autoClear: boolean;
  81507. /**
  81508. * Callback called when the texture is generated
  81509. */
  81510. onGenerated: () => void;
  81511. /**
  81512. * Event raised when the texture is generated
  81513. */
  81514. onGeneratedObservable: Observable<ProceduralTexture>;
  81515. /** @hidden */
  81516. _generateMipMaps: boolean;
  81517. /** @hidden **/
  81518. _effect: Effect;
  81519. /** @hidden */
  81520. _textures: {
  81521. [key: string]: Texture;
  81522. };
  81523. private _size;
  81524. private _currentRefreshId;
  81525. private _refreshRate;
  81526. private _vertexBuffers;
  81527. private _indexBuffer;
  81528. private _uniforms;
  81529. private _samplers;
  81530. private _fragment;
  81531. private _floats;
  81532. private _ints;
  81533. private _floatsArrays;
  81534. private _colors3;
  81535. private _colors4;
  81536. private _vectors2;
  81537. private _vectors3;
  81538. private _matrices;
  81539. private _fallbackTexture;
  81540. private _fallbackTextureUsed;
  81541. private _engine;
  81542. private _cachedDefines;
  81543. private _contentUpdateId;
  81544. private _contentData;
  81545. /**
  81546. * Instantiates a new procedural texture.
  81547. * 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.
  81548. * This is the base class of any Procedural texture and contains most of the shareable code.
  81549. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81550. * @param name Define the name of the texture
  81551. * @param size Define the size of the texture to create
  81552. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81553. * @param scene Define the scene the texture belongs to
  81554. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81555. * @param generateMipMaps Define if the texture should creates mip maps or not
  81556. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81557. */
  81558. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81559. /**
  81560. * The effect that is created when initializing the post process.
  81561. * @returns The created effect corresponding the the postprocess.
  81562. */
  81563. getEffect(): Effect;
  81564. /**
  81565. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81566. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81567. */
  81568. getContent(): Nullable<ArrayBufferView>;
  81569. private _createIndexBuffer;
  81570. /** @hidden */
  81571. _rebuild(): void;
  81572. /**
  81573. * Resets the texture in order to recreate its associated resources.
  81574. * This can be called in case of context loss
  81575. */
  81576. reset(): void;
  81577. protected _getDefines(): string;
  81578. /**
  81579. * Is the texture ready to be used ? (rendered at least once)
  81580. * @returns true if ready, otherwise, false.
  81581. */
  81582. isReady(): boolean;
  81583. /**
  81584. * Resets the refresh counter of the texture and start bak from scratch.
  81585. * Could be useful to regenerate the texture if it is setup to render only once.
  81586. */
  81587. resetRefreshCounter(): void;
  81588. /**
  81589. * Set the fragment shader to use in order to render the texture.
  81590. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81591. */
  81592. setFragment(fragment: any): void;
  81593. /**
  81594. * Define the refresh rate of the texture or the rendering frequency.
  81595. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81596. */
  81597. refreshRate: number;
  81598. /** @hidden */
  81599. _shouldRender(): boolean;
  81600. /**
  81601. * Get the size the texture is rendering at.
  81602. * @returns the size (texture is always squared)
  81603. */
  81604. getRenderSize(): number;
  81605. /**
  81606. * Resize the texture to new value.
  81607. * @param size Define the new size the texture should have
  81608. * @param generateMipMaps Define whether the new texture should create mip maps
  81609. */
  81610. resize(size: number, generateMipMaps: boolean): void;
  81611. private _checkUniform;
  81612. /**
  81613. * Set a texture in the shader program used to render.
  81614. * @param name Define the name of the uniform samplers as defined in the shader
  81615. * @param texture Define the texture to bind to this sampler
  81616. * @return the texture itself allowing "fluent" like uniform updates
  81617. */
  81618. setTexture(name: string, texture: Texture): ProceduralTexture;
  81619. /**
  81620. * Set a float in the shader.
  81621. * @param name Define the name of the uniform as defined in the shader
  81622. * @param value Define the value to give to the uniform
  81623. * @return the texture itself allowing "fluent" like uniform updates
  81624. */
  81625. setFloat(name: string, value: number): ProceduralTexture;
  81626. /**
  81627. * Set a int in the shader.
  81628. * @param name Define the name of the uniform as defined in the shader
  81629. * @param value Define the value to give to the uniform
  81630. * @return the texture itself allowing "fluent" like uniform updates
  81631. */
  81632. setInt(name: string, value: number): ProceduralTexture;
  81633. /**
  81634. * Set an array of floats in the shader.
  81635. * @param name Define the name of the uniform as defined in the shader
  81636. * @param value Define the value to give to the uniform
  81637. * @return the texture itself allowing "fluent" like uniform updates
  81638. */
  81639. setFloats(name: string, value: number[]): ProceduralTexture;
  81640. /**
  81641. * Set a vec3 in the shader from a Color3.
  81642. * @param name Define the name of the uniform as defined in the shader
  81643. * @param value Define the value to give to the uniform
  81644. * @return the texture itself allowing "fluent" like uniform updates
  81645. */
  81646. setColor3(name: string, value: Color3): ProceduralTexture;
  81647. /**
  81648. * Set a vec4 in the shader from a Color4.
  81649. * @param name Define the name of the uniform as defined in the shader
  81650. * @param value Define the value to give to the uniform
  81651. * @return the texture itself allowing "fluent" like uniform updates
  81652. */
  81653. setColor4(name: string, value: Color4): ProceduralTexture;
  81654. /**
  81655. * Set a vec2 in the shader from a Vector2.
  81656. * @param name Define the name of the uniform as defined in the shader
  81657. * @param value Define the value to give to the uniform
  81658. * @return the texture itself allowing "fluent" like uniform updates
  81659. */
  81660. setVector2(name: string, value: Vector2): ProceduralTexture;
  81661. /**
  81662. * Set a vec3 in the shader from a Vector3.
  81663. * @param name Define the name of the uniform as defined in the shader
  81664. * @param value Define the value to give to the uniform
  81665. * @return the texture itself allowing "fluent" like uniform updates
  81666. */
  81667. setVector3(name: string, value: Vector3): ProceduralTexture;
  81668. /**
  81669. * Set a mat4 in the shader from a MAtrix.
  81670. * @param name Define the name of the uniform as defined in the shader
  81671. * @param value Define the value to give to the uniform
  81672. * @return the texture itself allowing "fluent" like uniform updates
  81673. */
  81674. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81675. /**
  81676. * Render the texture to its associated render target.
  81677. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81678. */
  81679. render(useCameraPostProcess?: boolean): void;
  81680. /**
  81681. * Clone the texture.
  81682. * @returns the cloned texture
  81683. */
  81684. clone(): ProceduralTexture;
  81685. /**
  81686. * Dispose the texture and release its asoociated resources.
  81687. */
  81688. dispose(): void;
  81689. }
  81690. }
  81691. declare module BABYLON {
  81692. /**
  81693. * This represents the base class for particle system in Babylon.
  81694. * 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.
  81695. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81696. * @example https://doc.babylonjs.com/babylon101/particles
  81697. */
  81698. export class BaseParticleSystem {
  81699. /**
  81700. * Source color is added to the destination color without alpha affecting the result
  81701. */
  81702. static BLENDMODE_ONEONE: number;
  81703. /**
  81704. * Blend current color and particle color using particle’s alpha
  81705. */
  81706. static BLENDMODE_STANDARD: number;
  81707. /**
  81708. * Add current color and particle color multiplied by particle’s alpha
  81709. */
  81710. static BLENDMODE_ADD: number;
  81711. /**
  81712. * Multiply current color with particle color
  81713. */
  81714. static BLENDMODE_MULTIPLY: number;
  81715. /**
  81716. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81717. */
  81718. static BLENDMODE_MULTIPLYADD: number;
  81719. /**
  81720. * List of animations used by the particle system.
  81721. */
  81722. animations: Animation[];
  81723. /**
  81724. * The id of the Particle system.
  81725. */
  81726. id: string;
  81727. /**
  81728. * The friendly name of the Particle system.
  81729. */
  81730. name: string;
  81731. /**
  81732. * The rendering group used by the Particle system to chose when to render.
  81733. */
  81734. renderingGroupId: number;
  81735. /**
  81736. * The emitter represents the Mesh or position we are attaching the particle system to.
  81737. */
  81738. emitter: Nullable<AbstractMesh | Vector3>;
  81739. /**
  81740. * The maximum number of particles to emit per frame
  81741. */
  81742. emitRate: number;
  81743. /**
  81744. * If you want to launch only a few particles at once, that can be done, as well.
  81745. */
  81746. manualEmitCount: number;
  81747. /**
  81748. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81749. */
  81750. updateSpeed: number;
  81751. /**
  81752. * The amount of time the particle system is running (depends of the overall update speed).
  81753. */
  81754. targetStopDuration: number;
  81755. /**
  81756. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81757. */
  81758. disposeOnStop: boolean;
  81759. /**
  81760. * Minimum power of emitting particles.
  81761. */
  81762. minEmitPower: number;
  81763. /**
  81764. * Maximum power of emitting particles.
  81765. */
  81766. maxEmitPower: number;
  81767. /**
  81768. * Minimum life time of emitting particles.
  81769. */
  81770. minLifeTime: number;
  81771. /**
  81772. * Maximum life time of emitting particles.
  81773. */
  81774. maxLifeTime: number;
  81775. /**
  81776. * Minimum Size of emitting particles.
  81777. */
  81778. minSize: number;
  81779. /**
  81780. * Maximum Size of emitting particles.
  81781. */
  81782. maxSize: number;
  81783. /**
  81784. * Minimum scale of emitting particles on X axis.
  81785. */
  81786. minScaleX: number;
  81787. /**
  81788. * Maximum scale of emitting particles on X axis.
  81789. */
  81790. maxScaleX: number;
  81791. /**
  81792. * Minimum scale of emitting particles on Y axis.
  81793. */
  81794. minScaleY: number;
  81795. /**
  81796. * Maximum scale of emitting particles on Y axis.
  81797. */
  81798. maxScaleY: number;
  81799. /**
  81800. * Gets or sets the minimal initial rotation in radians.
  81801. */
  81802. minInitialRotation: number;
  81803. /**
  81804. * Gets or sets the maximal initial rotation in radians.
  81805. */
  81806. maxInitialRotation: number;
  81807. /**
  81808. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81809. */
  81810. minAngularSpeed: number;
  81811. /**
  81812. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81813. */
  81814. maxAngularSpeed: number;
  81815. /**
  81816. * The texture used to render each particle. (this can be a spritesheet)
  81817. */
  81818. particleTexture: Nullable<Texture>;
  81819. /**
  81820. * The layer mask we are rendering the particles through.
  81821. */
  81822. layerMask: number;
  81823. /**
  81824. * This can help using your own shader to render the particle system.
  81825. * The according effect will be created
  81826. */
  81827. customShader: any;
  81828. /**
  81829. * By default particle system starts as soon as they are created. This prevents the
  81830. * automatic start to happen and let you decide when to start emitting particles.
  81831. */
  81832. preventAutoStart: boolean;
  81833. private _noiseTexture;
  81834. /**
  81835. * Gets or sets a texture used to add random noise to particle positions
  81836. */
  81837. noiseTexture: Nullable<ProceduralTexture>;
  81838. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81839. noiseStrength: Vector3;
  81840. /**
  81841. * Callback triggered when the particle animation is ending.
  81842. */
  81843. onAnimationEnd: Nullable<() => void>;
  81844. /**
  81845. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81846. */
  81847. blendMode: number;
  81848. /**
  81849. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81850. * to override the particles.
  81851. */
  81852. forceDepthWrite: boolean;
  81853. /** 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 */
  81854. preWarmCycles: number;
  81855. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81856. preWarmStepOffset: number;
  81857. /**
  81858. * 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)
  81859. */
  81860. spriteCellChangeSpeed: number;
  81861. /**
  81862. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81863. */
  81864. startSpriteCellID: number;
  81865. /**
  81866. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81867. */
  81868. endSpriteCellID: number;
  81869. /**
  81870. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81871. */
  81872. spriteCellWidth: number;
  81873. /**
  81874. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81875. */
  81876. spriteCellHeight: number;
  81877. /**
  81878. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81879. */
  81880. spriteRandomStartCell: boolean;
  81881. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81882. translationPivot: Vector2;
  81883. /** @hidden */
  81884. protected _isAnimationSheetEnabled: boolean;
  81885. /**
  81886. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81887. */
  81888. beginAnimationOnStart: boolean;
  81889. /**
  81890. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81891. */
  81892. beginAnimationFrom: number;
  81893. /**
  81894. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81895. */
  81896. beginAnimationTo: number;
  81897. /**
  81898. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81899. */
  81900. beginAnimationLoop: boolean;
  81901. /**
  81902. * Gets or sets a world offset applied to all particles
  81903. */
  81904. worldOffset: Vector3;
  81905. /**
  81906. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81907. */
  81908. isAnimationSheetEnabled: boolean;
  81909. /**
  81910. * Get hosting scene
  81911. * @returns the scene
  81912. */
  81913. getScene(): Scene;
  81914. /**
  81915. * You can use gravity if you want to give an orientation to your particles.
  81916. */
  81917. gravity: Vector3;
  81918. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81919. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81920. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81921. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81922. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81923. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81924. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81925. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81926. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81927. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81928. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81929. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81930. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81931. /**
  81932. * Defines the delay in milliseconds before starting the system (0 by default)
  81933. */
  81934. startDelay: number;
  81935. /**
  81936. * Gets the current list of drag gradients.
  81937. * You must use addDragGradient and removeDragGradient to udpate this list
  81938. * @returns the list of drag gradients
  81939. */
  81940. getDragGradients(): Nullable<Array<FactorGradient>>;
  81941. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81942. limitVelocityDamping: number;
  81943. /**
  81944. * Gets the current list of limit velocity gradients.
  81945. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81946. * @returns the list of limit velocity gradients
  81947. */
  81948. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81949. /**
  81950. * Gets the current list of color gradients.
  81951. * You must use addColorGradient and removeColorGradient to udpate this list
  81952. * @returns the list of color gradients
  81953. */
  81954. getColorGradients(): Nullable<Array<ColorGradient>>;
  81955. /**
  81956. * Gets the current list of size gradients.
  81957. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81958. * @returns the list of size gradients
  81959. */
  81960. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81961. /**
  81962. * Gets the current list of color remap gradients.
  81963. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81964. * @returns the list of color remap gradients
  81965. */
  81966. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81967. /**
  81968. * Gets the current list of alpha remap gradients.
  81969. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81970. * @returns the list of alpha remap gradients
  81971. */
  81972. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81973. /**
  81974. * Gets the current list of life time gradients.
  81975. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81976. * @returns the list of life time gradients
  81977. */
  81978. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81979. /**
  81980. * Gets the current list of angular speed gradients.
  81981. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81982. * @returns the list of angular speed gradients
  81983. */
  81984. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81985. /**
  81986. * Gets the current list of velocity gradients.
  81987. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81988. * @returns the list of velocity gradients
  81989. */
  81990. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81991. /**
  81992. * Gets the current list of start size gradients.
  81993. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81994. * @returns the list of start size gradients
  81995. */
  81996. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81997. /**
  81998. * Gets the current list of emit rate gradients.
  81999. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82000. * @returns the list of emit rate gradients
  82001. */
  82002. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82003. /**
  82004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82005. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82006. */
  82007. direction1: Vector3;
  82008. /**
  82009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82010. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82011. */
  82012. direction2: Vector3;
  82013. /**
  82014. * 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.
  82015. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82016. */
  82017. minEmitBox: Vector3;
  82018. /**
  82019. * 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.
  82020. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82021. */
  82022. maxEmitBox: Vector3;
  82023. /**
  82024. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82025. */
  82026. color1: Color4;
  82027. /**
  82028. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82029. */
  82030. color2: Color4;
  82031. /**
  82032. * Color the particle will have at the end of its lifetime
  82033. */
  82034. colorDead: Color4;
  82035. /**
  82036. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82037. */
  82038. textureMask: Color4;
  82039. /**
  82040. * The particle emitter type defines the emitter used by the particle system.
  82041. * It can be for example box, sphere, or cone...
  82042. */
  82043. particleEmitterType: IParticleEmitterType;
  82044. /** @hidden */
  82045. _isSubEmitter: boolean;
  82046. /**
  82047. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82048. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82049. */
  82050. billboardMode: number;
  82051. protected _isBillboardBased: boolean;
  82052. /**
  82053. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82054. */
  82055. isBillboardBased: boolean;
  82056. /**
  82057. * The scene the particle system belongs to.
  82058. */
  82059. protected _scene: Scene;
  82060. /**
  82061. * Local cache of defines for image processing.
  82062. */
  82063. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82064. /**
  82065. * Default configuration related to image processing available in the standard Material.
  82066. */
  82067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82068. /**
  82069. * Gets the image processing configuration used either in this material.
  82070. */
  82071. /**
  82072. * Sets the Default image processing configuration used either in the this material.
  82073. *
  82074. * If sets to null, the scene one is in use.
  82075. */
  82076. imageProcessingConfiguration: ImageProcessingConfiguration;
  82077. /**
  82078. * Attaches a new image processing configuration to the Standard Material.
  82079. * @param configuration
  82080. */
  82081. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82082. /** @hidden */
  82083. protected _reset(): void;
  82084. /** @hidden */
  82085. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82086. /**
  82087. * Instantiates a particle system.
  82088. * 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.
  82089. * @param name The name of the particle system
  82090. */
  82091. constructor(name: string);
  82092. /**
  82093. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82094. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82095. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82096. * @returns the emitter
  82097. */
  82098. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82099. /**
  82100. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82101. * @param radius The radius of the hemisphere to emit from
  82102. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82103. * @returns the emitter
  82104. */
  82105. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82106. /**
  82107. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82108. * @param radius The radius of the sphere to emit from
  82109. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82110. * @returns the emitter
  82111. */
  82112. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82113. /**
  82114. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82115. * @param radius The radius of the sphere to emit from
  82116. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82117. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82118. * @returns the emitter
  82119. */
  82120. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82121. /**
  82122. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82123. * @param radius The radius of the emission cylinder
  82124. * @param height The height of the emission cylinder
  82125. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82126. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82127. * @returns the emitter
  82128. */
  82129. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82130. /**
  82131. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82132. * @param radius The radius of the cylinder to emit from
  82133. * @param height The height of the emission cylinder
  82134. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82135. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82136. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82137. * @returns the emitter
  82138. */
  82139. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82140. /**
  82141. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82142. * @param radius The radius of the cone to emit from
  82143. * @param angle The base angle of the cone
  82144. * @returns the emitter
  82145. */
  82146. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82147. /**
  82148. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82149. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82150. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82151. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82152. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82153. * @returns the emitter
  82154. */
  82155. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82156. }
  82157. }
  82158. declare module BABYLON {
  82159. /**
  82160. * Type of sub emitter
  82161. */
  82162. export enum SubEmitterType {
  82163. /**
  82164. * Attached to the particle over it's lifetime
  82165. */
  82166. ATTACHED = 0,
  82167. /**
  82168. * Created when the particle dies
  82169. */
  82170. END = 1
  82171. }
  82172. /**
  82173. * Sub emitter class used to emit particles from an existing particle
  82174. */
  82175. export class SubEmitter {
  82176. /**
  82177. * the particle system to be used by the sub emitter
  82178. */
  82179. particleSystem: ParticleSystem;
  82180. /**
  82181. * Type of the submitter (Default: END)
  82182. */
  82183. type: SubEmitterType;
  82184. /**
  82185. * 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)
  82186. * Note: This only is supported when using an emitter of type Mesh
  82187. */
  82188. inheritDirection: boolean;
  82189. /**
  82190. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82191. */
  82192. inheritedVelocityAmount: number;
  82193. /**
  82194. * Creates a sub emitter
  82195. * @param particleSystem the particle system to be used by the sub emitter
  82196. */
  82197. constructor(
  82198. /**
  82199. * the particle system to be used by the sub emitter
  82200. */
  82201. particleSystem: ParticleSystem);
  82202. /**
  82203. * Clones the sub emitter
  82204. * @returns the cloned sub emitter
  82205. */
  82206. clone(): SubEmitter;
  82207. /**
  82208. * Serialize current object to a JSON object
  82209. * @returns the serialized object
  82210. */
  82211. serialize(): any;
  82212. /** @hidden */
  82213. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82214. /**
  82215. * Creates a new SubEmitter from a serialized JSON version
  82216. * @param serializationObject defines the JSON object to read from
  82217. * @param scene defines the hosting scene
  82218. * @param rootUrl defines the rootUrl for data loading
  82219. * @returns a new SubEmitter
  82220. */
  82221. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82222. /** Release associated resources */
  82223. dispose(): void;
  82224. }
  82225. }
  82226. declare module BABYLON {
  82227. /** @hidden */
  82228. export var clipPlaneFragmentDeclaration: {
  82229. name: string;
  82230. shader: string;
  82231. };
  82232. }
  82233. declare module BABYLON {
  82234. /** @hidden */
  82235. export var imageProcessingDeclaration: {
  82236. name: string;
  82237. shader: string;
  82238. };
  82239. }
  82240. declare module BABYLON {
  82241. /** @hidden */
  82242. export var imageProcessingFunctions: {
  82243. name: string;
  82244. shader: string;
  82245. };
  82246. }
  82247. declare module BABYLON {
  82248. /** @hidden */
  82249. export var clipPlaneFragment: {
  82250. name: string;
  82251. shader: string;
  82252. };
  82253. }
  82254. declare module BABYLON {
  82255. /** @hidden */
  82256. export var particlesPixelShader: {
  82257. name: string;
  82258. shader: string;
  82259. };
  82260. }
  82261. declare module BABYLON {
  82262. /** @hidden */
  82263. export var clipPlaneVertexDeclaration: {
  82264. name: string;
  82265. shader: string;
  82266. };
  82267. }
  82268. declare module BABYLON {
  82269. /** @hidden */
  82270. export var clipPlaneVertex: {
  82271. name: string;
  82272. shader: string;
  82273. };
  82274. }
  82275. declare module BABYLON {
  82276. /** @hidden */
  82277. export var particlesVertexShader: {
  82278. name: string;
  82279. shader: string;
  82280. };
  82281. }
  82282. declare module BABYLON {
  82283. /**
  82284. * This represents a particle system in Babylon.
  82285. * 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.
  82286. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82287. * @example https://doc.babylonjs.com/babylon101/particles
  82288. */
  82289. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82290. /**
  82291. * Billboard mode will only apply to Y axis
  82292. */
  82293. static readonly BILLBOARDMODE_Y: number;
  82294. /**
  82295. * Billboard mode will apply to all axes
  82296. */
  82297. static readonly BILLBOARDMODE_ALL: number;
  82298. /**
  82299. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82300. */
  82301. static readonly BILLBOARDMODE_STRETCHED: number;
  82302. /**
  82303. * This function can be defined to provide custom update for active particles.
  82304. * This function will be called instead of regular update (age, position, color, etc.).
  82305. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82306. */
  82307. updateFunction: (particles: Particle[]) => void;
  82308. private _emitterWorldMatrix;
  82309. /**
  82310. * This function can be defined to specify initial direction for every new particle.
  82311. * It by default use the emitterType defined function
  82312. */
  82313. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82314. /**
  82315. * This function can be defined to specify initial position for every new particle.
  82316. * It by default use the emitterType defined function
  82317. */
  82318. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82319. /**
  82320. * @hidden
  82321. */
  82322. _inheritedVelocityOffset: Vector3;
  82323. /**
  82324. * An event triggered when the system is disposed
  82325. */
  82326. onDisposeObservable: Observable<ParticleSystem>;
  82327. private _onDisposeObserver;
  82328. /**
  82329. * Sets a callback that will be triggered when the system is disposed
  82330. */
  82331. onDispose: () => void;
  82332. private _particles;
  82333. private _epsilon;
  82334. private _capacity;
  82335. private _stockParticles;
  82336. private _newPartsExcess;
  82337. private _vertexData;
  82338. private _vertexBuffer;
  82339. private _vertexBuffers;
  82340. private _spriteBuffer;
  82341. private _indexBuffer;
  82342. private _effect;
  82343. private _customEffect;
  82344. private _cachedDefines;
  82345. private _scaledColorStep;
  82346. private _colorDiff;
  82347. private _scaledDirection;
  82348. private _scaledGravity;
  82349. private _currentRenderId;
  82350. private _alive;
  82351. private _useInstancing;
  82352. private _started;
  82353. private _stopped;
  82354. private _actualFrame;
  82355. private _scaledUpdateSpeed;
  82356. private _vertexBufferSize;
  82357. /** @hidden */
  82358. _currentEmitRateGradient: Nullable<FactorGradient>;
  82359. /** @hidden */
  82360. _currentEmitRate1: number;
  82361. /** @hidden */
  82362. _currentEmitRate2: number;
  82363. /** @hidden */
  82364. _currentStartSizeGradient: Nullable<FactorGradient>;
  82365. /** @hidden */
  82366. _currentStartSize1: number;
  82367. /** @hidden */
  82368. _currentStartSize2: number;
  82369. private readonly _rawTextureWidth;
  82370. private _rampGradientsTexture;
  82371. private _useRampGradients;
  82372. /** Gets or sets a boolean indicating that ramp gradients must be used
  82373. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82374. */
  82375. useRampGradients: boolean;
  82376. /**
  82377. * 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.
  82378. * 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: [])
  82379. */
  82380. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82381. private _subEmitters;
  82382. /**
  82383. * @hidden
  82384. * If the particle systems emitter should be disposed when the particle system is disposed
  82385. */
  82386. _disposeEmitterOnDispose: boolean;
  82387. /**
  82388. * The current active Sub-systems, this property is used by the root particle system only.
  82389. */
  82390. activeSubSystems: Array<ParticleSystem>;
  82391. private _rootParticleSystem;
  82392. /**
  82393. * Gets the current list of active particles
  82394. */
  82395. readonly particles: Particle[];
  82396. /**
  82397. * Returns the string "ParticleSystem"
  82398. * @returns a string containing the class name
  82399. */
  82400. getClassName(): string;
  82401. /**
  82402. * Instantiates a particle system.
  82403. * 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.
  82404. * @param name The name of the particle system
  82405. * @param capacity The max number of particles alive at the same time
  82406. * @param scene The scene the particle system belongs to
  82407. * @param customEffect a custom effect used to change the way particles are rendered by default
  82408. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82409. * @param epsilon Offset used to render the particles
  82410. */
  82411. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82412. private _addFactorGradient;
  82413. private _removeFactorGradient;
  82414. /**
  82415. * Adds a new life time gradient
  82416. * @param gradient defines the gradient to use (between 0 and 1)
  82417. * @param factor defines the life time factor to affect to the specified gradient
  82418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82419. * @returns the current particle system
  82420. */
  82421. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82422. /**
  82423. * Remove a specific life time gradient
  82424. * @param gradient defines the gradient to remove
  82425. * @returns the current particle system
  82426. */
  82427. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82428. /**
  82429. * Adds a new size gradient
  82430. * @param gradient defines the gradient to use (between 0 and 1)
  82431. * @param factor defines the size factor to affect to the specified gradient
  82432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82433. * @returns the current particle system
  82434. */
  82435. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82436. /**
  82437. * Remove a specific size gradient
  82438. * @param gradient defines the gradient to remove
  82439. * @returns the current particle system
  82440. */
  82441. removeSizeGradient(gradient: number): IParticleSystem;
  82442. /**
  82443. * Adds a new color remap gradient
  82444. * @param gradient defines the gradient to use (between 0 and 1)
  82445. * @param min defines the color remap minimal range
  82446. * @param max defines the color remap maximal range
  82447. * @returns the current particle system
  82448. */
  82449. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82450. /**
  82451. * Remove a specific color remap gradient
  82452. * @param gradient defines the gradient to remove
  82453. * @returns the current particle system
  82454. */
  82455. removeColorRemapGradient(gradient: number): IParticleSystem;
  82456. /**
  82457. * Adds a new alpha remap gradient
  82458. * @param gradient defines the gradient to use (between 0 and 1)
  82459. * @param min defines the alpha remap minimal range
  82460. * @param max defines the alpha remap maximal range
  82461. * @returns the current particle system
  82462. */
  82463. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82464. /**
  82465. * Remove a specific alpha remap gradient
  82466. * @param gradient defines the gradient to remove
  82467. * @returns the current particle system
  82468. */
  82469. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82470. /**
  82471. * Adds a new angular speed gradient
  82472. * @param gradient defines the gradient to use (between 0 and 1)
  82473. * @param factor defines the angular speed to affect to the specified gradient
  82474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82475. * @returns the current particle system
  82476. */
  82477. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82478. /**
  82479. * Remove a specific angular speed gradient
  82480. * @param gradient defines the gradient to remove
  82481. * @returns the current particle system
  82482. */
  82483. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82484. /**
  82485. * Adds a new velocity gradient
  82486. * @param gradient defines the gradient to use (between 0 and 1)
  82487. * @param factor defines the velocity to affect to the specified gradient
  82488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82489. * @returns the current particle system
  82490. */
  82491. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82492. /**
  82493. * Remove a specific velocity gradient
  82494. * @param gradient defines the gradient to remove
  82495. * @returns the current particle system
  82496. */
  82497. removeVelocityGradient(gradient: number): IParticleSystem;
  82498. /**
  82499. * Adds a new limit velocity gradient
  82500. * @param gradient defines the gradient to use (between 0 and 1)
  82501. * @param factor defines the limit velocity value to affect to the specified gradient
  82502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82503. * @returns the current particle system
  82504. */
  82505. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82506. /**
  82507. * Remove a specific limit velocity gradient
  82508. * @param gradient defines the gradient to remove
  82509. * @returns the current particle system
  82510. */
  82511. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82512. /**
  82513. * Adds a new drag gradient
  82514. * @param gradient defines the gradient to use (between 0 and 1)
  82515. * @param factor defines the drag value to affect to the specified gradient
  82516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82517. * @returns the current particle system
  82518. */
  82519. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82520. /**
  82521. * Remove a specific drag gradient
  82522. * @param gradient defines the gradient to remove
  82523. * @returns the current particle system
  82524. */
  82525. removeDragGradient(gradient: number): IParticleSystem;
  82526. /**
  82527. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82528. * @param gradient defines the gradient to use (between 0 and 1)
  82529. * @param factor defines the emit rate value to affect to the specified gradient
  82530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82531. * @returns the current particle system
  82532. */
  82533. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82534. /**
  82535. * Remove a specific emit rate gradient
  82536. * @param gradient defines the gradient to remove
  82537. * @returns the current particle system
  82538. */
  82539. removeEmitRateGradient(gradient: number): IParticleSystem;
  82540. /**
  82541. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82542. * @param gradient defines the gradient to use (between 0 and 1)
  82543. * @param factor defines the start size value to affect to the specified gradient
  82544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82545. * @returns the current particle system
  82546. */
  82547. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82548. /**
  82549. * Remove a specific start size gradient
  82550. * @param gradient defines the gradient to remove
  82551. * @returns the current particle system
  82552. */
  82553. removeStartSizeGradient(gradient: number): IParticleSystem;
  82554. private _createRampGradientTexture;
  82555. /**
  82556. * Gets the current list of ramp gradients.
  82557. * You must use addRampGradient and removeRampGradient to udpate this list
  82558. * @returns the list of ramp gradients
  82559. */
  82560. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82561. /**
  82562. * Adds a new ramp gradient used to remap particle colors
  82563. * @param gradient defines the gradient to use (between 0 and 1)
  82564. * @param color defines the color to affect to the specified gradient
  82565. * @returns the current particle system
  82566. */
  82567. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82568. /**
  82569. * Remove a specific ramp gradient
  82570. * @param gradient defines the gradient to remove
  82571. * @returns the current particle system
  82572. */
  82573. removeRampGradient(gradient: number): ParticleSystem;
  82574. /**
  82575. * Adds a new color gradient
  82576. * @param gradient defines the gradient to use (between 0 and 1)
  82577. * @param color1 defines the color to affect to the specified gradient
  82578. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82579. * @returns this particle system
  82580. */
  82581. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82582. /**
  82583. * Remove a specific color gradient
  82584. * @param gradient defines the gradient to remove
  82585. * @returns this particle system
  82586. */
  82587. removeColorGradient(gradient: number): IParticleSystem;
  82588. private _fetchR;
  82589. protected _reset(): void;
  82590. private _resetEffect;
  82591. private _createVertexBuffers;
  82592. private _createIndexBuffer;
  82593. /**
  82594. * Gets the maximum number of particles active at the same time.
  82595. * @returns The max number of active particles.
  82596. */
  82597. getCapacity(): number;
  82598. /**
  82599. * Gets whether there are still active particles in the system.
  82600. * @returns True if it is alive, otherwise false.
  82601. */
  82602. isAlive(): boolean;
  82603. /**
  82604. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82605. * @returns True if it has been started, otherwise false.
  82606. */
  82607. isStarted(): boolean;
  82608. private _prepareSubEmitterInternalArray;
  82609. /**
  82610. * Starts the particle system and begins to emit
  82611. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82612. */
  82613. start(delay?: number): void;
  82614. /**
  82615. * Stops the particle system.
  82616. * @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.
  82617. */
  82618. stop(stopSubEmitters?: boolean): void;
  82619. /**
  82620. * Remove all active particles
  82621. */
  82622. reset(): void;
  82623. /**
  82624. * @hidden (for internal use only)
  82625. */
  82626. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82627. /**
  82628. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82629. * Its lifetime will start back at 0.
  82630. */
  82631. recycleParticle: (particle: Particle) => void;
  82632. private _stopSubEmitters;
  82633. private _createParticle;
  82634. private _removeFromRoot;
  82635. private _emitFromParticle;
  82636. private _update;
  82637. /** @hidden */
  82638. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82639. /** @hidden */
  82640. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82641. /** @hidden */
  82642. private _getEffect;
  82643. /**
  82644. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82645. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82646. */
  82647. animate(preWarmOnly?: boolean): void;
  82648. private _appendParticleVertices;
  82649. /**
  82650. * Rebuilds the particle system.
  82651. */
  82652. rebuild(): void;
  82653. /**
  82654. * Is this system ready to be used/rendered
  82655. * @return true if the system is ready
  82656. */
  82657. isReady(): boolean;
  82658. private _render;
  82659. /**
  82660. * Renders the particle system in its current state.
  82661. * @returns the current number of particles
  82662. */
  82663. render(): number;
  82664. /**
  82665. * Disposes the particle system and free the associated resources
  82666. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82667. */
  82668. dispose(disposeTexture?: boolean): void;
  82669. /**
  82670. * Clones the particle system.
  82671. * @param name The name of the cloned object
  82672. * @param newEmitter The new emitter to use
  82673. * @returns the cloned particle system
  82674. */
  82675. clone(name: string, newEmitter: any): ParticleSystem;
  82676. /**
  82677. * Serializes the particle system to a JSON object.
  82678. * @returns the JSON object
  82679. */
  82680. serialize(): any;
  82681. /** @hidden */
  82682. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82683. /** @hidden */
  82684. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82685. /**
  82686. * Parses a JSON object to create a particle system.
  82687. * @param parsedParticleSystem The JSON object to parse
  82688. * @param scene The scene to create the particle system in
  82689. * @param rootUrl The root url to use to load external dependencies like texture
  82690. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82691. * @returns the Parsed particle system
  82692. */
  82693. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82694. }
  82695. }
  82696. declare module BABYLON {
  82697. /**
  82698. * A particle represents one of the element emitted by a particle system.
  82699. * This is mainly define by its coordinates, direction, velocity and age.
  82700. */
  82701. export class Particle {
  82702. /**
  82703. * The particle system the particle belongs to.
  82704. */
  82705. particleSystem: ParticleSystem;
  82706. private static _Count;
  82707. /**
  82708. * Unique ID of the particle
  82709. */
  82710. id: number;
  82711. /**
  82712. * The world position of the particle in the scene.
  82713. */
  82714. position: Vector3;
  82715. /**
  82716. * The world direction of the particle in the scene.
  82717. */
  82718. direction: Vector3;
  82719. /**
  82720. * The color of the particle.
  82721. */
  82722. color: Color4;
  82723. /**
  82724. * The color change of the particle per step.
  82725. */
  82726. colorStep: Color4;
  82727. /**
  82728. * Defines how long will the life of the particle be.
  82729. */
  82730. lifeTime: number;
  82731. /**
  82732. * The current age of the particle.
  82733. */
  82734. age: number;
  82735. /**
  82736. * The current size of the particle.
  82737. */
  82738. size: number;
  82739. /**
  82740. * The current scale of the particle.
  82741. */
  82742. scale: Vector2;
  82743. /**
  82744. * The current angle of the particle.
  82745. */
  82746. angle: number;
  82747. /**
  82748. * Defines how fast is the angle changing.
  82749. */
  82750. angularSpeed: number;
  82751. /**
  82752. * Defines the cell index used by the particle to be rendered from a sprite.
  82753. */
  82754. cellIndex: number;
  82755. /**
  82756. * The information required to support color remapping
  82757. */
  82758. remapData: Vector4;
  82759. /** @hidden */
  82760. _randomCellOffset?: number;
  82761. /** @hidden */
  82762. _initialDirection: Nullable<Vector3>;
  82763. /** @hidden */
  82764. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82765. /** @hidden */
  82766. _initialStartSpriteCellID: number;
  82767. /** @hidden */
  82768. _initialEndSpriteCellID: number;
  82769. /** @hidden */
  82770. _currentColorGradient: Nullable<ColorGradient>;
  82771. /** @hidden */
  82772. _currentColor1: Color4;
  82773. /** @hidden */
  82774. _currentColor2: Color4;
  82775. /** @hidden */
  82776. _currentSizeGradient: Nullable<FactorGradient>;
  82777. /** @hidden */
  82778. _currentSize1: number;
  82779. /** @hidden */
  82780. _currentSize2: number;
  82781. /** @hidden */
  82782. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82783. /** @hidden */
  82784. _currentAngularSpeed1: number;
  82785. /** @hidden */
  82786. _currentAngularSpeed2: number;
  82787. /** @hidden */
  82788. _currentVelocityGradient: Nullable<FactorGradient>;
  82789. /** @hidden */
  82790. _currentVelocity1: number;
  82791. /** @hidden */
  82792. _currentVelocity2: number;
  82793. /** @hidden */
  82794. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82795. /** @hidden */
  82796. _currentLimitVelocity1: number;
  82797. /** @hidden */
  82798. _currentLimitVelocity2: number;
  82799. /** @hidden */
  82800. _currentDragGradient: Nullable<FactorGradient>;
  82801. /** @hidden */
  82802. _currentDrag1: number;
  82803. /** @hidden */
  82804. _currentDrag2: number;
  82805. /** @hidden */
  82806. _randomNoiseCoordinates1: Vector3;
  82807. /** @hidden */
  82808. _randomNoiseCoordinates2: Vector3;
  82809. /**
  82810. * Creates a new instance Particle
  82811. * @param particleSystem the particle system the particle belongs to
  82812. */
  82813. constructor(
  82814. /**
  82815. * The particle system the particle belongs to.
  82816. */
  82817. particleSystem: ParticleSystem);
  82818. private updateCellInfoFromSystem;
  82819. /**
  82820. * Defines how the sprite cell index is updated for the particle
  82821. */
  82822. updateCellIndex(): void;
  82823. /** @hidden */
  82824. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82825. /** @hidden */
  82826. _inheritParticleInfoToSubEmitters(): void;
  82827. /** @hidden */
  82828. _reset(): void;
  82829. /**
  82830. * Copy the properties of particle to another one.
  82831. * @param other the particle to copy the information to.
  82832. */
  82833. copyTo(other: Particle): void;
  82834. }
  82835. }
  82836. declare module BABYLON {
  82837. /**
  82838. * Particle emitter represents a volume emitting particles.
  82839. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82840. */
  82841. export interface IParticleEmitterType {
  82842. /**
  82843. * Called by the particle System when the direction is computed for the created particle.
  82844. * @param worldMatrix is the world matrix of the particle system
  82845. * @param directionToUpdate is the direction vector to update with the result
  82846. * @param particle is the particle we are computed the direction for
  82847. */
  82848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82849. /**
  82850. * Called by the particle System when the position is computed for the created particle.
  82851. * @param worldMatrix is the world matrix of the particle system
  82852. * @param positionToUpdate is the position vector to update with the result
  82853. * @param particle is the particle we are computed the position for
  82854. */
  82855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82856. /**
  82857. * Clones the current emitter and returns a copy of it
  82858. * @returns the new emitter
  82859. */
  82860. clone(): IParticleEmitterType;
  82861. /**
  82862. * Called by the GPUParticleSystem to setup the update shader
  82863. * @param effect defines the update shader
  82864. */
  82865. applyToShader(effect: Effect): void;
  82866. /**
  82867. * Returns a string to use to update the GPU particles update shader
  82868. * @returns the effect defines string
  82869. */
  82870. getEffectDefines(): string;
  82871. /**
  82872. * Returns a string representing the class name
  82873. * @returns a string containing the class name
  82874. */
  82875. getClassName(): string;
  82876. /**
  82877. * Serializes the particle system to a JSON object.
  82878. * @returns the JSON object
  82879. */
  82880. serialize(): any;
  82881. /**
  82882. * Parse properties from a JSON object
  82883. * @param serializationObject defines the JSON object
  82884. */
  82885. parse(serializationObject: any): void;
  82886. }
  82887. }
  82888. declare module BABYLON {
  82889. /**
  82890. * Particle emitter emitting particles from the inside of a box.
  82891. * It emits the particles randomly between 2 given directions.
  82892. */
  82893. export class BoxParticleEmitter implements IParticleEmitterType {
  82894. /**
  82895. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82896. */
  82897. direction1: Vector3;
  82898. /**
  82899. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82900. */
  82901. direction2: Vector3;
  82902. /**
  82903. * 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.
  82904. */
  82905. minEmitBox: Vector3;
  82906. /**
  82907. * 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.
  82908. */
  82909. maxEmitBox: Vector3;
  82910. /**
  82911. * Creates a new instance BoxParticleEmitter
  82912. */
  82913. constructor();
  82914. /**
  82915. * Called by the particle System when the direction is computed for the created particle.
  82916. * @param worldMatrix is the world matrix of the particle system
  82917. * @param directionToUpdate is the direction vector to update with the result
  82918. * @param particle is the particle we are computed the direction for
  82919. */
  82920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82921. /**
  82922. * Called by the particle System when the position is computed for the created particle.
  82923. * @param worldMatrix is the world matrix of the particle system
  82924. * @param positionToUpdate is the position vector to update with the result
  82925. * @param particle is the particle we are computed the position for
  82926. */
  82927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82928. /**
  82929. * Clones the current emitter and returns a copy of it
  82930. * @returns the new emitter
  82931. */
  82932. clone(): BoxParticleEmitter;
  82933. /**
  82934. * Called by the GPUParticleSystem to setup the update shader
  82935. * @param effect defines the update shader
  82936. */
  82937. applyToShader(effect: Effect): void;
  82938. /**
  82939. * Returns a string to use to update the GPU particles update shader
  82940. * @returns a string containng the defines string
  82941. */
  82942. getEffectDefines(): string;
  82943. /**
  82944. * Returns the string "BoxParticleEmitter"
  82945. * @returns a string containing the class name
  82946. */
  82947. getClassName(): string;
  82948. /**
  82949. * Serializes the particle system to a JSON object.
  82950. * @returns the JSON object
  82951. */
  82952. serialize(): any;
  82953. /**
  82954. * Parse properties from a JSON object
  82955. * @param serializationObject defines the JSON object
  82956. */
  82957. parse(serializationObject: any): void;
  82958. }
  82959. }
  82960. declare module BABYLON {
  82961. /**
  82962. * Particle emitter emitting particles from the inside of a cone.
  82963. * It emits the particles alongside the cone volume from the base to the particle.
  82964. * The emission direction might be randomized.
  82965. */
  82966. export class ConeParticleEmitter implements IParticleEmitterType {
  82967. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82968. directionRandomizer: number;
  82969. private _radius;
  82970. private _angle;
  82971. private _height;
  82972. /**
  82973. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82974. */
  82975. radiusRange: number;
  82976. /**
  82977. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82978. */
  82979. heightRange: number;
  82980. /**
  82981. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82982. */
  82983. emitFromSpawnPointOnly: boolean;
  82984. /**
  82985. * Gets or sets the radius of the emission cone
  82986. */
  82987. radius: number;
  82988. /**
  82989. * Gets or sets the angle of the emission cone
  82990. */
  82991. angle: number;
  82992. private _buildHeight;
  82993. /**
  82994. * Creates a new instance ConeParticleEmitter
  82995. * @param radius the radius of the emission cone (1 by default)
  82996. * @param angle the cone base angle (PI by default)
  82997. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82998. */
  82999. constructor(radius?: number, angle?: number,
  83000. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83001. directionRandomizer?: number);
  83002. /**
  83003. * Called by the particle System when the direction is computed for the created particle.
  83004. * @param worldMatrix is the world matrix of the particle system
  83005. * @param directionToUpdate is the direction vector to update with the result
  83006. * @param particle is the particle we are computed the direction for
  83007. */
  83008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83009. /**
  83010. * Called by the particle System when the position is computed for the created particle.
  83011. * @param worldMatrix is the world matrix of the particle system
  83012. * @param positionToUpdate is the position vector to update with the result
  83013. * @param particle is the particle we are computed the position for
  83014. */
  83015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83016. /**
  83017. * Clones the current emitter and returns a copy of it
  83018. * @returns the new emitter
  83019. */
  83020. clone(): ConeParticleEmitter;
  83021. /**
  83022. * Called by the GPUParticleSystem to setup the update shader
  83023. * @param effect defines the update shader
  83024. */
  83025. applyToShader(effect: Effect): void;
  83026. /**
  83027. * Returns a string to use to update the GPU particles update shader
  83028. * @returns a string containng the defines string
  83029. */
  83030. getEffectDefines(): string;
  83031. /**
  83032. * Returns the string "ConeParticleEmitter"
  83033. * @returns a string containing the class name
  83034. */
  83035. getClassName(): string;
  83036. /**
  83037. * Serializes the particle system to a JSON object.
  83038. * @returns the JSON object
  83039. */
  83040. serialize(): any;
  83041. /**
  83042. * Parse properties from a JSON object
  83043. * @param serializationObject defines the JSON object
  83044. */
  83045. parse(serializationObject: any): void;
  83046. }
  83047. }
  83048. declare module BABYLON {
  83049. /**
  83050. * Particle emitter emitting particles from the inside of a cylinder.
  83051. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83052. */
  83053. export class CylinderParticleEmitter implements IParticleEmitterType {
  83054. /**
  83055. * The radius of the emission cylinder.
  83056. */
  83057. radius: number;
  83058. /**
  83059. * The height of the emission cylinder.
  83060. */
  83061. height: number;
  83062. /**
  83063. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83064. */
  83065. radiusRange: number;
  83066. /**
  83067. * How much to randomize the particle direction [0-1].
  83068. */
  83069. directionRandomizer: number;
  83070. /**
  83071. * Creates a new instance CylinderParticleEmitter
  83072. * @param radius the radius of the emission cylinder (1 by default)
  83073. * @param height the height of the emission cylinder (1 by default)
  83074. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83075. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83076. */
  83077. constructor(
  83078. /**
  83079. * The radius of the emission cylinder.
  83080. */
  83081. radius?: number,
  83082. /**
  83083. * The height of the emission cylinder.
  83084. */
  83085. height?: number,
  83086. /**
  83087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83088. */
  83089. radiusRange?: number,
  83090. /**
  83091. * How much to randomize the particle direction [0-1].
  83092. */
  83093. directionRandomizer?: number);
  83094. /**
  83095. * Called by the particle System when the direction is computed for the created particle.
  83096. * @param worldMatrix is the world matrix of the particle system
  83097. * @param directionToUpdate is the direction vector to update with the result
  83098. * @param particle is the particle we are computed the direction for
  83099. */
  83100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83101. /**
  83102. * Called by the particle System when the position is computed for the created particle.
  83103. * @param worldMatrix is the world matrix of the particle system
  83104. * @param positionToUpdate is the position vector to update with the result
  83105. * @param particle is the particle we are computed the position for
  83106. */
  83107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83108. /**
  83109. * Clones the current emitter and returns a copy of it
  83110. * @returns the new emitter
  83111. */
  83112. clone(): CylinderParticleEmitter;
  83113. /**
  83114. * Called by the GPUParticleSystem to setup the update shader
  83115. * @param effect defines the update shader
  83116. */
  83117. applyToShader(effect: Effect): void;
  83118. /**
  83119. * Returns a string to use to update the GPU particles update shader
  83120. * @returns a string containng the defines string
  83121. */
  83122. getEffectDefines(): string;
  83123. /**
  83124. * Returns the string "CylinderParticleEmitter"
  83125. * @returns a string containing the class name
  83126. */
  83127. getClassName(): string;
  83128. /**
  83129. * Serializes the particle system to a JSON object.
  83130. * @returns the JSON object
  83131. */
  83132. serialize(): any;
  83133. /**
  83134. * Parse properties from a JSON object
  83135. * @param serializationObject defines the JSON object
  83136. */
  83137. parse(serializationObject: any): void;
  83138. }
  83139. /**
  83140. * Particle emitter emitting particles from the inside of a cylinder.
  83141. * It emits the particles randomly between two vectors.
  83142. */
  83143. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83144. /**
  83145. * The min limit of the emission direction.
  83146. */
  83147. direction1: Vector3;
  83148. /**
  83149. * The max limit of the emission direction.
  83150. */
  83151. direction2: Vector3;
  83152. /**
  83153. * Creates a new instance CylinderDirectedParticleEmitter
  83154. * @param radius the radius of the emission cylinder (1 by default)
  83155. * @param height the height of the emission cylinder (1 by default)
  83156. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83157. * @param direction1 the min limit of the emission direction (up vector by default)
  83158. * @param direction2 the max limit of the emission direction (up vector by default)
  83159. */
  83160. constructor(radius?: number, height?: number, radiusRange?: number,
  83161. /**
  83162. * The min limit of the emission direction.
  83163. */
  83164. direction1?: Vector3,
  83165. /**
  83166. * The max limit of the emission direction.
  83167. */
  83168. direction2?: Vector3);
  83169. /**
  83170. * Called by the particle System when the direction is computed for the created particle.
  83171. * @param worldMatrix is the world matrix of the particle system
  83172. * @param directionToUpdate is the direction vector to update with the result
  83173. * @param particle is the particle we are computed the direction for
  83174. */
  83175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83176. /**
  83177. * Clones the current emitter and returns a copy of it
  83178. * @returns the new emitter
  83179. */
  83180. clone(): CylinderDirectedParticleEmitter;
  83181. /**
  83182. * Called by the GPUParticleSystem to setup the update shader
  83183. * @param effect defines the update shader
  83184. */
  83185. applyToShader(effect: Effect): void;
  83186. /**
  83187. * Returns a string to use to update the GPU particles update shader
  83188. * @returns a string containng the defines string
  83189. */
  83190. getEffectDefines(): string;
  83191. /**
  83192. * Returns the string "CylinderDirectedParticleEmitter"
  83193. * @returns a string containing the class name
  83194. */
  83195. getClassName(): string;
  83196. /**
  83197. * Serializes the particle system to a JSON object.
  83198. * @returns the JSON object
  83199. */
  83200. serialize(): any;
  83201. /**
  83202. * Parse properties from a JSON object
  83203. * @param serializationObject defines the JSON object
  83204. */
  83205. parse(serializationObject: any): void;
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /**
  83210. * Particle emitter emitting particles from the inside of a hemisphere.
  83211. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83212. */
  83213. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83214. /**
  83215. * The radius of the emission hemisphere.
  83216. */
  83217. radius: number;
  83218. /**
  83219. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83220. */
  83221. radiusRange: number;
  83222. /**
  83223. * How much to randomize the particle direction [0-1].
  83224. */
  83225. directionRandomizer: number;
  83226. /**
  83227. * Creates a new instance HemisphericParticleEmitter
  83228. * @param radius the radius of the emission hemisphere (1 by default)
  83229. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83230. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83231. */
  83232. constructor(
  83233. /**
  83234. * The radius of the emission hemisphere.
  83235. */
  83236. radius?: number,
  83237. /**
  83238. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83239. */
  83240. radiusRange?: number,
  83241. /**
  83242. * How much to randomize the particle direction [0-1].
  83243. */
  83244. directionRandomizer?: number);
  83245. /**
  83246. * Called by the particle System when the direction is computed for the created particle.
  83247. * @param worldMatrix is the world matrix of the particle system
  83248. * @param directionToUpdate is the direction vector to update with the result
  83249. * @param particle is the particle we are computed the direction for
  83250. */
  83251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83252. /**
  83253. * Called by the particle System when the position is computed for the created particle.
  83254. * @param worldMatrix is the world matrix of the particle system
  83255. * @param positionToUpdate is the position vector to update with the result
  83256. * @param particle is the particle we are computed the position for
  83257. */
  83258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83259. /**
  83260. * Clones the current emitter and returns a copy of it
  83261. * @returns the new emitter
  83262. */
  83263. clone(): HemisphericParticleEmitter;
  83264. /**
  83265. * Called by the GPUParticleSystem to setup the update shader
  83266. * @param effect defines the update shader
  83267. */
  83268. applyToShader(effect: Effect): void;
  83269. /**
  83270. * Returns a string to use to update the GPU particles update shader
  83271. * @returns a string containng the defines string
  83272. */
  83273. getEffectDefines(): string;
  83274. /**
  83275. * Returns the string "HemisphericParticleEmitter"
  83276. * @returns a string containing the class name
  83277. */
  83278. getClassName(): string;
  83279. /**
  83280. * Serializes the particle system to a JSON object.
  83281. * @returns the JSON object
  83282. */
  83283. serialize(): any;
  83284. /**
  83285. * Parse properties from a JSON object
  83286. * @param serializationObject defines the JSON object
  83287. */
  83288. parse(serializationObject: any): void;
  83289. }
  83290. }
  83291. declare module BABYLON {
  83292. /**
  83293. * Particle emitter emitting particles from a point.
  83294. * It emits the particles randomly between 2 given directions.
  83295. */
  83296. export class PointParticleEmitter implements IParticleEmitterType {
  83297. /**
  83298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83299. */
  83300. direction1: Vector3;
  83301. /**
  83302. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83303. */
  83304. direction2: Vector3;
  83305. /**
  83306. * Creates a new instance PointParticleEmitter
  83307. */
  83308. constructor();
  83309. /**
  83310. * Called by the particle System when the direction is computed for the created particle.
  83311. * @param worldMatrix is the world matrix of the particle system
  83312. * @param directionToUpdate is the direction vector to update with the result
  83313. * @param particle is the particle we are computed the direction for
  83314. */
  83315. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83316. /**
  83317. * Called by the particle System when the position is computed for the created particle.
  83318. * @param worldMatrix is the world matrix of the particle system
  83319. * @param positionToUpdate is the position vector to update with the result
  83320. * @param particle is the particle we are computed the position for
  83321. */
  83322. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83323. /**
  83324. * Clones the current emitter and returns a copy of it
  83325. * @returns the new emitter
  83326. */
  83327. clone(): PointParticleEmitter;
  83328. /**
  83329. * Called by the GPUParticleSystem to setup the update shader
  83330. * @param effect defines the update shader
  83331. */
  83332. applyToShader(effect: Effect): void;
  83333. /**
  83334. * Returns a string to use to update the GPU particles update shader
  83335. * @returns a string containng the defines string
  83336. */
  83337. getEffectDefines(): string;
  83338. /**
  83339. * Returns the string "PointParticleEmitter"
  83340. * @returns a string containing the class name
  83341. */
  83342. getClassName(): string;
  83343. /**
  83344. * Serializes the particle system to a JSON object.
  83345. * @returns the JSON object
  83346. */
  83347. serialize(): any;
  83348. /**
  83349. * Parse properties from a JSON object
  83350. * @param serializationObject defines the JSON object
  83351. */
  83352. parse(serializationObject: any): void;
  83353. }
  83354. }
  83355. declare module BABYLON {
  83356. /**
  83357. * Particle emitter emitting particles from the inside of a sphere.
  83358. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83359. */
  83360. export class SphereParticleEmitter implements IParticleEmitterType {
  83361. /**
  83362. * The radius of the emission sphere.
  83363. */
  83364. radius: number;
  83365. /**
  83366. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83367. */
  83368. radiusRange: number;
  83369. /**
  83370. * How much to randomize the particle direction [0-1].
  83371. */
  83372. directionRandomizer: number;
  83373. /**
  83374. * Creates a new instance SphereParticleEmitter
  83375. * @param radius the radius of the emission sphere (1 by default)
  83376. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83377. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83378. */
  83379. constructor(
  83380. /**
  83381. * The radius of the emission sphere.
  83382. */
  83383. radius?: number,
  83384. /**
  83385. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83386. */
  83387. radiusRange?: number,
  83388. /**
  83389. * How much to randomize the particle direction [0-1].
  83390. */
  83391. directionRandomizer?: number);
  83392. /**
  83393. * Called by the particle System when the direction is computed for the created particle.
  83394. * @param worldMatrix is the world matrix of the particle system
  83395. * @param directionToUpdate is the direction vector to update with the result
  83396. * @param particle is the particle we are computed the direction for
  83397. */
  83398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83399. /**
  83400. * Called by the particle System when the position is computed for the created particle.
  83401. * @param worldMatrix is the world matrix of the particle system
  83402. * @param positionToUpdate is the position vector to update with the result
  83403. * @param particle is the particle we are computed the position for
  83404. */
  83405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83406. /**
  83407. * Clones the current emitter and returns a copy of it
  83408. * @returns the new emitter
  83409. */
  83410. clone(): SphereParticleEmitter;
  83411. /**
  83412. * Called by the GPUParticleSystem to setup the update shader
  83413. * @param effect defines the update shader
  83414. */
  83415. applyToShader(effect: Effect): void;
  83416. /**
  83417. * Returns a string to use to update the GPU particles update shader
  83418. * @returns a string containng the defines string
  83419. */
  83420. getEffectDefines(): string;
  83421. /**
  83422. * Returns the string "SphereParticleEmitter"
  83423. * @returns a string containing the class name
  83424. */
  83425. getClassName(): string;
  83426. /**
  83427. * Serializes the particle system to a JSON object.
  83428. * @returns the JSON object
  83429. */
  83430. serialize(): any;
  83431. /**
  83432. * Parse properties from a JSON object
  83433. * @param serializationObject defines the JSON object
  83434. */
  83435. parse(serializationObject: any): void;
  83436. }
  83437. /**
  83438. * Particle emitter emitting particles from the inside of a sphere.
  83439. * It emits the particles randomly between two vectors.
  83440. */
  83441. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83442. /**
  83443. * The min limit of the emission direction.
  83444. */
  83445. direction1: Vector3;
  83446. /**
  83447. * The max limit of the emission direction.
  83448. */
  83449. direction2: Vector3;
  83450. /**
  83451. * Creates a new instance SphereDirectedParticleEmitter
  83452. * @param radius the radius of the emission sphere (1 by default)
  83453. * @param direction1 the min limit of the emission direction (up vector by default)
  83454. * @param direction2 the max limit of the emission direction (up vector by default)
  83455. */
  83456. constructor(radius?: number,
  83457. /**
  83458. * The min limit of the emission direction.
  83459. */
  83460. direction1?: Vector3,
  83461. /**
  83462. * The max limit of the emission direction.
  83463. */
  83464. direction2?: Vector3);
  83465. /**
  83466. * Called by the particle System when the direction is computed for the created particle.
  83467. * @param worldMatrix is the world matrix of the particle system
  83468. * @param directionToUpdate is the direction vector to update with the result
  83469. * @param particle is the particle we are computed the direction for
  83470. */
  83471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83472. /**
  83473. * Clones the current emitter and returns a copy of it
  83474. * @returns the new emitter
  83475. */
  83476. clone(): SphereDirectedParticleEmitter;
  83477. /**
  83478. * Called by the GPUParticleSystem to setup the update shader
  83479. * @param effect defines the update shader
  83480. */
  83481. applyToShader(effect: Effect): void;
  83482. /**
  83483. * Returns a string to use to update the GPU particles update shader
  83484. * @returns a string containng the defines string
  83485. */
  83486. getEffectDefines(): string;
  83487. /**
  83488. * Returns the string "SphereDirectedParticleEmitter"
  83489. * @returns a string containing the class name
  83490. */
  83491. getClassName(): string;
  83492. /**
  83493. * Serializes the particle system to a JSON object.
  83494. * @returns the JSON object
  83495. */
  83496. serialize(): any;
  83497. /**
  83498. * Parse properties from a JSON object
  83499. * @param serializationObject defines the JSON object
  83500. */
  83501. parse(serializationObject: any): void;
  83502. }
  83503. }
  83504. declare module BABYLON {
  83505. /**
  83506. * Interface representing a particle system in Babylon.js.
  83507. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83508. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83509. */
  83510. export interface IParticleSystem {
  83511. /**
  83512. * List of animations used by the particle system.
  83513. */
  83514. animations: Animation[];
  83515. /**
  83516. * The id of the Particle system.
  83517. */
  83518. id: string;
  83519. /**
  83520. * The name of the Particle system.
  83521. */
  83522. name: string;
  83523. /**
  83524. * The emitter represents the Mesh or position we are attaching the particle system to.
  83525. */
  83526. emitter: Nullable<AbstractMesh | Vector3>;
  83527. /**
  83528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83529. */
  83530. isBillboardBased: boolean;
  83531. /**
  83532. * The rendering group used by the Particle system to chose when to render.
  83533. */
  83534. renderingGroupId: number;
  83535. /**
  83536. * The layer mask we are rendering the particles through.
  83537. */
  83538. layerMask: number;
  83539. /**
  83540. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83541. */
  83542. updateSpeed: number;
  83543. /**
  83544. * The amount of time the particle system is running (depends of the overall update speed).
  83545. */
  83546. targetStopDuration: number;
  83547. /**
  83548. * The texture used to render each particle. (this can be a spritesheet)
  83549. */
  83550. particleTexture: Nullable<Texture>;
  83551. /**
  83552. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83553. */
  83554. blendMode: number;
  83555. /**
  83556. * Minimum life time of emitting particles.
  83557. */
  83558. minLifeTime: number;
  83559. /**
  83560. * Maximum life time of emitting particles.
  83561. */
  83562. maxLifeTime: number;
  83563. /**
  83564. * Minimum Size of emitting particles.
  83565. */
  83566. minSize: number;
  83567. /**
  83568. * Maximum Size of emitting particles.
  83569. */
  83570. maxSize: number;
  83571. /**
  83572. * Minimum scale of emitting particles on X axis.
  83573. */
  83574. minScaleX: number;
  83575. /**
  83576. * Maximum scale of emitting particles on X axis.
  83577. */
  83578. maxScaleX: number;
  83579. /**
  83580. * Minimum scale of emitting particles on Y axis.
  83581. */
  83582. minScaleY: number;
  83583. /**
  83584. * Maximum scale of emitting particles on Y axis.
  83585. */
  83586. maxScaleY: number;
  83587. /**
  83588. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83589. */
  83590. color1: Color4;
  83591. /**
  83592. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83593. */
  83594. color2: Color4;
  83595. /**
  83596. * Color the particle will have at the end of its lifetime.
  83597. */
  83598. colorDead: Color4;
  83599. /**
  83600. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83601. */
  83602. emitRate: number;
  83603. /**
  83604. * You can use gravity if you want to give an orientation to your particles.
  83605. */
  83606. gravity: Vector3;
  83607. /**
  83608. * Minimum power of emitting particles.
  83609. */
  83610. minEmitPower: number;
  83611. /**
  83612. * Maximum power of emitting particles.
  83613. */
  83614. maxEmitPower: number;
  83615. /**
  83616. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83617. */
  83618. minAngularSpeed: number;
  83619. /**
  83620. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83621. */
  83622. maxAngularSpeed: number;
  83623. /**
  83624. * Gets or sets the minimal initial rotation in radians.
  83625. */
  83626. minInitialRotation: number;
  83627. /**
  83628. * Gets or sets the maximal initial rotation in radians.
  83629. */
  83630. maxInitialRotation: number;
  83631. /**
  83632. * The particle emitter type defines the emitter used by the particle system.
  83633. * It can be for example box, sphere, or cone...
  83634. */
  83635. particleEmitterType: Nullable<IParticleEmitterType>;
  83636. /**
  83637. * Defines the delay in milliseconds before starting the system (0 by default)
  83638. */
  83639. startDelay: number;
  83640. /**
  83641. * 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
  83642. */
  83643. preWarmCycles: number;
  83644. /**
  83645. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83646. */
  83647. preWarmStepOffset: number;
  83648. /**
  83649. * 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)
  83650. */
  83651. spriteCellChangeSpeed: number;
  83652. /**
  83653. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83654. */
  83655. startSpriteCellID: number;
  83656. /**
  83657. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83658. */
  83659. endSpriteCellID: number;
  83660. /**
  83661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83662. */
  83663. spriteCellWidth: number;
  83664. /**
  83665. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83666. */
  83667. spriteCellHeight: number;
  83668. /**
  83669. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83670. */
  83671. spriteRandomStartCell: boolean;
  83672. /**
  83673. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83674. */
  83675. isAnimationSheetEnabled: boolean;
  83676. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83677. translationPivot: Vector2;
  83678. /**
  83679. * Gets or sets a texture used to add random noise to particle positions
  83680. */
  83681. noiseTexture: Nullable<BaseTexture>;
  83682. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83683. noiseStrength: Vector3;
  83684. /**
  83685. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83686. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83687. */
  83688. billboardMode: number;
  83689. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83690. limitVelocityDamping: number;
  83691. /**
  83692. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83693. */
  83694. beginAnimationOnStart: boolean;
  83695. /**
  83696. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83697. */
  83698. beginAnimationFrom: number;
  83699. /**
  83700. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83701. */
  83702. beginAnimationTo: number;
  83703. /**
  83704. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83705. */
  83706. beginAnimationLoop: boolean;
  83707. /**
  83708. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83709. */
  83710. disposeOnStop: boolean;
  83711. /**
  83712. * Gets the maximum number of particles active at the same time.
  83713. * @returns The max number of active particles.
  83714. */
  83715. getCapacity(): number;
  83716. /**
  83717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83718. * @returns True if it has been started, otherwise false.
  83719. */
  83720. isStarted(): boolean;
  83721. /**
  83722. * Animates the particle system for this frame.
  83723. */
  83724. animate(): void;
  83725. /**
  83726. * Renders the particle system in its current state.
  83727. * @returns the current number of particles
  83728. */
  83729. render(): number;
  83730. /**
  83731. * Dispose the particle system and frees its associated resources.
  83732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83733. */
  83734. dispose(disposeTexture?: boolean): void;
  83735. /**
  83736. * Clones the particle system.
  83737. * @param name The name of the cloned object
  83738. * @param newEmitter The new emitter to use
  83739. * @returns the cloned particle system
  83740. */
  83741. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83742. /**
  83743. * Serializes the particle system to a JSON object.
  83744. * @returns the JSON object
  83745. */
  83746. serialize(): any;
  83747. /**
  83748. * Rebuild the particle system
  83749. */
  83750. rebuild(): void;
  83751. /**
  83752. * Starts the particle system and begins to emit
  83753. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83754. */
  83755. start(delay?: number): void;
  83756. /**
  83757. * Stops the particle system.
  83758. */
  83759. stop(): void;
  83760. /**
  83761. * Remove all active particles
  83762. */
  83763. reset(): void;
  83764. /**
  83765. * Is this system ready to be used/rendered
  83766. * @return true if the system is ready
  83767. */
  83768. isReady(): boolean;
  83769. /**
  83770. * Adds a new color gradient
  83771. * @param gradient defines the gradient to use (between 0 and 1)
  83772. * @param color1 defines the color to affect to the specified gradient
  83773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83774. * @returns the current particle system
  83775. */
  83776. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83777. /**
  83778. * Remove a specific color gradient
  83779. * @param gradient defines the gradient to remove
  83780. * @returns the current particle system
  83781. */
  83782. removeColorGradient(gradient: number): IParticleSystem;
  83783. /**
  83784. * Adds a new size gradient
  83785. * @param gradient defines the gradient to use (between 0 and 1)
  83786. * @param factor defines the size factor to affect to the specified gradient
  83787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83788. * @returns the current particle system
  83789. */
  83790. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83791. /**
  83792. * Remove a specific size gradient
  83793. * @param gradient defines the gradient to remove
  83794. * @returns the current particle system
  83795. */
  83796. removeSizeGradient(gradient: number): IParticleSystem;
  83797. /**
  83798. * Gets the current list of color gradients.
  83799. * You must use addColorGradient and removeColorGradient to udpate this list
  83800. * @returns the list of color gradients
  83801. */
  83802. getColorGradients(): Nullable<Array<ColorGradient>>;
  83803. /**
  83804. * Gets the current list of size gradients.
  83805. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83806. * @returns the list of size gradients
  83807. */
  83808. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83809. /**
  83810. * Gets the current list of angular speed gradients.
  83811. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83812. * @returns the list of angular speed gradients
  83813. */
  83814. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83815. /**
  83816. * Adds a new angular speed gradient
  83817. * @param gradient defines the gradient to use (between 0 and 1)
  83818. * @param factor defines the angular speed to affect to the specified gradient
  83819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83820. * @returns the current particle system
  83821. */
  83822. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83823. /**
  83824. * Remove a specific angular speed gradient
  83825. * @param gradient defines the gradient to remove
  83826. * @returns the current particle system
  83827. */
  83828. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83829. /**
  83830. * Gets the current list of velocity gradients.
  83831. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83832. * @returns the list of velocity gradients
  83833. */
  83834. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83835. /**
  83836. * Adds a new velocity gradient
  83837. * @param gradient defines the gradient to use (between 0 and 1)
  83838. * @param factor defines the velocity to affect to the specified gradient
  83839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83840. * @returns the current particle system
  83841. */
  83842. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83843. /**
  83844. * Remove a specific velocity gradient
  83845. * @param gradient defines the gradient to remove
  83846. * @returns the current particle system
  83847. */
  83848. removeVelocityGradient(gradient: number): IParticleSystem;
  83849. /**
  83850. * Gets the current list of limit velocity gradients.
  83851. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83852. * @returns the list of limit velocity gradients
  83853. */
  83854. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83855. /**
  83856. * Adds a new limit velocity gradient
  83857. * @param gradient defines the gradient to use (between 0 and 1)
  83858. * @param factor defines the limit velocity to affect to the specified gradient
  83859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83860. * @returns the current particle system
  83861. */
  83862. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83863. /**
  83864. * Remove a specific limit velocity gradient
  83865. * @param gradient defines the gradient to remove
  83866. * @returns the current particle system
  83867. */
  83868. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83869. /**
  83870. * Adds a new drag gradient
  83871. * @param gradient defines the gradient to use (between 0 and 1)
  83872. * @param factor defines the drag to affect to the specified gradient
  83873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83874. * @returns the current particle system
  83875. */
  83876. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83877. /**
  83878. * Remove a specific drag gradient
  83879. * @param gradient defines the gradient to remove
  83880. * @returns the current particle system
  83881. */
  83882. removeDragGradient(gradient: number): IParticleSystem;
  83883. /**
  83884. * Gets the current list of drag gradients.
  83885. * You must use addDragGradient and removeDragGradient to udpate this list
  83886. * @returns the list of drag gradients
  83887. */
  83888. getDragGradients(): Nullable<Array<FactorGradient>>;
  83889. /**
  83890. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83891. * @param gradient defines the gradient to use (between 0 and 1)
  83892. * @param factor defines the emit rate to affect to the specified gradient
  83893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83894. * @returns the current particle system
  83895. */
  83896. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83897. /**
  83898. * Remove a specific emit rate gradient
  83899. * @param gradient defines the gradient to remove
  83900. * @returns the current particle system
  83901. */
  83902. removeEmitRateGradient(gradient: number): IParticleSystem;
  83903. /**
  83904. * Gets the current list of emit rate gradients.
  83905. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83906. * @returns the list of emit rate gradients
  83907. */
  83908. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83909. /**
  83910. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83911. * @param gradient defines the gradient to use (between 0 and 1)
  83912. * @param factor defines the start size to affect to the specified gradient
  83913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83914. * @returns the current particle system
  83915. */
  83916. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83917. /**
  83918. * Remove a specific start size gradient
  83919. * @param gradient defines the gradient to remove
  83920. * @returns the current particle system
  83921. */
  83922. removeStartSizeGradient(gradient: number): IParticleSystem;
  83923. /**
  83924. * Gets the current list of start size gradients.
  83925. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83926. * @returns the list of start size gradients
  83927. */
  83928. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83929. /**
  83930. * Adds a new life time gradient
  83931. * @param gradient defines the gradient to use (between 0 and 1)
  83932. * @param factor defines the life time factor to affect to the specified gradient
  83933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83934. * @returns the current particle system
  83935. */
  83936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83937. /**
  83938. * Remove a specific life time gradient
  83939. * @param gradient defines the gradient to remove
  83940. * @returns the current particle system
  83941. */
  83942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83943. /**
  83944. * Gets the current list of life time gradients.
  83945. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83946. * @returns the list of life time gradients
  83947. */
  83948. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83949. /**
  83950. * Gets the current list of color gradients.
  83951. * You must use addColorGradient and removeColorGradient to udpate this list
  83952. * @returns the list of color gradients
  83953. */
  83954. getColorGradients(): Nullable<Array<ColorGradient>>;
  83955. /**
  83956. * Adds a new ramp gradient used to remap particle colors
  83957. * @param gradient defines the gradient to use (between 0 and 1)
  83958. * @param color defines the color to affect to the specified gradient
  83959. * @returns the current particle system
  83960. */
  83961. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83962. /**
  83963. * Gets the current list of ramp gradients.
  83964. * You must use addRampGradient and removeRampGradient to udpate this list
  83965. * @returns the list of ramp gradients
  83966. */
  83967. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83968. /** Gets or sets a boolean indicating that ramp gradients must be used
  83969. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83970. */
  83971. useRampGradients: boolean;
  83972. /**
  83973. * Adds a new color remap gradient
  83974. * @param gradient defines the gradient to use (between 0 and 1)
  83975. * @param min defines the color remap minimal range
  83976. * @param max defines the color remap maximal range
  83977. * @returns the current particle system
  83978. */
  83979. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83980. /**
  83981. * Gets the current list of color remap gradients.
  83982. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83983. * @returns the list of color remap gradients
  83984. */
  83985. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83986. /**
  83987. * Adds a new alpha remap gradient
  83988. * @param gradient defines the gradient to use (between 0 and 1)
  83989. * @param min defines the alpha remap minimal range
  83990. * @param max defines the alpha remap maximal range
  83991. * @returns the current particle system
  83992. */
  83993. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83994. /**
  83995. * Gets the current list of alpha remap gradients.
  83996. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83997. * @returns the list of alpha remap gradients
  83998. */
  83999. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84000. /**
  84001. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84004. * @returns the emitter
  84005. */
  84006. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84007. /**
  84008. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84009. * @param radius The radius of the hemisphere to emit from
  84010. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84011. * @returns the emitter
  84012. */
  84013. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84014. /**
  84015. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84016. * @param radius The radius of the sphere to emit from
  84017. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84018. * @returns the emitter
  84019. */
  84020. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84021. /**
  84022. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84023. * @param radius The radius of the sphere to emit from
  84024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84026. * @returns the emitter
  84027. */
  84028. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84029. /**
  84030. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84031. * @param radius The radius of the emission cylinder
  84032. * @param height The height of the emission cylinder
  84033. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84034. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84035. * @returns the emitter
  84036. */
  84037. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84038. /**
  84039. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84040. * @param radius The radius of the cylinder to emit from
  84041. * @param height The height of the emission cylinder
  84042. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84043. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84044. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84045. * @returns the emitter
  84046. */
  84047. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84048. /**
  84049. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84050. * @param radius The radius of the cone to emit from
  84051. * @param angle The base angle of the cone
  84052. * @returns the emitter
  84053. */
  84054. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84055. /**
  84056. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84057. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84058. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84059. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84060. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84061. * @returns the emitter
  84062. */
  84063. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84064. /**
  84065. * Get hosting scene
  84066. * @returns the scene
  84067. */
  84068. getScene(): Scene;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. /**
  84073. * Creates an instance based on a source mesh.
  84074. */
  84075. export class InstancedMesh extends AbstractMesh {
  84076. private _sourceMesh;
  84077. private _currentLOD;
  84078. /** @hidden */
  84079. _indexInSourceMeshInstanceArray: number;
  84080. constructor(name: string, source: Mesh);
  84081. /**
  84082. * Returns the string "InstancedMesh".
  84083. */
  84084. getClassName(): string;
  84085. /** Gets the list of lights affecting that mesh */
  84086. readonly lightSources: Light[];
  84087. _resyncLightSources(): void;
  84088. _resyncLighSource(light: Light): void;
  84089. _removeLightSource(light: Light, dispose: boolean): void;
  84090. /**
  84091. * If the source mesh receives shadows
  84092. */
  84093. readonly receiveShadows: boolean;
  84094. /**
  84095. * The material of the source mesh
  84096. */
  84097. readonly material: Nullable<Material>;
  84098. /**
  84099. * Visibility of the source mesh
  84100. */
  84101. readonly visibility: number;
  84102. /**
  84103. * Skeleton of the source mesh
  84104. */
  84105. readonly skeleton: Nullable<Skeleton>;
  84106. /**
  84107. * Rendering ground id of the source mesh
  84108. */
  84109. renderingGroupId: number;
  84110. /**
  84111. * Returns the total number of vertices (integer).
  84112. */
  84113. getTotalVertices(): number;
  84114. /**
  84115. * Returns a positive integer : the total number of indices in this mesh geometry.
  84116. * @returns the numner of indices or zero if the mesh has no geometry.
  84117. */
  84118. getTotalIndices(): number;
  84119. /**
  84120. * The source mesh of the instance
  84121. */
  84122. readonly sourceMesh: Mesh;
  84123. /**
  84124. * Is this node ready to be used/rendered
  84125. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84126. * @return {boolean} is it ready
  84127. */
  84128. isReady(completeCheck?: boolean): boolean;
  84129. /**
  84130. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84131. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84132. * @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.
  84133. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84134. */
  84135. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84136. /**
  84137. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84138. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84139. * The `data` are either a numeric array either a Float32Array.
  84140. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84141. * 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).
  84142. * Note that a new underlying VertexBuffer object is created each call.
  84143. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84144. *
  84145. * Possible `kind` values :
  84146. * - VertexBuffer.PositionKind
  84147. * - VertexBuffer.UVKind
  84148. * - VertexBuffer.UV2Kind
  84149. * - VertexBuffer.UV3Kind
  84150. * - VertexBuffer.UV4Kind
  84151. * - VertexBuffer.UV5Kind
  84152. * - VertexBuffer.UV6Kind
  84153. * - VertexBuffer.ColorKind
  84154. * - VertexBuffer.MatricesIndicesKind
  84155. * - VertexBuffer.MatricesIndicesExtraKind
  84156. * - VertexBuffer.MatricesWeightsKind
  84157. * - VertexBuffer.MatricesWeightsExtraKind
  84158. *
  84159. * Returns the Mesh.
  84160. */
  84161. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84162. /**
  84163. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84164. * If the mesh has no geometry, it is simply returned as it is.
  84165. * The `data` are either a numeric array either a Float32Array.
  84166. * No new underlying VertexBuffer object is created.
  84167. * 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.
  84168. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84169. *
  84170. * Possible `kind` values :
  84171. * - VertexBuffer.PositionKind
  84172. * - VertexBuffer.UVKind
  84173. * - VertexBuffer.UV2Kind
  84174. * - VertexBuffer.UV3Kind
  84175. * - VertexBuffer.UV4Kind
  84176. * - VertexBuffer.UV5Kind
  84177. * - VertexBuffer.UV6Kind
  84178. * - VertexBuffer.ColorKind
  84179. * - VertexBuffer.MatricesIndicesKind
  84180. * - VertexBuffer.MatricesIndicesExtraKind
  84181. * - VertexBuffer.MatricesWeightsKind
  84182. * - VertexBuffer.MatricesWeightsExtraKind
  84183. *
  84184. * Returns the Mesh.
  84185. */
  84186. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84187. /**
  84188. * Sets the mesh indices.
  84189. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84190. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84191. * This method creates a new index buffer each call.
  84192. * Returns the Mesh.
  84193. */
  84194. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84195. /**
  84196. * Boolean : True if the mesh owns the requested kind of data.
  84197. */
  84198. isVerticesDataPresent(kind: string): boolean;
  84199. /**
  84200. * Returns an array of indices (IndicesArray).
  84201. */
  84202. getIndices(): Nullable<IndicesArray>;
  84203. readonly _positions: Nullable<Vector3[]>;
  84204. /**
  84205. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84206. * This means the mesh underlying bounding box and sphere are recomputed.
  84207. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84208. * @returns the current mesh
  84209. */
  84210. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84211. /** @hidden */
  84212. _preActivate(): InstancedMesh;
  84213. /** @hidden */
  84214. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84215. /** @hidden */
  84216. _postActivate(): void;
  84217. getWorldMatrix(): Matrix;
  84218. readonly isAnInstance: boolean;
  84219. /**
  84220. * Returns the current associated LOD AbstractMesh.
  84221. */
  84222. getLOD(camera: Camera): AbstractMesh;
  84223. /** @hidden */
  84224. _syncSubMeshes(): InstancedMesh;
  84225. /** @hidden */
  84226. _generatePointsArray(): boolean;
  84227. /**
  84228. * Creates a new InstancedMesh from the current mesh.
  84229. * - name (string) : the cloned mesh name
  84230. * - newParent (optional Node) : the optional Node to parent the clone to.
  84231. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84232. *
  84233. * Returns the clone.
  84234. */
  84235. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84236. /**
  84237. * Disposes the InstancedMesh.
  84238. * Returns nothing.
  84239. */
  84240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84241. }
  84242. }
  84243. declare module BABYLON {
  84244. /**
  84245. * Defines the options associated with the creation of a shader material.
  84246. */
  84247. export interface IShaderMaterialOptions {
  84248. /**
  84249. * Does the material work in alpha blend mode
  84250. */
  84251. needAlphaBlending: boolean;
  84252. /**
  84253. * Does the material work in alpha test mode
  84254. */
  84255. needAlphaTesting: boolean;
  84256. /**
  84257. * The list of attribute names used in the shader
  84258. */
  84259. attributes: string[];
  84260. /**
  84261. * The list of unifrom names used in the shader
  84262. */
  84263. uniforms: string[];
  84264. /**
  84265. * The list of UBO names used in the shader
  84266. */
  84267. uniformBuffers: string[];
  84268. /**
  84269. * The list of sampler names used in the shader
  84270. */
  84271. samplers: string[];
  84272. /**
  84273. * The list of defines used in the shader
  84274. */
  84275. defines: string[];
  84276. }
  84277. /**
  84278. * 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.
  84279. *
  84280. * This returned material effects how the mesh will look based on the code in the shaders.
  84281. *
  84282. * @see http://doc.babylonjs.com/how_to/shader_material
  84283. */
  84284. export class ShaderMaterial extends Material {
  84285. private _shaderPath;
  84286. private _options;
  84287. private _textures;
  84288. private _textureArrays;
  84289. private _floats;
  84290. private _ints;
  84291. private _floatsArrays;
  84292. private _colors3;
  84293. private _colors3Arrays;
  84294. private _colors4;
  84295. private _colors4Arrays;
  84296. private _vectors2;
  84297. private _vectors3;
  84298. private _vectors4;
  84299. private _matrices;
  84300. private _matrices3x3;
  84301. private _matrices2x2;
  84302. private _vectors2Arrays;
  84303. private _vectors3Arrays;
  84304. private _vectors4Arrays;
  84305. private _cachedWorldViewMatrix;
  84306. private _cachedWorldViewProjectionMatrix;
  84307. private _renderId;
  84308. /**
  84309. * Instantiate a new shader material.
  84310. * 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.
  84311. * This returned material effects how the mesh will look based on the code in the shaders.
  84312. * @see http://doc.babylonjs.com/how_to/shader_material
  84313. * @param name Define the name of the material in the scene
  84314. * @param scene Define the scene the material belongs to
  84315. * @param shaderPath Defines the route to the shader code in one of three ways:
  84316. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84317. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  84318. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84319. * @param options Define the options used to create the shader
  84320. */
  84321. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84322. /**
  84323. * Gets the options used to compile the shader.
  84324. * They can be modified to trigger a new compilation
  84325. */
  84326. readonly options: IShaderMaterialOptions;
  84327. /**
  84328. * Gets the current class name of the material e.g. "ShaderMaterial"
  84329. * Mainly use in serialization.
  84330. * @returns the class name
  84331. */
  84332. getClassName(): string;
  84333. /**
  84334. * Specifies if the material will require alpha blending
  84335. * @returns a boolean specifying if alpha blending is needed
  84336. */
  84337. needAlphaBlending(): boolean;
  84338. /**
  84339. * Specifies if this material should be rendered in alpha test mode
  84340. * @returns a boolean specifying if an alpha test is needed.
  84341. */
  84342. needAlphaTesting(): boolean;
  84343. private _checkUniform;
  84344. /**
  84345. * Set a texture in the shader.
  84346. * @param name Define the name of the uniform samplers as defined in the shader
  84347. * @param texture Define the texture to bind to this sampler
  84348. * @return the material itself allowing "fluent" like uniform updates
  84349. */
  84350. setTexture(name: string, texture: Texture): ShaderMaterial;
  84351. /**
  84352. * Set a texture array in the shader.
  84353. * @param name Define the name of the uniform sampler array as defined in the shader
  84354. * @param textures Define the list of textures to bind to this sampler
  84355. * @return the material itself allowing "fluent" like uniform updates
  84356. */
  84357. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84358. /**
  84359. * Set a float in the shader.
  84360. * @param name Define the name of the uniform as defined in the shader
  84361. * @param value Define the value to give to the uniform
  84362. * @return the material itself allowing "fluent" like uniform updates
  84363. */
  84364. setFloat(name: string, value: number): ShaderMaterial;
  84365. /**
  84366. * Set a int in the shader.
  84367. * @param name Define the name of the uniform as defined in the shader
  84368. * @param value Define the value to give to the uniform
  84369. * @return the material itself allowing "fluent" like uniform updates
  84370. */
  84371. setInt(name: string, value: number): ShaderMaterial;
  84372. /**
  84373. * Set an array of floats in the shader.
  84374. * @param name Define the name of the uniform as defined in the shader
  84375. * @param value Define the value to give to the uniform
  84376. * @return the material itself allowing "fluent" like uniform updates
  84377. */
  84378. setFloats(name: string, value: number[]): ShaderMaterial;
  84379. /**
  84380. * Set a vec3 in the shader from a Color3.
  84381. * @param name Define the name of the uniform as defined in the shader
  84382. * @param value Define the value to give to the uniform
  84383. * @return the material itself allowing "fluent" like uniform updates
  84384. */
  84385. setColor3(name: string, value: Color3): ShaderMaterial;
  84386. /**
  84387. * Set a vec3 array in the shader from a Color3 array.
  84388. * @param name Define the name of the uniform as defined in the shader
  84389. * @param value Define the value to give to the uniform
  84390. * @return the material itself allowing "fluent" like uniform updates
  84391. */
  84392. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84393. /**
  84394. * Set a vec4 in the shader from a Color4.
  84395. * @param name Define the name of the uniform as defined in the shader
  84396. * @param value Define the value to give to the uniform
  84397. * @return the material itself allowing "fluent" like uniform updates
  84398. */
  84399. setColor4(name: string, value: Color4): ShaderMaterial;
  84400. /**
  84401. * Set a vec4 array in the shader from a Color4 array.
  84402. * @param name Define the name of the uniform as defined in the shader
  84403. * @param value Define the value to give to the uniform
  84404. * @return the material itself allowing "fluent" like uniform updates
  84405. */
  84406. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84407. /**
  84408. * Set a vec2 in the shader from a Vector2.
  84409. * @param name Define the name of the uniform as defined in the shader
  84410. * @param value Define the value to give to the uniform
  84411. * @return the material itself allowing "fluent" like uniform updates
  84412. */
  84413. setVector2(name: string, value: Vector2): ShaderMaterial;
  84414. /**
  84415. * Set a vec3 in the shader from a Vector3.
  84416. * @param name Define the name of the uniform as defined in the shader
  84417. * @param value Define the value to give to the uniform
  84418. * @return the material itself allowing "fluent" like uniform updates
  84419. */
  84420. setVector3(name: string, value: Vector3): ShaderMaterial;
  84421. /**
  84422. * Set a vec4 in the shader from a Vector4.
  84423. * @param name Define the name of the uniform as defined in the shader
  84424. * @param value Define the value to give to the uniform
  84425. * @return the material itself allowing "fluent" like uniform updates
  84426. */
  84427. setVector4(name: string, value: Vector4): ShaderMaterial;
  84428. /**
  84429. * Set a mat4 in the shader from a Matrix.
  84430. * @param name Define the name of the uniform as defined in the shader
  84431. * @param value Define the value to give to the uniform
  84432. * @return the material itself allowing "fluent" like uniform updates
  84433. */
  84434. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84435. /**
  84436. * Set a mat3 in the shader from a Float32Array.
  84437. * @param name Define the name of the uniform as defined in the shader
  84438. * @param value Define the value to give to the uniform
  84439. * @return the material itself allowing "fluent" like uniform updates
  84440. */
  84441. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84442. /**
  84443. * Set a mat2 in the shader from a Float32Array.
  84444. * @param name Define the name of the uniform as defined in the shader
  84445. * @param value Define the value to give to the uniform
  84446. * @return the material itself allowing "fluent" like uniform updates
  84447. */
  84448. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84449. /**
  84450. * Set a vec2 array in the shader from a number array.
  84451. * @param name Define the name of the uniform as defined in the shader
  84452. * @param value Define the value to give to the uniform
  84453. * @return the material itself allowing "fluent" like uniform updates
  84454. */
  84455. setArray2(name: string, value: number[]): ShaderMaterial;
  84456. /**
  84457. * Set a vec3 array in the shader from a number array.
  84458. * @param name Define the name of the uniform as defined in the shader
  84459. * @param value Define the value to give to the uniform
  84460. * @return the material itself allowing "fluent" like uniform updates
  84461. */
  84462. setArray3(name: string, value: number[]): ShaderMaterial;
  84463. /**
  84464. * Set a vec4 array in the shader from a number array.
  84465. * @param name Define the name of the uniform as defined in the shader
  84466. * @param value Define the value to give to the uniform
  84467. * @return the material itself allowing "fluent" like uniform updates
  84468. */
  84469. setArray4(name: string, value: number[]): ShaderMaterial;
  84470. private _checkCache;
  84471. /**
  84472. * Specifies that the submesh is ready to be used
  84473. * @param mesh defines the mesh to check
  84474. * @param subMesh defines which submesh to check
  84475. * @param useInstances specifies that instances should be used
  84476. * @returns a boolean indicating that the submesh is ready or not
  84477. */
  84478. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84479. /**
  84480. * Checks if the material is ready to render the requested mesh
  84481. * @param mesh Define the mesh to render
  84482. * @param useInstances Define whether or not the material is used with instances
  84483. * @returns true if ready, otherwise false
  84484. */
  84485. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84486. /**
  84487. * Binds the world matrix to the material
  84488. * @param world defines the world transformation matrix
  84489. */
  84490. bindOnlyWorldMatrix(world: Matrix): void;
  84491. /**
  84492. * Binds the material to the mesh
  84493. * @param world defines the world transformation matrix
  84494. * @param mesh defines the mesh to bind the material to
  84495. */
  84496. bind(world: Matrix, mesh?: Mesh): void;
  84497. /**
  84498. * Gets the active textures from the material
  84499. * @returns an array of textures
  84500. */
  84501. getActiveTextures(): BaseTexture[];
  84502. /**
  84503. * Specifies if the material uses a texture
  84504. * @param texture defines the texture to check against the material
  84505. * @returns a boolean specifying if the material uses the texture
  84506. */
  84507. hasTexture(texture: BaseTexture): boolean;
  84508. /**
  84509. * Makes a duplicate of the material, and gives it a new name
  84510. * @param name defines the new name for the duplicated material
  84511. * @returns the cloned material
  84512. */
  84513. clone(name: string): ShaderMaterial;
  84514. /**
  84515. * Disposes the material
  84516. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84517. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84518. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84519. */
  84520. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84521. /**
  84522. * Serializes this material in a JSON representation
  84523. * @returns the serialized material object
  84524. */
  84525. serialize(): any;
  84526. /**
  84527. * Creates a shader material from parsed shader material data
  84528. * @param source defines the JSON represnetation of the material
  84529. * @param scene defines the hosting scene
  84530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84531. * @returns a new material
  84532. */
  84533. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84534. }
  84535. }
  84536. declare module BABYLON {
  84537. /** @hidden */
  84538. export var colorPixelShader: {
  84539. name: string;
  84540. shader: string;
  84541. };
  84542. }
  84543. declare module BABYLON {
  84544. /** @hidden */
  84545. export var colorVertexShader: {
  84546. name: string;
  84547. shader: string;
  84548. };
  84549. }
  84550. declare module BABYLON {
  84551. /**
  84552. * Line mesh
  84553. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84554. */
  84555. export class LinesMesh extends Mesh {
  84556. /**
  84557. * If vertex color should be applied to the mesh
  84558. */
  84559. readonly useVertexColor?: boolean | undefined;
  84560. /**
  84561. * If vertex alpha should be applied to the mesh
  84562. */
  84563. readonly useVertexAlpha?: boolean | undefined;
  84564. /**
  84565. * Color of the line (Default: White)
  84566. */
  84567. color: Color3;
  84568. /**
  84569. * Alpha of the line (Default: 1)
  84570. */
  84571. alpha: number;
  84572. /**
  84573. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84574. * This margin is expressed in world space coordinates, so its value may vary.
  84575. * Default value is 0.1
  84576. */
  84577. intersectionThreshold: number;
  84578. private _colorShader;
  84579. private color4;
  84580. /**
  84581. * Creates a new LinesMesh
  84582. * @param name defines the name
  84583. * @param scene defines the hosting scene
  84584. * @param parent defines the parent mesh if any
  84585. * @param source defines the optional source LinesMesh used to clone data from
  84586. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84587. * When false, achieved by calling a clone(), also passing False.
  84588. * This will make creation of children, recursive.
  84589. * @param useVertexColor defines if this LinesMesh supports vertex color
  84590. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84591. */
  84592. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84593. /**
  84594. * If vertex color should be applied to the mesh
  84595. */
  84596. useVertexColor?: boolean | undefined,
  84597. /**
  84598. * If vertex alpha should be applied to the mesh
  84599. */
  84600. useVertexAlpha?: boolean | undefined);
  84601. private _addClipPlaneDefine;
  84602. private _removeClipPlaneDefine;
  84603. isReady(): boolean;
  84604. /**
  84605. * Returns the string "LineMesh"
  84606. */
  84607. getClassName(): string;
  84608. /**
  84609. * @hidden
  84610. */
  84611. /**
  84612. * @hidden
  84613. */
  84614. material: Material;
  84615. /**
  84616. * @hidden
  84617. */
  84618. readonly checkCollisions: boolean;
  84619. /** @hidden */
  84620. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84621. /** @hidden */
  84622. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84623. /**
  84624. * Disposes of the line mesh
  84625. * @param doNotRecurse If children should be disposed
  84626. */
  84627. dispose(doNotRecurse?: boolean): void;
  84628. /**
  84629. * Returns a new LineMesh object cloned from the current one.
  84630. */
  84631. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84632. /**
  84633. * Creates a new InstancedLinesMesh object from the mesh model.
  84634. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84635. * @param name defines the name of the new instance
  84636. * @returns a new InstancedLinesMesh
  84637. */
  84638. createInstance(name: string): InstancedLinesMesh;
  84639. }
  84640. /**
  84641. * Creates an instance based on a source LinesMesh
  84642. */
  84643. export class InstancedLinesMesh extends InstancedMesh {
  84644. /**
  84645. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84646. * This margin is expressed in world space coordinates, so its value may vary.
  84647. * Initilized with the intersectionThreshold value of the source LinesMesh
  84648. */
  84649. intersectionThreshold: number;
  84650. constructor(name: string, source: LinesMesh);
  84651. /**
  84652. * Returns the string "InstancedLinesMesh".
  84653. */
  84654. getClassName(): string;
  84655. }
  84656. }
  84657. declare module BABYLON {
  84658. /** @hidden */
  84659. export var linePixelShader: {
  84660. name: string;
  84661. shader: string;
  84662. };
  84663. }
  84664. declare module BABYLON {
  84665. /** @hidden */
  84666. export var lineVertexShader: {
  84667. name: string;
  84668. shader: string;
  84669. };
  84670. }
  84671. declare module BABYLON {
  84672. interface AbstractMesh {
  84673. /**
  84674. * Gets the edgesRenderer associated with the mesh
  84675. */
  84676. edgesRenderer: Nullable<EdgesRenderer>;
  84677. }
  84678. interface LinesMesh {
  84679. /**
  84680. * Enables the edge rendering mode on the mesh.
  84681. * This mode makes the mesh edges visible
  84682. * @param epsilon defines the maximal distance between two angles to detect a face
  84683. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84684. * @returns the currentAbstractMesh
  84685. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84686. */
  84687. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84688. }
  84689. interface InstancedLinesMesh {
  84690. /**
  84691. * Enables the edge rendering mode on the mesh.
  84692. * This mode makes the mesh edges visible
  84693. * @param epsilon defines the maximal distance between two angles to detect a face
  84694. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84695. * @returns the current InstancedLinesMesh
  84696. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84697. */
  84698. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84699. }
  84700. /**
  84701. * Defines the minimum contract an Edges renderer should follow.
  84702. */
  84703. export interface IEdgesRenderer extends IDisposable {
  84704. /**
  84705. * Gets or sets a boolean indicating if the edgesRenderer is active
  84706. */
  84707. isEnabled: boolean;
  84708. /**
  84709. * Renders the edges of the attached mesh,
  84710. */
  84711. render(): void;
  84712. /**
  84713. * Checks wether or not the edges renderer is ready to render.
  84714. * @return true if ready, otherwise false.
  84715. */
  84716. isReady(): boolean;
  84717. }
  84718. /**
  84719. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84720. */
  84721. export class EdgesRenderer implements IEdgesRenderer {
  84722. /**
  84723. * Define the size of the edges with an orthographic camera
  84724. */
  84725. edgesWidthScalerForOrthographic: number;
  84726. /**
  84727. * Define the size of the edges with a perspective camera
  84728. */
  84729. edgesWidthScalerForPerspective: number;
  84730. protected _source: AbstractMesh;
  84731. protected _linesPositions: number[];
  84732. protected _linesNormals: number[];
  84733. protected _linesIndices: number[];
  84734. protected _epsilon: number;
  84735. protected _indicesCount: number;
  84736. protected _lineShader: ShaderMaterial;
  84737. protected _ib: DataBuffer;
  84738. protected _buffers: {
  84739. [key: string]: Nullable<VertexBuffer>;
  84740. };
  84741. protected _checkVerticesInsteadOfIndices: boolean;
  84742. private _meshRebuildObserver;
  84743. private _meshDisposeObserver;
  84744. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84745. isEnabled: boolean;
  84746. /**
  84747. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84748. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84749. * @param source Mesh used to create edges
  84750. * @param epsilon sum of angles in adjacency to check for edge
  84751. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84752. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84753. */
  84754. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84755. protected _prepareRessources(): void;
  84756. /** @hidden */
  84757. _rebuild(): void;
  84758. /**
  84759. * Releases the required resources for the edges renderer
  84760. */
  84761. dispose(): void;
  84762. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84763. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84764. /**
  84765. * Checks if the pair of p0 and p1 is en edge
  84766. * @param faceIndex
  84767. * @param edge
  84768. * @param faceNormals
  84769. * @param p0
  84770. * @param p1
  84771. * @private
  84772. */
  84773. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84774. /**
  84775. * push line into the position, normal and index buffer
  84776. * @protected
  84777. */
  84778. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84779. /**
  84780. * Generates lines edges from adjacencjes
  84781. * @private
  84782. */
  84783. _generateEdgesLines(): void;
  84784. /**
  84785. * Checks wether or not the edges renderer is ready to render.
  84786. * @return true if ready, otherwise false.
  84787. */
  84788. isReady(): boolean;
  84789. /**
  84790. * Renders the edges of the attached mesh,
  84791. */
  84792. render(): void;
  84793. }
  84794. /**
  84795. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84796. */
  84797. export class LineEdgesRenderer extends EdgesRenderer {
  84798. /**
  84799. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84800. * @param source LineMesh used to generate edges
  84801. * @param epsilon not important (specified angle for edge detection)
  84802. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84803. */
  84804. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84805. /**
  84806. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84807. */
  84808. _generateEdgesLines(): void;
  84809. }
  84810. }
  84811. declare module BABYLON {
  84812. /**
  84813. * This represents the object necessary to create a rendering group.
  84814. * This is exclusively used and created by the rendering manager.
  84815. * To modify the behavior, you use the available helpers in your scene or meshes.
  84816. * @hidden
  84817. */
  84818. export class RenderingGroup {
  84819. index: number;
  84820. private static _zeroVector;
  84821. private _scene;
  84822. private _opaqueSubMeshes;
  84823. private _transparentSubMeshes;
  84824. private _alphaTestSubMeshes;
  84825. private _depthOnlySubMeshes;
  84826. private _particleSystems;
  84827. private _spriteManagers;
  84828. private _opaqueSortCompareFn;
  84829. private _alphaTestSortCompareFn;
  84830. private _transparentSortCompareFn;
  84831. private _renderOpaque;
  84832. private _renderAlphaTest;
  84833. private _renderTransparent;
  84834. /** @hidden */
  84835. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84836. onBeforeTransparentRendering: () => void;
  84837. /**
  84838. * Set the opaque sort comparison function.
  84839. * If null the sub meshes will be render in the order they were created
  84840. */
  84841. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84842. /**
  84843. * Set the alpha test sort comparison function.
  84844. * If null the sub meshes will be render in the order they were created
  84845. */
  84846. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84847. /**
  84848. * Set the transparent sort comparison function.
  84849. * If null the sub meshes will be render in the order they were created
  84850. */
  84851. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84852. /**
  84853. * Creates a new rendering group.
  84854. * @param index The rendering group index
  84855. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84856. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84857. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84858. */
  84859. 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>);
  84860. /**
  84861. * Render all the sub meshes contained in the group.
  84862. * @param customRenderFunction Used to override the default render behaviour of the group.
  84863. * @returns true if rendered some submeshes.
  84864. */
  84865. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84866. /**
  84867. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84868. * @param subMeshes The submeshes to render
  84869. */
  84870. private renderOpaqueSorted;
  84871. /**
  84872. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84873. * @param subMeshes The submeshes to render
  84874. */
  84875. private renderAlphaTestSorted;
  84876. /**
  84877. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84878. * @param subMeshes The submeshes to render
  84879. */
  84880. private renderTransparentSorted;
  84881. /**
  84882. * Renders the submeshes in a specified order.
  84883. * @param subMeshes The submeshes to sort before render
  84884. * @param sortCompareFn The comparison function use to sort
  84885. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84886. * @param transparent Specifies to activate blending if true
  84887. */
  84888. private static renderSorted;
  84889. /**
  84890. * Renders the submeshes in the order they were dispatched (no sort applied).
  84891. * @param subMeshes The submeshes to render
  84892. */
  84893. private static renderUnsorted;
  84894. /**
  84895. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84896. * are rendered back to front if in the same alpha index.
  84897. *
  84898. * @param a The first submesh
  84899. * @param b The second submesh
  84900. * @returns The result of the comparison
  84901. */
  84902. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84903. /**
  84904. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84905. * are rendered back to front.
  84906. *
  84907. * @param a The first submesh
  84908. * @param b The second submesh
  84909. * @returns The result of the comparison
  84910. */
  84911. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84912. /**
  84913. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84914. * are rendered front to back (prevent overdraw).
  84915. *
  84916. * @param a The first submesh
  84917. * @param b The second submesh
  84918. * @returns The result of the comparison
  84919. */
  84920. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84921. /**
  84922. * Resets the different lists of submeshes to prepare a new frame.
  84923. */
  84924. prepare(): void;
  84925. dispose(): void;
  84926. /**
  84927. * Inserts the submesh in its correct queue depending on its material.
  84928. * @param subMesh The submesh to dispatch
  84929. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84930. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84931. */
  84932. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84933. dispatchSprites(spriteManager: ISpriteManager): void;
  84934. dispatchParticles(particleSystem: IParticleSystem): void;
  84935. private _renderParticles;
  84936. private _renderSprites;
  84937. }
  84938. }
  84939. declare module BABYLON {
  84940. /**
  84941. * Interface describing the different options available in the rendering manager
  84942. * regarding Auto Clear between groups.
  84943. */
  84944. export interface IRenderingManagerAutoClearSetup {
  84945. /**
  84946. * Defines whether or not autoclear is enable.
  84947. */
  84948. autoClear: boolean;
  84949. /**
  84950. * Defines whether or not to autoclear the depth buffer.
  84951. */
  84952. depth: boolean;
  84953. /**
  84954. * Defines whether or not to autoclear the stencil buffer.
  84955. */
  84956. stencil: boolean;
  84957. }
  84958. /**
  84959. * This class is used by the onRenderingGroupObservable
  84960. */
  84961. export class RenderingGroupInfo {
  84962. /**
  84963. * The Scene that being rendered
  84964. */
  84965. scene: Scene;
  84966. /**
  84967. * The camera currently used for the rendering pass
  84968. */
  84969. camera: Nullable<Camera>;
  84970. /**
  84971. * The ID of the renderingGroup being processed
  84972. */
  84973. renderingGroupId: number;
  84974. }
  84975. /**
  84976. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84977. * It is enable to manage the different groups as well as the different necessary sort functions.
  84978. * This should not be used directly aside of the few static configurations
  84979. */
  84980. export class RenderingManager {
  84981. /**
  84982. * The max id used for rendering groups (not included)
  84983. */
  84984. static MAX_RENDERINGGROUPS: number;
  84985. /**
  84986. * The min id used for rendering groups (included)
  84987. */
  84988. static MIN_RENDERINGGROUPS: number;
  84989. /**
  84990. * Used to globally prevent autoclearing scenes.
  84991. */
  84992. static AUTOCLEAR: boolean;
  84993. /**
  84994. * @hidden
  84995. */
  84996. _useSceneAutoClearSetup: boolean;
  84997. private _scene;
  84998. private _renderingGroups;
  84999. private _depthStencilBufferAlreadyCleaned;
  85000. private _autoClearDepthStencil;
  85001. private _customOpaqueSortCompareFn;
  85002. private _customAlphaTestSortCompareFn;
  85003. private _customTransparentSortCompareFn;
  85004. private _renderingGroupInfo;
  85005. /**
  85006. * Instantiates a new rendering group for a particular scene
  85007. * @param scene Defines the scene the groups belongs to
  85008. */
  85009. constructor(scene: Scene);
  85010. private _clearDepthStencilBuffer;
  85011. /**
  85012. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85013. * @hidden
  85014. */
  85015. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85016. /**
  85017. * Resets the different information of the group to prepare a new frame
  85018. * @hidden
  85019. */
  85020. reset(): void;
  85021. /**
  85022. * Dispose and release the group and its associated resources.
  85023. * @hidden
  85024. */
  85025. dispose(): void;
  85026. /**
  85027. * Clear the info related to rendering groups preventing retention points during dispose.
  85028. */
  85029. freeRenderingGroups(): void;
  85030. private _prepareRenderingGroup;
  85031. /**
  85032. * Add a sprite manager to the rendering manager in order to render it this frame.
  85033. * @param spriteManager Define the sprite manager to render
  85034. */
  85035. dispatchSprites(spriteManager: ISpriteManager): void;
  85036. /**
  85037. * Add a particle system to the rendering manager in order to render it this frame.
  85038. * @param particleSystem Define the particle system to render
  85039. */
  85040. dispatchParticles(particleSystem: IParticleSystem): void;
  85041. /**
  85042. * Add a submesh to the manager in order to render it this frame
  85043. * @param subMesh The submesh to dispatch
  85044. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85045. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85046. */
  85047. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85048. /**
  85049. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85050. * This allowed control for front to back rendering or reversly depending of the special needs.
  85051. *
  85052. * @param renderingGroupId The rendering group id corresponding to its index
  85053. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85054. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85055. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85056. */
  85057. 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;
  85058. /**
  85059. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85060. *
  85061. * @param renderingGroupId The rendering group id corresponding to its index
  85062. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85063. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85064. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85065. */
  85066. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85067. /**
  85068. * Gets the current auto clear configuration for one rendering group of the rendering
  85069. * manager.
  85070. * @param index the rendering group index to get the information for
  85071. * @returns The auto clear setup for the requested rendering group
  85072. */
  85073. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85074. }
  85075. }
  85076. declare module BABYLON {
  85077. /**
  85078. * This Helps creating a texture that will be created from a camera in your scene.
  85079. * It is basically a dynamic texture that could be used to create special effects for instance.
  85080. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85081. */
  85082. export class RenderTargetTexture extends Texture {
  85083. isCube: boolean;
  85084. /**
  85085. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85086. */
  85087. static readonly REFRESHRATE_RENDER_ONCE: number;
  85088. /**
  85089. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85090. */
  85091. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85092. /**
  85093. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85094. * the central point of your effect and can save a lot of performances.
  85095. */
  85096. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85097. /**
  85098. * Use this predicate to dynamically define the list of mesh you want to render.
  85099. * If set, the renderList property will be overwritten.
  85100. */
  85101. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85102. private _renderList;
  85103. /**
  85104. * Use this list to define the list of mesh you want to render.
  85105. */
  85106. renderList: Nullable<Array<AbstractMesh>>;
  85107. private _hookArray;
  85108. /**
  85109. * Define if particles should be rendered in your texture.
  85110. */
  85111. renderParticles: boolean;
  85112. /**
  85113. * Define if sprites should be rendered in your texture.
  85114. */
  85115. renderSprites: boolean;
  85116. /**
  85117. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85118. */
  85119. coordinatesMode: number;
  85120. /**
  85121. * Define the camera used to render the texture.
  85122. */
  85123. activeCamera: Nullable<Camera>;
  85124. /**
  85125. * Override the render function of the texture with your own one.
  85126. */
  85127. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85128. /**
  85129. * Define if camera post processes should be use while rendering the texture.
  85130. */
  85131. useCameraPostProcesses: boolean;
  85132. /**
  85133. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85134. */
  85135. ignoreCameraViewport: boolean;
  85136. private _postProcessManager;
  85137. private _postProcesses;
  85138. private _resizeObserver;
  85139. /**
  85140. * An event triggered when the texture is unbind.
  85141. */
  85142. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85143. /**
  85144. * An event triggered when the texture is unbind.
  85145. */
  85146. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85147. private _onAfterUnbindObserver;
  85148. /**
  85149. * Set a after unbind callback in the texture.
  85150. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85151. */
  85152. onAfterUnbind: () => void;
  85153. /**
  85154. * An event triggered before rendering the texture
  85155. */
  85156. onBeforeRenderObservable: Observable<number>;
  85157. private _onBeforeRenderObserver;
  85158. /**
  85159. * Set a before render callback in the texture.
  85160. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85161. */
  85162. onBeforeRender: (faceIndex: number) => void;
  85163. /**
  85164. * An event triggered after rendering the texture
  85165. */
  85166. onAfterRenderObservable: Observable<number>;
  85167. private _onAfterRenderObserver;
  85168. /**
  85169. * Set a after render callback in the texture.
  85170. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85171. */
  85172. onAfterRender: (faceIndex: number) => void;
  85173. /**
  85174. * An event triggered after the texture clear
  85175. */
  85176. onClearObservable: Observable<Engine>;
  85177. private _onClearObserver;
  85178. /**
  85179. * Set a clear callback in the texture.
  85180. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85181. */
  85182. onClear: (Engine: Engine) => void;
  85183. /**
  85184. * An event triggered when the texture is resized.
  85185. */
  85186. onResizeObservable: Observable<RenderTargetTexture>;
  85187. /**
  85188. * Define the clear color of the Render Target if it should be different from the scene.
  85189. */
  85190. clearColor: Color4;
  85191. protected _size: number | {
  85192. width: number;
  85193. height: number;
  85194. };
  85195. protected _initialSizeParameter: number | {
  85196. width: number;
  85197. height: number;
  85198. } | {
  85199. ratio: number;
  85200. };
  85201. protected _sizeRatio: Nullable<number>;
  85202. /** @hidden */
  85203. _generateMipMaps: boolean;
  85204. protected _renderingManager: RenderingManager;
  85205. /** @hidden */
  85206. _waitingRenderList: string[];
  85207. protected _doNotChangeAspectRatio: boolean;
  85208. protected _currentRefreshId: number;
  85209. protected _refreshRate: number;
  85210. protected _textureMatrix: Matrix;
  85211. protected _samples: number;
  85212. protected _renderTargetOptions: RenderTargetCreationOptions;
  85213. /**
  85214. * Gets render target creation options that were used.
  85215. */
  85216. readonly renderTargetOptions: RenderTargetCreationOptions;
  85217. protected _engine: Engine;
  85218. protected _onRatioRescale(): void;
  85219. /**
  85220. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85221. * It must define where the camera used to render the texture is set
  85222. */
  85223. boundingBoxPosition: Vector3;
  85224. private _boundingBoxSize;
  85225. /**
  85226. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85227. * When defined, the cubemap will switch to local mode
  85228. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85229. * @example https://www.babylonjs-playground.com/#RNASML
  85230. */
  85231. boundingBoxSize: Vector3;
  85232. /**
  85233. * In case the RTT has been created with a depth texture, get the associated
  85234. * depth texture.
  85235. * Otherwise, return null.
  85236. */
  85237. depthStencilTexture: Nullable<InternalTexture>;
  85238. /**
  85239. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85240. * or used a shadow, depth texture...
  85241. * @param name The friendly name of the texture
  85242. * @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)
  85243. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85244. * @param generateMipMaps True if mip maps need to be generated after render.
  85245. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85246. * @param type The type of the buffer in the RTT (int, half float, float...)
  85247. * @param isCube True if a cube texture needs to be created
  85248. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85249. * @param generateDepthBuffer True to generate a depth buffer
  85250. * @param generateStencilBuffer True to generate a stencil buffer
  85251. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85252. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85253. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85254. */
  85255. constructor(name: string, size: number | {
  85256. width: number;
  85257. height: number;
  85258. } | {
  85259. ratio: number;
  85260. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85261. /**
  85262. * Creates a depth stencil texture.
  85263. * This is only available in WebGL 2 or with the depth texture extension available.
  85264. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85265. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85266. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85267. */
  85268. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85269. private _processSizeParameter;
  85270. /**
  85271. * Define the number of samples to use in case of MSAA.
  85272. * It defaults to one meaning no MSAA has been enabled.
  85273. */
  85274. samples: number;
  85275. /**
  85276. * Resets the refresh counter of the texture and start bak from scratch.
  85277. * Could be useful to regenerate the texture if it is setup to render only once.
  85278. */
  85279. resetRefreshCounter(): void;
  85280. /**
  85281. * Define the refresh rate of the texture or the rendering frequency.
  85282. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85283. */
  85284. refreshRate: number;
  85285. /**
  85286. * Adds a post process to the render target rendering passes.
  85287. * @param postProcess define the post process to add
  85288. */
  85289. addPostProcess(postProcess: PostProcess): void;
  85290. /**
  85291. * Clear all the post processes attached to the render target
  85292. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85293. */
  85294. clearPostProcesses(dispose?: boolean): void;
  85295. /**
  85296. * Remove one of the post process from the list of attached post processes to the texture
  85297. * @param postProcess define the post process to remove from the list
  85298. */
  85299. removePostProcess(postProcess: PostProcess): void;
  85300. /** @hidden */
  85301. _shouldRender(): boolean;
  85302. /**
  85303. * Gets the actual render size of the texture.
  85304. * @returns the width of the render size
  85305. */
  85306. getRenderSize(): number;
  85307. /**
  85308. * Gets the actual render width of the texture.
  85309. * @returns the width of the render size
  85310. */
  85311. getRenderWidth(): number;
  85312. /**
  85313. * Gets the actual render height of the texture.
  85314. * @returns the height of the render size
  85315. */
  85316. getRenderHeight(): number;
  85317. /**
  85318. * Get if the texture can be rescaled or not.
  85319. */
  85320. readonly canRescale: boolean;
  85321. /**
  85322. * Resize the texture using a ratio.
  85323. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85324. */
  85325. scale(ratio: number): void;
  85326. /**
  85327. * Get the texture reflection matrix used to rotate/transform the reflection.
  85328. * @returns the reflection matrix
  85329. */
  85330. getReflectionTextureMatrix(): Matrix;
  85331. /**
  85332. * Resize the texture to a new desired size.
  85333. * Be carrefull as it will recreate all the data in the new texture.
  85334. * @param size Define the new size. It can be:
  85335. * - a number for squared texture,
  85336. * - an object containing { width: number, height: number }
  85337. * - or an object containing a ratio { ratio: number }
  85338. */
  85339. resize(size: number | {
  85340. width: number;
  85341. height: number;
  85342. } | {
  85343. ratio: number;
  85344. }): void;
  85345. /**
  85346. * Renders all the objects from the render list into the texture.
  85347. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85348. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85349. */
  85350. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85351. private _bestReflectionRenderTargetDimension;
  85352. /**
  85353. * @hidden
  85354. * @param faceIndex face index to bind to if this is a cubetexture
  85355. */
  85356. _bindFrameBuffer(faceIndex?: number): void;
  85357. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85358. private renderToTarget;
  85359. /**
  85360. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85361. * This allowed control for front to back rendering or reversly depending of the special needs.
  85362. *
  85363. * @param renderingGroupId The rendering group id corresponding to its index
  85364. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85365. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85366. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85367. */
  85368. 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;
  85369. /**
  85370. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85371. *
  85372. * @param renderingGroupId The rendering group id corresponding to its index
  85373. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85374. */
  85375. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85376. /**
  85377. * Clones the texture.
  85378. * @returns the cloned texture
  85379. */
  85380. clone(): RenderTargetTexture;
  85381. /**
  85382. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85383. * @returns The JSON representation of the texture
  85384. */
  85385. serialize(): any;
  85386. /**
  85387. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85388. */
  85389. disposeFramebufferObjects(): void;
  85390. /**
  85391. * Dispose the texture and release its associated resources.
  85392. */
  85393. dispose(): void;
  85394. /** @hidden */
  85395. _rebuild(): void;
  85396. /**
  85397. * Clear the info related to rendering groups preventing retention point in material dispose.
  85398. */
  85399. freeRenderingGroups(): void;
  85400. /**
  85401. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85402. * @returns the view count
  85403. */
  85404. getViewCount(): number;
  85405. }
  85406. }
  85407. declare module BABYLON {
  85408. /**
  85409. * Base class for the main features of a material in Babylon.js
  85410. */
  85411. export class Material implements IAnimatable {
  85412. /**
  85413. * Returns the triangle fill mode
  85414. */
  85415. static readonly TriangleFillMode: number;
  85416. /**
  85417. * Returns the wireframe mode
  85418. */
  85419. static readonly WireFrameFillMode: number;
  85420. /**
  85421. * Returns the point fill mode
  85422. */
  85423. static readonly PointFillMode: number;
  85424. /**
  85425. * Returns the point list draw mode
  85426. */
  85427. static readonly PointListDrawMode: number;
  85428. /**
  85429. * Returns the line list draw mode
  85430. */
  85431. static readonly LineListDrawMode: number;
  85432. /**
  85433. * Returns the line loop draw mode
  85434. */
  85435. static readonly LineLoopDrawMode: number;
  85436. /**
  85437. * Returns the line strip draw mode
  85438. */
  85439. static readonly LineStripDrawMode: number;
  85440. /**
  85441. * Returns the triangle strip draw mode
  85442. */
  85443. static readonly TriangleStripDrawMode: number;
  85444. /**
  85445. * Returns the triangle fan draw mode
  85446. */
  85447. static readonly TriangleFanDrawMode: number;
  85448. /**
  85449. * Stores the clock-wise side orientation
  85450. */
  85451. static readonly ClockWiseSideOrientation: number;
  85452. /**
  85453. * Stores the counter clock-wise side orientation
  85454. */
  85455. static readonly CounterClockWiseSideOrientation: number;
  85456. /**
  85457. * The dirty texture flag value
  85458. */
  85459. static readonly TextureDirtyFlag: number;
  85460. /**
  85461. * The dirty light flag value
  85462. */
  85463. static readonly LightDirtyFlag: number;
  85464. /**
  85465. * The dirty fresnel flag value
  85466. */
  85467. static readonly FresnelDirtyFlag: number;
  85468. /**
  85469. * The dirty attribute flag value
  85470. */
  85471. static readonly AttributesDirtyFlag: number;
  85472. /**
  85473. * The dirty misc flag value
  85474. */
  85475. static readonly MiscDirtyFlag: number;
  85476. /**
  85477. * The all dirty flag value
  85478. */
  85479. static readonly AllDirtyFlag: number;
  85480. /**
  85481. * The ID of the material
  85482. */
  85483. id: string;
  85484. /**
  85485. * Gets or sets the unique id of the material
  85486. */
  85487. uniqueId: number;
  85488. /**
  85489. * The name of the material
  85490. */
  85491. name: string;
  85492. /**
  85493. * Gets or sets user defined metadata
  85494. */
  85495. metadata: any;
  85496. /**
  85497. * For internal use only. Please do not use.
  85498. */
  85499. reservedDataStore: any;
  85500. /**
  85501. * Specifies if the ready state should be checked on each call
  85502. */
  85503. checkReadyOnEveryCall: boolean;
  85504. /**
  85505. * Specifies if the ready state should be checked once
  85506. */
  85507. checkReadyOnlyOnce: boolean;
  85508. /**
  85509. * The state of the material
  85510. */
  85511. state: string;
  85512. /**
  85513. * The alpha value of the material
  85514. */
  85515. protected _alpha: number;
  85516. /**
  85517. * List of inspectable custom properties (used by the Inspector)
  85518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85519. */
  85520. inspectableCustomProperties: IInspectable[];
  85521. /**
  85522. * Sets the alpha value of the material
  85523. */
  85524. /**
  85525. * Gets the alpha value of the material
  85526. */
  85527. alpha: number;
  85528. /**
  85529. * Specifies if back face culling is enabled
  85530. */
  85531. protected _backFaceCulling: boolean;
  85532. /**
  85533. * Sets the back-face culling state
  85534. */
  85535. /**
  85536. * Gets the back-face culling state
  85537. */
  85538. backFaceCulling: boolean;
  85539. /**
  85540. * Stores the value for side orientation
  85541. */
  85542. sideOrientation: number;
  85543. /**
  85544. * Callback triggered when the material is compiled
  85545. */
  85546. onCompiled: Nullable<(effect: Effect) => void>;
  85547. /**
  85548. * Callback triggered when an error occurs
  85549. */
  85550. onError: Nullable<(effect: Effect, errors: string) => void>;
  85551. /**
  85552. * Callback triggered to get the render target textures
  85553. */
  85554. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85555. /**
  85556. * Gets a boolean indicating that current material needs to register RTT
  85557. */
  85558. readonly hasRenderTargetTextures: boolean;
  85559. /**
  85560. * Specifies if the material should be serialized
  85561. */
  85562. doNotSerialize: boolean;
  85563. /**
  85564. * @hidden
  85565. */
  85566. _storeEffectOnSubMeshes: boolean;
  85567. /**
  85568. * Stores the animations for the material
  85569. */
  85570. animations: Nullable<Array<Animation>>;
  85571. /**
  85572. * An event triggered when the material is disposed
  85573. */
  85574. onDisposeObservable: Observable<Material>;
  85575. /**
  85576. * An observer which watches for dispose events
  85577. */
  85578. private _onDisposeObserver;
  85579. private _onUnBindObservable;
  85580. /**
  85581. * Called during a dispose event
  85582. */
  85583. onDispose: () => void;
  85584. private _onBindObservable;
  85585. /**
  85586. * An event triggered when the material is bound
  85587. */
  85588. readonly onBindObservable: Observable<AbstractMesh>;
  85589. /**
  85590. * An observer which watches for bind events
  85591. */
  85592. private _onBindObserver;
  85593. /**
  85594. * Called during a bind event
  85595. */
  85596. onBind: (Mesh: AbstractMesh) => void;
  85597. /**
  85598. * An event triggered when the material is unbound
  85599. */
  85600. readonly onUnBindObservable: Observable<Material>;
  85601. /**
  85602. * Stores the value of the alpha mode
  85603. */
  85604. private _alphaMode;
  85605. /**
  85606. * Sets the value of the alpha mode.
  85607. *
  85608. * | Value | Type | Description |
  85609. * | --- | --- | --- |
  85610. * | 0 | ALPHA_DISABLE | |
  85611. * | 1 | ALPHA_ADD | |
  85612. * | 2 | ALPHA_COMBINE | |
  85613. * | 3 | ALPHA_SUBTRACT | |
  85614. * | 4 | ALPHA_MULTIPLY | |
  85615. * | 5 | ALPHA_MAXIMIZED | |
  85616. * | 6 | ALPHA_ONEONE | |
  85617. * | 7 | ALPHA_PREMULTIPLIED | |
  85618. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85619. * | 9 | ALPHA_INTERPOLATE | |
  85620. * | 10 | ALPHA_SCREENMODE | |
  85621. *
  85622. */
  85623. /**
  85624. * Gets the value of the alpha mode
  85625. */
  85626. alphaMode: number;
  85627. /**
  85628. * Stores the state of the need depth pre-pass value
  85629. */
  85630. private _needDepthPrePass;
  85631. /**
  85632. * Sets the need depth pre-pass value
  85633. */
  85634. /**
  85635. * Gets the depth pre-pass value
  85636. */
  85637. needDepthPrePass: boolean;
  85638. /**
  85639. * Specifies if depth writing should be disabled
  85640. */
  85641. disableDepthWrite: boolean;
  85642. /**
  85643. * Specifies if depth writing should be forced
  85644. */
  85645. forceDepthWrite: boolean;
  85646. /**
  85647. * Specifies if there should be a separate pass for culling
  85648. */
  85649. separateCullingPass: boolean;
  85650. /**
  85651. * Stores the state specifing if fog should be enabled
  85652. */
  85653. private _fogEnabled;
  85654. /**
  85655. * Sets the state for enabling fog
  85656. */
  85657. /**
  85658. * Gets the value of the fog enabled state
  85659. */
  85660. fogEnabled: boolean;
  85661. /**
  85662. * Stores the size of points
  85663. */
  85664. pointSize: number;
  85665. /**
  85666. * Stores the z offset value
  85667. */
  85668. zOffset: number;
  85669. /**
  85670. * Gets a value specifying if wireframe mode is enabled
  85671. */
  85672. /**
  85673. * Sets the state of wireframe mode
  85674. */
  85675. wireframe: boolean;
  85676. /**
  85677. * Gets the value specifying if point clouds are enabled
  85678. */
  85679. /**
  85680. * Sets the state of point cloud mode
  85681. */
  85682. pointsCloud: boolean;
  85683. /**
  85684. * Gets the material fill mode
  85685. */
  85686. /**
  85687. * Sets the material fill mode
  85688. */
  85689. fillMode: number;
  85690. /**
  85691. * @hidden
  85692. * Stores the effects for the material
  85693. */
  85694. _effect: Nullable<Effect>;
  85695. /**
  85696. * @hidden
  85697. * Specifies if the material was previously ready
  85698. */
  85699. _wasPreviouslyReady: boolean;
  85700. /**
  85701. * Specifies if uniform buffers should be used
  85702. */
  85703. private _useUBO;
  85704. /**
  85705. * Stores a reference to the scene
  85706. */
  85707. private _scene;
  85708. /**
  85709. * Stores the fill mode state
  85710. */
  85711. private _fillMode;
  85712. /**
  85713. * Specifies if the depth write state should be cached
  85714. */
  85715. private _cachedDepthWriteState;
  85716. /**
  85717. * Stores the uniform buffer
  85718. */
  85719. protected _uniformBuffer: UniformBuffer;
  85720. /** @hidden */
  85721. _indexInSceneMaterialArray: number;
  85722. /** @hidden */
  85723. meshMap: Nullable<{
  85724. [id: string]: AbstractMesh | undefined;
  85725. }>;
  85726. /**
  85727. * Creates a material instance
  85728. * @param name defines the name of the material
  85729. * @param scene defines the scene to reference
  85730. * @param doNotAdd specifies if the material should be added to the scene
  85731. */
  85732. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85733. /**
  85734. * Returns a string representation of the current material
  85735. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85736. * @returns a string with material information
  85737. */
  85738. toString(fullDetails?: boolean): string;
  85739. /**
  85740. * Gets the class name of the material
  85741. * @returns a string with the class name of the material
  85742. */
  85743. getClassName(): string;
  85744. /**
  85745. * Specifies if updates for the material been locked
  85746. */
  85747. readonly isFrozen: boolean;
  85748. /**
  85749. * Locks updates for the material
  85750. */
  85751. freeze(): void;
  85752. /**
  85753. * Unlocks updates for the material
  85754. */
  85755. unfreeze(): void;
  85756. /**
  85757. * Specifies if the material is ready to be used
  85758. * @param mesh defines the mesh to check
  85759. * @param useInstances specifies if instances should be used
  85760. * @returns a boolean indicating if the material is ready to be used
  85761. */
  85762. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85763. /**
  85764. * Specifies that the submesh is ready to be used
  85765. * @param mesh defines the mesh to check
  85766. * @param subMesh defines which submesh to check
  85767. * @param useInstances specifies that instances should be used
  85768. * @returns a boolean indicating that the submesh is ready or not
  85769. */
  85770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85771. /**
  85772. * Returns the material effect
  85773. * @returns the effect associated with the material
  85774. */
  85775. getEffect(): Nullable<Effect>;
  85776. /**
  85777. * Returns the current scene
  85778. * @returns a Scene
  85779. */
  85780. getScene(): Scene;
  85781. /**
  85782. * Specifies if the material will require alpha blending
  85783. * @returns a boolean specifying if alpha blending is needed
  85784. */
  85785. needAlphaBlending(): boolean;
  85786. /**
  85787. * Specifies if the mesh will require alpha blending
  85788. * @param mesh defines the mesh to check
  85789. * @returns a boolean specifying if alpha blending is needed for the mesh
  85790. */
  85791. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85792. /**
  85793. * Specifies if this material should be rendered in alpha test mode
  85794. * @returns a boolean specifying if an alpha test is needed.
  85795. */
  85796. needAlphaTesting(): boolean;
  85797. /**
  85798. * Gets the texture used for the alpha test
  85799. * @returns the texture to use for alpha testing
  85800. */
  85801. getAlphaTestTexture(): Nullable<BaseTexture>;
  85802. /**
  85803. * Marks the material to indicate that it needs to be re-calculated
  85804. */
  85805. markDirty(): void;
  85806. /** @hidden */
  85807. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85808. /**
  85809. * Binds the material to the mesh
  85810. * @param world defines the world transformation matrix
  85811. * @param mesh defines the mesh to bind the material to
  85812. */
  85813. bind(world: Matrix, mesh?: Mesh): void;
  85814. /**
  85815. * Binds the submesh to the material
  85816. * @param world defines the world transformation matrix
  85817. * @param mesh defines the mesh containing the submesh
  85818. * @param subMesh defines the submesh to bind the material to
  85819. */
  85820. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85821. /**
  85822. * Binds the world matrix to the material
  85823. * @param world defines the world transformation matrix
  85824. */
  85825. bindOnlyWorldMatrix(world: Matrix): void;
  85826. /**
  85827. * Binds the scene's uniform buffer to the effect.
  85828. * @param effect defines the effect to bind to the scene uniform buffer
  85829. * @param sceneUbo defines the uniform buffer storing scene data
  85830. */
  85831. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85832. /**
  85833. * Binds the view matrix to the effect
  85834. * @param effect defines the effect to bind the view matrix to
  85835. */
  85836. bindView(effect: Effect): void;
  85837. /**
  85838. * Binds the view projection matrix to the effect
  85839. * @param effect defines the effect to bind the view projection matrix to
  85840. */
  85841. bindViewProjection(effect: Effect): void;
  85842. /**
  85843. * Specifies if material alpha testing should be turned on for the mesh
  85844. * @param mesh defines the mesh to check
  85845. */
  85846. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85847. /**
  85848. * Processes to execute after binding the material to a mesh
  85849. * @param mesh defines the rendered mesh
  85850. */
  85851. protected _afterBind(mesh?: Mesh): void;
  85852. /**
  85853. * Unbinds the material from the mesh
  85854. */
  85855. unbind(): void;
  85856. /**
  85857. * Gets the active textures from the material
  85858. * @returns an array of textures
  85859. */
  85860. getActiveTextures(): BaseTexture[];
  85861. /**
  85862. * Specifies if the material uses a texture
  85863. * @param texture defines the texture to check against the material
  85864. * @returns a boolean specifying if the material uses the texture
  85865. */
  85866. hasTexture(texture: BaseTexture): boolean;
  85867. /**
  85868. * Makes a duplicate of the material, and gives it a new name
  85869. * @param name defines the new name for the duplicated material
  85870. * @returns the cloned material
  85871. */
  85872. clone(name: string): Nullable<Material>;
  85873. /**
  85874. * Gets the meshes bound to the material
  85875. * @returns an array of meshes bound to the material
  85876. */
  85877. getBindedMeshes(): AbstractMesh[];
  85878. /**
  85879. * Force shader compilation
  85880. * @param mesh defines the mesh associated with this material
  85881. * @param onCompiled defines a function to execute once the material is compiled
  85882. * @param options defines the options to configure the compilation
  85883. */
  85884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85885. clipPlane: boolean;
  85886. }>): void;
  85887. /**
  85888. * Force shader compilation
  85889. * @param mesh defines the mesh that will use this material
  85890. * @param options defines additional options for compiling the shaders
  85891. * @returns a promise that resolves when the compilation completes
  85892. */
  85893. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85894. clipPlane: boolean;
  85895. }>): Promise<void>;
  85896. private static readonly _AllDirtyCallBack;
  85897. private static readonly _ImageProcessingDirtyCallBack;
  85898. private static readonly _TextureDirtyCallBack;
  85899. private static readonly _FresnelDirtyCallBack;
  85900. private static readonly _MiscDirtyCallBack;
  85901. private static readonly _LightsDirtyCallBack;
  85902. private static readonly _AttributeDirtyCallBack;
  85903. private static _FresnelAndMiscDirtyCallBack;
  85904. private static _TextureAndMiscDirtyCallBack;
  85905. private static readonly _DirtyCallbackArray;
  85906. private static readonly _RunDirtyCallBacks;
  85907. /**
  85908. * Marks a define in the material to indicate that it needs to be re-computed
  85909. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85910. */
  85911. markAsDirty(flag: number): void;
  85912. /**
  85913. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85914. * @param func defines a function which checks material defines against the submeshes
  85915. */
  85916. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85917. /**
  85918. * Indicates that we need to re-calculated for all submeshes
  85919. */
  85920. protected _markAllSubMeshesAsAllDirty(): void;
  85921. /**
  85922. * Indicates that image processing needs to be re-calculated for all submeshes
  85923. */
  85924. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85925. /**
  85926. * Indicates that textures need to be re-calculated for all submeshes
  85927. */
  85928. protected _markAllSubMeshesAsTexturesDirty(): void;
  85929. /**
  85930. * Indicates that fresnel needs to be re-calculated for all submeshes
  85931. */
  85932. protected _markAllSubMeshesAsFresnelDirty(): void;
  85933. /**
  85934. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85935. */
  85936. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85937. /**
  85938. * Indicates that lights need to be re-calculated for all submeshes
  85939. */
  85940. protected _markAllSubMeshesAsLightsDirty(): void;
  85941. /**
  85942. * Indicates that attributes need to be re-calculated for all submeshes
  85943. */
  85944. protected _markAllSubMeshesAsAttributesDirty(): void;
  85945. /**
  85946. * Indicates that misc needs to be re-calculated for all submeshes
  85947. */
  85948. protected _markAllSubMeshesAsMiscDirty(): void;
  85949. /**
  85950. * Indicates that textures and misc need to be re-calculated for all submeshes
  85951. */
  85952. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85953. /**
  85954. * Disposes the material
  85955. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85956. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85957. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85958. */
  85959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85960. /** @hidden */
  85961. private releaseVertexArrayObject;
  85962. /**
  85963. * Serializes this material
  85964. * @returns the serialized material object
  85965. */
  85966. serialize(): any;
  85967. /**
  85968. * Creates a material from parsed material data
  85969. * @param parsedMaterial defines parsed material data
  85970. * @param scene defines the hosting scene
  85971. * @param rootUrl defines the root URL to use to load textures
  85972. * @returns a new material
  85973. */
  85974. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85975. }
  85976. }
  85977. declare module BABYLON {
  85978. /**
  85979. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85980. * separate meshes. This can be use to improve performances.
  85981. * @see http://doc.babylonjs.com/how_to/multi_materials
  85982. */
  85983. export class MultiMaterial extends Material {
  85984. private _subMaterials;
  85985. /**
  85986. * Gets or Sets the list of Materials used within the multi material.
  85987. * They need to be ordered according to the submeshes order in the associated mesh
  85988. */
  85989. subMaterials: Nullable<Material>[];
  85990. /**
  85991. * Function used to align with Node.getChildren()
  85992. * @returns the list of Materials used within the multi material
  85993. */
  85994. getChildren(): Nullable<Material>[];
  85995. /**
  85996. * Instantiates a new Multi Material
  85997. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85998. * separate meshes. This can be use to improve performances.
  85999. * @see http://doc.babylonjs.com/how_to/multi_materials
  86000. * @param name Define the name in the scene
  86001. * @param scene Define the scene the material belongs to
  86002. */
  86003. constructor(name: string, scene: Scene);
  86004. private _hookArray;
  86005. /**
  86006. * Get one of the submaterial by its index in the submaterials array
  86007. * @param index The index to look the sub material at
  86008. * @returns The Material if the index has been defined
  86009. */
  86010. getSubMaterial(index: number): Nullable<Material>;
  86011. /**
  86012. * Get the list of active textures for the whole sub materials list.
  86013. * @returns All the textures that will be used during the rendering
  86014. */
  86015. getActiveTextures(): BaseTexture[];
  86016. /**
  86017. * Gets the current class name of the material e.g. "MultiMaterial"
  86018. * Mainly use in serialization.
  86019. * @returns the class name
  86020. */
  86021. getClassName(): string;
  86022. /**
  86023. * Checks if the material is ready to render the requested sub mesh
  86024. * @param mesh Define the mesh the submesh belongs to
  86025. * @param subMesh Define the sub mesh to look readyness for
  86026. * @param useInstances Define whether or not the material is used with instances
  86027. * @returns true if ready, otherwise false
  86028. */
  86029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86030. /**
  86031. * Clones the current material and its related sub materials
  86032. * @param name Define the name of the newly cloned material
  86033. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86034. * @returns the cloned material
  86035. */
  86036. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86037. /**
  86038. * Serializes the materials into a JSON representation.
  86039. * @returns the JSON representation
  86040. */
  86041. serialize(): any;
  86042. /**
  86043. * Dispose the material and release its associated resources
  86044. * @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)
  86045. * @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)
  86046. * @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)
  86047. */
  86048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86049. /**
  86050. * Creates a MultiMaterial from parsed MultiMaterial data.
  86051. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86052. * @param scene defines the hosting scene
  86053. * @returns a new MultiMaterial
  86054. */
  86055. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86056. }
  86057. }
  86058. declare module BABYLON {
  86059. /**
  86060. * Base class for submeshes
  86061. */
  86062. export class BaseSubMesh {
  86063. /** @hidden */
  86064. _materialDefines: Nullable<MaterialDefines>;
  86065. /** @hidden */
  86066. _materialEffect: Nullable<Effect>;
  86067. /**
  86068. * Gets associated effect
  86069. */
  86070. readonly effect: Nullable<Effect>;
  86071. /**
  86072. * Sets associated effect (effect used to render this submesh)
  86073. * @param effect defines the effect to associate with
  86074. * @param defines defines the set of defines used to compile this effect
  86075. */
  86076. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86077. }
  86078. /**
  86079. * Defines a subdivision inside a mesh
  86080. */
  86081. export class SubMesh extends BaseSubMesh implements ICullable {
  86082. /** the material index to use */
  86083. materialIndex: number;
  86084. /** vertex index start */
  86085. verticesStart: number;
  86086. /** vertices count */
  86087. verticesCount: number;
  86088. /** index start */
  86089. indexStart: number;
  86090. /** indices count */
  86091. indexCount: number;
  86092. /** @hidden */
  86093. _linesIndexCount: number;
  86094. private _mesh;
  86095. private _renderingMesh;
  86096. private _boundingInfo;
  86097. private _linesIndexBuffer;
  86098. /** @hidden */
  86099. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86100. /** @hidden */
  86101. _trianglePlanes: Plane[];
  86102. /** @hidden */
  86103. _lastColliderTransformMatrix: Nullable<Matrix>;
  86104. /** @hidden */
  86105. _renderId: number;
  86106. /** @hidden */
  86107. _alphaIndex: number;
  86108. /** @hidden */
  86109. _distanceToCamera: number;
  86110. /** @hidden */
  86111. _id: number;
  86112. private _currentMaterial;
  86113. /**
  86114. * Add a new submesh to a mesh
  86115. * @param materialIndex defines the material index to use
  86116. * @param verticesStart defines vertex index start
  86117. * @param verticesCount defines vertices count
  86118. * @param indexStart defines index start
  86119. * @param indexCount defines indices count
  86120. * @param mesh defines the parent mesh
  86121. * @param renderingMesh defines an optional rendering mesh
  86122. * @param createBoundingBox defines if bounding box should be created for this submesh
  86123. * @returns the new submesh
  86124. */
  86125. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86126. /**
  86127. * Creates a new submesh
  86128. * @param materialIndex defines the material index to use
  86129. * @param verticesStart defines vertex index start
  86130. * @param verticesCount defines vertices count
  86131. * @param indexStart defines index start
  86132. * @param indexCount defines indices count
  86133. * @param mesh defines the parent mesh
  86134. * @param renderingMesh defines an optional rendering mesh
  86135. * @param createBoundingBox defines if bounding box should be created for this submesh
  86136. */
  86137. constructor(
  86138. /** the material index to use */
  86139. materialIndex: number,
  86140. /** vertex index start */
  86141. verticesStart: number,
  86142. /** vertices count */
  86143. verticesCount: number,
  86144. /** index start */
  86145. indexStart: number,
  86146. /** indices count */
  86147. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86148. /**
  86149. * Returns true if this submesh covers the entire parent mesh
  86150. * @ignorenaming
  86151. */
  86152. readonly IsGlobal: boolean;
  86153. /**
  86154. * Returns the submesh BoudingInfo object
  86155. * @returns current bounding info (or mesh's one if the submesh is global)
  86156. */
  86157. getBoundingInfo(): BoundingInfo;
  86158. /**
  86159. * Sets the submesh BoundingInfo
  86160. * @param boundingInfo defines the new bounding info to use
  86161. * @returns the SubMesh
  86162. */
  86163. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86164. /**
  86165. * Returns the mesh of the current submesh
  86166. * @return the parent mesh
  86167. */
  86168. getMesh(): AbstractMesh;
  86169. /**
  86170. * Returns the rendering mesh of the submesh
  86171. * @returns the rendering mesh (could be different from parent mesh)
  86172. */
  86173. getRenderingMesh(): Mesh;
  86174. /**
  86175. * Returns the submesh material
  86176. * @returns null or the current material
  86177. */
  86178. getMaterial(): Nullable<Material>;
  86179. /**
  86180. * Sets a new updated BoundingInfo object to the submesh
  86181. * @param data defines an optional position array to use to determine the bounding info
  86182. * @returns the SubMesh
  86183. */
  86184. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86185. /** @hidden */
  86186. _checkCollision(collider: Collider): boolean;
  86187. /**
  86188. * Updates the submesh BoundingInfo
  86189. * @param world defines the world matrix to use to update the bounding info
  86190. * @returns the submesh
  86191. */
  86192. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86193. /**
  86194. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86195. * @param frustumPlanes defines the frustum planes
  86196. * @returns true if the submesh is intersecting with the frustum
  86197. */
  86198. isInFrustum(frustumPlanes: Plane[]): boolean;
  86199. /**
  86200. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86201. * @param frustumPlanes defines the frustum planes
  86202. * @returns true if the submesh is inside the frustum
  86203. */
  86204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86205. /**
  86206. * Renders the submesh
  86207. * @param enableAlphaMode defines if alpha needs to be used
  86208. * @returns the submesh
  86209. */
  86210. render(enableAlphaMode: boolean): SubMesh;
  86211. /**
  86212. * @hidden
  86213. */
  86214. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86215. /**
  86216. * Checks if the submesh intersects with a ray
  86217. * @param ray defines the ray to test
  86218. * @returns true is the passed ray intersects the submesh bounding box
  86219. */
  86220. canIntersects(ray: Ray): boolean;
  86221. /**
  86222. * Intersects current submesh with a ray
  86223. * @param ray defines the ray to test
  86224. * @param positions defines mesh's positions array
  86225. * @param indices defines mesh's indices array
  86226. * @param fastCheck defines if only bounding info should be used
  86227. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86228. * @returns intersection info or null if no intersection
  86229. */
  86230. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86231. /** @hidden */
  86232. private _intersectLines;
  86233. /** @hidden */
  86234. private _intersectUnIndexedLines;
  86235. /** @hidden */
  86236. private _intersectTriangles;
  86237. /** @hidden */
  86238. private _intersectUnIndexedTriangles;
  86239. /** @hidden */
  86240. _rebuild(): void;
  86241. /**
  86242. * Creates a new submesh from the passed mesh
  86243. * @param newMesh defines the new hosting mesh
  86244. * @param newRenderingMesh defines an optional rendering mesh
  86245. * @returns the new submesh
  86246. */
  86247. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86248. /**
  86249. * Release associated resources
  86250. */
  86251. dispose(): void;
  86252. /**
  86253. * Gets the class name
  86254. * @returns the string "SubMesh".
  86255. */
  86256. getClassName(): string;
  86257. /**
  86258. * Creates a new submesh from indices data
  86259. * @param materialIndex the index of the main mesh material
  86260. * @param startIndex the index where to start the copy in the mesh indices array
  86261. * @param indexCount the number of indices to copy then from the startIndex
  86262. * @param mesh the main mesh to create the submesh from
  86263. * @param renderingMesh the optional rendering mesh
  86264. * @returns a new submesh
  86265. */
  86266. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86267. }
  86268. }
  86269. declare module BABYLON {
  86270. /**
  86271. * Class used to represent data loading progression
  86272. */
  86273. export class SceneLoaderFlags {
  86274. private static _ForceFullSceneLoadingForIncremental;
  86275. private static _ShowLoadingScreen;
  86276. private static _CleanBoneMatrixWeights;
  86277. private static _loggingLevel;
  86278. /**
  86279. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86280. */
  86281. static ForceFullSceneLoadingForIncremental: boolean;
  86282. /**
  86283. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86284. */
  86285. static ShowLoadingScreen: boolean;
  86286. /**
  86287. * Defines the current logging level (while loading the scene)
  86288. * @ignorenaming
  86289. */
  86290. static loggingLevel: number;
  86291. /**
  86292. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86293. */
  86294. static CleanBoneMatrixWeights: boolean;
  86295. }
  86296. }
  86297. declare module BABYLON {
  86298. /**
  86299. * Class used to store geometry data (vertex buffers + index buffer)
  86300. */
  86301. export class Geometry implements IGetSetVerticesData {
  86302. /**
  86303. * Gets or sets the ID of the geometry
  86304. */
  86305. id: string;
  86306. /**
  86307. * Gets or sets the unique ID of the geometry
  86308. */
  86309. uniqueId: number;
  86310. /**
  86311. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86312. */
  86313. delayLoadState: number;
  86314. /**
  86315. * Gets the file containing the data to load when running in delay load state
  86316. */
  86317. delayLoadingFile: Nullable<string>;
  86318. /**
  86319. * Callback called when the geometry is updated
  86320. */
  86321. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86322. private _scene;
  86323. private _engine;
  86324. private _meshes;
  86325. private _totalVertices;
  86326. /** @hidden */
  86327. _indices: IndicesArray;
  86328. /** @hidden */
  86329. _vertexBuffers: {
  86330. [key: string]: VertexBuffer;
  86331. };
  86332. private _isDisposed;
  86333. private _extend;
  86334. private _boundingBias;
  86335. /** @hidden */
  86336. _delayInfo: Array<string>;
  86337. private _indexBuffer;
  86338. private _indexBufferIsUpdatable;
  86339. /** @hidden */
  86340. _boundingInfo: Nullable<BoundingInfo>;
  86341. /** @hidden */
  86342. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86343. /** @hidden */
  86344. _softwareSkinningFrameId: number;
  86345. private _vertexArrayObjects;
  86346. private _updatable;
  86347. /** @hidden */
  86348. _positions: Nullable<Vector3[]>;
  86349. /**
  86350. * 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
  86351. */
  86352. /**
  86353. * 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
  86354. */
  86355. boundingBias: Vector2;
  86356. /**
  86357. * Static function used to attach a new empty geometry to a mesh
  86358. * @param mesh defines the mesh to attach the geometry to
  86359. * @returns the new Geometry
  86360. */
  86361. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86362. /**
  86363. * Creates a new geometry
  86364. * @param id defines the unique ID
  86365. * @param scene defines the hosting scene
  86366. * @param vertexData defines the VertexData used to get geometry data
  86367. * @param updatable defines if geometry must be updatable (false by default)
  86368. * @param mesh defines the mesh that will be associated with the geometry
  86369. */
  86370. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86371. /**
  86372. * Gets the current extend of the geometry
  86373. */
  86374. readonly extend: {
  86375. minimum: Vector3;
  86376. maximum: Vector3;
  86377. };
  86378. /**
  86379. * Gets the hosting scene
  86380. * @returns the hosting Scene
  86381. */
  86382. getScene(): Scene;
  86383. /**
  86384. * Gets the hosting engine
  86385. * @returns the hosting Engine
  86386. */
  86387. getEngine(): Engine;
  86388. /**
  86389. * Defines if the geometry is ready to use
  86390. * @returns true if the geometry is ready to be used
  86391. */
  86392. isReady(): boolean;
  86393. /**
  86394. * Gets a value indicating that the geometry should not be serialized
  86395. */
  86396. readonly doNotSerialize: boolean;
  86397. /** @hidden */
  86398. _rebuild(): void;
  86399. /**
  86400. * Affects all geometry data in one call
  86401. * @param vertexData defines the geometry data
  86402. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86403. */
  86404. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86405. /**
  86406. * Set specific vertex data
  86407. * @param kind defines the data kind (Position, normal, etc...)
  86408. * @param data defines the vertex data to use
  86409. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86410. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86411. */
  86412. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86413. /**
  86414. * Removes a specific vertex data
  86415. * @param kind defines the data kind (Position, normal, etc...)
  86416. */
  86417. removeVerticesData(kind: string): void;
  86418. /**
  86419. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86420. * @param buffer defines the vertex buffer to use
  86421. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86422. */
  86423. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86424. /**
  86425. * Update a specific vertex buffer
  86426. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86427. * It will do nothing if the buffer is not updatable
  86428. * @param kind defines the data kind (Position, normal, etc...)
  86429. * @param data defines the data to use
  86430. * @param offset defines the offset in the target buffer where to store the data
  86431. * @param useBytes set to true if the offset is in bytes
  86432. */
  86433. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86434. /**
  86435. * Update a specific vertex buffer
  86436. * This function will create a new buffer if the current one is not updatable
  86437. * @param kind defines the data kind (Position, normal, etc...)
  86438. * @param data defines the data to use
  86439. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86440. */
  86441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86442. private _updateBoundingInfo;
  86443. /** @hidden */
  86444. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86445. /**
  86446. * Gets total number of vertices
  86447. * @returns the total number of vertices
  86448. */
  86449. getTotalVertices(): number;
  86450. /**
  86451. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86452. * @param kind defines the data kind (Position, normal, etc...)
  86453. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86454. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86455. * @returns a float array containing vertex data
  86456. */
  86457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86458. /**
  86459. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86460. * @param kind defines the data kind (Position, normal, etc...)
  86461. * @returns true if the vertex buffer with the specified kind is updatable
  86462. */
  86463. isVertexBufferUpdatable(kind: string): boolean;
  86464. /**
  86465. * Gets a specific vertex buffer
  86466. * @param kind defines the data kind (Position, normal, etc...)
  86467. * @returns a VertexBuffer
  86468. */
  86469. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86470. /**
  86471. * Returns all vertex buffers
  86472. * @return an object holding all vertex buffers indexed by kind
  86473. */
  86474. getVertexBuffers(): Nullable<{
  86475. [key: string]: VertexBuffer;
  86476. }>;
  86477. /**
  86478. * Gets a boolean indicating if specific vertex buffer is present
  86479. * @param kind defines the data kind (Position, normal, etc...)
  86480. * @returns true if data is present
  86481. */
  86482. isVerticesDataPresent(kind: string): boolean;
  86483. /**
  86484. * Gets a list of all attached data kinds (Position, normal, etc...)
  86485. * @returns a list of string containing all kinds
  86486. */
  86487. getVerticesDataKinds(): string[];
  86488. /**
  86489. * Update index buffer
  86490. * @param indices defines the indices to store in the index buffer
  86491. * @param offset defines the offset in the target buffer where to store the data
  86492. * @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)
  86493. */
  86494. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86495. /**
  86496. * Creates a new index buffer
  86497. * @param indices defines the indices to store in the index buffer
  86498. * @param totalVertices defines the total number of vertices (could be null)
  86499. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86500. */
  86501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86502. /**
  86503. * Return the total number of indices
  86504. * @returns the total number of indices
  86505. */
  86506. getTotalIndices(): number;
  86507. /**
  86508. * Gets the index buffer array
  86509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86511. * @returns the index buffer array
  86512. */
  86513. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86514. /**
  86515. * Gets the index buffer
  86516. * @return the index buffer
  86517. */
  86518. getIndexBuffer(): Nullable<DataBuffer>;
  86519. /** @hidden */
  86520. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86521. /**
  86522. * Release the associated resources for a specific mesh
  86523. * @param mesh defines the source mesh
  86524. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86525. */
  86526. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86527. /**
  86528. * Apply current geometry to a given mesh
  86529. * @param mesh defines the mesh to apply geometry to
  86530. */
  86531. applyToMesh(mesh: Mesh): void;
  86532. private _updateExtend;
  86533. private _applyToMesh;
  86534. private notifyUpdate;
  86535. /**
  86536. * Load the geometry if it was flagged as delay loaded
  86537. * @param scene defines the hosting scene
  86538. * @param onLoaded defines a callback called when the geometry is loaded
  86539. */
  86540. load(scene: Scene, onLoaded?: () => void): void;
  86541. private _queueLoad;
  86542. /**
  86543. * Invert the geometry to move from a right handed system to a left handed one.
  86544. */
  86545. toLeftHanded(): void;
  86546. /** @hidden */
  86547. _resetPointsArrayCache(): void;
  86548. /** @hidden */
  86549. _generatePointsArray(): boolean;
  86550. /**
  86551. * Gets a value indicating if the geometry is disposed
  86552. * @returns true if the geometry was disposed
  86553. */
  86554. isDisposed(): boolean;
  86555. private _disposeVertexArrayObjects;
  86556. /**
  86557. * Free all associated resources
  86558. */
  86559. dispose(): void;
  86560. /**
  86561. * Clone the current geometry into a new geometry
  86562. * @param id defines the unique ID of the new geometry
  86563. * @returns a new geometry object
  86564. */
  86565. copy(id: string): Geometry;
  86566. /**
  86567. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86568. * @return a JSON representation of the current geometry data (without the vertices data)
  86569. */
  86570. serialize(): any;
  86571. private toNumberArray;
  86572. /**
  86573. * Serialize all vertices data into a JSON oject
  86574. * @returns a JSON representation of the current geometry data
  86575. */
  86576. serializeVerticeData(): any;
  86577. /**
  86578. * Extracts a clone of a mesh geometry
  86579. * @param mesh defines the source mesh
  86580. * @param id defines the unique ID of the new geometry object
  86581. * @returns the new geometry object
  86582. */
  86583. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86584. /**
  86585. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86586. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86587. * Be aware Math.random() could cause collisions, but:
  86588. * "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"
  86589. * @returns a string containing a new GUID
  86590. */
  86591. static RandomId(): string;
  86592. /** @hidden */
  86593. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86594. private static _CleanMatricesWeights;
  86595. /**
  86596. * Create a new geometry from persisted data (Using .babylon file format)
  86597. * @param parsedVertexData defines the persisted data
  86598. * @param scene defines the hosting scene
  86599. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86600. * @returns the new geometry object
  86601. */
  86602. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86603. }
  86604. }
  86605. declare module BABYLON {
  86606. /**
  86607. * Define an interface for all classes that will get and set the data on vertices
  86608. */
  86609. export interface IGetSetVerticesData {
  86610. /**
  86611. * Gets a boolean indicating if specific vertex data is present
  86612. * @param kind defines the vertex data kind to use
  86613. * @returns true is data kind is present
  86614. */
  86615. isVerticesDataPresent(kind: string): boolean;
  86616. /**
  86617. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86618. * @param kind defines the data kind (Position, normal, etc...)
  86619. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86620. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86621. * @returns a float array containing vertex data
  86622. */
  86623. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86624. /**
  86625. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86626. * @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.
  86627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86628. * @returns the indices array or an empty array if the mesh has no geometry
  86629. */
  86630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86631. /**
  86632. * Set specific vertex data
  86633. * @param kind defines the data kind (Position, normal, etc...)
  86634. * @param data defines the vertex data to use
  86635. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86636. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86637. */
  86638. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86639. /**
  86640. * Update a specific associated vertex buffer
  86641. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86642. * - VertexBuffer.PositionKind
  86643. * - VertexBuffer.UVKind
  86644. * - VertexBuffer.UV2Kind
  86645. * - VertexBuffer.UV3Kind
  86646. * - VertexBuffer.UV4Kind
  86647. * - VertexBuffer.UV5Kind
  86648. * - VertexBuffer.UV6Kind
  86649. * - VertexBuffer.ColorKind
  86650. * - VertexBuffer.MatricesIndicesKind
  86651. * - VertexBuffer.MatricesIndicesExtraKind
  86652. * - VertexBuffer.MatricesWeightsKind
  86653. * - VertexBuffer.MatricesWeightsExtraKind
  86654. * @param data defines the data source
  86655. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86656. * @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)
  86657. */
  86658. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86659. /**
  86660. * Creates a new index buffer
  86661. * @param indices defines the indices to store in the index buffer
  86662. * @param totalVertices defines the total number of vertices (could be null)
  86663. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86664. */
  86665. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86666. }
  86667. /**
  86668. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86669. */
  86670. export class VertexData {
  86671. /**
  86672. * Mesh side orientation : usually the external or front surface
  86673. */
  86674. static readonly FRONTSIDE: number;
  86675. /**
  86676. * Mesh side orientation : usually the internal or back surface
  86677. */
  86678. static readonly BACKSIDE: number;
  86679. /**
  86680. * Mesh side orientation : both internal and external or front and back surfaces
  86681. */
  86682. static readonly DOUBLESIDE: number;
  86683. /**
  86684. * Mesh side orientation : by default, `FRONTSIDE`
  86685. */
  86686. static readonly DEFAULTSIDE: number;
  86687. /**
  86688. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86689. */
  86690. positions: Nullable<FloatArray>;
  86691. /**
  86692. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86693. */
  86694. normals: Nullable<FloatArray>;
  86695. /**
  86696. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86697. */
  86698. tangents: Nullable<FloatArray>;
  86699. /**
  86700. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86701. */
  86702. uvs: Nullable<FloatArray>;
  86703. /**
  86704. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86705. */
  86706. uvs2: Nullable<FloatArray>;
  86707. /**
  86708. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86709. */
  86710. uvs3: Nullable<FloatArray>;
  86711. /**
  86712. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86713. */
  86714. uvs4: Nullable<FloatArray>;
  86715. /**
  86716. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86717. */
  86718. uvs5: Nullable<FloatArray>;
  86719. /**
  86720. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86721. */
  86722. uvs6: Nullable<FloatArray>;
  86723. /**
  86724. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86725. */
  86726. colors: Nullable<FloatArray>;
  86727. /**
  86728. * 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).
  86729. */
  86730. matricesIndices: Nullable<FloatArray>;
  86731. /**
  86732. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86733. */
  86734. matricesWeights: Nullable<FloatArray>;
  86735. /**
  86736. * An array extending the number of possible indices
  86737. */
  86738. matricesIndicesExtra: Nullable<FloatArray>;
  86739. /**
  86740. * An array extending the number of possible weights when the number of indices is extended
  86741. */
  86742. matricesWeightsExtra: Nullable<FloatArray>;
  86743. /**
  86744. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86745. */
  86746. indices: Nullable<IndicesArray>;
  86747. /**
  86748. * Uses the passed data array to set the set the values for the specified kind of data
  86749. * @param data a linear array of floating numbers
  86750. * @param kind the type of data that is being set, eg positions, colors etc
  86751. */
  86752. set(data: FloatArray, kind: string): void;
  86753. /**
  86754. * Associates the vertexData to the passed Mesh.
  86755. * Sets it as updatable or not (default `false`)
  86756. * @param mesh the mesh the vertexData is applied to
  86757. * @param updatable when used and having the value true allows new data to update the vertexData
  86758. * @returns the VertexData
  86759. */
  86760. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86761. /**
  86762. * Associates the vertexData to the passed Geometry.
  86763. * Sets it as updatable or not (default `false`)
  86764. * @param geometry the geometry the vertexData is applied to
  86765. * @param updatable when used and having the value true allows new data to update the vertexData
  86766. * @returns VertexData
  86767. */
  86768. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86769. /**
  86770. * Updates the associated mesh
  86771. * @param mesh the mesh to be updated
  86772. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86773. * @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
  86774. * @returns VertexData
  86775. */
  86776. updateMesh(mesh: Mesh): VertexData;
  86777. /**
  86778. * Updates the associated geometry
  86779. * @param geometry the geometry to be updated
  86780. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86781. * @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
  86782. * @returns VertexData.
  86783. */
  86784. updateGeometry(geometry: Geometry): VertexData;
  86785. private _applyTo;
  86786. private _update;
  86787. /**
  86788. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86789. * @param matrix the transforming matrix
  86790. * @returns the VertexData
  86791. */
  86792. transform(matrix: Matrix): VertexData;
  86793. /**
  86794. * Merges the passed VertexData into the current one
  86795. * @param other the VertexData to be merged into the current one
  86796. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86797. * @returns the modified VertexData
  86798. */
  86799. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86800. private _mergeElement;
  86801. private _validate;
  86802. /**
  86803. * Serializes the VertexData
  86804. * @returns a serialized object
  86805. */
  86806. serialize(): any;
  86807. /**
  86808. * Extracts the vertexData from a mesh
  86809. * @param mesh the mesh from which to extract the VertexData
  86810. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86811. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86812. * @returns the object VertexData associated to the passed mesh
  86813. */
  86814. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86815. /**
  86816. * Extracts the vertexData from the geometry
  86817. * @param geometry the geometry from which to extract the VertexData
  86818. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86819. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86820. * @returns the object VertexData associated to the passed mesh
  86821. */
  86822. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86823. private static _ExtractFrom;
  86824. /**
  86825. * Creates the VertexData for a Ribbon
  86826. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86827. * * pathArray array of paths, each of which an array of successive Vector3
  86828. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86829. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86830. * * 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
  86831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86832. * * 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)
  86833. * * 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)
  86834. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86835. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86836. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86837. * @returns the VertexData of the ribbon
  86838. */
  86839. static CreateRibbon(options: {
  86840. pathArray: Vector3[][];
  86841. closeArray?: boolean;
  86842. closePath?: boolean;
  86843. offset?: number;
  86844. sideOrientation?: number;
  86845. frontUVs?: Vector4;
  86846. backUVs?: Vector4;
  86847. invertUV?: boolean;
  86848. uvs?: Vector2[];
  86849. colors?: Color4[];
  86850. }): VertexData;
  86851. /**
  86852. * Creates the VertexData for a box
  86853. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86854. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86855. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86856. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86857. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86858. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86859. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86861. * * 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)
  86862. * * 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)
  86863. * @returns the VertexData of the box
  86864. */
  86865. static CreateBox(options: {
  86866. size?: number;
  86867. width?: number;
  86868. height?: number;
  86869. depth?: number;
  86870. faceUV?: Vector4[];
  86871. faceColors?: Color4[];
  86872. sideOrientation?: number;
  86873. frontUVs?: Vector4;
  86874. backUVs?: Vector4;
  86875. }): VertexData;
  86876. /**
  86877. * Creates the VertexData for a tiled box
  86878. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86879. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86880. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86881. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86883. * @returns the VertexData of the box
  86884. */
  86885. static CreateTiledBox(options: {
  86886. pattern?: number;
  86887. width?: number;
  86888. height?: number;
  86889. depth?: number;
  86890. tileSize?: number;
  86891. tileWidth?: number;
  86892. tileHeight?: number;
  86893. alignHorizontal?: number;
  86894. alignVertical?: number;
  86895. faceUV?: Vector4[];
  86896. faceColors?: Color4[];
  86897. sideOrientation?: number;
  86898. }): VertexData;
  86899. /**
  86900. * Creates the VertexData for a tiled plane
  86901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86902. * * pattern a limited pattern arrangement depending on the number
  86903. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86904. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86905. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86907. * * 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)
  86908. * * 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)
  86909. * @returns the VertexData of the tiled plane
  86910. */
  86911. static CreateTiledPlane(options: {
  86912. pattern?: number;
  86913. tileSize?: number;
  86914. tileWidth?: number;
  86915. tileHeight?: number;
  86916. size?: number;
  86917. width?: number;
  86918. height?: number;
  86919. alignHorizontal?: number;
  86920. alignVertical?: number;
  86921. sideOrientation?: number;
  86922. frontUVs?: Vector4;
  86923. backUVs?: Vector4;
  86924. }): VertexData;
  86925. /**
  86926. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86928. * * segments sets the number of horizontal strips optional, default 32
  86929. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86930. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86931. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86932. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86933. * * 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
  86934. * * 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
  86935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86936. * * 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)
  86937. * * 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)
  86938. * @returns the VertexData of the ellipsoid
  86939. */
  86940. static CreateSphere(options: {
  86941. segments?: number;
  86942. diameter?: number;
  86943. diameterX?: number;
  86944. diameterY?: number;
  86945. diameterZ?: number;
  86946. arc?: number;
  86947. slice?: number;
  86948. sideOrientation?: number;
  86949. frontUVs?: Vector4;
  86950. backUVs?: Vector4;
  86951. }): VertexData;
  86952. /**
  86953. * Creates the VertexData for a cylinder, cone or prism
  86954. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86955. * * height sets the height (y direction) of the cylinder, optional, default 2
  86956. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86957. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86958. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86959. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86960. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86961. * * 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
  86962. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86963. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86964. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86965. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86966. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86967. * * 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)
  86968. * * 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)
  86969. * @returns the VertexData of the cylinder, cone or prism
  86970. */
  86971. static CreateCylinder(options: {
  86972. height?: number;
  86973. diameterTop?: number;
  86974. diameterBottom?: number;
  86975. diameter?: number;
  86976. tessellation?: number;
  86977. subdivisions?: number;
  86978. arc?: number;
  86979. faceColors?: Color4[];
  86980. faceUV?: Vector4[];
  86981. hasRings?: boolean;
  86982. enclose?: boolean;
  86983. sideOrientation?: number;
  86984. frontUVs?: Vector4;
  86985. backUVs?: Vector4;
  86986. }): VertexData;
  86987. /**
  86988. * Creates the VertexData for a torus
  86989. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86990. * * diameter the diameter of the torus, optional default 1
  86991. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86992. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86994. * * 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)
  86995. * * 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)
  86996. * @returns the VertexData of the torus
  86997. */
  86998. static CreateTorus(options: {
  86999. diameter?: number;
  87000. thickness?: number;
  87001. tessellation?: number;
  87002. sideOrientation?: number;
  87003. frontUVs?: Vector4;
  87004. backUVs?: Vector4;
  87005. }): VertexData;
  87006. /**
  87007. * Creates the VertexData of the LineSystem
  87008. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87009. * - lines an array of lines, each line being an array of successive Vector3
  87010. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87011. * @returns the VertexData of the LineSystem
  87012. */
  87013. static CreateLineSystem(options: {
  87014. lines: Vector3[][];
  87015. colors?: Nullable<Color4[][]>;
  87016. }): VertexData;
  87017. /**
  87018. * Create the VertexData for a DashedLines
  87019. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87020. * - points an array successive Vector3
  87021. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87022. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87023. * - dashNb the intended total number of dashes, optional, default 200
  87024. * @returns the VertexData for the DashedLines
  87025. */
  87026. static CreateDashedLines(options: {
  87027. points: Vector3[];
  87028. dashSize?: number;
  87029. gapSize?: number;
  87030. dashNb?: number;
  87031. }): VertexData;
  87032. /**
  87033. * Creates the VertexData for a Ground
  87034. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87035. * - width the width (x direction) of the ground, optional, default 1
  87036. * - height the height (z direction) of the ground, optional, default 1
  87037. * - subdivisions the number of subdivisions per side, optional, default 1
  87038. * @returns the VertexData of the Ground
  87039. */
  87040. static CreateGround(options: {
  87041. width?: number;
  87042. height?: number;
  87043. subdivisions?: number;
  87044. subdivisionsX?: number;
  87045. subdivisionsY?: number;
  87046. }): VertexData;
  87047. /**
  87048. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87049. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87050. * * xmin the ground minimum X coordinate, optional, default -1
  87051. * * zmin the ground minimum Z coordinate, optional, default -1
  87052. * * xmax the ground maximum X coordinate, optional, default 1
  87053. * * zmax the ground maximum Z coordinate, optional, default 1
  87054. * * 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}
  87055. * * 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}
  87056. * @returns the VertexData of the TiledGround
  87057. */
  87058. static CreateTiledGround(options: {
  87059. xmin: number;
  87060. zmin: number;
  87061. xmax: number;
  87062. zmax: number;
  87063. subdivisions?: {
  87064. w: number;
  87065. h: number;
  87066. };
  87067. precision?: {
  87068. w: number;
  87069. h: number;
  87070. };
  87071. }): VertexData;
  87072. /**
  87073. * Creates the VertexData of the Ground designed from a heightmap
  87074. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87075. * * width the width (x direction) of the ground
  87076. * * height the height (z direction) of the ground
  87077. * * subdivisions the number of subdivisions per side
  87078. * * minHeight the minimum altitude on the ground, optional, default 0
  87079. * * maxHeight the maximum altitude on the ground, optional default 1
  87080. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87081. * * buffer the array holding the image color data
  87082. * * bufferWidth the width of image
  87083. * * bufferHeight the height of image
  87084. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87085. * @returns the VertexData of the Ground designed from a heightmap
  87086. */
  87087. static CreateGroundFromHeightMap(options: {
  87088. width: number;
  87089. height: number;
  87090. subdivisions: number;
  87091. minHeight: number;
  87092. maxHeight: number;
  87093. colorFilter: Color3;
  87094. buffer: Uint8Array;
  87095. bufferWidth: number;
  87096. bufferHeight: number;
  87097. alphaFilter: number;
  87098. }): VertexData;
  87099. /**
  87100. * Creates the VertexData for a Plane
  87101. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87102. * * size sets the width and height of the plane to the value of size, optional default 1
  87103. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87104. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87106. * * 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)
  87107. * * 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)
  87108. * @returns the VertexData of the box
  87109. */
  87110. static CreatePlane(options: {
  87111. size?: number;
  87112. width?: number;
  87113. height?: number;
  87114. sideOrientation?: number;
  87115. frontUVs?: Vector4;
  87116. backUVs?: Vector4;
  87117. }): VertexData;
  87118. /**
  87119. * Creates the VertexData of the Disc or regular Polygon
  87120. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87121. * * radius the radius of the disc, optional default 0.5
  87122. * * tessellation the number of polygon sides, optional, default 64
  87123. * * 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
  87124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87125. * * 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)
  87126. * * 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)
  87127. * @returns the VertexData of the box
  87128. */
  87129. static CreateDisc(options: {
  87130. radius?: number;
  87131. tessellation?: number;
  87132. arc?: number;
  87133. sideOrientation?: number;
  87134. frontUVs?: Vector4;
  87135. backUVs?: Vector4;
  87136. }): VertexData;
  87137. /**
  87138. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87139. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87140. * @param polygon a mesh built from polygonTriangulation.build()
  87141. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87142. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87143. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87144. * @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)
  87145. * @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)
  87146. * @returns the VertexData of the Polygon
  87147. */
  87148. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87149. /**
  87150. * Creates the VertexData of the IcoSphere
  87151. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87152. * * radius the radius of the IcoSphere, optional default 1
  87153. * * radiusX allows stretching in the x direction, optional, default radius
  87154. * * radiusY allows stretching in the y direction, optional, default radius
  87155. * * radiusZ allows stretching in the z direction, optional, default radius
  87156. * * flat when true creates a flat shaded mesh, optional, default true
  87157. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87159. * * 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)
  87160. * * 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)
  87161. * @returns the VertexData of the IcoSphere
  87162. */
  87163. static CreateIcoSphere(options: {
  87164. radius?: number;
  87165. radiusX?: number;
  87166. radiusY?: number;
  87167. radiusZ?: number;
  87168. flat?: boolean;
  87169. subdivisions?: number;
  87170. sideOrientation?: number;
  87171. frontUVs?: Vector4;
  87172. backUVs?: Vector4;
  87173. }): VertexData;
  87174. /**
  87175. * Creates the VertexData for a Polyhedron
  87176. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87177. * * type provided types are:
  87178. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87179. * * 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)
  87180. * * size the size of the IcoSphere, optional default 1
  87181. * * sizeX allows stretching in the x direction, optional, default size
  87182. * * sizeY allows stretching in the y direction, optional, default size
  87183. * * sizeZ allows stretching in the z direction, optional, default size
  87184. * * 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
  87185. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87186. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87187. * * flat when true creates a flat shaded mesh, optional, default true
  87188. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87190. * * 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)
  87191. * * 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)
  87192. * @returns the VertexData of the Polyhedron
  87193. */
  87194. static CreatePolyhedron(options: {
  87195. type?: number;
  87196. size?: number;
  87197. sizeX?: number;
  87198. sizeY?: number;
  87199. sizeZ?: number;
  87200. custom?: any;
  87201. faceUV?: Vector4[];
  87202. faceColors?: Color4[];
  87203. flat?: boolean;
  87204. sideOrientation?: number;
  87205. frontUVs?: Vector4;
  87206. backUVs?: Vector4;
  87207. }): VertexData;
  87208. /**
  87209. * Creates the VertexData for a TorusKnot
  87210. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87211. * * radius the radius of the torus knot, optional, default 2
  87212. * * tube the thickness of the tube, optional, default 0.5
  87213. * * radialSegments the number of sides on each tube segments, optional, default 32
  87214. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87215. * * p the number of windings around the z axis, optional, default 2
  87216. * * q the number of windings around the x axis, optional, default 3
  87217. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87218. * * 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)
  87219. * * 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)
  87220. * @returns the VertexData of the Torus Knot
  87221. */
  87222. static CreateTorusKnot(options: {
  87223. radius?: number;
  87224. tube?: number;
  87225. radialSegments?: number;
  87226. tubularSegments?: number;
  87227. p?: number;
  87228. q?: number;
  87229. sideOrientation?: number;
  87230. frontUVs?: Vector4;
  87231. backUVs?: Vector4;
  87232. }): VertexData;
  87233. /**
  87234. * Compute normals for given positions and indices
  87235. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87236. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87237. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87238. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87239. * * facetNormals : optional array of facet normals (vector3)
  87240. * * facetPositions : optional array of facet positions (vector3)
  87241. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87242. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87243. * * bInfo : optional bounding info, required for facetPartitioning computation
  87244. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87245. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87246. * * useRightHandedSystem: optional boolean to for right handed system computation
  87247. * * depthSort : optional boolean to enable the facet depth sort computation
  87248. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87249. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87250. */
  87251. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87252. facetNormals?: any;
  87253. facetPositions?: any;
  87254. facetPartitioning?: any;
  87255. ratio?: number;
  87256. bInfo?: any;
  87257. bbSize?: Vector3;
  87258. subDiv?: any;
  87259. useRightHandedSystem?: boolean;
  87260. depthSort?: boolean;
  87261. distanceTo?: Vector3;
  87262. depthSortedFacets?: any;
  87263. }): void;
  87264. /** @hidden */
  87265. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87266. /**
  87267. * Applies VertexData created from the imported parameters to the geometry
  87268. * @param parsedVertexData the parsed data from an imported file
  87269. * @param geometry the geometry to apply the VertexData to
  87270. */
  87271. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87272. }
  87273. }
  87274. declare module BABYLON {
  87275. /**
  87276. * Defines a target to use with MorphTargetManager
  87277. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87278. */
  87279. export class MorphTarget implements IAnimatable {
  87280. /** defines the name of the target */
  87281. name: string;
  87282. /**
  87283. * Gets or sets the list of animations
  87284. */
  87285. animations: Animation[];
  87286. private _scene;
  87287. private _positions;
  87288. private _normals;
  87289. private _tangents;
  87290. private _uvs;
  87291. private _influence;
  87292. /**
  87293. * Observable raised when the influence changes
  87294. */
  87295. onInfluenceChanged: Observable<boolean>;
  87296. /** @hidden */
  87297. _onDataLayoutChanged: Observable<void>;
  87298. /**
  87299. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87300. */
  87301. influence: number;
  87302. /**
  87303. * Gets or sets the id of the morph Target
  87304. */
  87305. id: string;
  87306. private _animationPropertiesOverride;
  87307. /**
  87308. * Gets or sets the animation properties override
  87309. */
  87310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87311. /**
  87312. * Creates a new MorphTarget
  87313. * @param name defines the name of the target
  87314. * @param influence defines the influence to use
  87315. * @param scene defines the scene the morphtarget belongs to
  87316. */
  87317. constructor(
  87318. /** defines the name of the target */
  87319. name: string, influence?: number, scene?: Nullable<Scene>);
  87320. /**
  87321. * Gets a boolean defining if the target contains position data
  87322. */
  87323. readonly hasPositions: boolean;
  87324. /**
  87325. * Gets a boolean defining if the target contains normal data
  87326. */
  87327. readonly hasNormals: boolean;
  87328. /**
  87329. * Gets a boolean defining if the target contains tangent data
  87330. */
  87331. readonly hasTangents: boolean;
  87332. /**
  87333. * Gets a boolean defining if the target contains texture coordinates data
  87334. */
  87335. readonly hasUVs: boolean;
  87336. /**
  87337. * Affects position data to this target
  87338. * @param data defines the position data to use
  87339. */
  87340. setPositions(data: Nullable<FloatArray>): void;
  87341. /**
  87342. * Gets the position data stored in this target
  87343. * @returns a FloatArray containing the position data (or null if not present)
  87344. */
  87345. getPositions(): Nullable<FloatArray>;
  87346. /**
  87347. * Affects normal data to this target
  87348. * @param data defines the normal data to use
  87349. */
  87350. setNormals(data: Nullable<FloatArray>): void;
  87351. /**
  87352. * Gets the normal data stored in this target
  87353. * @returns a FloatArray containing the normal data (or null if not present)
  87354. */
  87355. getNormals(): Nullable<FloatArray>;
  87356. /**
  87357. * Affects tangent data to this target
  87358. * @param data defines the tangent data to use
  87359. */
  87360. setTangents(data: Nullable<FloatArray>): void;
  87361. /**
  87362. * Gets the tangent data stored in this target
  87363. * @returns a FloatArray containing the tangent data (or null if not present)
  87364. */
  87365. getTangents(): Nullable<FloatArray>;
  87366. /**
  87367. * Affects texture coordinates data to this target
  87368. * @param data defines the texture coordinates data to use
  87369. */
  87370. setUVs(data: Nullable<FloatArray>): void;
  87371. /**
  87372. * Gets the texture coordinates data stored in this target
  87373. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87374. */
  87375. getUVs(): Nullable<FloatArray>;
  87376. /**
  87377. * Serializes the current target into a Serialization object
  87378. * @returns the serialized object
  87379. */
  87380. serialize(): any;
  87381. /**
  87382. * Returns the string "MorphTarget"
  87383. * @returns "MorphTarget"
  87384. */
  87385. getClassName(): string;
  87386. /**
  87387. * Creates a new target from serialized data
  87388. * @param serializationObject defines the serialized data to use
  87389. * @returns a new MorphTarget
  87390. */
  87391. static Parse(serializationObject: any): MorphTarget;
  87392. /**
  87393. * Creates a MorphTarget from mesh data
  87394. * @param mesh defines the source mesh
  87395. * @param name defines the name to use for the new target
  87396. * @param influence defines the influence to attach to the target
  87397. * @returns a new MorphTarget
  87398. */
  87399. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87400. }
  87401. }
  87402. declare module BABYLON {
  87403. /**
  87404. * This class is used to deform meshes using morphing between different targets
  87405. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87406. */
  87407. export class MorphTargetManager {
  87408. private _targets;
  87409. private _targetInfluenceChangedObservers;
  87410. private _targetDataLayoutChangedObservers;
  87411. private _activeTargets;
  87412. private _scene;
  87413. private _influences;
  87414. private _supportsNormals;
  87415. private _supportsTangents;
  87416. private _supportsUVs;
  87417. private _vertexCount;
  87418. private _uniqueId;
  87419. private _tempInfluences;
  87420. /**
  87421. * Gets or sets a boolean indicating if normals must be morphed
  87422. */
  87423. enableNormalMorphing: boolean;
  87424. /**
  87425. * Gets or sets a boolean indicating if tangents must be morphed
  87426. */
  87427. enableTangentMorphing: boolean;
  87428. /**
  87429. * Gets or sets a boolean indicating if UV must be morphed
  87430. */
  87431. enableUVMorphing: boolean;
  87432. /**
  87433. * Creates a new MorphTargetManager
  87434. * @param scene defines the current scene
  87435. */
  87436. constructor(scene?: Nullable<Scene>);
  87437. /**
  87438. * Gets the unique ID of this manager
  87439. */
  87440. readonly uniqueId: number;
  87441. /**
  87442. * Gets the number of vertices handled by this manager
  87443. */
  87444. readonly vertexCount: number;
  87445. /**
  87446. * Gets a boolean indicating if this manager supports morphing of normals
  87447. */
  87448. readonly supportsNormals: boolean;
  87449. /**
  87450. * Gets a boolean indicating if this manager supports morphing of tangents
  87451. */
  87452. readonly supportsTangents: boolean;
  87453. /**
  87454. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87455. */
  87456. readonly supportsUVs: boolean;
  87457. /**
  87458. * Gets the number of targets stored in this manager
  87459. */
  87460. readonly numTargets: number;
  87461. /**
  87462. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87463. */
  87464. readonly numInfluencers: number;
  87465. /**
  87466. * Gets the list of influences (one per target)
  87467. */
  87468. readonly influences: Float32Array;
  87469. /**
  87470. * Gets the active target at specified index. An active target is a target with an influence > 0
  87471. * @param index defines the index to check
  87472. * @returns the requested target
  87473. */
  87474. getActiveTarget(index: number): MorphTarget;
  87475. /**
  87476. * Gets the target at specified index
  87477. * @param index defines the index to check
  87478. * @returns the requested target
  87479. */
  87480. getTarget(index: number): MorphTarget;
  87481. /**
  87482. * Add a new target to this manager
  87483. * @param target defines the target to add
  87484. */
  87485. addTarget(target: MorphTarget): void;
  87486. /**
  87487. * Removes a target from the manager
  87488. * @param target defines the target to remove
  87489. */
  87490. removeTarget(target: MorphTarget): void;
  87491. /**
  87492. * Serializes the current manager into a Serialization object
  87493. * @returns the serialized object
  87494. */
  87495. serialize(): any;
  87496. private _syncActiveTargets;
  87497. /**
  87498. * Syncrhonize the targets with all the meshes using this morph target manager
  87499. */
  87500. synchronize(): void;
  87501. /**
  87502. * Creates a new MorphTargetManager from serialized data
  87503. * @param serializationObject defines the serialized data
  87504. * @param scene defines the hosting scene
  87505. * @returns the new MorphTargetManager
  87506. */
  87507. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87508. }
  87509. }
  87510. declare module BABYLON {
  87511. /**
  87512. * Class used to represent a specific level of detail of a mesh
  87513. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87514. */
  87515. export class MeshLODLevel {
  87516. /** Defines the distance where this level should star being displayed */
  87517. distance: number;
  87518. /** Defines the mesh to use to render this level */
  87519. mesh: Nullable<Mesh>;
  87520. /**
  87521. * Creates a new LOD level
  87522. * @param distance defines the distance where this level should star being displayed
  87523. * @param mesh defines the mesh to use to render this level
  87524. */
  87525. constructor(
  87526. /** Defines the distance where this level should star being displayed */
  87527. distance: number,
  87528. /** Defines the mesh to use to render this level */
  87529. mesh: Nullable<Mesh>);
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /**
  87534. * Mesh representing the gorund
  87535. */
  87536. export class GroundMesh extends Mesh {
  87537. /** If octree should be generated */
  87538. generateOctree: boolean;
  87539. private _heightQuads;
  87540. /** @hidden */
  87541. _subdivisionsX: number;
  87542. /** @hidden */
  87543. _subdivisionsY: number;
  87544. /** @hidden */
  87545. _width: number;
  87546. /** @hidden */
  87547. _height: number;
  87548. /** @hidden */
  87549. _minX: number;
  87550. /** @hidden */
  87551. _maxX: number;
  87552. /** @hidden */
  87553. _minZ: number;
  87554. /** @hidden */
  87555. _maxZ: number;
  87556. constructor(name: string, scene: Scene);
  87557. /**
  87558. * "GroundMesh"
  87559. * @returns "GroundMesh"
  87560. */
  87561. getClassName(): string;
  87562. /**
  87563. * The minimum of x and y subdivisions
  87564. */
  87565. readonly subdivisions: number;
  87566. /**
  87567. * X subdivisions
  87568. */
  87569. readonly subdivisionsX: number;
  87570. /**
  87571. * Y subdivisions
  87572. */
  87573. readonly subdivisionsY: number;
  87574. /**
  87575. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87577. * @param chunksCount the number of subdivisions for x and y
  87578. * @param octreeBlocksSize (Default: 32)
  87579. */
  87580. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87581. /**
  87582. * Returns a height (y) value in the Worl system :
  87583. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87584. * @param x x coordinate
  87585. * @param z z coordinate
  87586. * @returns the ground y position if (x, z) are outside the ground surface.
  87587. */
  87588. getHeightAtCoordinates(x: number, z: number): number;
  87589. /**
  87590. * Returns a normalized vector (Vector3) orthogonal to the ground
  87591. * at the ground coordinates (x, z) expressed in the World system.
  87592. * @param x x coordinate
  87593. * @param z z coordinate
  87594. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87595. */
  87596. getNormalAtCoordinates(x: number, z: number): Vector3;
  87597. /**
  87598. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87599. * at the ground coordinates (x, z) expressed in the World system.
  87600. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87601. * @param x x coordinate
  87602. * @param z z coordinate
  87603. * @param ref vector to store the result
  87604. * @returns the GroundMesh.
  87605. */
  87606. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87607. /**
  87608. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87609. * if the ground has been updated.
  87610. * This can be used in the render loop.
  87611. * @returns the GroundMesh.
  87612. */
  87613. updateCoordinateHeights(): GroundMesh;
  87614. private _getFacetAt;
  87615. private _initHeightQuads;
  87616. private _computeHeightQuads;
  87617. /**
  87618. * Serializes this ground mesh
  87619. * @param serializationObject object to write serialization to
  87620. */
  87621. serialize(serializationObject: any): void;
  87622. /**
  87623. * Parses a serialized ground mesh
  87624. * @param parsedMesh the serialized mesh
  87625. * @param scene the scene to create the ground mesh in
  87626. * @returns the created ground mesh
  87627. */
  87628. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87629. }
  87630. }
  87631. declare module BABYLON {
  87632. /**
  87633. * Interface for Physics-Joint data
  87634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87635. */
  87636. export interface PhysicsJointData {
  87637. /**
  87638. * The main pivot of the joint
  87639. */
  87640. mainPivot?: Vector3;
  87641. /**
  87642. * The connected pivot of the joint
  87643. */
  87644. connectedPivot?: Vector3;
  87645. /**
  87646. * The main axis of the joint
  87647. */
  87648. mainAxis?: Vector3;
  87649. /**
  87650. * The connected axis of the joint
  87651. */
  87652. connectedAxis?: Vector3;
  87653. /**
  87654. * The collision of the joint
  87655. */
  87656. collision?: boolean;
  87657. /**
  87658. * Native Oimo/Cannon/Energy data
  87659. */
  87660. nativeParams?: any;
  87661. }
  87662. /**
  87663. * This is a holder class for the physics joint created by the physics plugin
  87664. * It holds a set of functions to control the underlying joint
  87665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87666. */
  87667. export class PhysicsJoint {
  87668. /**
  87669. * The type of the physics joint
  87670. */
  87671. type: number;
  87672. /**
  87673. * The data for the physics joint
  87674. */
  87675. jointData: PhysicsJointData;
  87676. private _physicsJoint;
  87677. protected _physicsPlugin: IPhysicsEnginePlugin;
  87678. /**
  87679. * Initializes the physics joint
  87680. * @param type The type of the physics joint
  87681. * @param jointData The data for the physics joint
  87682. */
  87683. constructor(
  87684. /**
  87685. * The type of the physics joint
  87686. */
  87687. type: number,
  87688. /**
  87689. * The data for the physics joint
  87690. */
  87691. jointData: PhysicsJointData);
  87692. /**
  87693. * Gets the physics joint
  87694. */
  87695. /**
  87696. * Sets the physics joint
  87697. */
  87698. physicsJoint: any;
  87699. /**
  87700. * Sets the physics plugin
  87701. */
  87702. physicsPlugin: IPhysicsEnginePlugin;
  87703. /**
  87704. * Execute a function that is physics-plugin specific.
  87705. * @param {Function} func the function that will be executed.
  87706. * It accepts two parameters: the physics world and the physics joint
  87707. */
  87708. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87709. /**
  87710. * Distance-Joint type
  87711. */
  87712. static DistanceJoint: number;
  87713. /**
  87714. * Hinge-Joint type
  87715. */
  87716. static HingeJoint: number;
  87717. /**
  87718. * Ball-and-Socket joint type
  87719. */
  87720. static BallAndSocketJoint: number;
  87721. /**
  87722. * Wheel-Joint type
  87723. */
  87724. static WheelJoint: number;
  87725. /**
  87726. * Slider-Joint type
  87727. */
  87728. static SliderJoint: number;
  87729. /**
  87730. * Prismatic-Joint type
  87731. */
  87732. static PrismaticJoint: number;
  87733. /**
  87734. * Universal-Joint type
  87735. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87736. */
  87737. static UniversalJoint: number;
  87738. /**
  87739. * Hinge-Joint 2 type
  87740. */
  87741. static Hinge2Joint: number;
  87742. /**
  87743. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87744. */
  87745. static PointToPointJoint: number;
  87746. /**
  87747. * Spring-Joint type
  87748. */
  87749. static SpringJoint: number;
  87750. /**
  87751. * Lock-Joint type
  87752. */
  87753. static LockJoint: number;
  87754. }
  87755. /**
  87756. * A class representing a physics distance joint
  87757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87758. */
  87759. export class DistanceJoint extends PhysicsJoint {
  87760. /**
  87761. *
  87762. * @param jointData The data for the Distance-Joint
  87763. */
  87764. constructor(jointData: DistanceJointData);
  87765. /**
  87766. * Update the predefined distance.
  87767. * @param maxDistance The maximum preferred distance
  87768. * @param minDistance The minimum preferred distance
  87769. */
  87770. updateDistance(maxDistance: number, minDistance?: number): void;
  87771. }
  87772. /**
  87773. * Represents a Motor-Enabled Joint
  87774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87775. */
  87776. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87777. /**
  87778. * Initializes the Motor-Enabled Joint
  87779. * @param type The type of the joint
  87780. * @param jointData The physica joint data for the joint
  87781. */
  87782. constructor(type: number, jointData: PhysicsJointData);
  87783. /**
  87784. * Set the motor values.
  87785. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87786. * @param force the force to apply
  87787. * @param maxForce max force for this motor.
  87788. */
  87789. setMotor(force?: number, maxForce?: number): void;
  87790. /**
  87791. * Set the motor's limits.
  87792. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87793. * @param upperLimit The upper limit of the motor
  87794. * @param lowerLimit The lower limit of the motor
  87795. */
  87796. setLimit(upperLimit: number, lowerLimit?: number): void;
  87797. }
  87798. /**
  87799. * This class represents a single physics Hinge-Joint
  87800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87801. */
  87802. export class HingeJoint extends MotorEnabledJoint {
  87803. /**
  87804. * Initializes the Hinge-Joint
  87805. * @param jointData The joint data for the Hinge-Joint
  87806. */
  87807. constructor(jointData: PhysicsJointData);
  87808. /**
  87809. * Set the motor values.
  87810. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87811. * @param {number} force the force to apply
  87812. * @param {number} maxForce max force for this motor.
  87813. */
  87814. setMotor(force?: number, maxForce?: number): void;
  87815. /**
  87816. * Set the motor's limits.
  87817. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87818. * @param upperLimit The upper limit of the motor
  87819. * @param lowerLimit The lower limit of the motor
  87820. */
  87821. setLimit(upperLimit: number, lowerLimit?: number): void;
  87822. }
  87823. /**
  87824. * This class represents a dual hinge physics joint (same as wheel joint)
  87825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87826. */
  87827. export class Hinge2Joint extends MotorEnabledJoint {
  87828. /**
  87829. * Initializes the Hinge2-Joint
  87830. * @param jointData The joint data for the Hinge2-Joint
  87831. */
  87832. constructor(jointData: PhysicsJointData);
  87833. /**
  87834. * Set the motor values.
  87835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87836. * @param {number} targetSpeed the speed the motor is to reach
  87837. * @param {number} maxForce max force for this motor.
  87838. * @param {motorIndex} the motor's index, 0 or 1.
  87839. */
  87840. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87841. /**
  87842. * Set the motor limits.
  87843. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87844. * @param {number} upperLimit the upper limit
  87845. * @param {number} lowerLimit lower limit
  87846. * @param {motorIndex} the motor's index, 0 or 1.
  87847. */
  87848. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87849. }
  87850. /**
  87851. * Interface for a motor enabled joint
  87852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87853. */
  87854. export interface IMotorEnabledJoint {
  87855. /**
  87856. * Physics joint
  87857. */
  87858. physicsJoint: any;
  87859. /**
  87860. * Sets the motor of the motor-enabled joint
  87861. * @param force The force of the motor
  87862. * @param maxForce The maximum force of the motor
  87863. * @param motorIndex The index of the motor
  87864. */
  87865. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87866. /**
  87867. * Sets the limit of the motor
  87868. * @param upperLimit The upper limit of the motor
  87869. * @param lowerLimit The lower limit of the motor
  87870. * @param motorIndex The index of the motor
  87871. */
  87872. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87873. }
  87874. /**
  87875. * Joint data for a Distance-Joint
  87876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87877. */
  87878. export interface DistanceJointData extends PhysicsJointData {
  87879. /**
  87880. * Max distance the 2 joint objects can be apart
  87881. */
  87882. maxDistance: number;
  87883. }
  87884. /**
  87885. * Joint data from a spring joint
  87886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87887. */
  87888. export interface SpringJointData extends PhysicsJointData {
  87889. /**
  87890. * Length of the spring
  87891. */
  87892. length: number;
  87893. /**
  87894. * Stiffness of the spring
  87895. */
  87896. stiffness: number;
  87897. /**
  87898. * Damping of the spring
  87899. */
  87900. damping: number;
  87901. /** this callback will be called when applying the force to the impostors. */
  87902. forceApplicationCallback: () => void;
  87903. }
  87904. }
  87905. declare module BABYLON {
  87906. /**
  87907. * Holds the data for the raycast result
  87908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87909. */
  87910. export class PhysicsRaycastResult {
  87911. private _hasHit;
  87912. private _hitDistance;
  87913. private _hitNormalWorld;
  87914. private _hitPointWorld;
  87915. private _rayFromWorld;
  87916. private _rayToWorld;
  87917. /**
  87918. * Gets if there was a hit
  87919. */
  87920. readonly hasHit: boolean;
  87921. /**
  87922. * Gets the distance from the hit
  87923. */
  87924. readonly hitDistance: number;
  87925. /**
  87926. * Gets the hit normal/direction in the world
  87927. */
  87928. readonly hitNormalWorld: Vector3;
  87929. /**
  87930. * Gets the hit point in the world
  87931. */
  87932. readonly hitPointWorld: Vector3;
  87933. /**
  87934. * Gets the ray "start point" of the ray in the world
  87935. */
  87936. readonly rayFromWorld: Vector3;
  87937. /**
  87938. * Gets the ray "end point" of the ray in the world
  87939. */
  87940. readonly rayToWorld: Vector3;
  87941. /**
  87942. * Sets the hit data (normal & point in world space)
  87943. * @param hitNormalWorld defines the normal in world space
  87944. * @param hitPointWorld defines the point in world space
  87945. */
  87946. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87947. /**
  87948. * Sets the distance from the start point to the hit point
  87949. * @param distance
  87950. */
  87951. setHitDistance(distance: number): void;
  87952. /**
  87953. * Calculates the distance manually
  87954. */
  87955. calculateHitDistance(): void;
  87956. /**
  87957. * Resets all the values to default
  87958. * @param from The from point on world space
  87959. * @param to The to point on world space
  87960. */
  87961. reset(from?: Vector3, to?: Vector3): void;
  87962. }
  87963. /**
  87964. * Interface for the size containing width and height
  87965. */
  87966. interface IXYZ {
  87967. /**
  87968. * X
  87969. */
  87970. x: number;
  87971. /**
  87972. * Y
  87973. */
  87974. y: number;
  87975. /**
  87976. * Z
  87977. */
  87978. z: number;
  87979. }
  87980. }
  87981. declare module BABYLON {
  87982. /**
  87983. * Interface used to describe a physics joint
  87984. */
  87985. export interface PhysicsImpostorJoint {
  87986. /** Defines the main impostor to which the joint is linked */
  87987. mainImpostor: PhysicsImpostor;
  87988. /** Defines the impostor that is connected to the main impostor using this joint */
  87989. connectedImpostor: PhysicsImpostor;
  87990. /** Defines the joint itself */
  87991. joint: PhysicsJoint;
  87992. }
  87993. /** @hidden */
  87994. export interface IPhysicsEnginePlugin {
  87995. world: any;
  87996. name: string;
  87997. setGravity(gravity: Vector3): void;
  87998. setTimeStep(timeStep: number): void;
  87999. getTimeStep(): number;
  88000. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88001. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88002. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88003. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88004. removePhysicsBody(impostor: PhysicsImpostor): void;
  88005. generateJoint(joint: PhysicsImpostorJoint): void;
  88006. removeJoint(joint: PhysicsImpostorJoint): void;
  88007. isSupported(): boolean;
  88008. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88009. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88010. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88011. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88012. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88013. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88014. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88015. getBodyMass(impostor: PhysicsImpostor): number;
  88016. getBodyFriction(impostor: PhysicsImpostor): number;
  88017. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88018. getBodyRestitution(impostor: PhysicsImpostor): number;
  88019. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88020. getBodyPressure?(impostor: PhysicsImpostor): number;
  88021. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88022. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88023. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88024. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88025. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88026. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88027. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88028. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88029. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88030. sleepBody(impostor: PhysicsImpostor): void;
  88031. wakeUpBody(impostor: PhysicsImpostor): void;
  88032. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88033. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88034. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88035. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88036. getRadius(impostor: PhysicsImpostor): number;
  88037. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88038. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88039. dispose(): void;
  88040. }
  88041. /**
  88042. * Interface used to define a physics engine
  88043. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88044. */
  88045. export interface IPhysicsEngine {
  88046. /**
  88047. * Gets the gravity vector used by the simulation
  88048. */
  88049. gravity: Vector3;
  88050. /**
  88051. * Sets the gravity vector used by the simulation
  88052. * @param gravity defines the gravity vector to use
  88053. */
  88054. setGravity(gravity: Vector3): void;
  88055. /**
  88056. * Set the time step of the physics engine.
  88057. * Default is 1/60.
  88058. * To slow it down, enter 1/600 for example.
  88059. * To speed it up, 1/30
  88060. * @param newTimeStep the new timestep to apply to this world.
  88061. */
  88062. setTimeStep(newTimeStep: number): void;
  88063. /**
  88064. * Get the time step of the physics engine.
  88065. * @returns the current time step
  88066. */
  88067. getTimeStep(): number;
  88068. /**
  88069. * Release all resources
  88070. */
  88071. dispose(): void;
  88072. /**
  88073. * Gets the name of the current physics plugin
  88074. * @returns the name of the plugin
  88075. */
  88076. getPhysicsPluginName(): string;
  88077. /**
  88078. * Adding a new impostor for the impostor tracking.
  88079. * This will be done by the impostor itself.
  88080. * @param impostor the impostor to add
  88081. */
  88082. addImpostor(impostor: PhysicsImpostor): void;
  88083. /**
  88084. * Remove an impostor from the engine.
  88085. * This impostor and its mesh will not longer be updated by the physics engine.
  88086. * @param impostor the impostor to remove
  88087. */
  88088. removeImpostor(impostor: PhysicsImpostor): void;
  88089. /**
  88090. * Add a joint to the physics engine
  88091. * @param mainImpostor defines the main impostor to which the joint is added.
  88092. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88093. * @param joint defines the joint that will connect both impostors.
  88094. */
  88095. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88096. /**
  88097. * Removes a joint from the simulation
  88098. * @param mainImpostor defines the impostor used with the joint
  88099. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88100. * @param joint defines the joint to remove
  88101. */
  88102. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88103. /**
  88104. * Gets the current plugin used to run the simulation
  88105. * @returns current plugin
  88106. */
  88107. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88108. /**
  88109. * Gets the list of physic impostors
  88110. * @returns an array of PhysicsImpostor
  88111. */
  88112. getImpostors(): Array<PhysicsImpostor>;
  88113. /**
  88114. * Gets the impostor for a physics enabled object
  88115. * @param object defines the object impersonated by the impostor
  88116. * @returns the PhysicsImpostor or null if not found
  88117. */
  88118. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88119. /**
  88120. * Gets the impostor for a physics body object
  88121. * @param body defines physics body used by the impostor
  88122. * @returns the PhysicsImpostor or null if not found
  88123. */
  88124. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88125. /**
  88126. * Does a raycast in the physics world
  88127. * @param from when should the ray start?
  88128. * @param to when should the ray end?
  88129. * @returns PhysicsRaycastResult
  88130. */
  88131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88132. /**
  88133. * Called by the scene. No need to call it.
  88134. * @param delta defines the timespam between frames
  88135. */
  88136. _step(delta: number): void;
  88137. }
  88138. }
  88139. declare module BABYLON {
  88140. /**
  88141. * The interface for the physics imposter parameters
  88142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88143. */
  88144. export interface PhysicsImpostorParameters {
  88145. /**
  88146. * The mass of the physics imposter
  88147. */
  88148. mass: number;
  88149. /**
  88150. * The friction of the physics imposter
  88151. */
  88152. friction?: number;
  88153. /**
  88154. * The coefficient of restitution of the physics imposter
  88155. */
  88156. restitution?: number;
  88157. /**
  88158. * The native options of the physics imposter
  88159. */
  88160. nativeOptions?: any;
  88161. /**
  88162. * Specifies if the parent should be ignored
  88163. */
  88164. ignoreParent?: boolean;
  88165. /**
  88166. * Specifies if bi-directional transformations should be disabled
  88167. */
  88168. disableBidirectionalTransformation?: boolean;
  88169. /**
  88170. * The pressure inside the physics imposter, soft object only
  88171. */
  88172. pressure?: number;
  88173. /**
  88174. * The stiffness the physics imposter, soft object only
  88175. */
  88176. stiffness?: number;
  88177. /**
  88178. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88179. */
  88180. velocityIterations?: number;
  88181. /**
  88182. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88183. */
  88184. positionIterations?: number;
  88185. /**
  88186. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88187. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88188. * Add to fix multiple points
  88189. */
  88190. fixedPoints?: number;
  88191. /**
  88192. * The collision margin around a soft object
  88193. */
  88194. margin?: number;
  88195. /**
  88196. * The collision margin around a soft object
  88197. */
  88198. damping?: number;
  88199. /**
  88200. * The path for a rope based on an extrusion
  88201. */
  88202. path?: any;
  88203. /**
  88204. * The shape of an extrusion used for a rope based on an extrusion
  88205. */
  88206. shape?: any;
  88207. }
  88208. /**
  88209. * Interface for a physics-enabled object
  88210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88211. */
  88212. export interface IPhysicsEnabledObject {
  88213. /**
  88214. * The position of the physics-enabled object
  88215. */
  88216. position: Vector3;
  88217. /**
  88218. * The rotation of the physics-enabled object
  88219. */
  88220. rotationQuaternion: Nullable<Quaternion>;
  88221. /**
  88222. * The scale of the physics-enabled object
  88223. */
  88224. scaling: Vector3;
  88225. /**
  88226. * The rotation of the physics-enabled object
  88227. */
  88228. rotation?: Vector3;
  88229. /**
  88230. * The parent of the physics-enabled object
  88231. */
  88232. parent?: any;
  88233. /**
  88234. * The bounding info of the physics-enabled object
  88235. * @returns The bounding info of the physics-enabled object
  88236. */
  88237. getBoundingInfo(): BoundingInfo;
  88238. /**
  88239. * Computes the world matrix
  88240. * @param force Specifies if the world matrix should be computed by force
  88241. * @returns A world matrix
  88242. */
  88243. computeWorldMatrix(force: boolean): Matrix;
  88244. /**
  88245. * Gets the world matrix
  88246. * @returns A world matrix
  88247. */
  88248. getWorldMatrix?(): Matrix;
  88249. /**
  88250. * Gets the child meshes
  88251. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88252. * @returns An array of abstract meshes
  88253. */
  88254. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88255. /**
  88256. * Gets the vertex data
  88257. * @param kind The type of vertex data
  88258. * @returns A nullable array of numbers, or a float32 array
  88259. */
  88260. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88261. /**
  88262. * Gets the indices from the mesh
  88263. * @returns A nullable array of index arrays
  88264. */
  88265. getIndices?(): Nullable<IndicesArray>;
  88266. /**
  88267. * Gets the scene from the mesh
  88268. * @returns the indices array or null
  88269. */
  88270. getScene?(): Scene;
  88271. /**
  88272. * Gets the absolute position from the mesh
  88273. * @returns the absolute position
  88274. */
  88275. getAbsolutePosition(): Vector3;
  88276. /**
  88277. * Gets the absolute pivot point from the mesh
  88278. * @returns the absolute pivot point
  88279. */
  88280. getAbsolutePivotPoint(): Vector3;
  88281. /**
  88282. * Rotates the mesh
  88283. * @param axis The axis of rotation
  88284. * @param amount The amount of rotation
  88285. * @param space The space of the rotation
  88286. * @returns The rotation transform node
  88287. */
  88288. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88289. /**
  88290. * Translates the mesh
  88291. * @param axis The axis of translation
  88292. * @param distance The distance of translation
  88293. * @param space The space of the translation
  88294. * @returns The transform node
  88295. */
  88296. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88297. /**
  88298. * Sets the absolute position of the mesh
  88299. * @param absolutePosition The absolute position of the mesh
  88300. * @returns The transform node
  88301. */
  88302. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88303. /**
  88304. * Gets the class name of the mesh
  88305. * @returns The class name
  88306. */
  88307. getClassName(): string;
  88308. }
  88309. /**
  88310. * Represents a physics imposter
  88311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88312. */
  88313. export class PhysicsImpostor {
  88314. /**
  88315. * The physics-enabled object used as the physics imposter
  88316. */
  88317. object: IPhysicsEnabledObject;
  88318. /**
  88319. * The type of the physics imposter
  88320. */
  88321. type: number;
  88322. private _options;
  88323. private _scene?;
  88324. /**
  88325. * The default object size of the imposter
  88326. */
  88327. static DEFAULT_OBJECT_SIZE: Vector3;
  88328. /**
  88329. * The identity quaternion of the imposter
  88330. */
  88331. static IDENTITY_QUATERNION: Quaternion;
  88332. /** @hidden */
  88333. _pluginData: any;
  88334. private _physicsEngine;
  88335. private _physicsBody;
  88336. private _bodyUpdateRequired;
  88337. private _onBeforePhysicsStepCallbacks;
  88338. private _onAfterPhysicsStepCallbacks;
  88339. /** @hidden */
  88340. _onPhysicsCollideCallbacks: Array<{
  88341. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88342. otherImpostors: Array<PhysicsImpostor>;
  88343. }>;
  88344. private _deltaPosition;
  88345. private _deltaRotation;
  88346. private _deltaRotationConjugated;
  88347. /** @hidden */
  88348. _isFromLine: boolean;
  88349. private _parent;
  88350. private _isDisposed;
  88351. private static _tmpVecs;
  88352. private static _tmpQuat;
  88353. /**
  88354. * Specifies if the physics imposter is disposed
  88355. */
  88356. readonly isDisposed: boolean;
  88357. /**
  88358. * Gets the mass of the physics imposter
  88359. */
  88360. mass: number;
  88361. /**
  88362. * Gets the coefficient of friction
  88363. */
  88364. /**
  88365. * Sets the coefficient of friction
  88366. */
  88367. friction: number;
  88368. /**
  88369. * Gets the coefficient of restitution
  88370. */
  88371. /**
  88372. * Sets the coefficient of restitution
  88373. */
  88374. restitution: number;
  88375. /**
  88376. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88377. */
  88378. /**
  88379. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88380. */
  88381. pressure: number;
  88382. /**
  88383. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88384. */
  88385. /**
  88386. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88387. */
  88388. stiffness: number;
  88389. /**
  88390. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88391. */
  88392. /**
  88393. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88394. */
  88395. velocityIterations: number;
  88396. /**
  88397. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88398. */
  88399. /**
  88400. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88401. */
  88402. positionIterations: number;
  88403. /**
  88404. * The unique id of the physics imposter
  88405. * set by the physics engine when adding this impostor to the array
  88406. */
  88407. uniqueId: number;
  88408. /**
  88409. * @hidden
  88410. */
  88411. soft: boolean;
  88412. /**
  88413. * @hidden
  88414. */
  88415. segments: number;
  88416. private _joints;
  88417. /**
  88418. * Initializes the physics imposter
  88419. * @param object The physics-enabled object used as the physics imposter
  88420. * @param type The type of the physics imposter
  88421. * @param _options The options for the physics imposter
  88422. * @param _scene The Babylon scene
  88423. */
  88424. constructor(
  88425. /**
  88426. * The physics-enabled object used as the physics imposter
  88427. */
  88428. object: IPhysicsEnabledObject,
  88429. /**
  88430. * The type of the physics imposter
  88431. */
  88432. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88433. /**
  88434. * This function will completly initialize this impostor.
  88435. * It will create a new body - but only if this mesh has no parent.
  88436. * If it has, this impostor will not be used other than to define the impostor
  88437. * of the child mesh.
  88438. * @hidden
  88439. */
  88440. _init(): void;
  88441. private _getPhysicsParent;
  88442. /**
  88443. * Should a new body be generated.
  88444. * @returns boolean specifying if body initialization is required
  88445. */
  88446. isBodyInitRequired(): boolean;
  88447. /**
  88448. * Sets the updated scaling
  88449. * @param updated Specifies if the scaling is updated
  88450. */
  88451. setScalingUpdated(): void;
  88452. /**
  88453. * Force a regeneration of this or the parent's impostor's body.
  88454. * Use under cautious - This will remove all joints already implemented.
  88455. */
  88456. forceUpdate(): void;
  88457. /**
  88458. * Gets the body that holds this impostor. Either its own, or its parent.
  88459. */
  88460. /**
  88461. * Set the physics body. Used mainly by the physics engine/plugin
  88462. */
  88463. physicsBody: any;
  88464. /**
  88465. * Get the parent of the physics imposter
  88466. * @returns Physics imposter or null
  88467. */
  88468. /**
  88469. * Sets the parent of the physics imposter
  88470. */
  88471. parent: Nullable<PhysicsImpostor>;
  88472. /**
  88473. * Resets the update flags
  88474. */
  88475. resetUpdateFlags(): void;
  88476. /**
  88477. * Gets the object extend size
  88478. * @returns the object extend size
  88479. */
  88480. getObjectExtendSize(): Vector3;
  88481. /**
  88482. * Gets the object center
  88483. * @returns The object center
  88484. */
  88485. getObjectCenter(): Vector3;
  88486. /**
  88487. * Get a specific parametes from the options parameter
  88488. * @param paramName The object parameter name
  88489. * @returns The object parameter
  88490. */
  88491. getParam(paramName: string): any;
  88492. /**
  88493. * Sets a specific parameter in the options given to the physics plugin
  88494. * @param paramName The parameter name
  88495. * @param value The value of the parameter
  88496. */
  88497. setParam(paramName: string, value: number): void;
  88498. /**
  88499. * Specifically change the body's mass option. Won't recreate the physics body object
  88500. * @param mass The mass of the physics imposter
  88501. */
  88502. setMass(mass: number): void;
  88503. /**
  88504. * Gets the linear velocity
  88505. * @returns linear velocity or null
  88506. */
  88507. getLinearVelocity(): Nullable<Vector3>;
  88508. /**
  88509. * Sets the linear velocity
  88510. * @param velocity linear velocity or null
  88511. */
  88512. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88513. /**
  88514. * Gets the angular velocity
  88515. * @returns angular velocity or null
  88516. */
  88517. getAngularVelocity(): Nullable<Vector3>;
  88518. /**
  88519. * Sets the angular velocity
  88520. * @param velocity The velocity or null
  88521. */
  88522. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88523. /**
  88524. * Execute a function with the physics plugin native code
  88525. * Provide a function the will have two variables - the world object and the physics body object
  88526. * @param func The function to execute with the physics plugin native code
  88527. */
  88528. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88529. /**
  88530. * Register a function that will be executed before the physics world is stepping forward
  88531. * @param func The function to execute before the physics world is stepped forward
  88532. */
  88533. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88534. /**
  88535. * Unregister a function that will be executed before the physics world is stepping forward
  88536. * @param func The function to execute before the physics world is stepped forward
  88537. */
  88538. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88539. /**
  88540. * Register a function that will be executed after the physics step
  88541. * @param func The function to execute after physics step
  88542. */
  88543. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88544. /**
  88545. * Unregisters a function that will be executed after the physics step
  88546. * @param func The function to execute after physics step
  88547. */
  88548. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88549. /**
  88550. * register a function that will be executed when this impostor collides against a different body
  88551. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88552. * @param func Callback that is executed on collision
  88553. */
  88554. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88555. /**
  88556. * Unregisters the physics imposter on contact
  88557. * @param collideAgainst The physics object to collide against
  88558. * @param func Callback to execute on collision
  88559. */
  88560. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88561. private _tmpQuat;
  88562. private _tmpQuat2;
  88563. /**
  88564. * Get the parent rotation
  88565. * @returns The parent rotation
  88566. */
  88567. getParentsRotation(): Quaternion;
  88568. /**
  88569. * this function is executed by the physics engine.
  88570. */
  88571. beforeStep: () => void;
  88572. /**
  88573. * this function is executed by the physics engine
  88574. */
  88575. afterStep: () => void;
  88576. /**
  88577. * Legacy collision detection event support
  88578. */
  88579. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88580. /**
  88581. * event and body object due to cannon's event-based architecture.
  88582. */
  88583. onCollide: (e: {
  88584. body: any;
  88585. }) => void;
  88586. /**
  88587. * Apply a force
  88588. * @param force The force to apply
  88589. * @param contactPoint The contact point for the force
  88590. * @returns The physics imposter
  88591. */
  88592. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88593. /**
  88594. * Apply an impulse
  88595. * @param force The impulse force
  88596. * @param contactPoint The contact point for the impulse force
  88597. * @returns The physics imposter
  88598. */
  88599. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88600. /**
  88601. * A help function to create a joint
  88602. * @param otherImpostor A physics imposter used to create a joint
  88603. * @param jointType The type of joint
  88604. * @param jointData The data for the joint
  88605. * @returns The physics imposter
  88606. */
  88607. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88608. /**
  88609. * Add a joint to this impostor with a different impostor
  88610. * @param otherImpostor A physics imposter used to add a joint
  88611. * @param joint The joint to add
  88612. * @returns The physics imposter
  88613. */
  88614. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88615. /**
  88616. * Add an anchor to a cloth impostor
  88617. * @param otherImpostor rigid impostor to anchor to
  88618. * @param width ratio across width from 0 to 1
  88619. * @param height ratio up height from 0 to 1
  88620. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88621. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88622. * @returns impostor the soft imposter
  88623. */
  88624. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88625. /**
  88626. * Add a hook to a rope impostor
  88627. * @param otherImpostor rigid impostor to anchor to
  88628. * @param length ratio across rope from 0 to 1
  88629. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88630. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88631. * @returns impostor the rope imposter
  88632. */
  88633. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88634. /**
  88635. * Will keep this body still, in a sleep mode.
  88636. * @returns the physics imposter
  88637. */
  88638. sleep(): PhysicsImpostor;
  88639. /**
  88640. * Wake the body up.
  88641. * @returns The physics imposter
  88642. */
  88643. wakeUp(): PhysicsImpostor;
  88644. /**
  88645. * Clones the physics imposter
  88646. * @param newObject The physics imposter clones to this physics-enabled object
  88647. * @returns A nullable physics imposter
  88648. */
  88649. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88650. /**
  88651. * Disposes the physics imposter
  88652. */
  88653. dispose(): void;
  88654. /**
  88655. * Sets the delta position
  88656. * @param position The delta position amount
  88657. */
  88658. setDeltaPosition(position: Vector3): void;
  88659. /**
  88660. * Sets the delta rotation
  88661. * @param rotation The delta rotation amount
  88662. */
  88663. setDeltaRotation(rotation: Quaternion): void;
  88664. /**
  88665. * Gets the box size of the physics imposter and stores the result in the input parameter
  88666. * @param result Stores the box size
  88667. * @returns The physics imposter
  88668. */
  88669. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88670. /**
  88671. * Gets the radius of the physics imposter
  88672. * @returns Radius of the physics imposter
  88673. */
  88674. getRadius(): number;
  88675. /**
  88676. * Sync a bone with this impostor
  88677. * @param bone The bone to sync to the impostor.
  88678. * @param boneMesh The mesh that the bone is influencing.
  88679. * @param jointPivot The pivot of the joint / bone in local space.
  88680. * @param distToJoint Optional distance from the impostor to the joint.
  88681. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88682. */
  88683. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88684. /**
  88685. * Sync impostor to a bone
  88686. * @param bone The bone that the impostor will be synced to.
  88687. * @param boneMesh The mesh that the bone is influencing.
  88688. * @param jointPivot The pivot of the joint / bone in local space.
  88689. * @param distToJoint Optional distance from the impostor to the joint.
  88690. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88691. * @param boneAxis Optional vector3 axis the bone is aligned with
  88692. */
  88693. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88694. /**
  88695. * No-Imposter type
  88696. */
  88697. static NoImpostor: number;
  88698. /**
  88699. * Sphere-Imposter type
  88700. */
  88701. static SphereImpostor: number;
  88702. /**
  88703. * Box-Imposter type
  88704. */
  88705. static BoxImpostor: number;
  88706. /**
  88707. * Plane-Imposter type
  88708. */
  88709. static PlaneImpostor: number;
  88710. /**
  88711. * Mesh-imposter type
  88712. */
  88713. static MeshImpostor: number;
  88714. /**
  88715. * Capsule-Impostor type (Ammo.js plugin only)
  88716. */
  88717. static CapsuleImpostor: number;
  88718. /**
  88719. * Cylinder-Imposter type
  88720. */
  88721. static CylinderImpostor: number;
  88722. /**
  88723. * Particle-Imposter type
  88724. */
  88725. static ParticleImpostor: number;
  88726. /**
  88727. * Heightmap-Imposter type
  88728. */
  88729. static HeightmapImpostor: number;
  88730. /**
  88731. * ConvexHull-Impostor type (Ammo.js plugin only)
  88732. */
  88733. static ConvexHullImpostor: number;
  88734. /**
  88735. * Rope-Imposter type
  88736. */
  88737. static RopeImpostor: number;
  88738. /**
  88739. * Cloth-Imposter type
  88740. */
  88741. static ClothImpostor: number;
  88742. /**
  88743. * Softbody-Imposter type
  88744. */
  88745. static SoftbodyImpostor: number;
  88746. }
  88747. }
  88748. declare module BABYLON {
  88749. /**
  88750. * @hidden
  88751. **/
  88752. export class _CreationDataStorage {
  88753. closePath?: boolean;
  88754. closeArray?: boolean;
  88755. idx: number[];
  88756. dashSize: number;
  88757. gapSize: number;
  88758. path3D: Path3D;
  88759. pathArray: Vector3[][];
  88760. arc: number;
  88761. radius: number;
  88762. cap: number;
  88763. tessellation: number;
  88764. }
  88765. /**
  88766. * @hidden
  88767. **/
  88768. class _InstanceDataStorage {
  88769. visibleInstances: any;
  88770. batchCache: _InstancesBatch;
  88771. instancesBufferSize: number;
  88772. instancesBuffer: Nullable<Buffer>;
  88773. instancesData: Float32Array;
  88774. overridenInstanceCount: number;
  88775. isFrozen: boolean;
  88776. previousBatch: Nullable<_InstancesBatch>;
  88777. hardwareInstancedRendering: boolean;
  88778. sideOrientation: number;
  88779. }
  88780. /**
  88781. * @hidden
  88782. **/
  88783. export class _InstancesBatch {
  88784. mustReturn: boolean;
  88785. visibleInstances: Nullable<InstancedMesh[]>[];
  88786. renderSelf: boolean[];
  88787. hardwareInstancedRendering: boolean[];
  88788. }
  88789. /**
  88790. * Class used to represent renderable models
  88791. */
  88792. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88793. /**
  88794. * Mesh side orientation : usually the external or front surface
  88795. */
  88796. static readonly FRONTSIDE: number;
  88797. /**
  88798. * Mesh side orientation : usually the internal or back surface
  88799. */
  88800. static readonly BACKSIDE: number;
  88801. /**
  88802. * Mesh side orientation : both internal and external or front and back surfaces
  88803. */
  88804. static readonly DOUBLESIDE: number;
  88805. /**
  88806. * Mesh side orientation : by default, `FRONTSIDE`
  88807. */
  88808. static readonly DEFAULTSIDE: number;
  88809. /**
  88810. * Mesh cap setting : no cap
  88811. */
  88812. static readonly NO_CAP: number;
  88813. /**
  88814. * Mesh cap setting : one cap at the beginning of the mesh
  88815. */
  88816. static readonly CAP_START: number;
  88817. /**
  88818. * Mesh cap setting : one cap at the end of the mesh
  88819. */
  88820. static readonly CAP_END: number;
  88821. /**
  88822. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88823. */
  88824. static readonly CAP_ALL: number;
  88825. /**
  88826. * Mesh pattern setting : no flip or rotate
  88827. */
  88828. static readonly NO_FLIP: number;
  88829. /**
  88830. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88831. */
  88832. static readonly FLIP_TILE: number;
  88833. /**
  88834. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88835. */
  88836. static readonly ROTATE_TILE: number;
  88837. /**
  88838. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88839. */
  88840. static readonly FLIP_ROW: number;
  88841. /**
  88842. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88843. */
  88844. static readonly ROTATE_ROW: number;
  88845. /**
  88846. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88847. */
  88848. static readonly FLIP_N_ROTATE_TILE: number;
  88849. /**
  88850. * Mesh pattern setting : rotate pattern and rotate
  88851. */
  88852. static readonly FLIP_N_ROTATE_ROW: number;
  88853. /**
  88854. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88855. */
  88856. static readonly CENTER: number;
  88857. /**
  88858. * Mesh tile positioning : part tiles on left
  88859. */
  88860. static readonly LEFT: number;
  88861. /**
  88862. * Mesh tile positioning : part tiles on right
  88863. */
  88864. static readonly RIGHT: number;
  88865. /**
  88866. * Mesh tile positioning : part tiles on top
  88867. */
  88868. static readonly TOP: number;
  88869. /**
  88870. * Mesh tile positioning : part tiles on bottom
  88871. */
  88872. static readonly BOTTOM: number;
  88873. /**
  88874. * Gets the default side orientation.
  88875. * @param orientation the orientation to value to attempt to get
  88876. * @returns the default orientation
  88877. * @hidden
  88878. */
  88879. static _GetDefaultSideOrientation(orientation?: number): number;
  88880. private _internalMeshDataInfo;
  88881. /**
  88882. * An event triggered before rendering the mesh
  88883. */
  88884. readonly onBeforeRenderObservable: Observable<Mesh>;
  88885. /**
  88886. * An event triggered before binding the mesh
  88887. */
  88888. readonly onBeforeBindObservable: Observable<Mesh>;
  88889. /**
  88890. * An event triggered after rendering the mesh
  88891. */
  88892. readonly onAfterRenderObservable: Observable<Mesh>;
  88893. /**
  88894. * An event triggered before drawing the mesh
  88895. */
  88896. readonly onBeforeDrawObservable: Observable<Mesh>;
  88897. private _onBeforeDrawObserver;
  88898. /**
  88899. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88900. */
  88901. onBeforeDraw: () => void;
  88902. readonly hasInstances: boolean;
  88903. /**
  88904. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88905. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88906. */
  88907. delayLoadState: number;
  88908. /**
  88909. * Gets the list of instances created from this mesh
  88910. * it is not supposed to be modified manually.
  88911. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88912. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88913. */
  88914. instances: InstancedMesh[];
  88915. /**
  88916. * Gets the file containing delay loading data for this mesh
  88917. */
  88918. delayLoadingFile: string;
  88919. /** @hidden */
  88920. _binaryInfo: any;
  88921. /**
  88922. * User defined function used to change how LOD level selection is done
  88923. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88924. */
  88925. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88926. /**
  88927. * Gets or sets the morph target manager
  88928. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88929. */
  88930. morphTargetManager: Nullable<MorphTargetManager>;
  88931. /** @hidden */
  88932. _creationDataStorage: Nullable<_CreationDataStorage>;
  88933. /** @hidden */
  88934. _geometry: Nullable<Geometry>;
  88935. /** @hidden */
  88936. _delayInfo: Array<string>;
  88937. /** @hidden */
  88938. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88939. /** @hidden */
  88940. _instanceDataStorage: _InstanceDataStorage;
  88941. private _effectiveMaterial;
  88942. /** @hidden */
  88943. _shouldGenerateFlatShading: boolean;
  88944. /** @hidden */
  88945. _originalBuilderSideOrientation: number;
  88946. /**
  88947. * Use this property to change the original side orientation defined at construction time
  88948. */
  88949. overrideMaterialSideOrientation: Nullable<number>;
  88950. /**
  88951. * Gets the source mesh (the one used to clone this one from)
  88952. */
  88953. readonly source: Nullable<Mesh>;
  88954. /**
  88955. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88956. */
  88957. isUnIndexed: boolean;
  88958. /**
  88959. * @constructor
  88960. * @param name The value used by scene.getMeshByName() to do a lookup.
  88961. * @param scene The scene to add this mesh to.
  88962. * @param parent The parent of this mesh, if it has one
  88963. * @param source An optional Mesh from which geometry is shared, cloned.
  88964. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88965. * When false, achieved by calling a clone(), also passing False.
  88966. * This will make creation of children, recursive.
  88967. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88968. */
  88969. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88970. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88971. /**
  88972. * Gets the class name
  88973. * @returns the string "Mesh".
  88974. */
  88975. getClassName(): string;
  88976. /** @hidden */
  88977. readonly _isMesh: boolean;
  88978. /**
  88979. * Returns a description of this mesh
  88980. * @param fullDetails define if full details about this mesh must be used
  88981. * @returns a descriptive string representing this mesh
  88982. */
  88983. toString(fullDetails?: boolean): string;
  88984. /** @hidden */
  88985. _unBindEffect(): void;
  88986. /**
  88987. * Gets a boolean indicating if this mesh has LOD
  88988. */
  88989. readonly hasLODLevels: boolean;
  88990. /**
  88991. * Gets the list of MeshLODLevel associated with the current mesh
  88992. * @returns an array of MeshLODLevel
  88993. */
  88994. getLODLevels(): MeshLODLevel[];
  88995. private _sortLODLevels;
  88996. /**
  88997. * Add a mesh as LOD level triggered at the given distance.
  88998. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88999. * @param distance The distance from the center of the object to show this level
  89000. * @param mesh The mesh to be added as LOD level (can be null)
  89001. * @return This mesh (for chaining)
  89002. */
  89003. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89004. /**
  89005. * Returns the LOD level mesh at the passed distance or null if not found.
  89006. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89007. * @param distance The distance from the center of the object to show this level
  89008. * @returns a Mesh or `null`
  89009. */
  89010. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89011. /**
  89012. * Remove a mesh from the LOD array
  89013. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89014. * @param mesh defines the mesh to be removed
  89015. * @return This mesh (for chaining)
  89016. */
  89017. removeLODLevel(mesh: Mesh): Mesh;
  89018. /**
  89019. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89020. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89021. * @param camera defines the camera to use to compute distance
  89022. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89023. * @return This mesh (for chaining)
  89024. */
  89025. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89026. /**
  89027. * Gets the mesh internal Geometry object
  89028. */
  89029. readonly geometry: Nullable<Geometry>;
  89030. /**
  89031. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89032. * @returns the total number of vertices
  89033. */
  89034. getTotalVertices(): number;
  89035. /**
  89036. * Returns the content of an associated vertex buffer
  89037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89038. * - VertexBuffer.PositionKind
  89039. * - VertexBuffer.UVKind
  89040. * - VertexBuffer.UV2Kind
  89041. * - VertexBuffer.UV3Kind
  89042. * - VertexBuffer.UV4Kind
  89043. * - VertexBuffer.UV5Kind
  89044. * - VertexBuffer.UV6Kind
  89045. * - VertexBuffer.ColorKind
  89046. * - VertexBuffer.MatricesIndicesKind
  89047. * - VertexBuffer.MatricesIndicesExtraKind
  89048. * - VertexBuffer.MatricesWeightsKind
  89049. * - VertexBuffer.MatricesWeightsExtraKind
  89050. * @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
  89051. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89052. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89053. */
  89054. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89055. /**
  89056. * Returns the mesh VertexBuffer object from the requested `kind`
  89057. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89058. * - VertexBuffer.PositionKind
  89059. * - VertexBuffer.NormalKind
  89060. * - VertexBuffer.UVKind
  89061. * - VertexBuffer.UV2Kind
  89062. * - VertexBuffer.UV3Kind
  89063. * - VertexBuffer.UV4Kind
  89064. * - VertexBuffer.UV5Kind
  89065. * - VertexBuffer.UV6Kind
  89066. * - VertexBuffer.ColorKind
  89067. * - VertexBuffer.MatricesIndicesKind
  89068. * - VertexBuffer.MatricesIndicesExtraKind
  89069. * - VertexBuffer.MatricesWeightsKind
  89070. * - VertexBuffer.MatricesWeightsExtraKind
  89071. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89072. */
  89073. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89074. /**
  89075. * Tests if a specific vertex buffer is associated with this mesh
  89076. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89077. * - VertexBuffer.PositionKind
  89078. * - VertexBuffer.NormalKind
  89079. * - VertexBuffer.UVKind
  89080. * - VertexBuffer.UV2Kind
  89081. * - VertexBuffer.UV3Kind
  89082. * - VertexBuffer.UV4Kind
  89083. * - VertexBuffer.UV5Kind
  89084. * - VertexBuffer.UV6Kind
  89085. * - VertexBuffer.ColorKind
  89086. * - VertexBuffer.MatricesIndicesKind
  89087. * - VertexBuffer.MatricesIndicesExtraKind
  89088. * - VertexBuffer.MatricesWeightsKind
  89089. * - VertexBuffer.MatricesWeightsExtraKind
  89090. * @returns a boolean
  89091. */
  89092. isVerticesDataPresent(kind: string): boolean;
  89093. /**
  89094. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89095. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89096. * - VertexBuffer.PositionKind
  89097. * - VertexBuffer.UVKind
  89098. * - VertexBuffer.UV2Kind
  89099. * - VertexBuffer.UV3Kind
  89100. * - VertexBuffer.UV4Kind
  89101. * - VertexBuffer.UV5Kind
  89102. * - VertexBuffer.UV6Kind
  89103. * - VertexBuffer.ColorKind
  89104. * - VertexBuffer.MatricesIndicesKind
  89105. * - VertexBuffer.MatricesIndicesExtraKind
  89106. * - VertexBuffer.MatricesWeightsKind
  89107. * - VertexBuffer.MatricesWeightsExtraKind
  89108. * @returns a boolean
  89109. */
  89110. isVertexBufferUpdatable(kind: string): boolean;
  89111. /**
  89112. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89113. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89114. * - VertexBuffer.PositionKind
  89115. * - VertexBuffer.NormalKind
  89116. * - VertexBuffer.UVKind
  89117. * - VertexBuffer.UV2Kind
  89118. * - VertexBuffer.UV3Kind
  89119. * - VertexBuffer.UV4Kind
  89120. * - VertexBuffer.UV5Kind
  89121. * - VertexBuffer.UV6Kind
  89122. * - VertexBuffer.ColorKind
  89123. * - VertexBuffer.MatricesIndicesKind
  89124. * - VertexBuffer.MatricesIndicesExtraKind
  89125. * - VertexBuffer.MatricesWeightsKind
  89126. * - VertexBuffer.MatricesWeightsExtraKind
  89127. * @returns an array of strings
  89128. */
  89129. getVerticesDataKinds(): string[];
  89130. /**
  89131. * Returns a positive integer : the total number of indices in this mesh geometry.
  89132. * @returns the numner of indices or zero if the mesh has no geometry.
  89133. */
  89134. getTotalIndices(): number;
  89135. /**
  89136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89137. * @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.
  89138. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89139. * @returns the indices array or an empty array if the mesh has no geometry
  89140. */
  89141. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89142. readonly isBlocked: boolean;
  89143. /**
  89144. * Determine if the current mesh is ready to be rendered
  89145. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89146. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89147. * @returns true if all associated assets are ready (material, textures, shaders)
  89148. */
  89149. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89150. /**
  89151. * 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.
  89152. */
  89153. readonly areNormalsFrozen: boolean;
  89154. /**
  89155. * 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.
  89156. * @returns the current mesh
  89157. */
  89158. freezeNormals(): Mesh;
  89159. /**
  89160. * 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
  89161. * @returns the current mesh
  89162. */
  89163. unfreezeNormals(): Mesh;
  89164. /**
  89165. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89166. */
  89167. overridenInstanceCount: number;
  89168. /** @hidden */
  89169. _preActivate(): Mesh;
  89170. /** @hidden */
  89171. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89172. /** @hidden */
  89173. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89174. /**
  89175. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89176. * This means the mesh underlying bounding box and sphere are recomputed.
  89177. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89178. * @returns the current mesh
  89179. */
  89180. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89181. /** @hidden */
  89182. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89183. /**
  89184. * This function will subdivide the mesh into multiple submeshes
  89185. * @param count defines the expected number of submeshes
  89186. */
  89187. subdivide(count: number): void;
  89188. /**
  89189. * Copy a FloatArray into a specific associated vertex buffer
  89190. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89191. * - VertexBuffer.PositionKind
  89192. * - VertexBuffer.UVKind
  89193. * - VertexBuffer.UV2Kind
  89194. * - VertexBuffer.UV3Kind
  89195. * - VertexBuffer.UV4Kind
  89196. * - VertexBuffer.UV5Kind
  89197. * - VertexBuffer.UV6Kind
  89198. * - VertexBuffer.ColorKind
  89199. * - VertexBuffer.MatricesIndicesKind
  89200. * - VertexBuffer.MatricesIndicesExtraKind
  89201. * - VertexBuffer.MatricesWeightsKind
  89202. * - VertexBuffer.MatricesWeightsExtraKind
  89203. * @param data defines the data source
  89204. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89205. * @param stride defines the data stride size (can be null)
  89206. * @returns the current mesh
  89207. */
  89208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89209. /**
  89210. * Flags an associated vertex buffer as updatable
  89211. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89212. * - VertexBuffer.PositionKind
  89213. * - VertexBuffer.UVKind
  89214. * - VertexBuffer.UV2Kind
  89215. * - VertexBuffer.UV3Kind
  89216. * - VertexBuffer.UV4Kind
  89217. * - VertexBuffer.UV5Kind
  89218. * - VertexBuffer.UV6Kind
  89219. * - VertexBuffer.ColorKind
  89220. * - VertexBuffer.MatricesIndicesKind
  89221. * - VertexBuffer.MatricesIndicesExtraKind
  89222. * - VertexBuffer.MatricesWeightsKind
  89223. * - VertexBuffer.MatricesWeightsExtraKind
  89224. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89225. */
  89226. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89227. /**
  89228. * Sets the mesh global Vertex Buffer
  89229. * @param buffer defines the buffer to use
  89230. * @returns the current mesh
  89231. */
  89232. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89233. /**
  89234. * Update a specific associated vertex buffer
  89235. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89236. * - VertexBuffer.PositionKind
  89237. * - VertexBuffer.UVKind
  89238. * - VertexBuffer.UV2Kind
  89239. * - VertexBuffer.UV3Kind
  89240. * - VertexBuffer.UV4Kind
  89241. * - VertexBuffer.UV5Kind
  89242. * - VertexBuffer.UV6Kind
  89243. * - VertexBuffer.ColorKind
  89244. * - VertexBuffer.MatricesIndicesKind
  89245. * - VertexBuffer.MatricesIndicesExtraKind
  89246. * - VertexBuffer.MatricesWeightsKind
  89247. * - VertexBuffer.MatricesWeightsExtraKind
  89248. * @param data defines the data source
  89249. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89250. * @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)
  89251. * @returns the current mesh
  89252. */
  89253. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89254. /**
  89255. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89256. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89257. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89258. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89259. * @returns the current mesh
  89260. */
  89261. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89262. /**
  89263. * Creates a un-shared specific occurence of the geometry for the mesh.
  89264. * @returns the current mesh
  89265. */
  89266. makeGeometryUnique(): Mesh;
  89267. /**
  89268. * Set the index buffer of this mesh
  89269. * @param indices defines the source data
  89270. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89271. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89272. * @returns the current mesh
  89273. */
  89274. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89275. /**
  89276. * Update the current index buffer
  89277. * @param indices defines the source data
  89278. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89279. * @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)
  89280. * @returns the current mesh
  89281. */
  89282. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89283. /**
  89284. * Invert the geometry to move from a right handed system to a left handed one.
  89285. * @returns the current mesh
  89286. */
  89287. toLeftHanded(): Mesh;
  89288. /** @hidden */
  89289. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89290. /** @hidden */
  89291. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89292. /**
  89293. * Registers for this mesh a javascript function called just before the rendering process
  89294. * @param func defines the function to call before rendering this mesh
  89295. * @returns the current mesh
  89296. */
  89297. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89298. /**
  89299. * Disposes a previously registered javascript function called before the rendering
  89300. * @param func defines the function to remove
  89301. * @returns the current mesh
  89302. */
  89303. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89304. /**
  89305. * Registers for this mesh a javascript function called just after the rendering is complete
  89306. * @param func defines the function to call after rendering this mesh
  89307. * @returns the current mesh
  89308. */
  89309. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89310. /**
  89311. * Disposes a previously registered javascript function called after the rendering.
  89312. * @param func defines the function to remove
  89313. * @returns the current mesh
  89314. */
  89315. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89316. /** @hidden */
  89317. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89318. /** @hidden */
  89319. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89320. /** @hidden */
  89321. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89322. /** @hidden */
  89323. _rebuild(): void;
  89324. /** @hidden */
  89325. _freeze(): void;
  89326. /** @hidden */
  89327. _unFreeze(): void;
  89328. /**
  89329. * 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
  89330. * @param subMesh defines the subMesh to render
  89331. * @param enableAlphaMode defines if alpha mode can be changed
  89332. * @returns the current mesh
  89333. */
  89334. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89335. private _onBeforeDraw;
  89336. /**
  89337. * Renormalize the mesh and patch it up if there are no weights
  89338. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89339. * However in the case of zero weights then we set just a single influence to 1.
  89340. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89341. */
  89342. cleanMatrixWeights(): void;
  89343. private normalizeSkinFourWeights;
  89344. private normalizeSkinWeightsAndExtra;
  89345. /**
  89346. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89347. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89348. * the user know there was an issue with importing the mesh
  89349. * @returns a validation object with skinned, valid and report string
  89350. */
  89351. validateSkinning(): {
  89352. skinned: boolean;
  89353. valid: boolean;
  89354. report: string;
  89355. };
  89356. /** @hidden */
  89357. _checkDelayState(): Mesh;
  89358. private _queueLoad;
  89359. /**
  89360. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89361. * A mesh is in the frustum if its bounding box intersects the frustum
  89362. * @param frustumPlanes defines the frustum to test
  89363. * @returns true if the mesh is in the frustum planes
  89364. */
  89365. isInFrustum(frustumPlanes: Plane[]): boolean;
  89366. /**
  89367. * Sets the mesh material by the material or multiMaterial `id` property
  89368. * @param id is a string identifying the material or the multiMaterial
  89369. * @returns the current mesh
  89370. */
  89371. setMaterialByID(id: string): Mesh;
  89372. /**
  89373. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89374. * @returns an array of IAnimatable
  89375. */
  89376. getAnimatables(): IAnimatable[];
  89377. /**
  89378. * Modifies the mesh geometry according to the passed transformation matrix.
  89379. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89380. * The mesh normals are modified using the same transformation.
  89381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89382. * @param transform defines the transform matrix to use
  89383. * @see http://doc.babylonjs.com/resources/baking_transformations
  89384. * @returns the current mesh
  89385. */
  89386. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89387. /**
  89388. * Modifies the mesh geometry according to its own current World Matrix.
  89389. * The mesh World Matrix is then reset.
  89390. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89391. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89392. * @see http://doc.babylonjs.com/resources/baking_transformations
  89393. * @returns the current mesh
  89394. */
  89395. bakeCurrentTransformIntoVertices(): Mesh;
  89396. /** @hidden */
  89397. readonly _positions: Nullable<Vector3[]>;
  89398. /** @hidden */
  89399. _resetPointsArrayCache(): Mesh;
  89400. /** @hidden */
  89401. _generatePointsArray(): boolean;
  89402. /**
  89403. * Returns a new Mesh object generated from the current mesh properties.
  89404. * This method must not get confused with createInstance()
  89405. * @param name is a string, the name given to the new mesh
  89406. * @param newParent can be any Node object (default `null`)
  89407. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89408. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89409. * @returns a new mesh
  89410. */
  89411. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89412. /**
  89413. * Releases resources associated with this mesh.
  89414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89416. */
  89417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89418. /**
  89419. * Modifies the mesh geometry according to a displacement map.
  89420. * 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.
  89421. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89422. * @param url is a string, the URL from the image file is to be downloaded.
  89423. * @param minHeight is the lower limit of the displacement.
  89424. * @param maxHeight is the upper limit of the displacement.
  89425. * @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.
  89426. * @param uvOffset is an optional vector2 used to offset UV.
  89427. * @param uvScale is an optional vector2 used to scale UV.
  89428. * @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.
  89429. * @returns the Mesh.
  89430. */
  89431. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89432. /**
  89433. * Modifies the mesh geometry according to a displacementMap buffer.
  89434. * 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.
  89435. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89436. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89437. * @param heightMapWidth is the width of the buffer image.
  89438. * @param heightMapHeight is the height of the buffer image.
  89439. * @param minHeight is the lower limit of the displacement.
  89440. * @param maxHeight is the upper limit of the displacement.
  89441. * @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.
  89442. * @param uvOffset is an optional vector2 used to offset UV.
  89443. * @param uvScale is an optional vector2 used to scale UV.
  89444. * @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.
  89445. * @returns the Mesh.
  89446. */
  89447. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89448. /**
  89449. * Modify the mesh to get a flat shading rendering.
  89450. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89451. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89452. * @returns current mesh
  89453. */
  89454. convertToFlatShadedMesh(): Mesh;
  89455. /**
  89456. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89457. * In other words, more vertices, no more indices and a single bigger VBO.
  89458. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89459. * @returns current mesh
  89460. */
  89461. convertToUnIndexedMesh(): Mesh;
  89462. /**
  89463. * Inverses facet orientations.
  89464. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89465. * @param flipNormals will also inverts the normals
  89466. * @returns current mesh
  89467. */
  89468. flipFaces(flipNormals?: boolean): Mesh;
  89469. /**
  89470. * Increase the number of facets and hence vertices in a mesh
  89471. * Vertex normals are interpolated from existing vertex normals
  89472. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89473. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89474. */
  89475. increaseVertices(numberPerEdge: number): void;
  89476. /**
  89477. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89478. * This will undo any application of covertToFlatShadedMesh
  89479. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89480. */
  89481. forceSharedVertices(): void;
  89482. /** @hidden */
  89483. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89484. /** @hidden */
  89485. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89486. /**
  89487. * Creates a new InstancedMesh object from the mesh model.
  89488. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89489. * @param name defines the name of the new instance
  89490. * @returns a new InstancedMesh
  89491. */
  89492. createInstance(name: string): InstancedMesh;
  89493. /**
  89494. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89495. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89496. * @returns the current mesh
  89497. */
  89498. synchronizeInstances(): Mesh;
  89499. /**
  89500. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89501. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89502. * This should be used together with the simplification to avoid disappearing triangles.
  89503. * @param successCallback an optional success callback to be called after the optimization finished.
  89504. * @returns the current mesh
  89505. */
  89506. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89507. /**
  89508. * Serialize current mesh
  89509. * @param serializationObject defines the object which will receive the serialization data
  89510. */
  89511. serialize(serializationObject: any): void;
  89512. /** @hidden */
  89513. _syncGeometryWithMorphTargetManager(): void;
  89514. /** @hidden */
  89515. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89516. /**
  89517. * Returns a new Mesh object parsed from the source provided.
  89518. * @param parsedMesh is the source
  89519. * @param scene defines the hosting scene
  89520. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89521. * @returns a new Mesh
  89522. */
  89523. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89524. /**
  89525. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89526. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89527. * @param name defines the name of the mesh to create
  89528. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89529. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89530. * @param closePath creates a seam between the first and the last points of each path of the path array
  89531. * @param offset is taken in account only if the `pathArray` is containing a single path
  89532. * @param scene defines the hosting scene
  89533. * @param updatable defines if the mesh must be flagged as updatable
  89534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89535. * @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)
  89536. * @returns a new Mesh
  89537. */
  89538. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89539. /**
  89540. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89541. * @param name defines the name of the mesh to create
  89542. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89543. * @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
  89544. * @param scene defines the hosting scene
  89545. * @param updatable defines if the mesh must be flagged as updatable
  89546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89547. * @returns a new Mesh
  89548. */
  89549. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89550. /**
  89551. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89552. * @param name defines the name of the mesh to create
  89553. * @param size sets the size (float) of each box side (default 1)
  89554. * @param scene defines the hosting scene
  89555. * @param updatable defines if the mesh must be flagged as updatable
  89556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89557. * @returns a new Mesh
  89558. */
  89559. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89560. /**
  89561. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89562. * @param name defines the name of the mesh to create
  89563. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89564. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89565. * @param scene defines the hosting scene
  89566. * @param updatable defines if the mesh must be flagged as updatable
  89567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89568. * @returns a new Mesh
  89569. */
  89570. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89571. /**
  89572. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89573. * @param name defines the name of the mesh to create
  89574. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89575. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89576. * @param scene defines the hosting scene
  89577. * @returns a new Mesh
  89578. */
  89579. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89580. /**
  89581. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89582. * @param name defines the name of the mesh to create
  89583. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89584. * @param diameterTop set the top cap diameter (floats, default 1)
  89585. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89586. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89587. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89588. * @param scene defines the hosting scene
  89589. * @param updatable defines if the mesh must be flagged as updatable
  89590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89591. * @returns a new Mesh
  89592. */
  89593. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89594. /**
  89595. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89596. * @param name defines the name of the mesh to create
  89597. * @param diameter sets the diameter size (float) of the torus (default 1)
  89598. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89599. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89600. * @param scene defines the hosting scene
  89601. * @param updatable defines if the mesh must be flagged as updatable
  89602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89603. * @returns a new Mesh
  89604. */
  89605. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89606. /**
  89607. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89608. * @param name defines the name of the mesh to create
  89609. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89610. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89611. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89612. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89613. * @param p the number of windings on X axis (positive integers, default 2)
  89614. * @param q the number of windings on Y axis (positive integers, default 3)
  89615. * @param scene defines the hosting scene
  89616. * @param updatable defines if the mesh must be flagged as updatable
  89617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89618. * @returns a new Mesh
  89619. */
  89620. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89621. /**
  89622. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89623. * @param name defines the name of the mesh to create
  89624. * @param points is an array successive Vector3
  89625. * @param scene defines the hosting scene
  89626. * @param updatable defines if the mesh must be flagged as updatable
  89627. * @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).
  89628. * @returns a new Mesh
  89629. */
  89630. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89631. /**
  89632. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89633. * @param name defines the name of the mesh to create
  89634. * @param points is an array successive Vector3
  89635. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89636. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89637. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89638. * @param scene defines the hosting scene
  89639. * @param updatable defines if the mesh must be flagged as updatable
  89640. * @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)
  89641. * @returns a new Mesh
  89642. */
  89643. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89644. /**
  89645. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89646. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89647. * 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.
  89648. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89649. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89650. * Remember you can only change the shape positions, not their number when updating a polygon.
  89651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89652. * @param name defines the name of the mesh to create
  89653. * @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
  89654. * @param scene defines the hosting scene
  89655. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89656. * @param updatable defines if the mesh must be flagged as updatable
  89657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89658. * @param earcutInjection can be used to inject your own earcut reference
  89659. * @returns a new Mesh
  89660. */
  89661. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89662. /**
  89663. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89664. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89665. * @param name defines the name of the mesh to create
  89666. * @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
  89667. * @param depth defines the height of extrusion
  89668. * @param scene defines the hosting scene
  89669. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89670. * @param updatable defines if the mesh must be flagged as updatable
  89671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89672. * @param earcutInjection can be used to inject your own earcut reference
  89673. * @returns a new Mesh
  89674. */
  89675. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89676. /**
  89677. * Creates an extruded shape mesh.
  89678. * 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
  89679. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89680. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89681. * @param name defines the name of the mesh to create
  89682. * @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
  89683. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89684. * @param scale is the value to scale the shape
  89685. * @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
  89686. * @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
  89687. * @param scene defines the hosting scene
  89688. * @param updatable defines if the mesh must be flagged as updatable
  89689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89690. * @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)
  89691. * @returns a new Mesh
  89692. */
  89693. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89694. /**
  89695. * Creates an custom extruded shape mesh.
  89696. * The custom extrusion is a parametric shape.
  89697. * It has no predefined shape. Its final shape will depend on the input parameters.
  89698. * Please consider using the same method from the MeshBuilder class instead
  89699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89700. * @param name defines the name of the mesh to create
  89701. * @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
  89702. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89703. * @param scaleFunction is a custom Javascript function called on each path point
  89704. * @param rotationFunction is a custom Javascript function called on each path point
  89705. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89706. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89707. * @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
  89708. * @param scene defines the hosting scene
  89709. * @param updatable defines if the mesh must be flagged as updatable
  89710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89711. * @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)
  89712. * @returns a new Mesh
  89713. */
  89714. 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;
  89715. /**
  89716. * Creates lathe mesh.
  89717. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89718. * Please consider using the same method from the MeshBuilder class instead
  89719. * @param name defines the name of the mesh to create
  89720. * @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
  89721. * @param radius is the radius value of the lathe
  89722. * @param tessellation is the side number of the lathe.
  89723. * @param scene defines the hosting scene
  89724. * @param updatable defines if the mesh must be flagged as updatable
  89725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89726. * @returns a new Mesh
  89727. */
  89728. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89729. /**
  89730. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89731. * @param name defines the name of the mesh to create
  89732. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89733. * @param scene defines the hosting scene
  89734. * @param updatable defines if the mesh must be flagged as updatable
  89735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89736. * @returns a new Mesh
  89737. */
  89738. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89739. /**
  89740. * Creates a ground mesh.
  89741. * Please consider using the same method from the MeshBuilder class instead
  89742. * @param name defines the name of the mesh to create
  89743. * @param width set the width of the ground
  89744. * @param height set the height of the ground
  89745. * @param subdivisions sets the number of subdivisions per side
  89746. * @param scene defines the hosting scene
  89747. * @param updatable defines if the mesh must be flagged as updatable
  89748. * @returns a new Mesh
  89749. */
  89750. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89751. /**
  89752. * Creates a tiled ground mesh.
  89753. * Please consider using the same method from the MeshBuilder class instead
  89754. * @param name defines the name of the mesh to create
  89755. * @param xmin set the ground minimum X coordinate
  89756. * @param zmin set the ground minimum Y coordinate
  89757. * @param xmax set the ground maximum X coordinate
  89758. * @param zmax set the ground maximum Z coordinate
  89759. * @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
  89760. * @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
  89761. * @param scene defines the hosting scene
  89762. * @param updatable defines if the mesh must be flagged as updatable
  89763. * @returns a new Mesh
  89764. */
  89765. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89766. w: number;
  89767. h: number;
  89768. }, precision: {
  89769. w: number;
  89770. h: number;
  89771. }, scene: Scene, updatable?: boolean): Mesh;
  89772. /**
  89773. * Creates a ground mesh from a height map.
  89774. * Please consider using the same method from the MeshBuilder class instead
  89775. * @see http://doc.babylonjs.com/babylon101/height_map
  89776. * @param name defines the name of the mesh to create
  89777. * @param url sets the URL of the height map image resource
  89778. * @param width set the ground width size
  89779. * @param height set the ground height size
  89780. * @param subdivisions sets the number of subdivision per side
  89781. * @param minHeight is the minimum altitude on the ground
  89782. * @param maxHeight is the maximum altitude on the ground
  89783. * @param scene defines the hosting scene
  89784. * @param updatable defines if the mesh must be flagged as updatable
  89785. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89786. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89787. * @returns a new Mesh
  89788. */
  89789. 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;
  89790. /**
  89791. * Creates a tube mesh.
  89792. * The tube is a parametric shape.
  89793. * It has no predefined shape. Its final shape will depend on the input parameters.
  89794. * Please consider using the same method from the MeshBuilder class instead
  89795. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89796. * @param name defines the name of the mesh to create
  89797. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89798. * @param radius sets the tube radius size
  89799. * @param tessellation is the number of sides on the tubular surface
  89800. * @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
  89801. * @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
  89802. * @param scene defines the hosting scene
  89803. * @param updatable defines if the mesh must be flagged as updatable
  89804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89805. * @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)
  89806. * @returns a new Mesh
  89807. */
  89808. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89809. (i: number, distance: number): number;
  89810. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89811. /**
  89812. * Creates a polyhedron mesh.
  89813. * Please consider using the same method from the MeshBuilder class instead.
  89814. * * 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
  89815. * * The parameter `size` (positive float, default 1) sets the polygon size
  89816. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89817. * * 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`
  89818. * * 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
  89819. * * 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)`)
  89820. * * 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
  89821. * * 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
  89822. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89823. * * If you create a double-sided mesh, you can choose what parts of 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
  89824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89825. * @param name defines the name of the mesh to create
  89826. * @param options defines the options used to create the mesh
  89827. * @param scene defines the hosting scene
  89828. * @returns a new Mesh
  89829. */
  89830. static CreatePolyhedron(name: string, options: {
  89831. type?: number;
  89832. size?: number;
  89833. sizeX?: number;
  89834. sizeY?: number;
  89835. sizeZ?: number;
  89836. custom?: any;
  89837. faceUV?: Vector4[];
  89838. faceColors?: Color4[];
  89839. updatable?: boolean;
  89840. sideOrientation?: number;
  89841. }, scene: Scene): Mesh;
  89842. /**
  89843. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89844. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89845. * * 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`)
  89846. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89847. * * 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
  89848. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89849. * * If you create a double-sided mesh, you can choose what parts of 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
  89850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89851. * @param name defines the name of the mesh
  89852. * @param options defines the options used to create the mesh
  89853. * @param scene defines the hosting scene
  89854. * @returns a new Mesh
  89855. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89856. */
  89857. static CreateIcoSphere(name: string, options: {
  89858. radius?: number;
  89859. flat?: boolean;
  89860. subdivisions?: number;
  89861. sideOrientation?: number;
  89862. updatable?: boolean;
  89863. }, scene: Scene): Mesh;
  89864. /**
  89865. * Creates a decal mesh.
  89866. * Please consider using the same method from the MeshBuilder class instead.
  89867. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89868. * @param name defines the name of the mesh
  89869. * @param sourceMesh defines the mesh receiving the decal
  89870. * @param position sets the position of the decal in world coordinates
  89871. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89872. * @param size sets the decal scaling
  89873. * @param angle sets the angle to rotate the decal
  89874. * @returns a new Mesh
  89875. */
  89876. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89877. /**
  89878. * Prepare internal position array for software CPU skinning
  89879. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89880. */
  89881. setPositionsForCPUSkinning(): Float32Array;
  89882. /**
  89883. * Prepare internal normal array for software CPU skinning
  89884. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89885. */
  89886. setNormalsForCPUSkinning(): Float32Array;
  89887. /**
  89888. * Updates the vertex buffer by applying transformation from the bones
  89889. * @param skeleton defines the skeleton to apply to current mesh
  89890. * @returns the current mesh
  89891. */
  89892. applySkeleton(skeleton: Skeleton): Mesh;
  89893. /**
  89894. * 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
  89895. * @param meshes defines the list of meshes to scan
  89896. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89897. */
  89898. static MinMax(meshes: AbstractMesh[]): {
  89899. min: Vector3;
  89900. max: Vector3;
  89901. };
  89902. /**
  89903. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89904. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89905. * @returns a vector3
  89906. */
  89907. static Center(meshesOrMinMaxVector: {
  89908. min: Vector3;
  89909. max: Vector3;
  89910. } | AbstractMesh[]): Vector3;
  89911. /**
  89912. * Merge the array of meshes into a single mesh for performance reasons.
  89913. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89914. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89915. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89916. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89917. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89918. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89919. * @returns a new mesh
  89920. */
  89921. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89922. /** @hidden */
  89923. addInstance(instance: InstancedMesh): void;
  89924. /** @hidden */
  89925. removeInstance(instance: InstancedMesh): void;
  89926. }
  89927. }
  89928. declare module BABYLON {
  89929. /**
  89930. * This is the base class of all the camera used in the application.
  89931. * @see http://doc.babylonjs.com/features/cameras
  89932. */
  89933. export class Camera extends Node {
  89934. /** @hidden */
  89935. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89936. /**
  89937. * This is the default projection mode used by the cameras.
  89938. * It helps recreating a feeling of perspective and better appreciate depth.
  89939. * This is the best way to simulate real life cameras.
  89940. */
  89941. static readonly PERSPECTIVE_CAMERA: number;
  89942. /**
  89943. * This helps creating camera with an orthographic mode.
  89944. * 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.
  89945. */
  89946. static readonly ORTHOGRAPHIC_CAMERA: number;
  89947. /**
  89948. * This is the default FOV mode for perspective cameras.
  89949. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89950. */
  89951. static readonly FOVMODE_VERTICAL_FIXED: number;
  89952. /**
  89953. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89954. */
  89955. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89956. /**
  89957. * This specifies ther is no need for a camera rig.
  89958. * Basically only one eye is rendered corresponding to the camera.
  89959. */
  89960. static readonly RIG_MODE_NONE: number;
  89961. /**
  89962. * Simulates a camera Rig with one blue eye and one red eye.
  89963. * This can be use with 3d blue and red glasses.
  89964. */
  89965. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89966. /**
  89967. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89968. */
  89969. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89970. /**
  89971. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89972. */
  89973. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89974. /**
  89975. * Defines that both eyes of the camera will be rendered over under each other.
  89976. */
  89977. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89978. /**
  89979. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89980. */
  89981. static readonly RIG_MODE_VR: number;
  89982. /**
  89983. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89984. */
  89985. static readonly RIG_MODE_WEBVR: number;
  89986. /**
  89987. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89988. */
  89989. static readonly RIG_MODE_CUSTOM: number;
  89990. /**
  89991. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89992. */
  89993. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89994. /**
  89995. * Define the input manager associated with the camera.
  89996. */
  89997. inputs: CameraInputsManager<Camera>;
  89998. /** @hidden */
  89999. _position: Vector3;
  90000. /**
  90001. * Define the current local position of the camera in the scene
  90002. */
  90003. position: Vector3;
  90004. /**
  90005. * The vector the camera should consider as up.
  90006. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90007. */
  90008. upVector: Vector3;
  90009. /**
  90010. * Define the current limit on the left side for an orthographic camera
  90011. * In scene unit
  90012. */
  90013. orthoLeft: Nullable<number>;
  90014. /**
  90015. * Define the current limit on the right side for an orthographic camera
  90016. * In scene unit
  90017. */
  90018. orthoRight: Nullable<number>;
  90019. /**
  90020. * Define the current limit on the bottom side for an orthographic camera
  90021. * In scene unit
  90022. */
  90023. orthoBottom: Nullable<number>;
  90024. /**
  90025. * Define the current limit on the top side for an orthographic camera
  90026. * In scene unit
  90027. */
  90028. orthoTop: Nullable<number>;
  90029. /**
  90030. * Field Of View is set in Radians. (default is 0.8)
  90031. */
  90032. fov: number;
  90033. /**
  90034. * Define the minimum distance the camera can see from.
  90035. * This is important to note that the depth buffer are not infinite and the closer it starts
  90036. * the more your scene might encounter depth fighting issue.
  90037. */
  90038. minZ: number;
  90039. /**
  90040. * Define the maximum distance the camera can see to.
  90041. * This is important to note that the depth buffer are not infinite and the further it end
  90042. * the more your scene might encounter depth fighting issue.
  90043. */
  90044. maxZ: number;
  90045. /**
  90046. * Define the default inertia of the camera.
  90047. * This helps giving a smooth feeling to the camera movement.
  90048. */
  90049. inertia: number;
  90050. /**
  90051. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90052. */
  90053. mode: number;
  90054. /**
  90055. * Define wether the camera is intermediate.
  90056. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90057. */
  90058. isIntermediate: boolean;
  90059. /**
  90060. * Define the viewport of the camera.
  90061. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90062. */
  90063. viewport: Viewport;
  90064. /**
  90065. * Restricts the camera to viewing objects with the same layerMask.
  90066. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90067. */
  90068. layerMask: number;
  90069. /**
  90070. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90071. */
  90072. fovMode: number;
  90073. /**
  90074. * Rig mode of the camera.
  90075. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90076. * This is normally controlled byt the camera themselves as internal use.
  90077. */
  90078. cameraRigMode: number;
  90079. /**
  90080. * Defines the distance between both "eyes" in case of a RIG
  90081. */
  90082. interaxialDistance: number;
  90083. /**
  90084. * Defines if stereoscopic rendering is done side by side or over under.
  90085. */
  90086. isStereoscopicSideBySide: boolean;
  90087. /**
  90088. * 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
  90089. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90090. * else in the scene. (Eg. security camera)
  90091. *
  90092. * 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)
  90093. */
  90094. customRenderTargets: RenderTargetTexture[];
  90095. /**
  90096. * When set, the camera will render to this render target instead of the default canvas
  90097. *
  90098. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90099. */
  90100. outputRenderTarget: Nullable<RenderTargetTexture>;
  90101. /**
  90102. * Observable triggered when the camera view matrix has changed.
  90103. */
  90104. onViewMatrixChangedObservable: Observable<Camera>;
  90105. /**
  90106. * Observable triggered when the camera Projection matrix has changed.
  90107. */
  90108. onProjectionMatrixChangedObservable: Observable<Camera>;
  90109. /**
  90110. * Observable triggered when the inputs have been processed.
  90111. */
  90112. onAfterCheckInputsObservable: Observable<Camera>;
  90113. /**
  90114. * Observable triggered when reset has been called and applied to the camera.
  90115. */
  90116. onRestoreStateObservable: Observable<Camera>;
  90117. /** @hidden */
  90118. _cameraRigParams: any;
  90119. /** @hidden */
  90120. _rigCameras: Camera[];
  90121. /** @hidden */
  90122. _rigPostProcess: Nullable<PostProcess>;
  90123. protected _webvrViewMatrix: Matrix;
  90124. /** @hidden */
  90125. _skipRendering: boolean;
  90126. /** @hidden */
  90127. _projectionMatrix: Matrix;
  90128. /** @hidden */
  90129. _postProcesses: Nullable<PostProcess>[];
  90130. /** @hidden */
  90131. _activeMeshes: SmartArray<AbstractMesh>;
  90132. protected _globalPosition: Vector3;
  90133. /** @hidden */
  90134. _computedViewMatrix: Matrix;
  90135. private _doNotComputeProjectionMatrix;
  90136. private _transformMatrix;
  90137. private _frustumPlanes;
  90138. private _refreshFrustumPlanes;
  90139. private _storedFov;
  90140. private _stateStored;
  90141. /**
  90142. * Instantiates a new camera object.
  90143. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90144. * @see http://doc.babylonjs.com/features/cameras
  90145. * @param name Defines the name of the camera in the scene
  90146. * @param position Defines the position of the camera
  90147. * @param scene Defines the scene the camera belongs too
  90148. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90149. */
  90150. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90151. /**
  90152. * Store current camera state (fov, position, etc..)
  90153. * @returns the camera
  90154. */
  90155. storeState(): Camera;
  90156. /**
  90157. * Restores the camera state values if it has been stored. You must call storeState() first
  90158. */
  90159. protected _restoreStateValues(): boolean;
  90160. /**
  90161. * Restored camera state. You must call storeState() first.
  90162. * @returns true if restored and false otherwise
  90163. */
  90164. restoreState(): boolean;
  90165. /**
  90166. * Gets the class name of the camera.
  90167. * @returns the class name
  90168. */
  90169. getClassName(): string;
  90170. /** @hidden */
  90171. readonly _isCamera: boolean;
  90172. /**
  90173. * Gets a string representation of the camera useful for debug purpose.
  90174. * @param fullDetails Defines that a more verboe level of logging is required
  90175. * @returns the string representation
  90176. */
  90177. toString(fullDetails?: boolean): string;
  90178. /**
  90179. * Gets the current world space position of the camera.
  90180. */
  90181. readonly globalPosition: Vector3;
  90182. /**
  90183. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90184. * @returns the active meshe list
  90185. */
  90186. getActiveMeshes(): SmartArray<AbstractMesh>;
  90187. /**
  90188. * Check wether a mesh is part of the current active mesh list of the camera
  90189. * @param mesh Defines the mesh to check
  90190. * @returns true if active, false otherwise
  90191. */
  90192. isActiveMesh(mesh: Mesh): boolean;
  90193. /**
  90194. * Is this camera ready to be used/rendered
  90195. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90196. * @return true if the camera is ready
  90197. */
  90198. isReady(completeCheck?: boolean): boolean;
  90199. /** @hidden */
  90200. _initCache(): void;
  90201. /** @hidden */
  90202. _updateCache(ignoreParentClass?: boolean): void;
  90203. /** @hidden */
  90204. _isSynchronized(): boolean;
  90205. /** @hidden */
  90206. _isSynchronizedViewMatrix(): boolean;
  90207. /** @hidden */
  90208. _isSynchronizedProjectionMatrix(): boolean;
  90209. /**
  90210. * Attach the input controls to a specific dom element to get the input from.
  90211. * @param element Defines the element the controls should be listened from
  90212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90213. */
  90214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90215. /**
  90216. * Detach the current controls from the specified dom element.
  90217. * @param element Defines the element to stop listening the inputs from
  90218. */
  90219. detachControl(element: HTMLElement): void;
  90220. /**
  90221. * Update the camera state according to the different inputs gathered during the frame.
  90222. */
  90223. update(): void;
  90224. /** @hidden */
  90225. _checkInputs(): void;
  90226. /** @hidden */
  90227. readonly rigCameras: Camera[];
  90228. /**
  90229. * Gets the post process used by the rig cameras
  90230. */
  90231. readonly rigPostProcess: Nullable<PostProcess>;
  90232. /**
  90233. * Internal, gets the first post proces.
  90234. * @returns the first post process to be run on this camera.
  90235. */
  90236. _getFirstPostProcess(): Nullable<PostProcess>;
  90237. private _cascadePostProcessesToRigCams;
  90238. /**
  90239. * Attach a post process to the camera.
  90240. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90241. * @param postProcess The post process to attach to the camera
  90242. * @param insertAt The position of the post process in case several of them are in use in the scene
  90243. * @returns the position the post process has been inserted at
  90244. */
  90245. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90246. /**
  90247. * Detach a post process to the camera.
  90248. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90249. * @param postProcess The post process to detach from the camera
  90250. */
  90251. detachPostProcess(postProcess: PostProcess): void;
  90252. /**
  90253. * Gets the current world matrix of the camera
  90254. */
  90255. getWorldMatrix(): Matrix;
  90256. /** @hidden */
  90257. _getViewMatrix(): Matrix;
  90258. /**
  90259. * Gets the current view matrix of the camera.
  90260. * @param force forces the camera to recompute the matrix without looking at the cached state
  90261. * @returns the view matrix
  90262. */
  90263. getViewMatrix(force?: boolean): Matrix;
  90264. /**
  90265. * Freeze the projection matrix.
  90266. * It will prevent the cache check of the camera projection compute and can speed up perf
  90267. * if no parameter of the camera are meant to change
  90268. * @param projection Defines manually a projection if necessary
  90269. */
  90270. freezeProjectionMatrix(projection?: Matrix): void;
  90271. /**
  90272. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90273. */
  90274. unfreezeProjectionMatrix(): void;
  90275. /**
  90276. * Gets the current projection matrix of the camera.
  90277. * @param force forces the camera to recompute the matrix without looking at the cached state
  90278. * @returns the projection matrix
  90279. */
  90280. getProjectionMatrix(force?: boolean): Matrix;
  90281. /**
  90282. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90283. * @returns a Matrix
  90284. */
  90285. getTransformationMatrix(): Matrix;
  90286. private _updateFrustumPlanes;
  90287. /**
  90288. * Checks if a cullable object (mesh...) is in the camera frustum
  90289. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90290. * @param target The object to check
  90291. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90292. * @returns true if the object is in frustum otherwise false
  90293. */
  90294. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90295. /**
  90296. * Checks if a cullable object (mesh...) is in the camera frustum
  90297. * Unlike isInFrustum this cheks the full bounding box
  90298. * @param target The object to check
  90299. * @returns true if the object is in frustum otherwise false
  90300. */
  90301. isCompletelyInFrustum(target: ICullable): boolean;
  90302. /**
  90303. * Gets a ray in the forward direction from the camera.
  90304. * @param length Defines the length of the ray to create
  90305. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90306. * @param origin Defines the start point of the ray which defaults to the camera position
  90307. * @returns the forward ray
  90308. */
  90309. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90310. /**
  90311. * Releases resources associated with this node.
  90312. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90313. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90314. */
  90315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90316. /** @hidden */
  90317. _isLeftCamera: boolean;
  90318. /**
  90319. * Gets the left camera of a rig setup in case of Rigged Camera
  90320. */
  90321. readonly isLeftCamera: boolean;
  90322. /** @hidden */
  90323. _isRightCamera: boolean;
  90324. /**
  90325. * Gets the right camera of a rig setup in case of Rigged Camera
  90326. */
  90327. readonly isRightCamera: boolean;
  90328. /**
  90329. * Gets the left camera of a rig setup in case of Rigged Camera
  90330. */
  90331. readonly leftCamera: Nullable<FreeCamera>;
  90332. /**
  90333. * Gets the right camera of a rig setup in case of Rigged Camera
  90334. */
  90335. readonly rightCamera: Nullable<FreeCamera>;
  90336. /**
  90337. * Gets the left camera target of a rig setup in case of Rigged Camera
  90338. * @returns the target position
  90339. */
  90340. getLeftTarget(): Nullable<Vector3>;
  90341. /**
  90342. * Gets the right camera target of a rig setup in case of Rigged Camera
  90343. * @returns the target position
  90344. */
  90345. getRightTarget(): Nullable<Vector3>;
  90346. /**
  90347. * @hidden
  90348. */
  90349. setCameraRigMode(mode: number, rigParams: any): void;
  90350. /** @hidden */
  90351. static _setStereoscopicRigMode(camera: Camera): void;
  90352. /** @hidden */
  90353. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90354. /** @hidden */
  90355. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90356. /** @hidden */
  90357. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90358. /** @hidden */
  90359. _getVRProjectionMatrix(): Matrix;
  90360. protected _updateCameraRotationMatrix(): void;
  90361. protected _updateWebVRCameraRotationMatrix(): void;
  90362. /**
  90363. * This function MUST be overwritten by the different WebVR cameras available.
  90364. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90365. * @hidden
  90366. */
  90367. _getWebVRProjectionMatrix(): Matrix;
  90368. /**
  90369. * This function MUST be overwritten by the different WebVR cameras available.
  90370. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90371. * @hidden
  90372. */
  90373. _getWebVRViewMatrix(): Matrix;
  90374. /** @hidden */
  90375. setCameraRigParameter(name: string, value: any): void;
  90376. /**
  90377. * needs to be overridden by children so sub has required properties to be copied
  90378. * @hidden
  90379. */
  90380. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90381. /**
  90382. * May need to be overridden by children
  90383. * @hidden
  90384. */
  90385. _updateRigCameras(): void;
  90386. /** @hidden */
  90387. _setupInputs(): void;
  90388. /**
  90389. * Serialiaze the camera setup to a json represention
  90390. * @returns the JSON representation
  90391. */
  90392. serialize(): any;
  90393. /**
  90394. * Clones the current camera.
  90395. * @param name The cloned camera name
  90396. * @returns the cloned camera
  90397. */
  90398. clone(name: string): Camera;
  90399. /**
  90400. * Gets the direction of the camera relative to a given local axis.
  90401. * @param localAxis Defines the reference axis to provide a relative direction.
  90402. * @return the direction
  90403. */
  90404. getDirection(localAxis: Vector3): Vector3;
  90405. /**
  90406. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90407. * @param localAxis Defines the reference axis to provide a relative direction.
  90408. * @param result Defines the vector to store the result in
  90409. */
  90410. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90411. /**
  90412. * Gets a camera constructor for a given camera type
  90413. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90414. * @param name The name of the camera the result will be able to instantiate
  90415. * @param scene The scene the result will construct the camera in
  90416. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90417. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90418. * @returns a factory method to construc the camera
  90419. */
  90420. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90421. /**
  90422. * Compute the world matrix of the camera.
  90423. * @returns the camera workd matrix
  90424. */
  90425. computeWorldMatrix(): Matrix;
  90426. /**
  90427. * Parse a JSON and creates the camera from the parsed information
  90428. * @param parsedCamera The JSON to parse
  90429. * @param scene The scene to instantiate the camera in
  90430. * @returns the newly constructed camera
  90431. */
  90432. static Parse(parsedCamera: any, scene: Scene): Camera;
  90433. }
  90434. }
  90435. declare module BABYLON {
  90436. /**
  90437. * Class containing static functions to help procedurally build meshes
  90438. */
  90439. export class DiscBuilder {
  90440. /**
  90441. * Creates a plane polygonal mesh. By default, this is a disc
  90442. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90443. * * 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
  90444. * * 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
  90445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90448. * @param name defines the name of the mesh
  90449. * @param options defines the options used to create the mesh
  90450. * @param scene defines the hosting scene
  90451. * @returns the plane polygonal mesh
  90452. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90453. */
  90454. static CreateDisc(name: string, options: {
  90455. radius?: number;
  90456. tessellation?: number;
  90457. arc?: number;
  90458. updatable?: boolean;
  90459. sideOrientation?: number;
  90460. frontUVs?: Vector4;
  90461. backUVs?: Vector4;
  90462. }, scene?: Nullable<Scene>): Mesh;
  90463. }
  90464. }
  90465. declare module BABYLON {
  90466. /**
  90467. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90468. *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.
  90469. * The SPS is also a particle system. It provides some methods to manage the particles.
  90470. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90471. *
  90472. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90473. */
  90474. export class SolidParticleSystem implements IDisposable {
  90475. /**
  90476. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90477. * Example : var p = SPS.particles[i];
  90478. */
  90479. particles: SolidParticle[];
  90480. /**
  90481. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90482. */
  90483. nbParticles: number;
  90484. /**
  90485. * If the particles must ever face the camera (default false). Useful for planar particles.
  90486. */
  90487. billboard: boolean;
  90488. /**
  90489. * Recompute normals when adding a shape
  90490. */
  90491. recomputeNormals: boolean;
  90492. /**
  90493. * This a counter ofr your own usage. It's not set by any SPS functions.
  90494. */
  90495. counter: number;
  90496. /**
  90497. * The SPS name. This name is also given to the underlying mesh.
  90498. */
  90499. name: string;
  90500. /**
  90501. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90502. */
  90503. mesh: Mesh;
  90504. /**
  90505. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90506. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90507. */
  90508. vars: any;
  90509. /**
  90510. * This array is populated when the SPS is set as 'pickable'.
  90511. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90512. * Each element of this array is an object `{idx: int, faceId: int}`.
  90513. * `idx` is the picked particle index in the `SPS.particles` array
  90514. * `faceId` is the picked face index counted within this particle.
  90515. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90516. */
  90517. pickedParticles: {
  90518. idx: number;
  90519. faceId: number;
  90520. }[];
  90521. /**
  90522. * This array is populated when `enableDepthSort` is set to true.
  90523. * Each element of this array is an instance of the class DepthSortedParticle.
  90524. */
  90525. depthSortedParticles: DepthSortedParticle[];
  90526. /**
  90527. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90528. * @hidden
  90529. */
  90530. _bSphereOnly: boolean;
  90531. /**
  90532. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90533. * @hidden
  90534. */
  90535. _bSphereRadiusFactor: number;
  90536. private _scene;
  90537. private _positions;
  90538. private _indices;
  90539. private _normals;
  90540. private _colors;
  90541. private _uvs;
  90542. private _indices32;
  90543. private _positions32;
  90544. private _normals32;
  90545. private _fixedNormal32;
  90546. private _colors32;
  90547. private _uvs32;
  90548. private _index;
  90549. private _updatable;
  90550. private _pickable;
  90551. private _isVisibilityBoxLocked;
  90552. private _alwaysVisible;
  90553. private _depthSort;
  90554. private _shapeCounter;
  90555. private _copy;
  90556. private _color;
  90557. private _computeParticleColor;
  90558. private _computeParticleTexture;
  90559. private _computeParticleRotation;
  90560. private _computeParticleVertex;
  90561. private _computeBoundingBox;
  90562. private _depthSortParticles;
  90563. private _camera;
  90564. private _mustUnrotateFixedNormals;
  90565. private _particlesIntersect;
  90566. private _needs32Bits;
  90567. /**
  90568. * Creates a SPS (Solid Particle System) object.
  90569. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90570. * @param scene (Scene) is the scene in which the SPS is added.
  90571. * @param options defines the options of the sps e.g.
  90572. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90573. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90574. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90575. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90576. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90577. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90578. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90579. */
  90580. constructor(name: string, scene: Scene, options?: {
  90581. updatable?: boolean;
  90582. isPickable?: boolean;
  90583. enableDepthSort?: boolean;
  90584. particleIntersection?: boolean;
  90585. boundingSphereOnly?: boolean;
  90586. bSphereRadiusFactor?: number;
  90587. });
  90588. /**
  90589. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90590. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90591. * @returns the created mesh
  90592. */
  90593. buildMesh(): Mesh;
  90594. /**
  90595. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90596. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90597. * Thus the particles generated from `digest()` have their property `position` set yet.
  90598. * @param mesh ( Mesh ) is the mesh to be digested
  90599. * @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
  90600. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90601. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90602. * @returns the current SPS
  90603. */
  90604. digest(mesh: Mesh, options?: {
  90605. facetNb?: number;
  90606. number?: number;
  90607. delta?: number;
  90608. }): SolidParticleSystem;
  90609. private _unrotateFixedNormals;
  90610. private _resetCopy;
  90611. private _meshBuilder;
  90612. private _posToShape;
  90613. private _uvsToShapeUV;
  90614. private _addParticle;
  90615. /**
  90616. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90617. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90618. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90619. * @param nb (positive integer) the number of particles to be created from this model
  90620. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90621. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90622. * @returns the number of shapes in the system
  90623. */
  90624. addShape(mesh: Mesh, nb: number, options?: {
  90625. positionFunction?: any;
  90626. vertexFunction?: any;
  90627. }): number;
  90628. private _rebuildParticle;
  90629. /**
  90630. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90631. * @returns the SPS.
  90632. */
  90633. rebuildMesh(): SolidParticleSystem;
  90634. /**
  90635. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90636. * This method calls `updateParticle()` for each particle of the SPS.
  90637. * For an animated SPS, it is usually called within the render loop.
  90638. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90639. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90640. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90641. * @returns the SPS.
  90642. */
  90643. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90644. /**
  90645. * Disposes the SPS.
  90646. */
  90647. dispose(): void;
  90648. /**
  90649. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90650. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90651. * @returns the SPS.
  90652. */
  90653. refreshVisibleSize(): SolidParticleSystem;
  90654. /**
  90655. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90656. * @param size the size (float) of the visibility box
  90657. * note : this doesn't lock the SPS mesh bounding box.
  90658. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90659. */
  90660. setVisibilityBox(size: number): void;
  90661. /**
  90662. * Gets whether the SPS as always visible or not
  90663. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90664. */
  90665. /**
  90666. * Sets the SPS as always visible or not
  90667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90668. */
  90669. isAlwaysVisible: boolean;
  90670. /**
  90671. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90672. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90673. */
  90674. /**
  90675. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90676. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90677. */
  90678. isVisibilityBoxLocked: boolean;
  90679. /**
  90680. * Tells to `setParticles()` to compute the particle rotations or not.
  90681. * Default value : true. The SPS is faster when it's set to false.
  90682. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90683. */
  90684. /**
  90685. * Gets if `setParticles()` computes the particle rotations or not.
  90686. * Default value : true. The SPS is faster when it's set to false.
  90687. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90688. */
  90689. computeParticleRotation: boolean;
  90690. /**
  90691. * Tells to `setParticles()` to compute the particle colors or not.
  90692. * Default value : true. The SPS is faster when it's set to false.
  90693. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90694. */
  90695. /**
  90696. * Gets if `setParticles()` computes the particle colors or not.
  90697. * Default value : true. The SPS is faster when it's set to false.
  90698. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90699. */
  90700. computeParticleColor: boolean;
  90701. /**
  90702. * Gets if `setParticles()` computes the particle textures or not.
  90703. * Default value : true. The SPS is faster when it's set to false.
  90704. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90705. */
  90706. computeParticleTexture: boolean;
  90707. /**
  90708. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90709. * Default value : false. The SPS is faster when it's set to false.
  90710. * Note : the particle custom vertex positions aren't stored values.
  90711. */
  90712. /**
  90713. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90714. * Default value : false. The SPS is faster when it's set to false.
  90715. * Note : the particle custom vertex positions aren't stored values.
  90716. */
  90717. computeParticleVertex: boolean;
  90718. /**
  90719. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90720. */
  90721. /**
  90722. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90723. */
  90724. computeBoundingBox: boolean;
  90725. /**
  90726. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90727. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90728. * Default : `true`
  90729. */
  90730. /**
  90731. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90732. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90733. * Default : `true`
  90734. */
  90735. depthSortParticles: boolean;
  90736. /**
  90737. * This function does nothing. It may be overwritten to set all the particle first values.
  90738. * The SPS doesn't call this function, you may have to call it by your own.
  90739. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90740. */
  90741. initParticles(): void;
  90742. /**
  90743. * This function does nothing. It may be overwritten to recycle a particle.
  90744. * The SPS doesn't call this function, you may have to call it by your own.
  90745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90746. * @param particle The particle to recycle
  90747. * @returns the recycled particle
  90748. */
  90749. recycleParticle(particle: SolidParticle): SolidParticle;
  90750. /**
  90751. * Updates a particle : this function should be overwritten by the user.
  90752. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90753. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90754. * @example : just set a particle position or velocity and recycle conditions
  90755. * @param particle The particle to update
  90756. * @returns the updated particle
  90757. */
  90758. updateParticle(particle: SolidParticle): SolidParticle;
  90759. /**
  90760. * Updates a vertex of a particle : it can be overwritten by the user.
  90761. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90762. * @param particle the current particle
  90763. * @param vertex the current index of the current particle
  90764. * @param pt the index of the current vertex in the particle shape
  90765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90766. * @example : just set a vertex particle position
  90767. * @returns the updated vertex
  90768. */
  90769. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90770. /**
  90771. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90772. * This does nothing and may be overwritten by the user.
  90773. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90774. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90775. * @param update the boolean update value actually passed to setParticles()
  90776. */
  90777. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90778. /**
  90779. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90780. * This will be passed three parameters.
  90781. * This does nothing and may be overwritten by the user.
  90782. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90783. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90784. * @param update the boolean update value actually passed to setParticles()
  90785. */
  90786. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90787. }
  90788. }
  90789. declare module BABYLON {
  90790. /**
  90791. * Represents one particle of a solid particle system.
  90792. */
  90793. export class SolidParticle {
  90794. /**
  90795. * particle global index
  90796. */
  90797. idx: number;
  90798. /**
  90799. * The color of the particle
  90800. */
  90801. color: Nullable<Color4>;
  90802. /**
  90803. * The world space position of the particle.
  90804. */
  90805. position: Vector3;
  90806. /**
  90807. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90808. */
  90809. rotation: Vector3;
  90810. /**
  90811. * The world space rotation quaternion of the particle.
  90812. */
  90813. rotationQuaternion: Nullable<Quaternion>;
  90814. /**
  90815. * The scaling of the particle.
  90816. */
  90817. scaling: Vector3;
  90818. /**
  90819. * The uvs of the particle.
  90820. */
  90821. uvs: Vector4;
  90822. /**
  90823. * The current speed of the particle.
  90824. */
  90825. velocity: Vector3;
  90826. /**
  90827. * The pivot point in the particle local space.
  90828. */
  90829. pivot: Vector3;
  90830. /**
  90831. * Must the particle be translated from its pivot point in its local space ?
  90832. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90833. * Default : false
  90834. */
  90835. translateFromPivot: boolean;
  90836. /**
  90837. * Is the particle active or not ?
  90838. */
  90839. alive: boolean;
  90840. /**
  90841. * Is the particle visible or not ?
  90842. */
  90843. isVisible: boolean;
  90844. /**
  90845. * Index of this particle in the global "positions" array (Internal use)
  90846. * @hidden
  90847. */
  90848. _pos: number;
  90849. /**
  90850. * @hidden Index of this particle in the global "indices" array (Internal use)
  90851. */
  90852. _ind: number;
  90853. /**
  90854. * @hidden ModelShape of this particle (Internal use)
  90855. */
  90856. _model: ModelShape;
  90857. /**
  90858. * ModelShape id of this particle
  90859. */
  90860. shapeId: number;
  90861. /**
  90862. * Index of the particle in its shape id
  90863. */
  90864. idxInShape: number;
  90865. /**
  90866. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90867. */
  90868. _modelBoundingInfo: BoundingInfo;
  90869. /**
  90870. * @hidden Particle BoundingInfo object (Internal use)
  90871. */
  90872. _boundingInfo: BoundingInfo;
  90873. /**
  90874. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90875. */
  90876. _sps: SolidParticleSystem;
  90877. /**
  90878. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90879. */
  90880. _stillInvisible: boolean;
  90881. /**
  90882. * @hidden Last computed particle rotation matrix
  90883. */
  90884. _rotationMatrix: number[];
  90885. /**
  90886. * Parent particle Id, if any.
  90887. * Default null.
  90888. */
  90889. parentId: Nullable<number>;
  90890. /**
  90891. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90892. * The possible values are :
  90893. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90894. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90895. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90896. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90897. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90898. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90899. * */
  90900. cullingStrategy: number;
  90901. /**
  90902. * @hidden Internal global position in the SPS.
  90903. */
  90904. _globalPosition: Vector3;
  90905. /**
  90906. * Creates a Solid Particle object.
  90907. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90908. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90909. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90910. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90911. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90912. * @param shapeId (integer) is the model shape identifier in the SPS.
  90913. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90914. * @param sps defines the sps it is associated to
  90915. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90916. */
  90917. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90918. /**
  90919. * Legacy support, changed scale to scaling
  90920. */
  90921. /**
  90922. * Legacy support, changed scale to scaling
  90923. */
  90924. scale: Vector3;
  90925. /**
  90926. * Legacy support, changed quaternion to rotationQuaternion
  90927. */
  90928. /**
  90929. * Legacy support, changed quaternion to rotationQuaternion
  90930. */
  90931. quaternion: Nullable<Quaternion>;
  90932. /**
  90933. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90934. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90935. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90936. * @returns true if it intersects
  90937. */
  90938. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90939. /**
  90940. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90941. * A particle is in the frustum if its bounding box intersects the frustum
  90942. * @param frustumPlanes defines the frustum to test
  90943. * @returns true if the particle is in the frustum planes
  90944. */
  90945. isInFrustum(frustumPlanes: Plane[]): boolean;
  90946. /**
  90947. * get the rotation matrix of the particle
  90948. * @hidden
  90949. */
  90950. getRotationMatrix(m: Matrix): void;
  90951. }
  90952. /**
  90953. * Represents the shape of the model used by one particle of a solid particle system.
  90954. * SPS internal tool, don't use it manually.
  90955. */
  90956. export class ModelShape {
  90957. /**
  90958. * The shape id
  90959. * @hidden
  90960. */
  90961. shapeID: number;
  90962. /**
  90963. * flat array of model positions (internal use)
  90964. * @hidden
  90965. */
  90966. _shape: Vector3[];
  90967. /**
  90968. * flat array of model UVs (internal use)
  90969. * @hidden
  90970. */
  90971. _shapeUV: number[];
  90972. /**
  90973. * length of the shape in the model indices array (internal use)
  90974. * @hidden
  90975. */
  90976. _indicesLength: number;
  90977. /**
  90978. * Custom position function (internal use)
  90979. * @hidden
  90980. */
  90981. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90982. /**
  90983. * Custom vertex function (internal use)
  90984. * @hidden
  90985. */
  90986. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90987. /**
  90988. * 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.
  90989. * SPS internal tool, don't use it manually.
  90990. * @hidden
  90991. */
  90992. 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>);
  90993. }
  90994. /**
  90995. * Represents a Depth Sorted Particle in the solid particle system.
  90996. */
  90997. export class DepthSortedParticle {
  90998. /**
  90999. * Index of the particle in the "indices" array
  91000. */
  91001. ind: number;
  91002. /**
  91003. * Length of the particle shape in the "indices" array
  91004. */
  91005. indicesLength: number;
  91006. /**
  91007. * Squared distance from the particle to the camera
  91008. */
  91009. sqDistance: number;
  91010. }
  91011. }
  91012. declare module BABYLON {
  91013. /**
  91014. * @hidden
  91015. */
  91016. export class _MeshCollisionData {
  91017. _checkCollisions: boolean;
  91018. _collisionMask: number;
  91019. _collisionGroup: number;
  91020. _collider: Nullable<Collider>;
  91021. _oldPositionForCollisions: Vector3;
  91022. _diffPositionForCollisions: Vector3;
  91023. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91024. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91025. }
  91026. }
  91027. declare module BABYLON {
  91028. /** @hidden */
  91029. class _FacetDataStorage {
  91030. facetPositions: Vector3[];
  91031. facetNormals: Vector3[];
  91032. facetPartitioning: number[][];
  91033. facetNb: number;
  91034. partitioningSubdivisions: number;
  91035. partitioningBBoxRatio: number;
  91036. facetDataEnabled: boolean;
  91037. facetParameters: any;
  91038. bbSize: Vector3;
  91039. subDiv: {
  91040. max: number;
  91041. X: number;
  91042. Y: number;
  91043. Z: number;
  91044. };
  91045. facetDepthSort: boolean;
  91046. facetDepthSortEnabled: boolean;
  91047. depthSortedIndices: IndicesArray;
  91048. depthSortedFacets: {
  91049. ind: number;
  91050. sqDistance: number;
  91051. }[];
  91052. facetDepthSortFunction: (f1: {
  91053. ind: number;
  91054. sqDistance: number;
  91055. }, f2: {
  91056. ind: number;
  91057. sqDistance: number;
  91058. }) => number;
  91059. facetDepthSortFrom: Vector3;
  91060. facetDepthSortOrigin: Vector3;
  91061. invertedMatrix: Matrix;
  91062. }
  91063. /**
  91064. * @hidden
  91065. **/
  91066. class _InternalAbstractMeshDataInfo {
  91067. _hasVertexAlpha: boolean;
  91068. _useVertexColors: boolean;
  91069. _numBoneInfluencers: number;
  91070. _applyFog: boolean;
  91071. _receiveShadows: boolean;
  91072. _facetData: _FacetDataStorage;
  91073. _visibility: number;
  91074. _skeleton: Nullable<Skeleton>;
  91075. _layerMask: number;
  91076. _computeBonesUsingShaders: boolean;
  91077. _isActive: boolean;
  91078. _onlyForInstances: boolean;
  91079. _isActiveIntermediate: boolean;
  91080. _onlyForInstancesIntermediate: boolean;
  91081. }
  91082. /**
  91083. * Class used to store all common mesh properties
  91084. */
  91085. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91086. /** No occlusion */
  91087. static OCCLUSION_TYPE_NONE: number;
  91088. /** Occlusion set to optimisitic */
  91089. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91090. /** Occlusion set to strict */
  91091. static OCCLUSION_TYPE_STRICT: number;
  91092. /** Use an accurante occlusion algorithm */
  91093. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91094. /** Use a conservative occlusion algorithm */
  91095. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91096. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91097. * Test order :
  91098. * Is the bounding sphere outside the frustum ?
  91099. * If not, are the bounding box vertices outside the frustum ?
  91100. * It not, then the cullable object is in the frustum.
  91101. */
  91102. static readonly CULLINGSTRATEGY_STANDARD: number;
  91103. /** Culling strategy : Bounding Sphere Only.
  91104. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91105. * It's also less accurate than the standard because some not visible objects can still be selected.
  91106. * Test : is the bounding sphere outside the frustum ?
  91107. * If not, then the cullable object is in the frustum.
  91108. */
  91109. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91110. /** Culling strategy : Optimistic Inclusion.
  91111. * This in an inclusion test first, then the standard exclusion test.
  91112. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91113. * 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.
  91114. * Anyway, it's as accurate as the standard strategy.
  91115. * Test :
  91116. * Is the cullable object bounding sphere center in the frustum ?
  91117. * If not, apply the default culling strategy.
  91118. */
  91119. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91120. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91121. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91122. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91123. * 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.
  91124. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91125. * Test :
  91126. * Is the cullable object bounding sphere center in the frustum ?
  91127. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91128. */
  91129. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91130. /**
  91131. * No billboard
  91132. */
  91133. static readonly BILLBOARDMODE_NONE: number;
  91134. /** Billboard on X axis */
  91135. static readonly BILLBOARDMODE_X: number;
  91136. /** Billboard on Y axis */
  91137. static readonly BILLBOARDMODE_Y: number;
  91138. /** Billboard on Z axis */
  91139. static readonly BILLBOARDMODE_Z: number;
  91140. /** Billboard on all axes */
  91141. static readonly BILLBOARDMODE_ALL: number;
  91142. /** Billboard on using position instead of orientation */
  91143. static readonly BILLBOARDMODE_USE_POSITION: number;
  91144. /** @hidden */
  91145. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91146. /**
  91147. * The culling strategy to use to check whether the mesh must be rendered or not.
  91148. * This value can be changed at any time and will be used on the next render mesh selection.
  91149. * The possible values are :
  91150. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91151. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91152. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91153. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91154. * Please read each static variable documentation to get details about the culling process.
  91155. * */
  91156. cullingStrategy: number;
  91157. /**
  91158. * Gets the number of facets in the mesh
  91159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91160. */
  91161. readonly facetNb: number;
  91162. /**
  91163. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91165. */
  91166. partitioningSubdivisions: number;
  91167. /**
  91168. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91169. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91171. */
  91172. partitioningBBoxRatio: number;
  91173. /**
  91174. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91175. * Works only for updatable meshes.
  91176. * Doesn't work with multi-materials
  91177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91178. */
  91179. mustDepthSortFacets: boolean;
  91180. /**
  91181. * The location (Vector3) where the facet depth sort must be computed from.
  91182. * By default, the active camera position.
  91183. * Used only when facet depth sort is enabled
  91184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91185. */
  91186. facetDepthSortFrom: Vector3;
  91187. /**
  91188. * gets a boolean indicating if facetData is enabled
  91189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91190. */
  91191. readonly isFacetDataEnabled: boolean;
  91192. /** @hidden */
  91193. _updateNonUniformScalingState(value: boolean): boolean;
  91194. /**
  91195. * An event triggered when this mesh collides with another one
  91196. */
  91197. onCollideObservable: Observable<AbstractMesh>;
  91198. /** Set a function to call when this mesh collides with another one */
  91199. onCollide: () => void;
  91200. /**
  91201. * An event triggered when the collision's position changes
  91202. */
  91203. onCollisionPositionChangeObservable: Observable<Vector3>;
  91204. /** Set a function to call when the collision's position changes */
  91205. onCollisionPositionChange: () => void;
  91206. /**
  91207. * An event triggered when material is changed
  91208. */
  91209. onMaterialChangedObservable: Observable<AbstractMesh>;
  91210. /**
  91211. * Gets or sets the orientation for POV movement & rotation
  91212. */
  91213. definedFacingForward: boolean;
  91214. /** @hidden */
  91215. _occlusionQuery: Nullable<WebGLQuery>;
  91216. /** @hidden */
  91217. _renderingGroup: Nullable<RenderingGroup>;
  91218. /**
  91219. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91220. */
  91221. /**
  91222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91223. */
  91224. visibility: number;
  91225. /** Gets or sets the alpha index used to sort transparent meshes
  91226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91227. */
  91228. alphaIndex: number;
  91229. /**
  91230. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91231. */
  91232. isVisible: boolean;
  91233. /**
  91234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91235. */
  91236. isPickable: boolean;
  91237. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91238. showSubMeshesBoundingBox: boolean;
  91239. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91241. */
  91242. isBlocker: boolean;
  91243. /**
  91244. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91245. */
  91246. enablePointerMoveEvents: boolean;
  91247. /**
  91248. * Specifies the rendering group id for this mesh (0 by default)
  91249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91250. */
  91251. renderingGroupId: number;
  91252. private _material;
  91253. /** Gets or sets current material */
  91254. material: Nullable<Material>;
  91255. /**
  91256. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91257. * @see http://doc.babylonjs.com/babylon101/shadows
  91258. */
  91259. receiveShadows: boolean;
  91260. /** Defines color to use when rendering outline */
  91261. outlineColor: Color3;
  91262. /** Define width to use when rendering outline */
  91263. outlineWidth: number;
  91264. /** Defines color to use when rendering overlay */
  91265. overlayColor: Color3;
  91266. /** Defines alpha to use when rendering overlay */
  91267. overlayAlpha: number;
  91268. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91269. hasVertexAlpha: boolean;
  91270. /** 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) */
  91271. useVertexColors: boolean;
  91272. /**
  91273. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91274. */
  91275. computeBonesUsingShaders: boolean;
  91276. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91277. numBoneInfluencers: number;
  91278. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91279. applyFog: boolean;
  91280. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91281. useOctreeForRenderingSelection: boolean;
  91282. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91283. useOctreeForPicking: boolean;
  91284. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91285. useOctreeForCollisions: boolean;
  91286. /**
  91287. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91288. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91289. */
  91290. layerMask: number;
  91291. /**
  91292. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91293. */
  91294. alwaysSelectAsActiveMesh: boolean;
  91295. /**
  91296. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91297. */
  91298. doNotSyncBoundingInfo: boolean;
  91299. /**
  91300. * Gets or sets the current action manager
  91301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91302. */
  91303. actionManager: Nullable<AbstractActionManager>;
  91304. private _meshCollisionData;
  91305. /**
  91306. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91308. */
  91309. ellipsoid: Vector3;
  91310. /**
  91311. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91313. */
  91314. ellipsoidOffset: Vector3;
  91315. /**
  91316. * Gets or sets a collision mask used to mask collisions (default is -1).
  91317. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91318. */
  91319. collisionMask: number;
  91320. /**
  91321. * Gets or sets the current collision group mask (-1 by default).
  91322. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91323. */
  91324. collisionGroup: number;
  91325. /**
  91326. * Defines edge width used when edgesRenderer is enabled
  91327. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91328. */
  91329. edgesWidth: number;
  91330. /**
  91331. * Defines edge color used when edgesRenderer is enabled
  91332. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91333. */
  91334. edgesColor: Color4;
  91335. /** @hidden */
  91336. _edgesRenderer: Nullable<IEdgesRenderer>;
  91337. /** @hidden */
  91338. _masterMesh: Nullable<AbstractMesh>;
  91339. /** @hidden */
  91340. _boundingInfo: Nullable<BoundingInfo>;
  91341. /** @hidden */
  91342. _renderId: number;
  91343. /**
  91344. * Gets or sets the list of subMeshes
  91345. * @see http://doc.babylonjs.com/how_to/multi_materials
  91346. */
  91347. subMeshes: SubMesh[];
  91348. /** @hidden */
  91349. _intersectionsInProgress: AbstractMesh[];
  91350. /** @hidden */
  91351. _unIndexed: boolean;
  91352. /** @hidden */
  91353. _lightSources: Light[];
  91354. /** Gets the list of lights affecting that mesh */
  91355. readonly lightSources: Light[];
  91356. /** @hidden */
  91357. readonly _positions: Nullable<Vector3[]>;
  91358. /** @hidden */
  91359. _waitingData: {
  91360. lods: Nullable<any>;
  91361. actions: Nullable<any>;
  91362. freezeWorldMatrix: Nullable<boolean>;
  91363. };
  91364. /** @hidden */
  91365. _bonesTransformMatrices: Nullable<Float32Array>;
  91366. /** @hidden */
  91367. _transformMatrixTexture: Nullable<RawTexture>;
  91368. /**
  91369. * Gets or sets a skeleton to apply skining transformations
  91370. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91371. */
  91372. skeleton: Nullable<Skeleton>;
  91373. /**
  91374. * An event triggered when the mesh is rebuilt.
  91375. */
  91376. onRebuildObservable: Observable<AbstractMesh>;
  91377. /**
  91378. * Creates a new AbstractMesh
  91379. * @param name defines the name of the mesh
  91380. * @param scene defines the hosting scene
  91381. */
  91382. constructor(name: string, scene?: Nullable<Scene>);
  91383. /**
  91384. * Returns the string "AbstractMesh"
  91385. * @returns "AbstractMesh"
  91386. */
  91387. getClassName(): string;
  91388. /**
  91389. * Gets a string representation of the current mesh
  91390. * @param fullDetails defines a boolean indicating if full details must be included
  91391. * @returns a string representation of the current mesh
  91392. */
  91393. toString(fullDetails?: boolean): string;
  91394. /**
  91395. * @hidden
  91396. */
  91397. protected _getEffectiveParent(): Nullable<Node>;
  91398. /** @hidden */
  91399. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91400. /** @hidden */
  91401. _rebuild(): void;
  91402. /** @hidden */
  91403. _resyncLightSources(): void;
  91404. /** @hidden */
  91405. _resyncLighSource(light: Light): void;
  91406. /** @hidden */
  91407. _unBindEffect(): void;
  91408. /** @hidden */
  91409. _removeLightSource(light: Light, dispose: boolean): void;
  91410. private _markSubMeshesAsDirty;
  91411. /** @hidden */
  91412. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91413. /** @hidden */
  91414. _markSubMeshesAsAttributesDirty(): void;
  91415. /** @hidden */
  91416. _markSubMeshesAsMiscDirty(): void;
  91417. /**
  91418. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91419. */
  91420. scaling: Vector3;
  91421. /**
  91422. * Returns true if the mesh is blocked. Implemented by child classes
  91423. */
  91424. readonly isBlocked: boolean;
  91425. /**
  91426. * Returns the mesh itself by default. Implemented by child classes
  91427. * @param camera defines the camera to use to pick the right LOD level
  91428. * @returns the currentAbstractMesh
  91429. */
  91430. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91431. /**
  91432. * Returns 0 by default. Implemented by child classes
  91433. * @returns an integer
  91434. */
  91435. getTotalVertices(): number;
  91436. /**
  91437. * Returns a positive integer : the total number of indices in this mesh geometry.
  91438. * @returns the numner of indices or zero if the mesh has no geometry.
  91439. */
  91440. getTotalIndices(): number;
  91441. /**
  91442. * Returns null by default. Implemented by child classes
  91443. * @returns null
  91444. */
  91445. getIndices(): Nullable<IndicesArray>;
  91446. /**
  91447. * Returns the array of the requested vertex data kind. Implemented by child classes
  91448. * @param kind defines the vertex data kind to use
  91449. * @returns null
  91450. */
  91451. getVerticesData(kind: string): Nullable<FloatArray>;
  91452. /**
  91453. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91454. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91455. * Note that a new underlying VertexBuffer object is created each call.
  91456. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91457. * @param kind defines vertex data kind:
  91458. * * VertexBuffer.PositionKind
  91459. * * VertexBuffer.UVKind
  91460. * * VertexBuffer.UV2Kind
  91461. * * VertexBuffer.UV3Kind
  91462. * * VertexBuffer.UV4Kind
  91463. * * VertexBuffer.UV5Kind
  91464. * * VertexBuffer.UV6Kind
  91465. * * VertexBuffer.ColorKind
  91466. * * VertexBuffer.MatricesIndicesKind
  91467. * * VertexBuffer.MatricesIndicesExtraKind
  91468. * * VertexBuffer.MatricesWeightsKind
  91469. * * VertexBuffer.MatricesWeightsExtraKind
  91470. * @param data defines the data source
  91471. * @param updatable defines if the data must be flagged as updatable (or static)
  91472. * @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
  91473. * @returns the current mesh
  91474. */
  91475. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91476. /**
  91477. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91478. * If the mesh has no geometry, it is simply returned as it is.
  91479. * @param kind defines vertex data kind:
  91480. * * VertexBuffer.PositionKind
  91481. * * VertexBuffer.UVKind
  91482. * * VertexBuffer.UV2Kind
  91483. * * VertexBuffer.UV3Kind
  91484. * * VertexBuffer.UV4Kind
  91485. * * VertexBuffer.UV5Kind
  91486. * * VertexBuffer.UV6Kind
  91487. * * VertexBuffer.ColorKind
  91488. * * VertexBuffer.MatricesIndicesKind
  91489. * * VertexBuffer.MatricesIndicesExtraKind
  91490. * * VertexBuffer.MatricesWeightsKind
  91491. * * VertexBuffer.MatricesWeightsExtraKind
  91492. * @param data defines the data source
  91493. * @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
  91494. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91495. * @returns the current mesh
  91496. */
  91497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91498. /**
  91499. * Sets the mesh indices,
  91500. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91501. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91502. * @param totalVertices Defines the total number of vertices
  91503. * @returns the current mesh
  91504. */
  91505. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91506. /**
  91507. * Gets a boolean indicating if specific vertex data is present
  91508. * @param kind defines the vertex data kind to use
  91509. * @returns true is data kind is present
  91510. */
  91511. isVerticesDataPresent(kind: string): boolean;
  91512. /**
  91513. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91514. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91515. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91516. * @returns a BoundingInfo
  91517. */
  91518. getBoundingInfo(): BoundingInfo;
  91519. /**
  91520. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91521. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91522. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91523. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91524. * @returns the current mesh
  91525. */
  91526. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91527. /**
  91528. * Overwrite the current bounding info
  91529. * @param boundingInfo defines the new bounding info
  91530. * @returns the current mesh
  91531. */
  91532. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91533. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91534. readonly useBones: boolean;
  91535. /** @hidden */
  91536. _preActivate(): void;
  91537. /** @hidden */
  91538. _preActivateForIntermediateRendering(renderId: number): void;
  91539. /** @hidden */
  91540. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91541. /** @hidden */
  91542. _postActivate(): void;
  91543. /** @hidden */
  91544. _freeze(): void;
  91545. /** @hidden */
  91546. _unFreeze(): void;
  91547. /**
  91548. * Gets the current world matrix
  91549. * @returns a Matrix
  91550. */
  91551. getWorldMatrix(): Matrix;
  91552. /** @hidden */
  91553. _getWorldMatrixDeterminant(): number;
  91554. /**
  91555. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91556. */
  91557. readonly isAnInstance: boolean;
  91558. /**
  91559. * Gets a boolean indicating if this mesh has instances
  91560. */
  91561. readonly hasInstances: boolean;
  91562. /**
  91563. * Perform relative position change from the point of view of behind the front of the mesh.
  91564. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91565. * Supports definition of mesh facing forward or backward
  91566. * @param amountRight defines the distance on the right axis
  91567. * @param amountUp defines the distance on the up axis
  91568. * @param amountForward defines the distance on the forward axis
  91569. * @returns the current mesh
  91570. */
  91571. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91572. /**
  91573. * Calculate relative position change from the point of view of behind the front of the mesh.
  91574. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91575. * Supports definition of mesh facing forward or backward
  91576. * @param amountRight defines the distance on the right axis
  91577. * @param amountUp defines the distance on the up axis
  91578. * @param amountForward defines the distance on the forward axis
  91579. * @returns the new displacement vector
  91580. */
  91581. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91582. /**
  91583. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91584. * Supports definition of mesh facing forward or backward
  91585. * @param flipBack defines the flip
  91586. * @param twirlClockwise defines the twirl
  91587. * @param tiltRight defines the tilt
  91588. * @returns the current mesh
  91589. */
  91590. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91591. /**
  91592. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91593. * Supports definition of mesh facing forward or backward.
  91594. * @param flipBack defines the flip
  91595. * @param twirlClockwise defines the twirl
  91596. * @param tiltRight defines the tilt
  91597. * @returns the new rotation vector
  91598. */
  91599. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91600. /**
  91601. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91602. * This means the mesh underlying bounding box and sphere are recomputed.
  91603. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91604. * @returns the current mesh
  91605. */
  91606. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91607. /** @hidden */
  91608. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91609. /** @hidden */
  91610. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91611. /** @hidden */
  91612. _updateBoundingInfo(): AbstractMesh;
  91613. /** @hidden */
  91614. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91615. /** @hidden */
  91616. protected _afterComputeWorldMatrix(): void;
  91617. /** @hidden */
  91618. readonly _effectiveMesh: AbstractMesh;
  91619. /**
  91620. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91621. * A mesh is in the frustum if its bounding box intersects the frustum
  91622. * @param frustumPlanes defines the frustum to test
  91623. * @returns true if the mesh is in the frustum planes
  91624. */
  91625. isInFrustum(frustumPlanes: Plane[]): boolean;
  91626. /**
  91627. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91628. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91629. * @param frustumPlanes defines the frustum to test
  91630. * @returns true if the mesh is completely in the frustum planes
  91631. */
  91632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91633. /**
  91634. * True if the mesh intersects another mesh or a SolidParticle object
  91635. * @param mesh defines a target mesh or SolidParticle to test
  91636. * @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)
  91637. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91638. * @returns true if there is an intersection
  91639. */
  91640. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91641. /**
  91642. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91643. * @param point defines the point to test
  91644. * @returns true if there is an intersection
  91645. */
  91646. intersectsPoint(point: Vector3): boolean;
  91647. /**
  91648. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91650. */
  91651. checkCollisions: boolean;
  91652. /**
  91653. * Gets Collider object used to compute collisions (not physics)
  91654. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91655. */
  91656. readonly collider: Nullable<Collider>;
  91657. /**
  91658. * Move the mesh using collision engine
  91659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91660. * @param displacement defines the requested displacement vector
  91661. * @returns the current mesh
  91662. */
  91663. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91664. private _onCollisionPositionChange;
  91665. /** @hidden */
  91666. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91667. /** @hidden */
  91668. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91669. /** @hidden */
  91670. _checkCollision(collider: Collider): AbstractMesh;
  91671. /** @hidden */
  91672. _generatePointsArray(): boolean;
  91673. /**
  91674. * Checks if the passed Ray intersects with the mesh
  91675. * @param ray defines the ray to use
  91676. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91677. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91678. * @returns the picking info
  91679. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91680. */
  91681. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91682. /**
  91683. * Clones the current mesh
  91684. * @param name defines the mesh name
  91685. * @param newParent defines the new mesh parent
  91686. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91687. * @returns the new mesh
  91688. */
  91689. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91690. /**
  91691. * Disposes all the submeshes of the current meshnp
  91692. * @returns the current mesh
  91693. */
  91694. releaseSubMeshes(): AbstractMesh;
  91695. /**
  91696. * Releases resources associated with this abstract mesh.
  91697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91699. */
  91700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91701. /**
  91702. * Adds the passed mesh as a child to the current mesh
  91703. * @param mesh defines the child mesh
  91704. * @returns the current mesh
  91705. */
  91706. addChild(mesh: AbstractMesh): AbstractMesh;
  91707. /**
  91708. * Removes the passed mesh from the current mesh children list
  91709. * @param mesh defines the child mesh
  91710. * @returns the current mesh
  91711. */
  91712. removeChild(mesh: AbstractMesh): AbstractMesh;
  91713. /** @hidden */
  91714. private _initFacetData;
  91715. /**
  91716. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91717. * This method can be called within the render loop.
  91718. * 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
  91719. * @returns the current mesh
  91720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91721. */
  91722. updateFacetData(): AbstractMesh;
  91723. /**
  91724. * Returns the facetLocalNormals array.
  91725. * The normals are expressed in the mesh local spac
  91726. * @returns an array of Vector3
  91727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91728. */
  91729. getFacetLocalNormals(): Vector3[];
  91730. /**
  91731. * Returns the facetLocalPositions array.
  91732. * The facet positions are expressed in the mesh local space
  91733. * @returns an array of Vector3
  91734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91735. */
  91736. getFacetLocalPositions(): Vector3[];
  91737. /**
  91738. * Returns the facetLocalPartioning array
  91739. * @returns an array of array of numbers
  91740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91741. */
  91742. getFacetLocalPartitioning(): number[][];
  91743. /**
  91744. * Returns the i-th facet position in the world system.
  91745. * This method allocates a new Vector3 per call
  91746. * @param i defines the facet index
  91747. * @returns a new Vector3
  91748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91749. */
  91750. getFacetPosition(i: number): Vector3;
  91751. /**
  91752. * Sets the reference Vector3 with the i-th facet position in the world system
  91753. * @param i defines the facet index
  91754. * @param ref defines the target vector
  91755. * @returns the current mesh
  91756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91757. */
  91758. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91759. /**
  91760. * Returns the i-th facet normal in the world system.
  91761. * This method allocates a new Vector3 per call
  91762. * @param i defines the facet index
  91763. * @returns a new Vector3
  91764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91765. */
  91766. getFacetNormal(i: number): Vector3;
  91767. /**
  91768. * Sets the reference Vector3 with the i-th facet normal in the world system
  91769. * @param i defines the facet index
  91770. * @param ref defines the target vector
  91771. * @returns the current mesh
  91772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91773. */
  91774. getFacetNormalToRef(i: number, ref: Vector3): this;
  91775. /**
  91776. * 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)
  91777. * @param x defines x coordinate
  91778. * @param y defines y coordinate
  91779. * @param z defines z coordinate
  91780. * @returns the array of facet indexes
  91781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91782. */
  91783. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91784. /**
  91785. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91786. * @param projected sets as the (x,y,z) world projection on the facet
  91787. * @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
  91788. * @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
  91789. * @param x defines x coordinate
  91790. * @param y defines y coordinate
  91791. * @param z defines z coordinate
  91792. * @returns the face index if found (or null instead)
  91793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91794. */
  91795. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91796. /**
  91797. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91798. * @param projected sets as the (x,y,z) local projection on the facet
  91799. * @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
  91800. * @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
  91801. * @param x defines x coordinate
  91802. * @param y defines y coordinate
  91803. * @param z defines z coordinate
  91804. * @returns the face index if found (or null instead)
  91805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91806. */
  91807. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91808. /**
  91809. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91810. * @returns the parameters
  91811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91812. */
  91813. getFacetDataParameters(): any;
  91814. /**
  91815. * Disables the feature FacetData and frees the related memory
  91816. * @returns the current mesh
  91817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91818. */
  91819. disableFacetData(): AbstractMesh;
  91820. /**
  91821. * Updates the AbstractMesh indices array
  91822. * @param indices defines the data source
  91823. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91824. * @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)
  91825. * @returns the current mesh
  91826. */
  91827. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91828. /**
  91829. * Creates new normals data for the mesh
  91830. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91831. * @returns the current mesh
  91832. */
  91833. createNormals(updatable: boolean): AbstractMesh;
  91834. /**
  91835. * Align the mesh with a normal
  91836. * @param normal defines the normal to use
  91837. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91838. * @returns the current mesh
  91839. */
  91840. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91841. /** @hidden */
  91842. _checkOcclusionQuery(): boolean;
  91843. /**
  91844. * Disables the mesh edge rendering mode
  91845. * @returns the currentAbstractMesh
  91846. */
  91847. disableEdgesRendering(): AbstractMesh;
  91848. /**
  91849. * Enables the edge rendering mode on the mesh.
  91850. * This mode makes the mesh edges visible
  91851. * @param epsilon defines the maximal distance between two angles to detect a face
  91852. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91853. * @returns the currentAbstractMesh
  91854. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91855. */
  91856. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91857. }
  91858. }
  91859. declare module BABYLON {
  91860. /**
  91861. * Interface used to define ActionEvent
  91862. */
  91863. export interface IActionEvent {
  91864. /** The mesh or sprite that triggered the action */
  91865. source: any;
  91866. /** The X mouse cursor position at the time of the event */
  91867. pointerX: number;
  91868. /** The Y mouse cursor position at the time of the event */
  91869. pointerY: number;
  91870. /** The mesh that is currently pointed at (can be null) */
  91871. meshUnderPointer: Nullable<AbstractMesh>;
  91872. /** the original (browser) event that triggered the ActionEvent */
  91873. sourceEvent?: any;
  91874. /** additional data for the event */
  91875. additionalData?: any;
  91876. }
  91877. /**
  91878. * ActionEvent is the event being sent when an action is triggered.
  91879. */
  91880. export class ActionEvent implements IActionEvent {
  91881. /** The mesh or sprite that triggered the action */
  91882. source: any;
  91883. /** The X mouse cursor position at the time of the event */
  91884. pointerX: number;
  91885. /** The Y mouse cursor position at the time of the event */
  91886. pointerY: number;
  91887. /** The mesh that is currently pointed at (can be null) */
  91888. meshUnderPointer: Nullable<AbstractMesh>;
  91889. /** the original (browser) event that triggered the ActionEvent */
  91890. sourceEvent?: any;
  91891. /** additional data for the event */
  91892. additionalData?: any;
  91893. /**
  91894. * Creates a new ActionEvent
  91895. * @param source The mesh or sprite that triggered the action
  91896. * @param pointerX The X mouse cursor position at the time of the event
  91897. * @param pointerY The Y mouse cursor position at the time of the event
  91898. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91899. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91900. * @param additionalData additional data for the event
  91901. */
  91902. constructor(
  91903. /** The mesh or sprite that triggered the action */
  91904. source: any,
  91905. /** The X mouse cursor position at the time of the event */
  91906. pointerX: number,
  91907. /** The Y mouse cursor position at the time of the event */
  91908. pointerY: number,
  91909. /** The mesh that is currently pointed at (can be null) */
  91910. meshUnderPointer: Nullable<AbstractMesh>,
  91911. /** the original (browser) event that triggered the ActionEvent */
  91912. sourceEvent?: any,
  91913. /** additional data for the event */
  91914. additionalData?: any);
  91915. /**
  91916. * Helper function to auto-create an ActionEvent from a source mesh.
  91917. * @param source The source mesh that triggered the event
  91918. * @param evt The original (browser) event
  91919. * @param additionalData additional data for the event
  91920. * @returns the new ActionEvent
  91921. */
  91922. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91923. /**
  91924. * Helper function to auto-create an ActionEvent from a source sprite
  91925. * @param source The source sprite that triggered the event
  91926. * @param scene Scene associated with the sprite
  91927. * @param evt The original (browser) event
  91928. * @param additionalData additional data for the event
  91929. * @returns the new ActionEvent
  91930. */
  91931. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91932. /**
  91933. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91934. * @param scene the scene where the event occurred
  91935. * @param evt The original (browser) event
  91936. * @returns the new ActionEvent
  91937. */
  91938. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91939. /**
  91940. * Helper function to auto-create an ActionEvent from a primitive
  91941. * @param prim defines the target primitive
  91942. * @param pointerPos defines the pointer position
  91943. * @param evt The original (browser) event
  91944. * @param additionalData additional data for the event
  91945. * @returns the new ActionEvent
  91946. */
  91947. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91948. }
  91949. }
  91950. declare module BABYLON {
  91951. /**
  91952. * Abstract class used to decouple action Manager from scene and meshes.
  91953. * Do not instantiate.
  91954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91955. */
  91956. export abstract class AbstractActionManager implements IDisposable {
  91957. /** Gets the list of active triggers */
  91958. static Triggers: {
  91959. [key: string]: number;
  91960. };
  91961. /** Gets the cursor to use when hovering items */
  91962. hoverCursor: string;
  91963. /** Gets the list of actions */
  91964. actions: IAction[];
  91965. /**
  91966. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91967. */
  91968. isRecursive: boolean;
  91969. /**
  91970. * Releases all associated resources
  91971. */
  91972. abstract dispose(): void;
  91973. /**
  91974. * Does this action manager has pointer triggers
  91975. */
  91976. abstract readonly hasPointerTriggers: boolean;
  91977. /**
  91978. * Does this action manager has pick triggers
  91979. */
  91980. abstract readonly hasPickTriggers: boolean;
  91981. /**
  91982. * Process a specific trigger
  91983. * @param trigger defines the trigger to process
  91984. * @param evt defines the event details to be processed
  91985. */
  91986. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91987. /**
  91988. * Does this action manager handles actions of any of the given triggers
  91989. * @param triggers defines the triggers to be tested
  91990. * @return a boolean indicating whether one (or more) of the triggers is handled
  91991. */
  91992. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91993. /**
  91994. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91995. * speed.
  91996. * @param triggerA defines the trigger to be tested
  91997. * @param triggerB defines the trigger to be tested
  91998. * @return a boolean indicating whether one (or more) of the triggers is handled
  91999. */
  92000. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92001. /**
  92002. * Does this action manager handles actions of a given trigger
  92003. * @param trigger defines the trigger to be tested
  92004. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92005. * @return whether the trigger is handled
  92006. */
  92007. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92008. /**
  92009. * Serialize this manager to a JSON object
  92010. * @param name defines the property name to store this manager
  92011. * @returns a JSON representation of this manager
  92012. */
  92013. abstract serialize(name: string): any;
  92014. /**
  92015. * Registers an action to this action manager
  92016. * @param action defines the action to be registered
  92017. * @return the action amended (prepared) after registration
  92018. */
  92019. abstract registerAction(action: IAction): Nullable<IAction>;
  92020. /**
  92021. * Unregisters an action to this action manager
  92022. * @param action defines the action to be unregistered
  92023. * @return a boolean indicating whether the action has been unregistered
  92024. */
  92025. abstract unregisterAction(action: IAction): Boolean;
  92026. /**
  92027. * Does exist one action manager with at least one trigger
  92028. **/
  92029. static readonly HasTriggers: boolean;
  92030. /**
  92031. * Does exist one action manager with at least one pick trigger
  92032. **/
  92033. static readonly HasPickTriggers: boolean;
  92034. /**
  92035. * Does exist one action manager that handles actions of a given trigger
  92036. * @param trigger defines the trigger to be tested
  92037. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92038. **/
  92039. static HasSpecificTrigger(trigger: number): boolean;
  92040. }
  92041. }
  92042. declare module BABYLON {
  92043. /**
  92044. * Defines how a node can be built from a string name.
  92045. */
  92046. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92047. /**
  92048. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92049. */
  92050. export class Node implements IBehaviorAware<Node> {
  92051. /** @hidden */
  92052. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92053. private static _NodeConstructors;
  92054. /**
  92055. * Add a new node constructor
  92056. * @param type defines the type name of the node to construct
  92057. * @param constructorFunc defines the constructor function
  92058. */
  92059. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92060. /**
  92061. * Returns a node constructor based on type name
  92062. * @param type defines the type name
  92063. * @param name defines the new node name
  92064. * @param scene defines the hosting scene
  92065. * @param options defines optional options to transmit to constructors
  92066. * @returns the new constructor or null
  92067. */
  92068. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92069. /**
  92070. * Gets or sets the name of the node
  92071. */
  92072. name: string;
  92073. /**
  92074. * Gets or sets the id of the node
  92075. */
  92076. id: string;
  92077. /**
  92078. * Gets or sets the unique id of the node
  92079. */
  92080. uniqueId: number;
  92081. /**
  92082. * Gets or sets a string used to store user defined state for the node
  92083. */
  92084. state: string;
  92085. /**
  92086. * Gets or sets an object used to store user defined information for the node
  92087. */
  92088. metadata: any;
  92089. /**
  92090. * For internal use only. Please do not use.
  92091. */
  92092. reservedDataStore: any;
  92093. /**
  92094. * List of inspectable custom properties (used by the Inspector)
  92095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92096. */
  92097. inspectableCustomProperties: IInspectable[];
  92098. /**
  92099. * Gets or sets a boolean used to define if the node must be serialized
  92100. */
  92101. doNotSerialize: boolean;
  92102. /** @hidden */
  92103. _isDisposed: boolean;
  92104. /**
  92105. * Gets a list of Animations associated with the node
  92106. */
  92107. animations: Animation[];
  92108. protected _ranges: {
  92109. [name: string]: Nullable<AnimationRange>;
  92110. };
  92111. /**
  92112. * Callback raised when the node is ready to be used
  92113. */
  92114. onReady: Nullable<(node: Node) => void>;
  92115. private _isEnabled;
  92116. private _isParentEnabled;
  92117. private _isReady;
  92118. /** @hidden */
  92119. _currentRenderId: number;
  92120. private _parentUpdateId;
  92121. /** @hidden */
  92122. _childUpdateId: number;
  92123. /** @hidden */
  92124. _waitingParentId: Nullable<string>;
  92125. /** @hidden */
  92126. _scene: Scene;
  92127. /** @hidden */
  92128. _cache: any;
  92129. private _parentNode;
  92130. private _children;
  92131. /** @hidden */
  92132. _worldMatrix: Matrix;
  92133. /** @hidden */
  92134. _worldMatrixDeterminant: number;
  92135. /** @hidden */
  92136. _worldMatrixDeterminantIsDirty: boolean;
  92137. /** @hidden */
  92138. private _sceneRootNodesIndex;
  92139. /**
  92140. * Gets a boolean indicating if the node has been disposed
  92141. * @returns true if the node was disposed
  92142. */
  92143. isDisposed(): boolean;
  92144. /**
  92145. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92146. * @see https://doc.babylonjs.com/how_to/parenting
  92147. */
  92148. parent: Nullable<Node>;
  92149. private addToSceneRootNodes;
  92150. private removeFromSceneRootNodes;
  92151. private _animationPropertiesOverride;
  92152. /**
  92153. * Gets or sets the animation properties override
  92154. */
  92155. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92156. /**
  92157. * Gets a string idenfifying the name of the class
  92158. * @returns "Node" string
  92159. */
  92160. getClassName(): string;
  92161. /** @hidden */
  92162. readonly _isNode: boolean;
  92163. /**
  92164. * An event triggered when the mesh is disposed
  92165. */
  92166. onDisposeObservable: Observable<Node>;
  92167. private _onDisposeObserver;
  92168. /**
  92169. * Sets a callback that will be raised when the node will be disposed
  92170. */
  92171. onDispose: () => void;
  92172. /**
  92173. * Creates a new Node
  92174. * @param name the name and id to be given to this node
  92175. * @param scene the scene this node will be added to
  92176. * @param addToRootNodes the node will be added to scene.rootNodes
  92177. */
  92178. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92179. /**
  92180. * Gets the scene of the node
  92181. * @returns a scene
  92182. */
  92183. getScene(): Scene;
  92184. /**
  92185. * Gets the engine of the node
  92186. * @returns a Engine
  92187. */
  92188. getEngine(): Engine;
  92189. private _behaviors;
  92190. /**
  92191. * Attach a behavior to the node
  92192. * @see http://doc.babylonjs.com/features/behaviour
  92193. * @param behavior defines the behavior to attach
  92194. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92195. * @returns the current Node
  92196. */
  92197. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92198. /**
  92199. * Remove an attached behavior
  92200. * @see http://doc.babylonjs.com/features/behaviour
  92201. * @param behavior defines the behavior to attach
  92202. * @returns the current Node
  92203. */
  92204. removeBehavior(behavior: Behavior<Node>): Node;
  92205. /**
  92206. * Gets the list of attached behaviors
  92207. * @see http://doc.babylonjs.com/features/behaviour
  92208. */
  92209. readonly behaviors: Behavior<Node>[];
  92210. /**
  92211. * Gets an attached behavior by name
  92212. * @param name defines the name of the behavior to look for
  92213. * @see http://doc.babylonjs.com/features/behaviour
  92214. * @returns null if behavior was not found else the requested behavior
  92215. */
  92216. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92217. /**
  92218. * Returns the latest update of the World matrix
  92219. * @returns a Matrix
  92220. */
  92221. getWorldMatrix(): Matrix;
  92222. /** @hidden */
  92223. _getWorldMatrixDeterminant(): number;
  92224. /**
  92225. * Returns directly the latest state of the mesh World matrix.
  92226. * A Matrix is returned.
  92227. */
  92228. readonly worldMatrixFromCache: Matrix;
  92229. /** @hidden */
  92230. _initCache(): void;
  92231. /** @hidden */
  92232. updateCache(force?: boolean): void;
  92233. /** @hidden */
  92234. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92235. /** @hidden */
  92236. _updateCache(ignoreParentClass?: boolean): void;
  92237. /** @hidden */
  92238. _isSynchronized(): boolean;
  92239. /** @hidden */
  92240. _markSyncedWithParent(): void;
  92241. /** @hidden */
  92242. isSynchronizedWithParent(): boolean;
  92243. /** @hidden */
  92244. isSynchronized(): boolean;
  92245. /**
  92246. * Is this node ready to be used/rendered
  92247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92248. * @return true if the node is ready
  92249. */
  92250. isReady(completeCheck?: boolean): boolean;
  92251. /**
  92252. * Is this node enabled?
  92253. * 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
  92254. * @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
  92255. * @return whether this node (and its parent) is enabled
  92256. */
  92257. isEnabled(checkAncestors?: boolean): boolean;
  92258. /** @hidden */
  92259. protected _syncParentEnabledState(): void;
  92260. /**
  92261. * Set the enabled state of this node
  92262. * @param value defines the new enabled state
  92263. */
  92264. setEnabled(value: boolean): void;
  92265. /**
  92266. * Is this node a descendant of the given node?
  92267. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92268. * @param ancestor defines the parent node to inspect
  92269. * @returns a boolean indicating if this node is a descendant of the given node
  92270. */
  92271. isDescendantOf(ancestor: Node): boolean;
  92272. /** @hidden */
  92273. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92274. /**
  92275. * Will return all nodes that have this node as ascendant
  92276. * @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
  92277. * @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
  92278. * @return all children nodes of all types
  92279. */
  92280. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92281. /**
  92282. * Get all child-meshes of this node
  92283. * @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)
  92284. * @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
  92285. * @returns an array of AbstractMesh
  92286. */
  92287. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92288. /**
  92289. * Get all direct children of this node
  92290. * @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
  92291. * @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)
  92292. * @returns an array of Node
  92293. */
  92294. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92295. /** @hidden */
  92296. _setReady(state: boolean): void;
  92297. /**
  92298. * Get an animation by name
  92299. * @param name defines the name of the animation to look for
  92300. * @returns null if not found else the requested animation
  92301. */
  92302. getAnimationByName(name: string): Nullable<Animation>;
  92303. /**
  92304. * Creates an animation range for this node
  92305. * @param name defines the name of the range
  92306. * @param from defines the starting key
  92307. * @param to defines the end key
  92308. */
  92309. createAnimationRange(name: string, from: number, to: number): void;
  92310. /**
  92311. * Delete a specific animation range
  92312. * @param name defines the name of the range to delete
  92313. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92314. */
  92315. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92316. /**
  92317. * Get an animation range by name
  92318. * @param name defines the name of the animation range to look for
  92319. * @returns null if not found else the requested animation range
  92320. */
  92321. getAnimationRange(name: string): Nullable<AnimationRange>;
  92322. /**
  92323. * Gets the list of all animation ranges defined on this node
  92324. * @returns an array
  92325. */
  92326. getAnimationRanges(): Nullable<AnimationRange>[];
  92327. /**
  92328. * Will start the animation sequence
  92329. * @param name defines the range frames for animation sequence
  92330. * @param loop defines if the animation should loop (false by default)
  92331. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92332. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92333. * @returns the object created for this animation. If range does not exist, it will return null
  92334. */
  92335. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92336. /**
  92337. * Serialize animation ranges into a JSON compatible object
  92338. * @returns serialization object
  92339. */
  92340. serializeAnimationRanges(): any;
  92341. /**
  92342. * Computes the world matrix of the node
  92343. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92344. * @returns the world matrix
  92345. */
  92346. computeWorldMatrix(force?: boolean): Matrix;
  92347. /**
  92348. * Releases resources associated with this node.
  92349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92351. */
  92352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92353. /**
  92354. * Parse animation range data from a serialization object and store them into a given node
  92355. * @param node defines where to store the animation ranges
  92356. * @param parsedNode defines the serialization object to read data from
  92357. * @param scene defines the hosting scene
  92358. */
  92359. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92360. /**
  92361. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92362. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92363. * @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
  92364. * @returns the new bounding vectors
  92365. */
  92366. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92367. min: Vector3;
  92368. max: Vector3;
  92369. };
  92370. }
  92371. }
  92372. declare module BABYLON {
  92373. /**
  92374. * @hidden
  92375. */
  92376. export class _IAnimationState {
  92377. key: number;
  92378. repeatCount: number;
  92379. workValue?: any;
  92380. loopMode?: number;
  92381. offsetValue?: any;
  92382. highLimitValue?: any;
  92383. }
  92384. /**
  92385. * Class used to store any kind of animation
  92386. */
  92387. export class Animation {
  92388. /**Name of the animation */
  92389. name: string;
  92390. /**Property to animate */
  92391. targetProperty: string;
  92392. /**The frames per second of the animation */
  92393. framePerSecond: number;
  92394. /**The data type of the animation */
  92395. dataType: number;
  92396. /**The loop mode of the animation */
  92397. loopMode?: number | undefined;
  92398. /**Specifies if blending should be enabled */
  92399. enableBlending?: boolean | undefined;
  92400. /**
  92401. * Use matrix interpolation instead of using direct key value when animating matrices
  92402. */
  92403. static AllowMatricesInterpolation: boolean;
  92404. /**
  92405. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92406. */
  92407. static AllowMatrixDecomposeForInterpolation: boolean;
  92408. /**
  92409. * Stores the key frames of the animation
  92410. */
  92411. private _keys;
  92412. /**
  92413. * Stores the easing function of the animation
  92414. */
  92415. private _easingFunction;
  92416. /**
  92417. * @hidden Internal use only
  92418. */
  92419. _runtimeAnimations: RuntimeAnimation[];
  92420. /**
  92421. * The set of event that will be linked to this animation
  92422. */
  92423. private _events;
  92424. /**
  92425. * Stores an array of target property paths
  92426. */
  92427. targetPropertyPath: string[];
  92428. /**
  92429. * Stores the blending speed of the animation
  92430. */
  92431. blendingSpeed: number;
  92432. /**
  92433. * Stores the animation ranges for the animation
  92434. */
  92435. private _ranges;
  92436. /**
  92437. * @hidden Internal use
  92438. */
  92439. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92440. /**
  92441. * Sets up an animation
  92442. * @param property The property to animate
  92443. * @param animationType The animation type to apply
  92444. * @param framePerSecond The frames per second of the animation
  92445. * @param easingFunction The easing function used in the animation
  92446. * @returns The created animation
  92447. */
  92448. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92449. /**
  92450. * Create and start an animation on a node
  92451. * @param name defines the name of the global animation that will be run on all nodes
  92452. * @param node defines the root node where the animation will take place
  92453. * @param targetProperty defines property to animate
  92454. * @param framePerSecond defines the number of frame per second yo use
  92455. * @param totalFrame defines the number of frames in total
  92456. * @param from defines the initial value
  92457. * @param to defines the final value
  92458. * @param loopMode defines which loop mode you want to use (off by default)
  92459. * @param easingFunction defines the easing function to use (linear by default)
  92460. * @param onAnimationEnd defines the callback to call when animation end
  92461. * @returns the animatable created for this animation
  92462. */
  92463. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92464. /**
  92465. * Create and start an animation on a node and its descendants
  92466. * @param name defines the name of the global animation that will be run on all nodes
  92467. * @param node defines the root node where the animation will take place
  92468. * @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
  92469. * @param targetProperty defines property to animate
  92470. * @param framePerSecond defines the number of frame per second to use
  92471. * @param totalFrame defines the number of frames in total
  92472. * @param from defines the initial value
  92473. * @param to defines the final value
  92474. * @param loopMode defines which loop mode you want to use (off by default)
  92475. * @param easingFunction defines the easing function to use (linear by default)
  92476. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92477. * @returns the list of animatables created for all nodes
  92478. * @example https://www.babylonjs-playground.com/#MH0VLI
  92479. */
  92480. 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[]>;
  92481. /**
  92482. * Creates a new animation, merges it with the existing animations and starts it
  92483. * @param name Name of the animation
  92484. * @param node Node which contains the scene that begins the animations
  92485. * @param targetProperty Specifies which property to animate
  92486. * @param framePerSecond The frames per second of the animation
  92487. * @param totalFrame The total number of frames
  92488. * @param from The frame at the beginning of the animation
  92489. * @param to The frame at the end of the animation
  92490. * @param loopMode Specifies the loop mode of the animation
  92491. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92492. * @param onAnimationEnd Callback to run once the animation is complete
  92493. * @returns Nullable animation
  92494. */
  92495. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92496. /**
  92497. * Transition property of an host to the target Value
  92498. * @param property The property to transition
  92499. * @param targetValue The target Value of the property
  92500. * @param host The object where the property to animate belongs
  92501. * @param scene Scene used to run the animation
  92502. * @param frameRate Framerate (in frame/s) to use
  92503. * @param transition The transition type we want to use
  92504. * @param duration The duration of the animation, in milliseconds
  92505. * @param onAnimationEnd Callback trigger at the end of the animation
  92506. * @returns Nullable animation
  92507. */
  92508. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92509. /**
  92510. * Return the array of runtime animations currently using this animation
  92511. */
  92512. readonly runtimeAnimations: RuntimeAnimation[];
  92513. /**
  92514. * Specifies if any of the runtime animations are currently running
  92515. */
  92516. readonly hasRunningRuntimeAnimations: boolean;
  92517. /**
  92518. * Initializes the animation
  92519. * @param name Name of the animation
  92520. * @param targetProperty Property to animate
  92521. * @param framePerSecond The frames per second of the animation
  92522. * @param dataType The data type of the animation
  92523. * @param loopMode The loop mode of the animation
  92524. * @param enableBlending Specifies if blending should be enabled
  92525. */
  92526. constructor(
  92527. /**Name of the animation */
  92528. name: string,
  92529. /**Property to animate */
  92530. targetProperty: string,
  92531. /**The frames per second of the animation */
  92532. framePerSecond: number,
  92533. /**The data type of the animation */
  92534. dataType: number,
  92535. /**The loop mode of the animation */
  92536. loopMode?: number | undefined,
  92537. /**Specifies if blending should be enabled */
  92538. enableBlending?: boolean | undefined);
  92539. /**
  92540. * Converts the animation to a string
  92541. * @param fullDetails support for multiple levels of logging within scene loading
  92542. * @returns String form of the animation
  92543. */
  92544. toString(fullDetails?: boolean): string;
  92545. /**
  92546. * Add an event to this animation
  92547. * @param event Event to add
  92548. */
  92549. addEvent(event: AnimationEvent): void;
  92550. /**
  92551. * Remove all events found at the given frame
  92552. * @param frame The frame to remove events from
  92553. */
  92554. removeEvents(frame: number): void;
  92555. /**
  92556. * Retrieves all the events from the animation
  92557. * @returns Events from the animation
  92558. */
  92559. getEvents(): AnimationEvent[];
  92560. /**
  92561. * Creates an animation range
  92562. * @param name Name of the animation range
  92563. * @param from Starting frame of the animation range
  92564. * @param to Ending frame of the animation
  92565. */
  92566. createRange(name: string, from: number, to: number): void;
  92567. /**
  92568. * Deletes an animation range by name
  92569. * @param name Name of the animation range to delete
  92570. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92571. */
  92572. deleteRange(name: string, deleteFrames?: boolean): void;
  92573. /**
  92574. * Gets the animation range by name, or null if not defined
  92575. * @param name Name of the animation range
  92576. * @returns Nullable animation range
  92577. */
  92578. getRange(name: string): Nullable<AnimationRange>;
  92579. /**
  92580. * Gets the key frames from the animation
  92581. * @returns The key frames of the animation
  92582. */
  92583. getKeys(): Array<IAnimationKey>;
  92584. /**
  92585. * Gets the highest frame rate of the animation
  92586. * @returns Highest frame rate of the animation
  92587. */
  92588. getHighestFrame(): number;
  92589. /**
  92590. * Gets the easing function of the animation
  92591. * @returns Easing function of the animation
  92592. */
  92593. getEasingFunction(): IEasingFunction;
  92594. /**
  92595. * Sets the easing function of the animation
  92596. * @param easingFunction A custom mathematical formula for animation
  92597. */
  92598. setEasingFunction(easingFunction: EasingFunction): void;
  92599. /**
  92600. * Interpolates a scalar linearly
  92601. * @param startValue Start value of the animation curve
  92602. * @param endValue End value of the animation curve
  92603. * @param gradient Scalar amount to interpolate
  92604. * @returns Interpolated scalar value
  92605. */
  92606. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92607. /**
  92608. * Interpolates a scalar cubically
  92609. * @param startValue Start value of the animation curve
  92610. * @param outTangent End tangent of the animation
  92611. * @param endValue End value of the animation curve
  92612. * @param inTangent Start tangent of the animation curve
  92613. * @param gradient Scalar amount to interpolate
  92614. * @returns Interpolated scalar value
  92615. */
  92616. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92617. /**
  92618. * Interpolates a quaternion using a spherical linear interpolation
  92619. * @param startValue Start value of the animation curve
  92620. * @param endValue End value of the animation curve
  92621. * @param gradient Scalar amount to interpolate
  92622. * @returns Interpolated quaternion value
  92623. */
  92624. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92625. /**
  92626. * Interpolates a quaternion cubically
  92627. * @param startValue Start value of the animation curve
  92628. * @param outTangent End tangent of the animation curve
  92629. * @param endValue End value of the animation curve
  92630. * @param inTangent Start tangent of the animation curve
  92631. * @param gradient Scalar amount to interpolate
  92632. * @returns Interpolated quaternion value
  92633. */
  92634. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92635. /**
  92636. * Interpolates a Vector3 linearl
  92637. * @param startValue Start value of the animation curve
  92638. * @param endValue End value of the animation curve
  92639. * @param gradient Scalar amount to interpolate
  92640. * @returns Interpolated scalar value
  92641. */
  92642. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92643. /**
  92644. * Interpolates a Vector3 cubically
  92645. * @param startValue Start value of the animation curve
  92646. * @param outTangent End tangent of the animation
  92647. * @param endValue End value of the animation curve
  92648. * @param inTangent Start tangent of the animation curve
  92649. * @param gradient Scalar amount to interpolate
  92650. * @returns InterpolatedVector3 value
  92651. */
  92652. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92653. /**
  92654. * Interpolates a Vector2 linearly
  92655. * @param startValue Start value of the animation curve
  92656. * @param endValue End value of the animation curve
  92657. * @param gradient Scalar amount to interpolate
  92658. * @returns Interpolated Vector2 value
  92659. */
  92660. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92661. /**
  92662. * Interpolates a Vector2 cubically
  92663. * @param startValue Start value of the animation curve
  92664. * @param outTangent End tangent of the animation
  92665. * @param endValue End value of the animation curve
  92666. * @param inTangent Start tangent of the animation curve
  92667. * @param gradient Scalar amount to interpolate
  92668. * @returns Interpolated Vector2 value
  92669. */
  92670. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92671. /**
  92672. * Interpolates a size linearly
  92673. * @param startValue Start value of the animation curve
  92674. * @param endValue End value of the animation curve
  92675. * @param gradient Scalar amount to interpolate
  92676. * @returns Interpolated Size value
  92677. */
  92678. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92679. /**
  92680. * Interpolates a Color3 linearly
  92681. * @param startValue Start value of the animation curve
  92682. * @param endValue End value of the animation curve
  92683. * @param gradient Scalar amount to interpolate
  92684. * @returns Interpolated Color3 value
  92685. */
  92686. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92687. /**
  92688. * @hidden Internal use only
  92689. */
  92690. _getKeyValue(value: any): any;
  92691. /**
  92692. * @hidden Internal use only
  92693. */
  92694. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92695. /**
  92696. * Defines the function to use to interpolate matrices
  92697. * @param startValue defines the start matrix
  92698. * @param endValue defines the end matrix
  92699. * @param gradient defines the gradient between both matrices
  92700. * @param result defines an optional target matrix where to store the interpolation
  92701. * @returns the interpolated matrix
  92702. */
  92703. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92704. /**
  92705. * Makes a copy of the animation
  92706. * @returns Cloned animation
  92707. */
  92708. clone(): Animation;
  92709. /**
  92710. * Sets the key frames of the animation
  92711. * @param values The animation key frames to set
  92712. */
  92713. setKeys(values: Array<IAnimationKey>): void;
  92714. /**
  92715. * Serializes the animation to an object
  92716. * @returns Serialized object
  92717. */
  92718. serialize(): any;
  92719. /**
  92720. * Float animation type
  92721. */
  92722. private static _ANIMATIONTYPE_FLOAT;
  92723. /**
  92724. * Vector3 animation type
  92725. */
  92726. private static _ANIMATIONTYPE_VECTOR3;
  92727. /**
  92728. * Quaternion animation type
  92729. */
  92730. private static _ANIMATIONTYPE_QUATERNION;
  92731. /**
  92732. * Matrix animation type
  92733. */
  92734. private static _ANIMATIONTYPE_MATRIX;
  92735. /**
  92736. * Color3 animation type
  92737. */
  92738. private static _ANIMATIONTYPE_COLOR3;
  92739. /**
  92740. * Vector2 animation type
  92741. */
  92742. private static _ANIMATIONTYPE_VECTOR2;
  92743. /**
  92744. * Size animation type
  92745. */
  92746. private static _ANIMATIONTYPE_SIZE;
  92747. /**
  92748. * Relative Loop Mode
  92749. */
  92750. private static _ANIMATIONLOOPMODE_RELATIVE;
  92751. /**
  92752. * Cycle Loop Mode
  92753. */
  92754. private static _ANIMATIONLOOPMODE_CYCLE;
  92755. /**
  92756. * Constant Loop Mode
  92757. */
  92758. private static _ANIMATIONLOOPMODE_CONSTANT;
  92759. /**
  92760. * Get the float animation type
  92761. */
  92762. static readonly ANIMATIONTYPE_FLOAT: number;
  92763. /**
  92764. * Get the Vector3 animation type
  92765. */
  92766. static readonly ANIMATIONTYPE_VECTOR3: number;
  92767. /**
  92768. * Get the Vector2 animation type
  92769. */
  92770. static readonly ANIMATIONTYPE_VECTOR2: number;
  92771. /**
  92772. * Get the Size animation type
  92773. */
  92774. static readonly ANIMATIONTYPE_SIZE: number;
  92775. /**
  92776. * Get the Quaternion animation type
  92777. */
  92778. static readonly ANIMATIONTYPE_QUATERNION: number;
  92779. /**
  92780. * Get the Matrix animation type
  92781. */
  92782. static readonly ANIMATIONTYPE_MATRIX: number;
  92783. /**
  92784. * Get the Color3 animation type
  92785. */
  92786. static readonly ANIMATIONTYPE_COLOR3: number;
  92787. /**
  92788. * Get the Relative Loop Mode
  92789. */
  92790. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92791. /**
  92792. * Get the Cycle Loop Mode
  92793. */
  92794. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92795. /**
  92796. * Get the Constant Loop Mode
  92797. */
  92798. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92799. /** @hidden */
  92800. static _UniversalLerp(left: any, right: any, amount: number): any;
  92801. /**
  92802. * Parses an animation object and creates an animation
  92803. * @param parsedAnimation Parsed animation object
  92804. * @returns Animation object
  92805. */
  92806. static Parse(parsedAnimation: any): Animation;
  92807. /**
  92808. * Appends the serialized animations from the source animations
  92809. * @param source Source containing the animations
  92810. * @param destination Target to store the animations
  92811. */
  92812. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92813. }
  92814. }
  92815. declare module BABYLON {
  92816. /**
  92817. * Interface containing an array of animations
  92818. */
  92819. export interface IAnimatable {
  92820. /**
  92821. * Array of animations
  92822. */
  92823. animations: Nullable<Array<Animation>>;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * This represents all the required information to add a fresnel effect on a material:
  92829. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92830. */
  92831. export class FresnelParameters {
  92832. private _isEnabled;
  92833. /**
  92834. * Define if the fresnel effect is enable or not.
  92835. */
  92836. isEnabled: boolean;
  92837. /**
  92838. * Define the color used on edges (grazing angle)
  92839. */
  92840. leftColor: Color3;
  92841. /**
  92842. * Define the color used on center
  92843. */
  92844. rightColor: Color3;
  92845. /**
  92846. * Define bias applied to computed fresnel term
  92847. */
  92848. bias: number;
  92849. /**
  92850. * Defined the power exponent applied to fresnel term
  92851. */
  92852. power: number;
  92853. /**
  92854. * Clones the current fresnel and its valuues
  92855. * @returns a clone fresnel configuration
  92856. */
  92857. clone(): FresnelParameters;
  92858. /**
  92859. * Serializes the current fresnel parameters to a JSON representation.
  92860. * @return the JSON serialization
  92861. */
  92862. serialize(): any;
  92863. /**
  92864. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92865. * @param parsedFresnelParameters Define the JSON representation
  92866. * @returns the parsed parameters
  92867. */
  92868. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92869. }
  92870. }
  92871. declare module BABYLON {
  92872. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92873. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92874. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92875. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92876. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92877. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92878. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92879. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92880. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92881. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92882. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92883. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92884. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92885. /**
  92886. * Decorator used to define property that can be serialized as reference to a camera
  92887. * @param sourceName defines the name of the property to decorate
  92888. */
  92889. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92890. /**
  92891. * Class used to help serialization objects
  92892. */
  92893. export class SerializationHelper {
  92894. /** @hidden */
  92895. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92896. /** @hidden */
  92897. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92898. /** @hidden */
  92899. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92900. /** @hidden */
  92901. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92902. /**
  92903. * Appends the serialized animations from the source animations
  92904. * @param source Source containing the animations
  92905. * @param destination Target to store the animations
  92906. */
  92907. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92908. /**
  92909. * Static function used to serialized a specific entity
  92910. * @param entity defines the entity to serialize
  92911. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92912. * @returns a JSON compatible object representing the serialization of the entity
  92913. */
  92914. static Serialize<T>(entity: T, serializationObject?: any): any;
  92915. /**
  92916. * Creates a new entity from a serialization data object
  92917. * @param creationFunction defines a function used to instanciated the new entity
  92918. * @param source defines the source serialization data
  92919. * @param scene defines the hosting scene
  92920. * @param rootUrl defines the root url for resources
  92921. * @returns a new entity
  92922. */
  92923. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92924. /**
  92925. * Clones an object
  92926. * @param creationFunction defines the function used to instanciate the new object
  92927. * @param source defines the source object
  92928. * @returns the cloned object
  92929. */
  92930. static Clone<T>(creationFunction: () => T, source: T): T;
  92931. /**
  92932. * Instanciates a new object based on a source one (some data will be shared between both object)
  92933. * @param creationFunction defines the function used to instanciate the new object
  92934. * @param source defines the source object
  92935. * @returns the new object
  92936. */
  92937. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92938. }
  92939. }
  92940. declare module BABYLON {
  92941. /**
  92942. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92943. */
  92944. export interface CubeMapInfo {
  92945. /**
  92946. * The pixel array for the front face.
  92947. * This is stored in format, left to right, up to down format.
  92948. */
  92949. front: Nullable<ArrayBufferView>;
  92950. /**
  92951. * The pixel array for the back face.
  92952. * This is stored in format, left to right, up to down format.
  92953. */
  92954. back: Nullable<ArrayBufferView>;
  92955. /**
  92956. * The pixel array for the left face.
  92957. * This is stored in format, left to right, up to down format.
  92958. */
  92959. left: Nullable<ArrayBufferView>;
  92960. /**
  92961. * The pixel array for the right face.
  92962. * This is stored in format, left to right, up to down format.
  92963. */
  92964. right: Nullable<ArrayBufferView>;
  92965. /**
  92966. * The pixel array for the up face.
  92967. * This is stored in format, left to right, up to down format.
  92968. */
  92969. up: Nullable<ArrayBufferView>;
  92970. /**
  92971. * The pixel array for the down face.
  92972. * This is stored in format, left to right, up to down format.
  92973. */
  92974. down: Nullable<ArrayBufferView>;
  92975. /**
  92976. * The size of the cubemap stored.
  92977. *
  92978. * Each faces will be size * size pixels.
  92979. */
  92980. size: number;
  92981. /**
  92982. * The format of the texture.
  92983. *
  92984. * RGBA, RGB.
  92985. */
  92986. format: number;
  92987. /**
  92988. * The type of the texture data.
  92989. *
  92990. * UNSIGNED_INT, FLOAT.
  92991. */
  92992. type: number;
  92993. /**
  92994. * Specifies whether the texture is in gamma space.
  92995. */
  92996. gammaSpace: boolean;
  92997. }
  92998. /**
  92999. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93000. */
  93001. export class PanoramaToCubeMapTools {
  93002. private static FACE_FRONT;
  93003. private static FACE_BACK;
  93004. private static FACE_RIGHT;
  93005. private static FACE_LEFT;
  93006. private static FACE_DOWN;
  93007. private static FACE_UP;
  93008. /**
  93009. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93010. *
  93011. * @param float32Array The source data.
  93012. * @param inputWidth The width of the input panorama.
  93013. * @param inputHeight The height of the input panorama.
  93014. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93015. * @return The cubemap data
  93016. */
  93017. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93018. private static CreateCubemapTexture;
  93019. private static CalcProjectionSpherical;
  93020. }
  93021. }
  93022. declare module BABYLON {
  93023. /**
  93024. * Helper class dealing with the extraction of spherical polynomial dataArray
  93025. * from a cube map.
  93026. */
  93027. export class CubeMapToSphericalPolynomialTools {
  93028. private static FileFaces;
  93029. /**
  93030. * Converts a texture to the according Spherical Polynomial data.
  93031. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93032. *
  93033. * @param texture The texture to extract the information from.
  93034. * @return The Spherical Polynomial data.
  93035. */
  93036. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93037. /**
  93038. * Converts a cubemap to the according Spherical Polynomial data.
  93039. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93040. *
  93041. * @param cubeInfo The Cube map to extract the information from.
  93042. * @return The Spherical Polynomial data.
  93043. */
  93044. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93045. }
  93046. }
  93047. declare module BABYLON {
  93048. /**
  93049. * Class used to manipulate GUIDs
  93050. */
  93051. export class GUID {
  93052. /**
  93053. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93054. * Be aware Math.random() could cause collisions, but:
  93055. * "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"
  93056. * @returns a pseudo random id
  93057. */
  93058. static RandomId(): string;
  93059. }
  93060. }
  93061. declare module BABYLON {
  93062. /**
  93063. * Base class of all the textures in babylon.
  93064. * It groups all the common properties the materials, post process, lights... might need
  93065. * in order to make a correct use of the texture.
  93066. */
  93067. export class BaseTexture implements IAnimatable {
  93068. /**
  93069. * Default anisotropic filtering level for the application.
  93070. * It is set to 4 as a good tradeoff between perf and quality.
  93071. */
  93072. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93073. /**
  93074. * Gets or sets the unique id of the texture
  93075. */
  93076. uniqueId: number;
  93077. /**
  93078. * Define the name of the texture.
  93079. */
  93080. name: string;
  93081. /**
  93082. * Gets or sets an object used to store user defined information.
  93083. */
  93084. metadata: any;
  93085. /**
  93086. * For internal use only. Please do not use.
  93087. */
  93088. reservedDataStore: any;
  93089. private _hasAlpha;
  93090. /**
  93091. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93092. */
  93093. hasAlpha: boolean;
  93094. /**
  93095. * Defines if the alpha value should be determined via the rgb values.
  93096. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93097. */
  93098. getAlphaFromRGB: boolean;
  93099. /**
  93100. * Intensity or strength of the texture.
  93101. * It is commonly used by materials to fine tune the intensity of the texture
  93102. */
  93103. level: number;
  93104. /**
  93105. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93106. * This is part of the texture as textures usually maps to one uv set.
  93107. */
  93108. coordinatesIndex: number;
  93109. private _coordinatesMode;
  93110. /**
  93111. * How a texture is mapped.
  93112. *
  93113. * | Value | Type | Description |
  93114. * | ----- | ----------------------------------- | ----------- |
  93115. * | 0 | EXPLICIT_MODE | |
  93116. * | 1 | SPHERICAL_MODE | |
  93117. * | 2 | PLANAR_MODE | |
  93118. * | 3 | CUBIC_MODE | |
  93119. * | 4 | PROJECTION_MODE | |
  93120. * | 5 | SKYBOX_MODE | |
  93121. * | 6 | INVCUBIC_MODE | |
  93122. * | 7 | EQUIRECTANGULAR_MODE | |
  93123. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93124. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93125. */
  93126. coordinatesMode: number;
  93127. /**
  93128. * | Value | Type | Description |
  93129. * | ----- | ------------------ | ----------- |
  93130. * | 0 | CLAMP_ADDRESSMODE | |
  93131. * | 1 | WRAP_ADDRESSMODE | |
  93132. * | 2 | MIRROR_ADDRESSMODE | |
  93133. */
  93134. wrapU: number;
  93135. /**
  93136. * | Value | Type | Description |
  93137. * | ----- | ------------------ | ----------- |
  93138. * | 0 | CLAMP_ADDRESSMODE | |
  93139. * | 1 | WRAP_ADDRESSMODE | |
  93140. * | 2 | MIRROR_ADDRESSMODE | |
  93141. */
  93142. wrapV: number;
  93143. /**
  93144. * | Value | Type | Description |
  93145. * | ----- | ------------------ | ----------- |
  93146. * | 0 | CLAMP_ADDRESSMODE | |
  93147. * | 1 | WRAP_ADDRESSMODE | |
  93148. * | 2 | MIRROR_ADDRESSMODE | |
  93149. */
  93150. wrapR: number;
  93151. /**
  93152. * With compliant hardware and browser (supporting anisotropic filtering)
  93153. * this defines the level of anisotropic filtering in the texture.
  93154. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93155. */
  93156. anisotropicFilteringLevel: number;
  93157. /**
  93158. * Define if the texture is a cube texture or if false a 2d texture.
  93159. */
  93160. isCube: boolean;
  93161. /**
  93162. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93163. */
  93164. is3D: boolean;
  93165. /**
  93166. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93167. * HDR texture are usually stored in linear space.
  93168. * This only impacts the PBR and Background materials
  93169. */
  93170. gammaSpace: boolean;
  93171. /**
  93172. * Gets whether or not the texture contains RGBD data.
  93173. */
  93174. readonly isRGBD: boolean;
  93175. /**
  93176. * Is Z inverted in the texture (useful in a cube texture).
  93177. */
  93178. invertZ: boolean;
  93179. /**
  93180. * Are mip maps generated for this texture or not.
  93181. */
  93182. readonly noMipmap: boolean;
  93183. /**
  93184. * @hidden
  93185. */
  93186. lodLevelInAlpha: boolean;
  93187. /**
  93188. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93189. */
  93190. lodGenerationOffset: number;
  93191. /**
  93192. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93193. */
  93194. lodGenerationScale: number;
  93195. /**
  93196. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93197. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93198. * average roughness values.
  93199. */
  93200. linearSpecularLOD: boolean;
  93201. /**
  93202. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93203. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93204. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93205. */
  93206. irradianceTexture: Nullable<BaseTexture>;
  93207. /**
  93208. * Define if the texture is a render target.
  93209. */
  93210. isRenderTarget: boolean;
  93211. /**
  93212. * Define the unique id of the texture in the scene.
  93213. */
  93214. readonly uid: string;
  93215. /**
  93216. * Return a string representation of the texture.
  93217. * @returns the texture as a string
  93218. */
  93219. toString(): string;
  93220. /**
  93221. * Get the class name of the texture.
  93222. * @returns "BaseTexture"
  93223. */
  93224. getClassName(): string;
  93225. /**
  93226. * Define the list of animation attached to the texture.
  93227. */
  93228. animations: Animation[];
  93229. /**
  93230. * An event triggered when the texture is disposed.
  93231. */
  93232. onDisposeObservable: Observable<BaseTexture>;
  93233. private _onDisposeObserver;
  93234. /**
  93235. * Callback triggered when the texture has been disposed.
  93236. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93237. */
  93238. onDispose: () => void;
  93239. /**
  93240. * Define the current state of the loading sequence when in delayed load mode.
  93241. */
  93242. delayLoadState: number;
  93243. private _scene;
  93244. /** @hidden */
  93245. _texture: Nullable<InternalTexture>;
  93246. private _uid;
  93247. /**
  93248. * Define if the texture is preventinga material to render or not.
  93249. * If not and the texture is not ready, the engine will use a default black texture instead.
  93250. */
  93251. readonly isBlocking: boolean;
  93252. /**
  93253. * Instantiates a new BaseTexture.
  93254. * Base class of all the textures in babylon.
  93255. * It groups all the common properties the materials, post process, lights... might need
  93256. * in order to make a correct use of the texture.
  93257. * @param scene Define the scene the texture blongs to
  93258. */
  93259. constructor(scene: Nullable<Scene>);
  93260. /**
  93261. * Get the scene the texture belongs to.
  93262. * @returns the scene or null if undefined
  93263. */
  93264. getScene(): Nullable<Scene>;
  93265. /**
  93266. * Get the texture transform matrix used to offset tile the texture for istance.
  93267. * @returns the transformation matrix
  93268. */
  93269. getTextureMatrix(): Matrix;
  93270. /**
  93271. * Get the texture reflection matrix used to rotate/transform the reflection.
  93272. * @returns the reflection matrix
  93273. */
  93274. getReflectionTextureMatrix(): Matrix;
  93275. /**
  93276. * Get the underlying lower level texture from Babylon.
  93277. * @returns the insternal texture
  93278. */
  93279. getInternalTexture(): Nullable<InternalTexture>;
  93280. /**
  93281. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93282. * @returns true if ready or not blocking
  93283. */
  93284. isReadyOrNotBlocking(): boolean;
  93285. /**
  93286. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93287. * @returns true if fully ready
  93288. */
  93289. isReady(): boolean;
  93290. private _cachedSize;
  93291. /**
  93292. * Get the size of the texture.
  93293. * @returns the texture size.
  93294. */
  93295. getSize(): ISize;
  93296. /**
  93297. * Get the base size of the texture.
  93298. * It can be different from the size if the texture has been resized for POT for instance
  93299. * @returns the base size
  93300. */
  93301. getBaseSize(): ISize;
  93302. /**
  93303. * Update the sampling mode of the texture.
  93304. * Default is Trilinear mode.
  93305. *
  93306. * | Value | Type | Description |
  93307. * | ----- | ------------------ | ----------- |
  93308. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93309. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93310. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93311. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93312. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93313. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93314. * | 7 | NEAREST_LINEAR | |
  93315. * | 8 | NEAREST_NEAREST | |
  93316. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93317. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93318. * | 11 | LINEAR_LINEAR | |
  93319. * | 12 | LINEAR_NEAREST | |
  93320. *
  93321. * > _mag_: magnification filter (close to the viewer)
  93322. * > _min_: minification filter (far from the viewer)
  93323. * > _mip_: filter used between mip map levels
  93324. *@param samplingMode Define the new sampling mode of the texture
  93325. */
  93326. updateSamplingMode(samplingMode: number): void;
  93327. /**
  93328. * Scales the texture if is `canRescale()`
  93329. * @param ratio the resize factor we want to use to rescale
  93330. */
  93331. scale(ratio: number): void;
  93332. /**
  93333. * Get if the texture can rescale.
  93334. */
  93335. readonly canRescale: boolean;
  93336. /** @hidden */
  93337. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93338. /** @hidden */
  93339. _rebuild(): void;
  93340. /**
  93341. * Triggers the load sequence in delayed load mode.
  93342. */
  93343. delayLoad(): void;
  93344. /**
  93345. * Clones the texture.
  93346. * @returns the cloned texture
  93347. */
  93348. clone(): Nullable<BaseTexture>;
  93349. /**
  93350. * Get the texture underlying type (INT, FLOAT...)
  93351. */
  93352. readonly textureType: number;
  93353. /**
  93354. * Get the texture underlying format (RGB, RGBA...)
  93355. */
  93356. readonly textureFormat: number;
  93357. /**
  93358. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93359. * This will returns an RGBA array buffer containing either in values (0-255) or
  93360. * float values (0-1) depending of the underlying buffer type.
  93361. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93362. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93363. * @param buffer defines a user defined buffer to fill with data (can be null)
  93364. * @returns The Array buffer containing the pixels data.
  93365. */
  93366. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93367. /**
  93368. * Release and destroy the underlying lower level texture aka internalTexture.
  93369. */
  93370. releaseInternalTexture(): void;
  93371. /**
  93372. * Get the polynomial representation of the texture data.
  93373. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93374. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93375. */
  93376. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93377. /** @hidden */
  93378. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93379. /** @hidden */
  93380. readonly _lodTextureMid: Nullable<BaseTexture>;
  93381. /** @hidden */
  93382. readonly _lodTextureLow: Nullable<BaseTexture>;
  93383. /**
  93384. * Dispose the texture and release its associated resources.
  93385. */
  93386. dispose(): void;
  93387. /**
  93388. * Serialize the texture into a JSON representation that can be parsed later on.
  93389. * @returns the JSON representation of the texture
  93390. */
  93391. serialize(): any;
  93392. /**
  93393. * Helper function to be called back once a list of texture contains only ready textures.
  93394. * @param textures Define the list of textures to wait for
  93395. * @param callback Define the callback triggered once the entire list will be ready
  93396. */
  93397. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93398. }
  93399. }
  93400. declare module BABYLON {
  93401. /**
  93402. * Class used to store data associated with WebGL texture data for the engine
  93403. * This class should not be used directly
  93404. */
  93405. export class InternalTexture {
  93406. /** @hidden */
  93407. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93408. /**
  93409. * The source of the texture data is unknown
  93410. */
  93411. static DATASOURCE_UNKNOWN: number;
  93412. /**
  93413. * Texture data comes from an URL
  93414. */
  93415. static DATASOURCE_URL: number;
  93416. /**
  93417. * Texture data is only used for temporary storage
  93418. */
  93419. static DATASOURCE_TEMP: number;
  93420. /**
  93421. * Texture data comes from raw data (ArrayBuffer)
  93422. */
  93423. static DATASOURCE_RAW: number;
  93424. /**
  93425. * Texture content is dynamic (video or dynamic texture)
  93426. */
  93427. static DATASOURCE_DYNAMIC: number;
  93428. /**
  93429. * Texture content is generated by rendering to it
  93430. */
  93431. static DATASOURCE_RENDERTARGET: number;
  93432. /**
  93433. * Texture content is part of a multi render target process
  93434. */
  93435. static DATASOURCE_MULTIRENDERTARGET: number;
  93436. /**
  93437. * Texture data comes from a cube data file
  93438. */
  93439. static DATASOURCE_CUBE: number;
  93440. /**
  93441. * Texture data comes from a raw cube data
  93442. */
  93443. static DATASOURCE_CUBERAW: number;
  93444. /**
  93445. * Texture data come from a prefiltered cube data file
  93446. */
  93447. static DATASOURCE_CUBEPREFILTERED: number;
  93448. /**
  93449. * Texture content is raw 3D data
  93450. */
  93451. static DATASOURCE_RAW3D: number;
  93452. /**
  93453. * Texture content is a depth texture
  93454. */
  93455. static DATASOURCE_DEPTHTEXTURE: number;
  93456. /**
  93457. * Texture data comes from a raw cube data encoded with RGBD
  93458. */
  93459. static DATASOURCE_CUBERAW_RGBD: number;
  93460. /**
  93461. * Defines if the texture is ready
  93462. */
  93463. isReady: boolean;
  93464. /**
  93465. * Defines if the texture is a cube texture
  93466. */
  93467. isCube: boolean;
  93468. /**
  93469. * Defines if the texture contains 3D data
  93470. */
  93471. is3D: boolean;
  93472. /**
  93473. * Defines if the texture contains multiview data
  93474. */
  93475. isMultiview: boolean;
  93476. /**
  93477. * Gets the URL used to load this texture
  93478. */
  93479. url: string;
  93480. /**
  93481. * Gets the sampling mode of the texture
  93482. */
  93483. samplingMode: number;
  93484. /**
  93485. * Gets a boolean indicating if the texture needs mipmaps generation
  93486. */
  93487. generateMipMaps: boolean;
  93488. /**
  93489. * Gets the number of samples used by the texture (WebGL2+ only)
  93490. */
  93491. samples: number;
  93492. /**
  93493. * Gets the type of the texture (int, float...)
  93494. */
  93495. type: number;
  93496. /**
  93497. * Gets the format of the texture (RGB, RGBA...)
  93498. */
  93499. format: number;
  93500. /**
  93501. * Observable called when the texture is loaded
  93502. */
  93503. onLoadedObservable: Observable<InternalTexture>;
  93504. /**
  93505. * Gets the width of the texture
  93506. */
  93507. width: number;
  93508. /**
  93509. * Gets the height of the texture
  93510. */
  93511. height: number;
  93512. /**
  93513. * Gets the depth of the texture
  93514. */
  93515. depth: number;
  93516. /**
  93517. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93518. */
  93519. baseWidth: number;
  93520. /**
  93521. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93522. */
  93523. baseHeight: number;
  93524. /**
  93525. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93526. */
  93527. baseDepth: number;
  93528. /**
  93529. * Gets a boolean indicating if the texture is inverted on Y axis
  93530. */
  93531. invertY: boolean;
  93532. /** @hidden */
  93533. _invertVScale: boolean;
  93534. /** @hidden */
  93535. _associatedChannel: number;
  93536. /** @hidden */
  93537. _dataSource: number;
  93538. /** @hidden */
  93539. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93540. /** @hidden */
  93541. _bufferView: Nullable<ArrayBufferView>;
  93542. /** @hidden */
  93543. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93544. /** @hidden */
  93545. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93546. /** @hidden */
  93547. _size: number;
  93548. /** @hidden */
  93549. _extension: string;
  93550. /** @hidden */
  93551. _files: Nullable<string[]>;
  93552. /** @hidden */
  93553. _workingCanvas: Nullable<HTMLCanvasElement>;
  93554. /** @hidden */
  93555. _workingContext: Nullable<CanvasRenderingContext2D>;
  93556. /** @hidden */
  93557. _framebuffer: Nullable<WebGLFramebuffer>;
  93558. /** @hidden */
  93559. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93560. /** @hidden */
  93561. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93562. /** @hidden */
  93563. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93564. /** @hidden */
  93565. _attachments: Nullable<number[]>;
  93566. /** @hidden */
  93567. _cachedCoordinatesMode: Nullable<number>;
  93568. /** @hidden */
  93569. _cachedWrapU: Nullable<number>;
  93570. /** @hidden */
  93571. _cachedWrapV: Nullable<number>;
  93572. /** @hidden */
  93573. _cachedWrapR: Nullable<number>;
  93574. /** @hidden */
  93575. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93576. /** @hidden */
  93577. _isDisabled: boolean;
  93578. /** @hidden */
  93579. _compression: Nullable<string>;
  93580. /** @hidden */
  93581. _generateStencilBuffer: boolean;
  93582. /** @hidden */
  93583. _generateDepthBuffer: boolean;
  93584. /** @hidden */
  93585. _comparisonFunction: number;
  93586. /** @hidden */
  93587. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93588. /** @hidden */
  93589. _lodGenerationScale: number;
  93590. /** @hidden */
  93591. _lodGenerationOffset: number;
  93592. /** @hidden */
  93593. _colorTextureArray: Nullable<WebGLTexture>;
  93594. /** @hidden */
  93595. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93596. /** @hidden */
  93597. _lodTextureHigh: Nullable<BaseTexture>;
  93598. /** @hidden */
  93599. _lodTextureMid: Nullable<BaseTexture>;
  93600. /** @hidden */
  93601. _lodTextureLow: Nullable<BaseTexture>;
  93602. /** @hidden */
  93603. _isRGBD: boolean;
  93604. /** @hidden */
  93605. _linearSpecularLOD: boolean;
  93606. /** @hidden */
  93607. _irradianceTexture: Nullable<BaseTexture>;
  93608. /** @hidden */
  93609. _webGLTexture: Nullable<WebGLTexture>;
  93610. /** @hidden */
  93611. _references: number;
  93612. private _engine;
  93613. /**
  93614. * Gets the Engine the texture belongs to.
  93615. * @returns The babylon engine
  93616. */
  93617. getEngine(): Engine;
  93618. /**
  93619. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93620. */
  93621. readonly dataSource: number;
  93622. /**
  93623. * Creates a new InternalTexture
  93624. * @param engine defines the engine to use
  93625. * @param dataSource defines the type of data that will be used
  93626. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93627. */
  93628. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93629. /**
  93630. * Increments the number of references (ie. the number of Texture that point to it)
  93631. */
  93632. incrementReferences(): void;
  93633. /**
  93634. * Change the size of the texture (not the size of the content)
  93635. * @param width defines the new width
  93636. * @param height defines the new height
  93637. * @param depth defines the new depth (1 by default)
  93638. */
  93639. updateSize(width: int, height: int, depth?: int): void;
  93640. /** @hidden */
  93641. _rebuild(): void;
  93642. /** @hidden */
  93643. _swapAndDie(target: InternalTexture): void;
  93644. /**
  93645. * Dispose the current allocated resources
  93646. */
  93647. dispose(): void;
  93648. }
  93649. }
  93650. declare module BABYLON {
  93651. /**
  93652. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93653. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93654. */
  93655. export class EffectFallbacks {
  93656. private _defines;
  93657. private _currentRank;
  93658. private _maxRank;
  93659. private _mesh;
  93660. /**
  93661. * Removes the fallback from the bound mesh.
  93662. */
  93663. unBindMesh(): void;
  93664. /**
  93665. * Adds a fallback on the specified property.
  93666. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93667. * @param define The name of the define in the shader
  93668. */
  93669. addFallback(rank: number, define: string): void;
  93670. /**
  93671. * Sets the mesh to use CPU skinning when needing to fallback.
  93672. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93673. * @param mesh The mesh to use the fallbacks.
  93674. */
  93675. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93676. /**
  93677. * Checks to see if more fallbacks are still availible.
  93678. */
  93679. readonly hasMoreFallbacks: boolean;
  93680. /**
  93681. * Removes the defines that should be removed when falling back.
  93682. * @param currentDefines defines the current define statements for the shader.
  93683. * @param effect defines the current effect we try to compile
  93684. * @returns The resulting defines with defines of the current rank removed.
  93685. */
  93686. reduce(currentDefines: string, effect: Effect): string;
  93687. }
  93688. /**
  93689. * Options to be used when creating an effect.
  93690. */
  93691. export class EffectCreationOptions {
  93692. /**
  93693. * Atrributes that will be used in the shader.
  93694. */
  93695. attributes: string[];
  93696. /**
  93697. * Uniform varible names that will be set in the shader.
  93698. */
  93699. uniformsNames: string[];
  93700. /**
  93701. * Uniform buffer varible names that will be set in the shader.
  93702. */
  93703. uniformBuffersNames: string[];
  93704. /**
  93705. * Sampler texture variable names that will be set in the shader.
  93706. */
  93707. samplers: string[];
  93708. /**
  93709. * Define statements that will be set in the shader.
  93710. */
  93711. defines: any;
  93712. /**
  93713. * Possible fallbacks for this effect to improve performance when needed.
  93714. */
  93715. fallbacks: Nullable<EffectFallbacks>;
  93716. /**
  93717. * Callback that will be called when the shader is compiled.
  93718. */
  93719. onCompiled: Nullable<(effect: Effect) => void>;
  93720. /**
  93721. * Callback that will be called if an error occurs during shader compilation.
  93722. */
  93723. onError: Nullable<(effect: Effect, errors: string) => void>;
  93724. /**
  93725. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93726. */
  93727. indexParameters: any;
  93728. /**
  93729. * Max number of lights that can be used in the shader.
  93730. */
  93731. maxSimultaneousLights: number;
  93732. /**
  93733. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93734. */
  93735. transformFeedbackVaryings: Nullable<string[]>;
  93736. }
  93737. /**
  93738. * Effect containing vertex and fragment shader that can be executed on an object.
  93739. */
  93740. export class Effect implements IDisposable {
  93741. /**
  93742. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93743. */
  93744. static ShadersRepository: string;
  93745. /**
  93746. * Name of the effect.
  93747. */
  93748. name: any;
  93749. /**
  93750. * String container all the define statements that should be set on the shader.
  93751. */
  93752. defines: string;
  93753. /**
  93754. * Callback that will be called when the shader is compiled.
  93755. */
  93756. onCompiled: Nullable<(effect: Effect) => void>;
  93757. /**
  93758. * Callback that will be called if an error occurs during shader compilation.
  93759. */
  93760. onError: Nullable<(effect: Effect, errors: string) => void>;
  93761. /**
  93762. * Callback that will be called when effect is bound.
  93763. */
  93764. onBind: Nullable<(effect: Effect) => void>;
  93765. /**
  93766. * Unique ID of the effect.
  93767. */
  93768. uniqueId: number;
  93769. /**
  93770. * Observable that will be called when the shader is compiled.
  93771. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93772. */
  93773. onCompileObservable: Observable<Effect>;
  93774. /**
  93775. * Observable that will be called if an error occurs during shader compilation.
  93776. */
  93777. onErrorObservable: Observable<Effect>;
  93778. /** @hidden */
  93779. _onBindObservable: Nullable<Observable<Effect>>;
  93780. /**
  93781. * Observable that will be called when effect is bound.
  93782. */
  93783. readonly onBindObservable: Observable<Effect>;
  93784. /** @hidden */
  93785. _bonesComputationForcedToCPU: boolean;
  93786. private static _uniqueIdSeed;
  93787. private _engine;
  93788. private _uniformBuffersNames;
  93789. private _uniformsNames;
  93790. private _samplerList;
  93791. private _samplers;
  93792. private _isReady;
  93793. private _compilationError;
  93794. private _attributesNames;
  93795. private _attributes;
  93796. private _uniforms;
  93797. /**
  93798. * Key for the effect.
  93799. * @hidden
  93800. */
  93801. _key: string;
  93802. private _indexParameters;
  93803. private _fallbacks;
  93804. private _vertexSourceCode;
  93805. private _fragmentSourceCode;
  93806. private _vertexSourceCodeOverride;
  93807. private _fragmentSourceCodeOverride;
  93808. private _transformFeedbackVaryings;
  93809. /**
  93810. * Compiled shader to webGL program.
  93811. * @hidden
  93812. */
  93813. _pipelineContext: Nullable<IPipelineContext>;
  93814. private _valueCache;
  93815. private static _baseCache;
  93816. /**
  93817. * Instantiates an effect.
  93818. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93819. * @param baseName Name of the effect.
  93820. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93821. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93822. * @param samplers List of sampler variables that will be passed to the shader.
  93823. * @param engine Engine to be used to render the effect
  93824. * @param defines Define statements to be added to the shader.
  93825. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93826. * @param onCompiled Callback that will be called when the shader is compiled.
  93827. * @param onError Callback that will be called if an error occurs during shader compilation.
  93828. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93829. */
  93830. 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);
  93831. private _useFinalCode;
  93832. /**
  93833. * Unique key for this effect
  93834. */
  93835. readonly key: string;
  93836. /**
  93837. * If the effect has been compiled and prepared.
  93838. * @returns if the effect is compiled and prepared.
  93839. */
  93840. isReady(): boolean;
  93841. private _isReadyInternal;
  93842. /**
  93843. * The engine the effect was initialized with.
  93844. * @returns the engine.
  93845. */
  93846. getEngine(): Engine;
  93847. /**
  93848. * The pipeline context for this effect
  93849. * @returns the associated pipeline context
  93850. */
  93851. getPipelineContext(): Nullable<IPipelineContext>;
  93852. /**
  93853. * The set of names of attribute variables for the shader.
  93854. * @returns An array of attribute names.
  93855. */
  93856. getAttributesNames(): string[];
  93857. /**
  93858. * Returns the attribute at the given index.
  93859. * @param index The index of the attribute.
  93860. * @returns The location of the attribute.
  93861. */
  93862. getAttributeLocation(index: number): number;
  93863. /**
  93864. * Returns the attribute based on the name of the variable.
  93865. * @param name of the attribute to look up.
  93866. * @returns the attribute location.
  93867. */
  93868. getAttributeLocationByName(name: string): number;
  93869. /**
  93870. * The number of attributes.
  93871. * @returns the numnber of attributes.
  93872. */
  93873. getAttributesCount(): number;
  93874. /**
  93875. * Gets the index of a uniform variable.
  93876. * @param uniformName of the uniform to look up.
  93877. * @returns the index.
  93878. */
  93879. getUniformIndex(uniformName: string): number;
  93880. /**
  93881. * Returns the attribute based on the name of the variable.
  93882. * @param uniformName of the uniform to look up.
  93883. * @returns the location of the uniform.
  93884. */
  93885. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93886. /**
  93887. * Returns an array of sampler variable names
  93888. * @returns The array of sampler variable neames.
  93889. */
  93890. getSamplers(): string[];
  93891. /**
  93892. * The error from the last compilation.
  93893. * @returns the error string.
  93894. */
  93895. getCompilationError(): string;
  93896. /**
  93897. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93898. * @param func The callback to be used.
  93899. */
  93900. executeWhenCompiled(func: (effect: Effect) => void): void;
  93901. private _checkIsReady;
  93902. /** @hidden */
  93903. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93904. /** @hidden */
  93905. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93906. /** @hidden */
  93907. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93908. /**
  93909. * Recompiles the webGL program
  93910. * @param vertexSourceCode The source code for the vertex shader.
  93911. * @param fragmentSourceCode The source code for the fragment shader.
  93912. * @param onCompiled Callback called when completed.
  93913. * @param onError Callback called on error.
  93914. * @hidden
  93915. */
  93916. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93917. /**
  93918. * Prepares the effect
  93919. * @hidden
  93920. */
  93921. _prepareEffect(): void;
  93922. private _processCompilationErrors;
  93923. /**
  93924. * Checks if the effect is supported. (Must be called after compilation)
  93925. */
  93926. readonly isSupported: boolean;
  93927. /**
  93928. * Binds a texture to the engine to be used as output of the shader.
  93929. * @param channel Name of the output variable.
  93930. * @param texture Texture to bind.
  93931. * @hidden
  93932. */
  93933. _bindTexture(channel: string, texture: InternalTexture): void;
  93934. /**
  93935. * Sets a texture on the engine to be used in the shader.
  93936. * @param channel Name of the sampler variable.
  93937. * @param texture Texture to set.
  93938. */
  93939. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93940. /**
  93941. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93942. * @param channel Name of the sampler variable.
  93943. * @param texture Texture to set.
  93944. */
  93945. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93946. /**
  93947. * Sets an array of textures on the engine to be used in the shader.
  93948. * @param channel Name of the variable.
  93949. * @param textures Textures to set.
  93950. */
  93951. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93952. /**
  93953. * 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)
  93954. * @param channel Name of the sampler variable.
  93955. * @param postProcess Post process to get the input texture from.
  93956. */
  93957. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93958. /**
  93959. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93960. * 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)
  93961. * @param channel Name of the sampler variable.
  93962. * @param postProcess Post process to get the output texture from.
  93963. */
  93964. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93965. /** @hidden */
  93966. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93967. /** @hidden */
  93968. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93969. /** @hidden */
  93970. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93971. /** @hidden */
  93972. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93973. /**
  93974. * Binds a buffer to a uniform.
  93975. * @param buffer Buffer to bind.
  93976. * @param name Name of the uniform variable to bind to.
  93977. */
  93978. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93979. /**
  93980. * Binds block to a uniform.
  93981. * @param blockName Name of the block to bind.
  93982. * @param index Index to bind.
  93983. */
  93984. bindUniformBlock(blockName: string, index: number): void;
  93985. /**
  93986. * Sets an interger value on a uniform variable.
  93987. * @param uniformName Name of the variable.
  93988. * @param value Value to be set.
  93989. * @returns this effect.
  93990. */
  93991. setInt(uniformName: string, value: number): Effect;
  93992. /**
  93993. * Sets an int array on a uniform variable.
  93994. * @param uniformName Name of the variable.
  93995. * @param array array to be set.
  93996. * @returns this effect.
  93997. */
  93998. setIntArray(uniformName: string, array: Int32Array): Effect;
  93999. /**
  94000. * 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)
  94001. * @param uniformName Name of the variable.
  94002. * @param array array to be set.
  94003. * @returns this effect.
  94004. */
  94005. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94006. /**
  94007. * 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)
  94008. * @param uniformName Name of the variable.
  94009. * @param array array to be set.
  94010. * @returns this effect.
  94011. */
  94012. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94013. /**
  94014. * 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)
  94015. * @param uniformName Name of the variable.
  94016. * @param array array to be set.
  94017. * @returns this effect.
  94018. */
  94019. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94020. /**
  94021. * Sets an float array on a uniform variable.
  94022. * @param uniformName Name of the variable.
  94023. * @param array array to be set.
  94024. * @returns this effect.
  94025. */
  94026. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94027. /**
  94028. * 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)
  94029. * @param uniformName Name of the variable.
  94030. * @param array array to be set.
  94031. * @returns this effect.
  94032. */
  94033. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94034. /**
  94035. * 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)
  94036. * @param uniformName Name of the variable.
  94037. * @param array array to be set.
  94038. * @returns this effect.
  94039. */
  94040. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94041. /**
  94042. * 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)
  94043. * @param uniformName Name of the variable.
  94044. * @param array array to be set.
  94045. * @returns this effect.
  94046. */
  94047. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94048. /**
  94049. * Sets an array on a uniform variable.
  94050. * @param uniformName Name of the variable.
  94051. * @param array array to be set.
  94052. * @returns this effect.
  94053. */
  94054. setArray(uniformName: string, array: number[]): Effect;
  94055. /**
  94056. * 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)
  94057. * @param uniformName Name of the variable.
  94058. * @param array array to be set.
  94059. * @returns this effect.
  94060. */
  94061. setArray2(uniformName: string, array: number[]): Effect;
  94062. /**
  94063. * 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)
  94064. * @param uniformName Name of the variable.
  94065. * @param array array to be set.
  94066. * @returns this effect.
  94067. */
  94068. setArray3(uniformName: string, array: number[]): Effect;
  94069. /**
  94070. * 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)
  94071. * @param uniformName Name of the variable.
  94072. * @param array array to be set.
  94073. * @returns this effect.
  94074. */
  94075. setArray4(uniformName: string, array: number[]): Effect;
  94076. /**
  94077. * Sets matrices on a uniform variable.
  94078. * @param uniformName Name of the variable.
  94079. * @param matrices matrices to be set.
  94080. * @returns this effect.
  94081. */
  94082. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94083. /**
  94084. * Sets matrix on a uniform variable.
  94085. * @param uniformName Name of the variable.
  94086. * @param matrix matrix to be set.
  94087. * @returns this effect.
  94088. */
  94089. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94090. /**
  94091. * 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)
  94092. * @param uniformName Name of the variable.
  94093. * @param matrix matrix to be set.
  94094. * @returns this effect.
  94095. */
  94096. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94097. /**
  94098. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94099. * @param uniformName Name of the variable.
  94100. * @param matrix matrix to be set.
  94101. * @returns this effect.
  94102. */
  94103. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94104. /**
  94105. * Sets a float on a uniform variable.
  94106. * @param uniformName Name of the variable.
  94107. * @param value value to be set.
  94108. * @returns this effect.
  94109. */
  94110. setFloat(uniformName: string, value: number): Effect;
  94111. /**
  94112. * Sets a boolean on a uniform variable.
  94113. * @param uniformName Name of the variable.
  94114. * @param bool value to be set.
  94115. * @returns this effect.
  94116. */
  94117. setBool(uniformName: string, bool: boolean): Effect;
  94118. /**
  94119. * Sets a Vector2 on a uniform variable.
  94120. * @param uniformName Name of the variable.
  94121. * @param vector2 vector2 to be set.
  94122. * @returns this effect.
  94123. */
  94124. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94125. /**
  94126. * Sets a float2 on a uniform variable.
  94127. * @param uniformName Name of the variable.
  94128. * @param x First float in float2.
  94129. * @param y Second float in float2.
  94130. * @returns this effect.
  94131. */
  94132. setFloat2(uniformName: string, x: number, y: number): Effect;
  94133. /**
  94134. * Sets a Vector3 on a uniform variable.
  94135. * @param uniformName Name of the variable.
  94136. * @param vector3 Value to be set.
  94137. * @returns this effect.
  94138. */
  94139. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94140. /**
  94141. * Sets a float3 on a uniform variable.
  94142. * @param uniformName Name of the variable.
  94143. * @param x First float in float3.
  94144. * @param y Second float in float3.
  94145. * @param z Third float in float3.
  94146. * @returns this effect.
  94147. */
  94148. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94149. /**
  94150. * Sets a Vector4 on a uniform variable.
  94151. * @param uniformName Name of the variable.
  94152. * @param vector4 Value to be set.
  94153. * @returns this effect.
  94154. */
  94155. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94156. /**
  94157. * Sets a float4 on a uniform variable.
  94158. * @param uniformName Name of the variable.
  94159. * @param x First float in float4.
  94160. * @param y Second float in float4.
  94161. * @param z Third float in float4.
  94162. * @param w Fourth float in float4.
  94163. * @returns this effect.
  94164. */
  94165. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94166. /**
  94167. * Sets a Color3 on a uniform variable.
  94168. * @param uniformName Name of the variable.
  94169. * @param color3 Value to be set.
  94170. * @returns this effect.
  94171. */
  94172. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94173. /**
  94174. * Sets a Color4 on a uniform variable.
  94175. * @param uniformName Name of the variable.
  94176. * @param color3 Value to be set.
  94177. * @param alpha Alpha value to be set.
  94178. * @returns this effect.
  94179. */
  94180. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94181. /**
  94182. * Sets a Color4 on a uniform variable
  94183. * @param uniformName defines the name of the variable
  94184. * @param color4 defines the value to be set
  94185. * @returns this effect.
  94186. */
  94187. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94188. /** Release all associated resources */
  94189. dispose(): void;
  94190. /**
  94191. * This function will add a new shader to the shader store
  94192. * @param name the name of the shader
  94193. * @param pixelShader optional pixel shader content
  94194. * @param vertexShader optional vertex shader content
  94195. */
  94196. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94197. /**
  94198. * Store of each shader (The can be looked up using effect.key)
  94199. */
  94200. static ShadersStore: {
  94201. [key: string]: string;
  94202. };
  94203. /**
  94204. * Store of each included file for a shader (The can be looked up using effect.key)
  94205. */
  94206. static IncludesShadersStore: {
  94207. [key: string]: string;
  94208. };
  94209. /**
  94210. * Resets the cache of effects.
  94211. */
  94212. static ResetCache(): void;
  94213. }
  94214. }
  94215. declare module BABYLON {
  94216. /**
  94217. * Uniform buffer objects.
  94218. *
  94219. * Handles blocks of uniform on the GPU.
  94220. *
  94221. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94222. *
  94223. * For more information, please refer to :
  94224. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94225. */
  94226. export class UniformBuffer {
  94227. private _engine;
  94228. private _buffer;
  94229. private _data;
  94230. private _bufferData;
  94231. private _dynamic?;
  94232. private _uniformLocations;
  94233. private _uniformSizes;
  94234. private _uniformLocationPointer;
  94235. private _needSync;
  94236. private _noUBO;
  94237. private _currentEffect;
  94238. private static _MAX_UNIFORM_SIZE;
  94239. private static _tempBuffer;
  94240. /**
  94241. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94242. * This is dynamic to allow compat with webgl 1 and 2.
  94243. * You will need to pass the name of the uniform as well as the value.
  94244. */
  94245. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94246. /**
  94247. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94248. * This is dynamic to allow compat with webgl 1 and 2.
  94249. * You will need to pass the name of the uniform as well as the value.
  94250. */
  94251. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94252. /**
  94253. * Lambda to Update a single float in a uniform buffer.
  94254. * This is dynamic to allow compat with webgl 1 and 2.
  94255. * You will need to pass the name of the uniform as well as the value.
  94256. */
  94257. updateFloat: (name: string, x: number) => void;
  94258. /**
  94259. * Lambda to Update a vec2 of float in a uniform buffer.
  94260. * This is dynamic to allow compat with webgl 1 and 2.
  94261. * You will need to pass the name of the uniform as well as the value.
  94262. */
  94263. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94264. /**
  94265. * Lambda to Update a vec3 of float in a uniform buffer.
  94266. * This is dynamic to allow compat with webgl 1 and 2.
  94267. * You will need to pass the name of the uniform as well as the value.
  94268. */
  94269. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94270. /**
  94271. * Lambda to Update a vec4 of float in a uniform buffer.
  94272. * This is dynamic to allow compat with webgl 1 and 2.
  94273. * You will need to pass the name of the uniform as well as the value.
  94274. */
  94275. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94276. /**
  94277. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94278. * This is dynamic to allow compat with webgl 1 and 2.
  94279. * You will need to pass the name of the uniform as well as the value.
  94280. */
  94281. updateMatrix: (name: string, mat: Matrix) => void;
  94282. /**
  94283. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94284. * This is dynamic to allow compat with webgl 1 and 2.
  94285. * You will need to pass the name of the uniform as well as the value.
  94286. */
  94287. updateVector3: (name: string, vector: Vector3) => void;
  94288. /**
  94289. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94290. * This is dynamic to allow compat with webgl 1 and 2.
  94291. * You will need to pass the name of the uniform as well as the value.
  94292. */
  94293. updateVector4: (name: string, vector: Vector4) => void;
  94294. /**
  94295. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94296. * This is dynamic to allow compat with webgl 1 and 2.
  94297. * You will need to pass the name of the uniform as well as the value.
  94298. */
  94299. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94300. /**
  94301. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94302. * This is dynamic to allow compat with webgl 1 and 2.
  94303. * You will need to pass the name of the uniform as well as the value.
  94304. */
  94305. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94306. /**
  94307. * Instantiates a new Uniform buffer objects.
  94308. *
  94309. * Handles blocks of uniform on the GPU.
  94310. *
  94311. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94312. *
  94313. * For more information, please refer to :
  94314. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94315. * @param engine Define the engine the buffer is associated with
  94316. * @param data Define the data contained in the buffer
  94317. * @param dynamic Define if the buffer is updatable
  94318. */
  94319. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94320. /**
  94321. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94322. * or just falling back on setUniformXXX calls.
  94323. */
  94324. readonly useUbo: boolean;
  94325. /**
  94326. * Indicates if the WebGL underlying uniform buffer is in sync
  94327. * with the javascript cache data.
  94328. */
  94329. readonly isSync: boolean;
  94330. /**
  94331. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94332. * Also, a dynamic UniformBuffer will disable cache verification and always
  94333. * update the underlying WebGL uniform buffer to the GPU.
  94334. * @returns if Dynamic, otherwise false
  94335. */
  94336. isDynamic(): boolean;
  94337. /**
  94338. * The data cache on JS side.
  94339. * @returns the underlying data as a float array
  94340. */
  94341. getData(): Float32Array;
  94342. /**
  94343. * The underlying WebGL Uniform buffer.
  94344. * @returns the webgl buffer
  94345. */
  94346. getBuffer(): Nullable<DataBuffer>;
  94347. /**
  94348. * std140 layout specifies how to align data within an UBO structure.
  94349. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94350. * for specs.
  94351. */
  94352. private _fillAlignment;
  94353. /**
  94354. * Adds an uniform in the buffer.
  94355. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94356. * for the layout to be correct !
  94357. * @param name Name of the uniform, as used in the uniform block in the shader.
  94358. * @param size Data size, or data directly.
  94359. */
  94360. addUniform(name: string, size: number | number[]): void;
  94361. /**
  94362. * Adds a Matrix 4x4 to the uniform buffer.
  94363. * @param name Name of the uniform, as used in the uniform block in the shader.
  94364. * @param mat A 4x4 matrix.
  94365. */
  94366. addMatrix(name: string, mat: Matrix): void;
  94367. /**
  94368. * Adds a vec2 to the uniform buffer.
  94369. * @param name Name of the uniform, as used in the uniform block in the shader.
  94370. * @param x Define the x component value of the vec2
  94371. * @param y Define the y component value of the vec2
  94372. */
  94373. addFloat2(name: string, x: number, y: number): void;
  94374. /**
  94375. * Adds a vec3 to the uniform buffer.
  94376. * @param name Name of the uniform, as used in the uniform block in the shader.
  94377. * @param x Define the x component value of the vec3
  94378. * @param y Define the y component value of the vec3
  94379. * @param z Define the z component value of the vec3
  94380. */
  94381. addFloat3(name: string, x: number, y: number, z: number): void;
  94382. /**
  94383. * Adds a vec3 to the uniform buffer.
  94384. * @param name Name of the uniform, as used in the uniform block in the shader.
  94385. * @param color Define the vec3 from a Color
  94386. */
  94387. addColor3(name: string, color: Color3): void;
  94388. /**
  94389. * Adds a vec4 to the uniform buffer.
  94390. * @param name Name of the uniform, as used in the uniform block in the shader.
  94391. * @param color Define the rgb components from a Color
  94392. * @param alpha Define the a component of the vec4
  94393. */
  94394. addColor4(name: string, color: Color3, alpha: number): void;
  94395. /**
  94396. * Adds a vec3 to the uniform buffer.
  94397. * @param name Name of the uniform, as used in the uniform block in the shader.
  94398. * @param vector Define the vec3 components from a Vector
  94399. */
  94400. addVector3(name: string, vector: Vector3): void;
  94401. /**
  94402. * Adds a Matrix 3x3 to the uniform buffer.
  94403. * @param name Name of the uniform, as used in the uniform block in the shader.
  94404. */
  94405. addMatrix3x3(name: string): void;
  94406. /**
  94407. * Adds a Matrix 2x2 to the uniform buffer.
  94408. * @param name Name of the uniform, as used in the uniform block in the shader.
  94409. */
  94410. addMatrix2x2(name: string): void;
  94411. /**
  94412. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94413. */
  94414. create(): void;
  94415. /** @hidden */
  94416. _rebuild(): void;
  94417. /**
  94418. * Updates the WebGL Uniform Buffer on the GPU.
  94419. * If the `dynamic` flag is set to true, no cache comparison is done.
  94420. * Otherwise, the buffer will be updated only if the cache differs.
  94421. */
  94422. update(): void;
  94423. /**
  94424. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94425. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94426. * @param data Define the flattened data
  94427. * @param size Define the size of the data.
  94428. */
  94429. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94430. private _valueCache;
  94431. private _cacheMatrix;
  94432. private _updateMatrix3x3ForUniform;
  94433. private _updateMatrix3x3ForEffect;
  94434. private _updateMatrix2x2ForEffect;
  94435. private _updateMatrix2x2ForUniform;
  94436. private _updateFloatForEffect;
  94437. private _updateFloatForUniform;
  94438. private _updateFloat2ForEffect;
  94439. private _updateFloat2ForUniform;
  94440. private _updateFloat3ForEffect;
  94441. private _updateFloat3ForUniform;
  94442. private _updateFloat4ForEffect;
  94443. private _updateFloat4ForUniform;
  94444. private _updateMatrixForEffect;
  94445. private _updateMatrixForUniform;
  94446. private _updateVector3ForEffect;
  94447. private _updateVector3ForUniform;
  94448. private _updateVector4ForEffect;
  94449. private _updateVector4ForUniform;
  94450. private _updateColor3ForEffect;
  94451. private _updateColor3ForUniform;
  94452. private _updateColor4ForEffect;
  94453. private _updateColor4ForUniform;
  94454. /**
  94455. * Sets a sampler uniform on the effect.
  94456. * @param name Define the name of the sampler.
  94457. * @param texture Define the texture to set in the sampler
  94458. */
  94459. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94460. /**
  94461. * Directly updates the value of the uniform in the cache AND on the GPU.
  94462. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94463. * @param data Define the flattened data
  94464. */
  94465. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94466. /**
  94467. * Binds this uniform buffer to an effect.
  94468. * @param effect Define the effect to bind the buffer to
  94469. * @param name Name of the uniform block in the shader.
  94470. */
  94471. bindToEffect(effect: Effect, name: string): void;
  94472. /**
  94473. * Disposes the uniform buffer.
  94474. */
  94475. dispose(): void;
  94476. }
  94477. }
  94478. declare module BABYLON {
  94479. /**
  94480. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94482. */
  94483. export class Analyser {
  94484. /**
  94485. * Gets or sets the smoothing
  94486. * @ignorenaming
  94487. */
  94488. SMOOTHING: number;
  94489. /**
  94490. * Gets or sets the FFT table size
  94491. * @ignorenaming
  94492. */
  94493. FFT_SIZE: number;
  94494. /**
  94495. * Gets or sets the bar graph amplitude
  94496. * @ignorenaming
  94497. */
  94498. BARGRAPHAMPLITUDE: number;
  94499. /**
  94500. * Gets or sets the position of the debug canvas
  94501. * @ignorenaming
  94502. */
  94503. DEBUGCANVASPOS: {
  94504. x: number;
  94505. y: number;
  94506. };
  94507. /**
  94508. * Gets or sets the debug canvas size
  94509. * @ignorenaming
  94510. */
  94511. DEBUGCANVASSIZE: {
  94512. width: number;
  94513. height: number;
  94514. };
  94515. private _byteFreqs;
  94516. private _byteTime;
  94517. private _floatFreqs;
  94518. private _webAudioAnalyser;
  94519. private _debugCanvas;
  94520. private _debugCanvasContext;
  94521. private _scene;
  94522. private _registerFunc;
  94523. private _audioEngine;
  94524. /**
  94525. * Creates a new analyser
  94526. * @param scene defines hosting scene
  94527. */
  94528. constructor(scene: Scene);
  94529. /**
  94530. * Get the number of data values you will have to play with for the visualization
  94531. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94532. * @returns a number
  94533. */
  94534. getFrequencyBinCount(): number;
  94535. /**
  94536. * Gets the current frequency data as a byte array
  94537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94538. * @returns a Uint8Array
  94539. */
  94540. getByteFrequencyData(): Uint8Array;
  94541. /**
  94542. * Gets the current waveform as a byte array
  94543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94544. * @returns a Uint8Array
  94545. */
  94546. getByteTimeDomainData(): Uint8Array;
  94547. /**
  94548. * Gets the current frequency data as a float array
  94549. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94550. * @returns a Float32Array
  94551. */
  94552. getFloatFrequencyData(): Float32Array;
  94553. /**
  94554. * Renders the debug canvas
  94555. */
  94556. drawDebugCanvas(): void;
  94557. /**
  94558. * Stops rendering the debug canvas and removes it
  94559. */
  94560. stopDebugCanvas(): void;
  94561. /**
  94562. * Connects two audio nodes
  94563. * @param inputAudioNode defines first node to connect
  94564. * @param outputAudioNode defines second node to connect
  94565. */
  94566. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94567. /**
  94568. * Releases all associated resources
  94569. */
  94570. dispose(): void;
  94571. }
  94572. }
  94573. declare module BABYLON {
  94574. /**
  94575. * This represents an audio engine and it is responsible
  94576. * to play, synchronize and analyse sounds throughout the application.
  94577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94578. */
  94579. export interface IAudioEngine extends IDisposable {
  94580. /**
  94581. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94582. */
  94583. readonly canUseWebAudio: boolean;
  94584. /**
  94585. * Gets the current AudioContext if available.
  94586. */
  94587. readonly audioContext: Nullable<AudioContext>;
  94588. /**
  94589. * The master gain node defines the global audio volume of your audio engine.
  94590. */
  94591. readonly masterGain: GainNode;
  94592. /**
  94593. * Gets whether or not mp3 are supported by your browser.
  94594. */
  94595. readonly isMP3supported: boolean;
  94596. /**
  94597. * Gets whether or not ogg are supported by your browser.
  94598. */
  94599. readonly isOGGsupported: boolean;
  94600. /**
  94601. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94602. * @ignoreNaming
  94603. */
  94604. WarnedWebAudioUnsupported: boolean;
  94605. /**
  94606. * Defines if the audio engine relies on a custom unlocked button.
  94607. * In this case, the embedded button will not be displayed.
  94608. */
  94609. useCustomUnlockedButton: boolean;
  94610. /**
  94611. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94612. */
  94613. readonly unlocked: boolean;
  94614. /**
  94615. * Event raised when audio has been unlocked on the browser.
  94616. */
  94617. onAudioUnlockedObservable: Observable<AudioEngine>;
  94618. /**
  94619. * Event raised when audio has been locked on the browser.
  94620. */
  94621. onAudioLockedObservable: Observable<AudioEngine>;
  94622. /**
  94623. * Flags the audio engine in Locked state.
  94624. * This happens due to new browser policies preventing audio to autoplay.
  94625. */
  94626. lock(): void;
  94627. /**
  94628. * Unlocks the audio engine once a user action has been done on the dom.
  94629. * This is helpful to resume play once browser policies have been satisfied.
  94630. */
  94631. unlock(): void;
  94632. }
  94633. /**
  94634. * This represents the default audio engine used in babylon.
  94635. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94637. */
  94638. export class AudioEngine implements IAudioEngine {
  94639. private _audioContext;
  94640. private _audioContextInitialized;
  94641. private _muteButton;
  94642. private _hostElement;
  94643. /**
  94644. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94645. */
  94646. canUseWebAudio: boolean;
  94647. /**
  94648. * The master gain node defines the global audio volume of your audio engine.
  94649. */
  94650. masterGain: GainNode;
  94651. /**
  94652. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94653. * @ignoreNaming
  94654. */
  94655. WarnedWebAudioUnsupported: boolean;
  94656. /**
  94657. * Gets whether or not mp3 are supported by your browser.
  94658. */
  94659. isMP3supported: boolean;
  94660. /**
  94661. * Gets whether or not ogg are supported by your browser.
  94662. */
  94663. isOGGsupported: boolean;
  94664. /**
  94665. * Gets whether audio has been unlocked on the device.
  94666. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94667. * a user interaction has happened.
  94668. */
  94669. unlocked: boolean;
  94670. /**
  94671. * Defines if the audio engine relies on a custom unlocked button.
  94672. * In this case, the embedded button will not be displayed.
  94673. */
  94674. useCustomUnlockedButton: boolean;
  94675. /**
  94676. * Event raised when audio has been unlocked on the browser.
  94677. */
  94678. onAudioUnlockedObservable: Observable<AudioEngine>;
  94679. /**
  94680. * Event raised when audio has been locked on the browser.
  94681. */
  94682. onAudioLockedObservable: Observable<AudioEngine>;
  94683. /**
  94684. * Gets the current AudioContext if available.
  94685. */
  94686. readonly audioContext: Nullable<AudioContext>;
  94687. private _connectedAnalyser;
  94688. /**
  94689. * Instantiates a new audio engine.
  94690. *
  94691. * There should be only one per page as some browsers restrict the number
  94692. * of audio contexts you can create.
  94693. * @param hostElement defines the host element where to display the mute icon if necessary
  94694. */
  94695. constructor(hostElement?: Nullable<HTMLElement>);
  94696. /**
  94697. * Flags the audio engine in Locked state.
  94698. * This happens due to new browser policies preventing audio to autoplay.
  94699. */
  94700. lock(): void;
  94701. /**
  94702. * Unlocks the audio engine once a user action has been done on the dom.
  94703. * This is helpful to resume play once browser policies have been satisfied.
  94704. */
  94705. unlock(): void;
  94706. private _resumeAudioContext;
  94707. private _initializeAudioContext;
  94708. private _tryToRun;
  94709. private _triggerRunningState;
  94710. private _triggerSuspendedState;
  94711. private _displayMuteButton;
  94712. private _moveButtonToTopLeft;
  94713. private _onResize;
  94714. private _hideMuteButton;
  94715. /**
  94716. * Destroy and release the resources associated with the audio ccontext.
  94717. */
  94718. dispose(): void;
  94719. /**
  94720. * Gets the global volume sets on the master gain.
  94721. * @returns the global volume if set or -1 otherwise
  94722. */
  94723. getGlobalVolume(): number;
  94724. /**
  94725. * Sets the global volume of your experience (sets on the master gain).
  94726. * @param newVolume Defines the new global volume of the application
  94727. */
  94728. setGlobalVolume(newVolume: number): void;
  94729. /**
  94730. * Connect the audio engine to an audio analyser allowing some amazing
  94731. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94733. * @param analyser The analyser to connect to the engine
  94734. */
  94735. connectToAnalyser(analyser: Analyser): void;
  94736. }
  94737. }
  94738. declare module BABYLON {
  94739. /**
  94740. * Interface used to present a loading screen while loading a scene
  94741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94742. */
  94743. export interface ILoadingScreen {
  94744. /**
  94745. * Function called to display the loading screen
  94746. */
  94747. displayLoadingUI: () => void;
  94748. /**
  94749. * Function called to hide the loading screen
  94750. */
  94751. hideLoadingUI: () => void;
  94752. /**
  94753. * Gets or sets the color to use for the background
  94754. */
  94755. loadingUIBackgroundColor: string;
  94756. /**
  94757. * Gets or sets the text to display while loading
  94758. */
  94759. loadingUIText: string;
  94760. }
  94761. /**
  94762. * Class used for the default loading screen
  94763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94764. */
  94765. export class DefaultLoadingScreen implements ILoadingScreen {
  94766. private _renderingCanvas;
  94767. private _loadingText;
  94768. private _loadingDivBackgroundColor;
  94769. private _loadingDiv;
  94770. private _loadingTextDiv;
  94771. /** Gets or sets the logo url to use for the default loading screen */
  94772. static DefaultLogoUrl: string;
  94773. /** Gets or sets the spinner url to use for the default loading screen */
  94774. static DefaultSpinnerUrl: string;
  94775. /**
  94776. * Creates a new default loading screen
  94777. * @param _renderingCanvas defines the canvas used to render the scene
  94778. * @param _loadingText defines the default text to display
  94779. * @param _loadingDivBackgroundColor defines the default background color
  94780. */
  94781. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94782. /**
  94783. * Function called to display the loading screen
  94784. */
  94785. displayLoadingUI(): void;
  94786. /**
  94787. * Function called to hide the loading screen
  94788. */
  94789. hideLoadingUI(): void;
  94790. /**
  94791. * Gets or sets the text to display while loading
  94792. */
  94793. loadingUIText: string;
  94794. /**
  94795. * Gets or sets the color to use for the background
  94796. */
  94797. loadingUIBackgroundColor: string;
  94798. private _resizeLoadingUI;
  94799. }
  94800. }
  94801. declare module BABYLON {
  94802. /** @hidden */
  94803. export class WebGLPipelineContext implements IPipelineContext {
  94804. engine: Engine;
  94805. program: Nullable<WebGLProgram>;
  94806. context?: WebGLRenderingContext;
  94807. vertexShader?: WebGLShader;
  94808. fragmentShader?: WebGLShader;
  94809. isParallelCompiled: boolean;
  94810. onCompiled?: () => void;
  94811. transformFeedback?: WebGLTransformFeedback | null;
  94812. readonly isAsync: boolean;
  94813. readonly isReady: boolean;
  94814. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94815. }
  94816. }
  94817. declare module BABYLON {
  94818. /** @hidden */
  94819. export class WebGLDataBuffer extends DataBuffer {
  94820. private _buffer;
  94821. constructor(resource: WebGLBuffer);
  94822. readonly underlyingResource: any;
  94823. }
  94824. }
  94825. declare module BABYLON {
  94826. /** @hidden */
  94827. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94828. attributeProcessor(attribute: string): string;
  94829. varyingProcessor(varying: string, isFragment: boolean): string;
  94830. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94831. }
  94832. }
  94833. declare module BABYLON {
  94834. /**
  94835. * This class is used to track a performance counter which is number based.
  94836. * The user has access to many properties which give statistics of different nature.
  94837. *
  94838. * The implementer can track two kinds of Performance Counter: time and count.
  94839. * 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.
  94840. * 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.
  94841. */
  94842. export class PerfCounter {
  94843. /**
  94844. * Gets or sets a global boolean to turn on and off all the counters
  94845. */
  94846. static Enabled: boolean;
  94847. /**
  94848. * Returns the smallest value ever
  94849. */
  94850. readonly min: number;
  94851. /**
  94852. * Returns the biggest value ever
  94853. */
  94854. readonly max: number;
  94855. /**
  94856. * Returns the average value since the performance counter is running
  94857. */
  94858. readonly average: number;
  94859. /**
  94860. * Returns the average value of the last second the counter was monitored
  94861. */
  94862. readonly lastSecAverage: number;
  94863. /**
  94864. * Returns the current value
  94865. */
  94866. readonly current: number;
  94867. /**
  94868. * Gets the accumulated total
  94869. */
  94870. readonly total: number;
  94871. /**
  94872. * Gets the total value count
  94873. */
  94874. readonly count: number;
  94875. /**
  94876. * Creates a new counter
  94877. */
  94878. constructor();
  94879. /**
  94880. * Call this method to start monitoring a new frame.
  94881. * 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.
  94882. */
  94883. fetchNewFrame(): void;
  94884. /**
  94885. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94886. * @param newCount the count value to add to the monitored count
  94887. * @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.
  94888. */
  94889. addCount(newCount: number, fetchResult: boolean): void;
  94890. /**
  94891. * Start monitoring this performance counter
  94892. */
  94893. beginMonitoring(): void;
  94894. /**
  94895. * Compute the time lapsed since the previous beginMonitoring() call.
  94896. * @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
  94897. */
  94898. endMonitoring(newFrame?: boolean): void;
  94899. private _fetchResult;
  94900. private _startMonitoringTime;
  94901. private _min;
  94902. private _max;
  94903. private _average;
  94904. private _current;
  94905. private _totalValueCount;
  94906. private _totalAccumulated;
  94907. private _lastSecAverage;
  94908. private _lastSecAccumulated;
  94909. private _lastSecTime;
  94910. private _lastSecValueCount;
  94911. }
  94912. }
  94913. declare module BABYLON {
  94914. /**
  94915. * Interface for any object that can request an animation frame
  94916. */
  94917. export interface ICustomAnimationFrameRequester {
  94918. /**
  94919. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94920. */
  94921. renderFunction?: Function;
  94922. /**
  94923. * Called to request the next frame to render to
  94924. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94925. */
  94926. requestAnimationFrame: Function;
  94927. /**
  94928. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94929. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94930. */
  94931. requestID?: number;
  94932. }
  94933. }
  94934. declare module BABYLON {
  94935. /**
  94936. * Settings for finer control over video usage
  94937. */
  94938. export interface VideoTextureSettings {
  94939. /**
  94940. * Applies `autoplay` to video, if specified
  94941. */
  94942. autoPlay?: boolean;
  94943. /**
  94944. * Applies `loop` to video, if specified
  94945. */
  94946. loop?: boolean;
  94947. /**
  94948. * Automatically updates internal texture from video at every frame in the render loop
  94949. */
  94950. autoUpdateTexture: boolean;
  94951. /**
  94952. * Image src displayed during the video loading or until the user interacts with the video.
  94953. */
  94954. poster?: string;
  94955. }
  94956. /**
  94957. * If you want to display a video in your scene, this is the special texture for that.
  94958. * This special texture works similar to other textures, with the exception of a few parameters.
  94959. * @see https://doc.babylonjs.com/how_to/video_texture
  94960. */
  94961. export class VideoTexture extends Texture {
  94962. /**
  94963. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94964. */
  94965. readonly autoUpdateTexture: boolean;
  94966. /**
  94967. * The video instance used by the texture internally
  94968. */
  94969. readonly video: HTMLVideoElement;
  94970. private _onUserActionRequestedObservable;
  94971. /**
  94972. * Event triggerd when a dom action is required by the user to play the video.
  94973. * This happens due to recent changes in browser policies preventing video to auto start.
  94974. */
  94975. readonly onUserActionRequestedObservable: Observable<Texture>;
  94976. private _generateMipMaps;
  94977. private _engine;
  94978. private _stillImageCaptured;
  94979. private _displayingPosterTexture;
  94980. private _settings;
  94981. private _createInternalTextureOnEvent;
  94982. private _frameId;
  94983. /**
  94984. * Creates a video texture.
  94985. * If you want to display a video in your scene, this is the special texture for that.
  94986. * This special texture works similar to other textures, with the exception of a few parameters.
  94987. * @see https://doc.babylonjs.com/how_to/video_texture
  94988. * @param name optional name, will detect from video source, if not defined
  94989. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94990. * @param scene is obviously the current scene.
  94991. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94992. * @param invertY is false by default but can be used to invert video on Y axis
  94993. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94994. * @param settings allows finer control over video usage
  94995. */
  94996. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94997. private _getName;
  94998. private _getVideo;
  94999. private _createInternalTexture;
  95000. private reset;
  95001. /**
  95002. * @hidden Internal method to initiate `update`.
  95003. */
  95004. _rebuild(): void;
  95005. /**
  95006. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95007. */
  95008. update(): void;
  95009. /**
  95010. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95011. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95012. */
  95013. updateTexture(isVisible: boolean): void;
  95014. protected _updateInternalTexture: () => void;
  95015. /**
  95016. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95017. * @param url New url.
  95018. */
  95019. updateURL(url: string): void;
  95020. /**
  95021. * Dispose the texture and release its associated resources.
  95022. */
  95023. dispose(): void;
  95024. /**
  95025. * Creates a video texture straight from a stream.
  95026. * @param scene Define the scene the texture should be created in
  95027. * @param stream Define the stream the texture should be created from
  95028. * @returns The created video texture as a promise
  95029. */
  95030. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95031. /**
  95032. * Creates a video texture straight from your WebCam video feed.
  95033. * @param scene Define the scene the texture should be created in
  95034. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95035. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95036. * @returns The created video texture as a promise
  95037. */
  95038. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95039. minWidth: number;
  95040. maxWidth: number;
  95041. minHeight: number;
  95042. maxHeight: number;
  95043. deviceId: string;
  95044. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95045. /**
  95046. * Creates a video texture straight from your WebCam video feed.
  95047. * @param scene Define the scene the texture should be created in
  95048. * @param onReady Define a callback to triggered once the texture will be ready
  95049. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95050. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95051. */
  95052. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95053. minWidth: number;
  95054. maxWidth: number;
  95055. minHeight: number;
  95056. maxHeight: number;
  95057. deviceId: string;
  95058. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95059. }
  95060. }
  95061. declare module BABYLON {
  95062. /**
  95063. * Defines the interface used by objects containing a viewport (like a camera)
  95064. */
  95065. interface IViewportOwnerLike {
  95066. /**
  95067. * Gets or sets the viewport
  95068. */
  95069. viewport: IViewportLike;
  95070. }
  95071. /**
  95072. * Interface for attribute information associated with buffer instanciation
  95073. */
  95074. export class InstancingAttributeInfo {
  95075. /**
  95076. * Index/offset of the attribute in the vertex shader
  95077. */
  95078. index: number;
  95079. /**
  95080. * size of the attribute, 1, 2, 3 or 4
  95081. */
  95082. attributeSize: number;
  95083. /**
  95084. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95085. * default is FLOAT
  95086. */
  95087. attribyteType: number;
  95088. /**
  95089. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95090. */
  95091. normalized: boolean;
  95092. /**
  95093. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95094. */
  95095. offset: number;
  95096. /**
  95097. * Name of the GLSL attribute, for debugging purpose only
  95098. */
  95099. attributeName: string;
  95100. }
  95101. /**
  95102. * Define options used to create a depth texture
  95103. */
  95104. export class DepthTextureCreationOptions {
  95105. /** Specifies whether or not a stencil should be allocated in the texture */
  95106. generateStencil?: boolean;
  95107. /** Specifies whether or not bilinear filtering is enable on the texture */
  95108. bilinearFiltering?: boolean;
  95109. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95110. comparisonFunction?: number;
  95111. /** Specifies if the created texture is a cube texture */
  95112. isCube?: boolean;
  95113. }
  95114. /**
  95115. * Class used to describe the capabilities of the engine relatively to the current browser
  95116. */
  95117. export class EngineCapabilities {
  95118. /** Maximum textures units per fragment shader */
  95119. maxTexturesImageUnits: number;
  95120. /** Maximum texture units per vertex shader */
  95121. maxVertexTextureImageUnits: number;
  95122. /** Maximum textures units in the entire pipeline */
  95123. maxCombinedTexturesImageUnits: number;
  95124. /** Maximum texture size */
  95125. maxTextureSize: number;
  95126. /** Maximum cube texture size */
  95127. maxCubemapTextureSize: number;
  95128. /** Maximum render texture size */
  95129. maxRenderTextureSize: number;
  95130. /** Maximum number of vertex attributes */
  95131. maxVertexAttribs: number;
  95132. /** Maximum number of varyings */
  95133. maxVaryingVectors: number;
  95134. /** Maximum number of uniforms per vertex shader */
  95135. maxVertexUniformVectors: number;
  95136. /** Maximum number of uniforms per fragment shader */
  95137. maxFragmentUniformVectors: number;
  95138. /** Defines if standard derivates (dx/dy) are supported */
  95139. standardDerivatives: boolean;
  95140. /** Defines if s3tc texture compression is supported */
  95141. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95142. /** Defines if pvrtc texture compression is supported */
  95143. pvrtc: any;
  95144. /** Defines if etc1 texture compression is supported */
  95145. etc1: any;
  95146. /** Defines if etc2 texture compression is supported */
  95147. etc2: any;
  95148. /** Defines if astc texture compression is supported */
  95149. astc: any;
  95150. /** Defines if float textures are supported */
  95151. textureFloat: boolean;
  95152. /** Defines if vertex array objects are supported */
  95153. vertexArrayObject: boolean;
  95154. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95155. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95156. /** Gets the maximum level of anisotropy supported */
  95157. maxAnisotropy: number;
  95158. /** Defines if instancing is supported */
  95159. instancedArrays: boolean;
  95160. /** Defines if 32 bits indices are supported */
  95161. uintIndices: boolean;
  95162. /** Defines if high precision shaders are supported */
  95163. highPrecisionShaderSupported: boolean;
  95164. /** Defines if depth reading in the fragment shader is supported */
  95165. fragmentDepthSupported: boolean;
  95166. /** Defines if float texture linear filtering is supported*/
  95167. textureFloatLinearFiltering: boolean;
  95168. /** Defines if rendering to float textures is supported */
  95169. textureFloatRender: boolean;
  95170. /** Defines if half float textures are supported*/
  95171. textureHalfFloat: boolean;
  95172. /** Defines if half float texture linear filtering is supported*/
  95173. textureHalfFloatLinearFiltering: boolean;
  95174. /** Defines if rendering to half float textures is supported */
  95175. textureHalfFloatRender: boolean;
  95176. /** Defines if textureLOD shader command is supported */
  95177. textureLOD: boolean;
  95178. /** Defines if draw buffers extension is supported */
  95179. drawBuffersExtension: boolean;
  95180. /** Defines if depth textures are supported */
  95181. depthTextureExtension: boolean;
  95182. /** Defines if float color buffer are supported */
  95183. colorBufferFloat: boolean;
  95184. /** Gets disjoint timer query extension (null if not supported) */
  95185. timerQuery: EXT_disjoint_timer_query;
  95186. /** Defines if timestamp can be used with timer query */
  95187. canUseTimestampForTimerQuery: boolean;
  95188. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95189. multiview: any;
  95190. /** Function used to let the system compiles shaders in background */
  95191. parallelShaderCompile: {
  95192. COMPLETION_STATUS_KHR: number;
  95193. };
  95194. /** Max number of texture samples for MSAA */
  95195. maxMSAASamples: number;
  95196. }
  95197. /** Interface defining initialization parameters for Engine class */
  95198. export interface EngineOptions extends WebGLContextAttributes {
  95199. /**
  95200. * Defines if the engine should no exceed a specified device ratio
  95201. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95202. */
  95203. limitDeviceRatio?: number;
  95204. /**
  95205. * Defines if webvr should be enabled automatically
  95206. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95207. */
  95208. autoEnableWebVR?: boolean;
  95209. /**
  95210. * Defines if webgl2 should be turned off even if supported
  95211. * @see http://doc.babylonjs.com/features/webgl2
  95212. */
  95213. disableWebGL2Support?: boolean;
  95214. /**
  95215. * Defines if webaudio should be initialized as well
  95216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95217. */
  95218. audioEngine?: boolean;
  95219. /**
  95220. * Defines if animations should run using a deterministic lock step
  95221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95222. */
  95223. deterministicLockstep?: boolean;
  95224. /** Defines the maximum steps to use with deterministic lock step mode */
  95225. lockstepMaxSteps?: number;
  95226. /**
  95227. * Defines that engine should ignore context lost events
  95228. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95229. */
  95230. doNotHandleContextLost?: boolean;
  95231. /**
  95232. * Defines that engine should ignore modifying touch action attribute and style
  95233. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95234. */
  95235. doNotHandleTouchAction?: boolean;
  95236. /**
  95237. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95238. */
  95239. useHighPrecisionFloats?: boolean;
  95240. }
  95241. /**
  95242. * Defines the interface used by display changed events
  95243. */
  95244. export interface IDisplayChangedEventArgs {
  95245. /** Gets the vrDisplay object (if any) */
  95246. vrDisplay: Nullable<any>;
  95247. /** Gets a boolean indicating if webVR is supported */
  95248. vrSupported: boolean;
  95249. }
  95250. /**
  95251. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95252. */
  95253. export class Engine {
  95254. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95255. static ExceptionList: ({
  95256. key: string;
  95257. capture: string;
  95258. captureConstraint: number;
  95259. targets: string[];
  95260. } | {
  95261. key: string;
  95262. capture: null;
  95263. captureConstraint: null;
  95264. targets: string[];
  95265. })[];
  95266. /** Gets the list of created engines */
  95267. static readonly Instances: Engine[];
  95268. /**
  95269. * Gets the latest created engine
  95270. */
  95271. static readonly LastCreatedEngine: Nullable<Engine>;
  95272. /**
  95273. * Gets the latest created scene
  95274. */
  95275. static readonly LastCreatedScene: Nullable<Scene>;
  95276. /**
  95277. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95278. * @param flag defines which part of the materials must be marked as dirty
  95279. * @param predicate defines a predicate used to filter which materials should be affected
  95280. */
  95281. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95282. /** @hidden */
  95283. static _TextureLoaders: IInternalTextureLoader[];
  95284. /** Defines that alpha blending is disabled */
  95285. static readonly ALPHA_DISABLE: number;
  95286. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95287. static readonly ALPHA_ADD: number;
  95288. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95289. static readonly ALPHA_COMBINE: number;
  95290. /** Defines that alpha blending to DEST - SRC * DEST */
  95291. static readonly ALPHA_SUBTRACT: number;
  95292. /** Defines that alpha blending to SRC * DEST */
  95293. static readonly ALPHA_MULTIPLY: number;
  95294. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95295. static readonly ALPHA_MAXIMIZED: number;
  95296. /** Defines that alpha blending to SRC + DEST */
  95297. static readonly ALPHA_ONEONE: number;
  95298. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95299. static readonly ALPHA_PREMULTIPLIED: number;
  95300. /**
  95301. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95302. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95303. */
  95304. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95305. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95306. static readonly ALPHA_INTERPOLATE: number;
  95307. /**
  95308. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95309. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95310. */
  95311. static readonly ALPHA_SCREENMODE: number;
  95312. /** Defines that the ressource is not delayed*/
  95313. static readonly DELAYLOADSTATE_NONE: number;
  95314. /** Defines that the ressource was successfully delay loaded */
  95315. static readonly DELAYLOADSTATE_LOADED: number;
  95316. /** Defines that the ressource is currently delay loading */
  95317. static readonly DELAYLOADSTATE_LOADING: number;
  95318. /** Defines that the ressource is delayed and has not started loading */
  95319. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95320. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95321. static readonly NEVER: number;
  95322. /** 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 */
  95323. static readonly ALWAYS: number;
  95324. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95325. static readonly LESS: number;
  95326. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95327. static readonly EQUAL: number;
  95328. /** 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 */
  95329. static readonly LEQUAL: number;
  95330. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95331. static readonly GREATER: number;
  95332. /** 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 */
  95333. static readonly GEQUAL: number;
  95334. /** 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 */
  95335. static readonly NOTEQUAL: number;
  95336. /** Passed to stencilOperation to specify that stencil value must be kept */
  95337. static readonly KEEP: number;
  95338. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95339. static readonly REPLACE: number;
  95340. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95341. static readonly INCR: number;
  95342. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95343. static readonly DECR: number;
  95344. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95345. static readonly INVERT: number;
  95346. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95347. static readonly INCR_WRAP: number;
  95348. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95349. static readonly DECR_WRAP: number;
  95350. /** Texture is not repeating outside of 0..1 UVs */
  95351. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95352. /** Texture is repeating outside of 0..1 UVs */
  95353. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95354. /** Texture is repeating and mirrored */
  95355. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95356. /** ALPHA */
  95357. static readonly TEXTUREFORMAT_ALPHA: number;
  95358. /** LUMINANCE */
  95359. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95360. /** LUMINANCE_ALPHA */
  95361. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95362. /** RGB */
  95363. static readonly TEXTUREFORMAT_RGB: number;
  95364. /** RGBA */
  95365. static readonly TEXTUREFORMAT_RGBA: number;
  95366. /** RED */
  95367. static readonly TEXTUREFORMAT_RED: number;
  95368. /** RED (2nd reference) */
  95369. static readonly TEXTUREFORMAT_R: number;
  95370. /** RG */
  95371. static readonly TEXTUREFORMAT_RG: number;
  95372. /** RED_INTEGER */
  95373. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95374. /** RED_INTEGER (2nd reference) */
  95375. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95376. /** RG_INTEGER */
  95377. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95378. /** RGB_INTEGER */
  95379. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95380. /** RGBA_INTEGER */
  95381. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95382. /** UNSIGNED_BYTE */
  95383. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95384. /** UNSIGNED_BYTE (2nd reference) */
  95385. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95386. /** FLOAT */
  95387. static readonly TEXTURETYPE_FLOAT: number;
  95388. /** HALF_FLOAT */
  95389. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95390. /** BYTE */
  95391. static readonly TEXTURETYPE_BYTE: number;
  95392. /** SHORT */
  95393. static readonly TEXTURETYPE_SHORT: number;
  95394. /** UNSIGNED_SHORT */
  95395. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95396. /** INT */
  95397. static readonly TEXTURETYPE_INT: number;
  95398. /** UNSIGNED_INT */
  95399. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95400. /** UNSIGNED_SHORT_4_4_4_4 */
  95401. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95402. /** UNSIGNED_SHORT_5_5_5_1 */
  95403. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95404. /** UNSIGNED_SHORT_5_6_5 */
  95405. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95406. /** UNSIGNED_INT_2_10_10_10_REV */
  95407. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95408. /** UNSIGNED_INT_24_8 */
  95409. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95410. /** UNSIGNED_INT_10F_11F_11F_REV */
  95411. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95412. /** UNSIGNED_INT_5_9_9_9_REV */
  95413. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95414. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95415. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95416. /** nearest is mag = nearest and min = nearest and mip = linear */
  95417. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95418. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95419. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95420. /** Trilinear is mag = linear and min = linear and mip = linear */
  95421. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95422. /** nearest is mag = nearest and min = nearest and mip = linear */
  95423. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95424. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95425. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95426. /** Trilinear is mag = linear and min = linear and mip = linear */
  95427. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95428. /** mag = nearest and min = nearest and mip = nearest */
  95429. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95430. /** mag = nearest and min = linear and mip = nearest */
  95431. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95432. /** mag = nearest and min = linear and mip = linear */
  95433. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95434. /** mag = nearest and min = linear and mip = none */
  95435. static readonly TEXTURE_NEAREST_LINEAR: number;
  95436. /** mag = nearest and min = nearest and mip = none */
  95437. static readonly TEXTURE_NEAREST_NEAREST: number;
  95438. /** mag = linear and min = nearest and mip = nearest */
  95439. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95440. /** mag = linear and min = nearest and mip = linear */
  95441. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95442. /** mag = linear and min = linear and mip = none */
  95443. static readonly TEXTURE_LINEAR_LINEAR: number;
  95444. /** mag = linear and min = nearest and mip = none */
  95445. static readonly TEXTURE_LINEAR_NEAREST: number;
  95446. /** Explicit coordinates mode */
  95447. static readonly TEXTURE_EXPLICIT_MODE: number;
  95448. /** Spherical coordinates mode */
  95449. static readonly TEXTURE_SPHERICAL_MODE: number;
  95450. /** Planar coordinates mode */
  95451. static readonly TEXTURE_PLANAR_MODE: number;
  95452. /** Cubic coordinates mode */
  95453. static readonly TEXTURE_CUBIC_MODE: number;
  95454. /** Projection coordinates mode */
  95455. static readonly TEXTURE_PROJECTION_MODE: number;
  95456. /** Skybox coordinates mode */
  95457. static readonly TEXTURE_SKYBOX_MODE: number;
  95458. /** Inverse Cubic coordinates mode */
  95459. static readonly TEXTURE_INVCUBIC_MODE: number;
  95460. /** Equirectangular coordinates mode */
  95461. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95462. /** Equirectangular Fixed coordinates mode */
  95463. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95464. /** Equirectangular Fixed Mirrored coordinates mode */
  95465. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95466. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95467. static readonly SCALEMODE_FLOOR: number;
  95468. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95469. static readonly SCALEMODE_NEAREST: number;
  95470. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95471. static readonly SCALEMODE_CEILING: number;
  95472. /**
  95473. * Returns the current npm package of the sdk
  95474. */
  95475. static readonly NpmPackage: string;
  95476. /**
  95477. * Returns the current version of the framework
  95478. */
  95479. static readonly Version: string;
  95480. /**
  95481. * Returns a string describing the current engine
  95482. */
  95483. readonly description: string;
  95484. /**
  95485. * Gets or sets the epsilon value used by collision engine
  95486. */
  95487. static CollisionsEpsilon: number;
  95488. /**
  95489. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95490. */
  95491. static ShadersRepository: string;
  95492. /**
  95493. * Method called to create the default loading screen.
  95494. * This can be overriden in your own app.
  95495. * @param canvas The rendering canvas element
  95496. * @returns The loading screen
  95497. */
  95498. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95499. /**
  95500. * Method called to create the default rescale post process on each engine.
  95501. */
  95502. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95503. /** @hidden */
  95504. _shaderProcessor: IShaderProcessor;
  95505. /**
  95506. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95507. */
  95508. forcePOTTextures: boolean;
  95509. /**
  95510. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95511. */
  95512. isFullscreen: boolean;
  95513. /**
  95514. * Gets a boolean indicating if the pointer is currently locked
  95515. */
  95516. isPointerLock: boolean;
  95517. /**
  95518. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95519. */
  95520. cullBackFaces: boolean;
  95521. /**
  95522. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95523. */
  95524. renderEvenInBackground: boolean;
  95525. /**
  95526. * Gets or sets a boolean indicating that cache can be kept between frames
  95527. */
  95528. preventCacheWipeBetweenFrames: boolean;
  95529. /**
  95530. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95531. **/
  95532. enableOfflineSupport: boolean;
  95533. /**
  95534. * 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)
  95535. **/
  95536. disableManifestCheck: boolean;
  95537. /**
  95538. * Gets the list of created scenes
  95539. */
  95540. scenes: Scene[];
  95541. /**
  95542. * Event raised when a new scene is created
  95543. */
  95544. onNewSceneAddedObservable: Observable<Scene>;
  95545. /**
  95546. * Gets the list of created postprocesses
  95547. */
  95548. postProcesses: PostProcess[];
  95549. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95550. validateShaderPrograms: boolean;
  95551. /**
  95552. * Observable event triggered each time the rendering canvas is resized
  95553. */
  95554. onResizeObservable: Observable<Engine>;
  95555. /**
  95556. * Observable event triggered each time the canvas loses focus
  95557. */
  95558. onCanvasBlurObservable: Observable<Engine>;
  95559. /**
  95560. * Observable event triggered each time the canvas gains focus
  95561. */
  95562. onCanvasFocusObservable: Observable<Engine>;
  95563. /**
  95564. * Observable event triggered each time the canvas receives pointerout event
  95565. */
  95566. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95567. /**
  95568. * Observable event triggered before each texture is initialized
  95569. */
  95570. onBeforeTextureInitObservable: Observable<Texture>;
  95571. /**
  95572. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95573. */
  95574. disableUniformBuffers: boolean;
  95575. /** @hidden */
  95576. _uniformBuffers: UniformBuffer[];
  95577. /**
  95578. * Gets a boolean indicating that the engine supports uniform buffers
  95579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95580. */
  95581. readonly supportsUniformBuffers: boolean;
  95582. /**
  95583. * Observable raised when the engine begins a new frame
  95584. */
  95585. onBeginFrameObservable: Observable<Engine>;
  95586. /**
  95587. * If set, will be used to request the next animation frame for the render loop
  95588. */
  95589. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95590. /**
  95591. * Observable raised when the engine ends the current frame
  95592. */
  95593. onEndFrameObservable: Observable<Engine>;
  95594. /**
  95595. * Observable raised when the engine is about to compile a shader
  95596. */
  95597. onBeforeShaderCompilationObservable: Observable<Engine>;
  95598. /**
  95599. * Observable raised when the engine has jsut compiled a shader
  95600. */
  95601. onAfterShaderCompilationObservable: Observable<Engine>;
  95602. /** @hidden */
  95603. _gl: WebGLRenderingContext;
  95604. private _renderingCanvas;
  95605. private _windowIsBackground;
  95606. protected _webGLVersion: number;
  95607. protected _highPrecisionShadersAllowed: boolean;
  95608. /** @hidden */
  95609. readonly _shouldUseHighPrecisionShader: boolean;
  95610. /**
  95611. * Gets a boolean indicating that only power of 2 textures are supported
  95612. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95613. */
  95614. readonly needPOTTextures: boolean;
  95615. /** @hidden */
  95616. _badOS: boolean;
  95617. /** @hidden */
  95618. _badDesktopOS: boolean;
  95619. /**
  95620. * Gets the audio engine
  95621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95622. * @ignorenaming
  95623. */
  95624. static audioEngine: IAudioEngine;
  95625. /**
  95626. * Default AudioEngine factory responsible of creating the Audio Engine.
  95627. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95628. */
  95629. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95630. /**
  95631. * Default offline support factory responsible of creating a tool used to store data locally.
  95632. * By default, this will create a Database object if the workload has been embedded.
  95633. */
  95634. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95635. private _onFocus;
  95636. private _onBlur;
  95637. private _onCanvasPointerOut;
  95638. private _onCanvasBlur;
  95639. private _onCanvasFocus;
  95640. private _onFullscreenChange;
  95641. private _onPointerLockChange;
  95642. private _hardwareScalingLevel;
  95643. /** @hidden */
  95644. _caps: EngineCapabilities;
  95645. private _pointerLockRequested;
  95646. private _isStencilEnable;
  95647. protected _colorWrite: boolean;
  95648. private _loadingScreen;
  95649. /** @hidden */
  95650. _drawCalls: PerfCounter;
  95651. private _glVersion;
  95652. private _glRenderer;
  95653. private _glVendor;
  95654. private _videoTextureSupported;
  95655. private _renderingQueueLaunched;
  95656. private _activeRenderLoops;
  95657. private _deterministicLockstep;
  95658. private _lockstepMaxSteps;
  95659. /**
  95660. * Observable signaled when a context lost event is raised
  95661. */
  95662. onContextLostObservable: Observable<Engine>;
  95663. /**
  95664. * Observable signaled when a context restored event is raised
  95665. */
  95666. onContextRestoredObservable: Observable<Engine>;
  95667. private _onContextLost;
  95668. private _onContextRestored;
  95669. private _contextWasLost;
  95670. /** @hidden */
  95671. _doNotHandleContextLost: boolean;
  95672. /**
  95673. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95675. */
  95676. doNotHandleContextLost: boolean;
  95677. private _performanceMonitor;
  95678. private _fps;
  95679. private _deltaTime;
  95680. /**
  95681. * Turn this value on if you want to pause FPS computation when in background
  95682. */
  95683. disablePerformanceMonitorInBackground: boolean;
  95684. /**
  95685. * Gets the performance monitor attached to this engine
  95686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95687. */
  95688. readonly performanceMonitor: PerformanceMonitor;
  95689. /**
  95690. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95691. */
  95692. disableVertexArrayObjects: boolean;
  95693. /** @hidden */
  95694. protected _depthCullingState: _DepthCullingState;
  95695. /** @hidden */
  95696. protected _stencilState: _StencilState;
  95697. /** @hidden */
  95698. protected _alphaState: _AlphaState;
  95699. /** @hidden */
  95700. protected _alphaMode: number;
  95701. /** @hidden */
  95702. _internalTexturesCache: InternalTexture[];
  95703. /** @hidden */
  95704. protected _activeChannel: number;
  95705. private _currentTextureChannel;
  95706. /** @hidden */
  95707. protected _boundTexturesCache: {
  95708. [key: string]: Nullable<InternalTexture>;
  95709. };
  95710. /** @hidden */
  95711. protected _currentEffect: Nullable<Effect>;
  95712. /** @hidden */
  95713. protected _currentProgram: Nullable<WebGLProgram>;
  95714. private _compiledEffects;
  95715. private _vertexAttribArraysEnabled;
  95716. /** @hidden */
  95717. protected _cachedViewport: Nullable<IViewportLike>;
  95718. private _cachedVertexArrayObject;
  95719. /** @hidden */
  95720. protected _cachedVertexBuffers: any;
  95721. /** @hidden */
  95722. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95723. /** @hidden */
  95724. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95725. /** @hidden */
  95726. _currentRenderTarget: Nullable<InternalTexture>;
  95727. private _uintIndicesCurrentlySet;
  95728. private _currentBoundBuffer;
  95729. /** @hidden */
  95730. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95731. private _currentBufferPointers;
  95732. private _currentInstanceLocations;
  95733. private _currentInstanceBuffers;
  95734. private _textureUnits;
  95735. /** @hidden */
  95736. _workingCanvas: Nullable<HTMLCanvasElement>;
  95737. /** @hidden */
  95738. _workingContext: Nullable<CanvasRenderingContext2D>;
  95739. private _rescalePostProcess;
  95740. private _dummyFramebuffer;
  95741. private _externalData;
  95742. /** @hidden */
  95743. _bindedRenderFunction: any;
  95744. private _vaoRecordInProgress;
  95745. private _mustWipeVertexAttributes;
  95746. private _emptyTexture;
  95747. private _emptyCubeTexture;
  95748. private _emptyTexture3D;
  95749. /** @hidden */
  95750. _frameHandler: number;
  95751. private _nextFreeTextureSlots;
  95752. private _maxSimultaneousTextures;
  95753. private _activeRequests;
  95754. private _texturesSupported;
  95755. /** @hidden */
  95756. _textureFormatInUse: Nullable<string>;
  95757. /**
  95758. * Gets the list of texture formats supported
  95759. */
  95760. readonly texturesSupported: Array<string>;
  95761. /**
  95762. * Gets the list of texture formats in use
  95763. */
  95764. readonly textureFormatInUse: Nullable<string>;
  95765. /**
  95766. * Gets the current viewport
  95767. */
  95768. readonly currentViewport: Nullable<IViewportLike>;
  95769. /**
  95770. * Gets the default empty texture
  95771. */
  95772. readonly emptyTexture: InternalTexture;
  95773. /**
  95774. * Gets the default empty 3D texture
  95775. */
  95776. readonly emptyTexture3D: InternalTexture;
  95777. /**
  95778. * Gets the default empty cube texture
  95779. */
  95780. readonly emptyCubeTexture: InternalTexture;
  95781. /**
  95782. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95783. */
  95784. readonly premultipliedAlpha: boolean;
  95785. /**
  95786. * Creates a new engine
  95787. * @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
  95788. * @param antialias defines enable antialiasing (default: false)
  95789. * @param options defines further options to be sent to the getContext() function
  95790. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95791. */
  95792. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95793. /**
  95794. * Initializes a webVR display and starts listening to display change events
  95795. * The onVRDisplayChangedObservable will be notified upon these changes
  95796. * @returns The onVRDisplayChangedObservable
  95797. */
  95798. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95799. /** @hidden */
  95800. _prepareVRComponent(): void;
  95801. /** @hidden */
  95802. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95803. /** @hidden */
  95804. _submitVRFrame(): void;
  95805. /**
  95806. * Call this function to leave webVR mode
  95807. * Will do nothing if webVR is not supported or if there is no webVR device
  95808. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95809. */
  95810. disableVR(): void;
  95811. /**
  95812. * Gets a boolean indicating that the system is in VR mode and is presenting
  95813. * @returns true if VR mode is engaged
  95814. */
  95815. isVRPresenting(): boolean;
  95816. /** @hidden */
  95817. _requestVRFrame(): void;
  95818. private _disableTouchAction;
  95819. private _rebuildInternalTextures;
  95820. private _rebuildEffects;
  95821. /**
  95822. * Gets a boolean indicating if all created effects are ready
  95823. * @returns true if all effects are ready
  95824. */
  95825. areAllEffectsReady(): boolean;
  95826. private _rebuildBuffers;
  95827. private _initGLContext;
  95828. /**
  95829. * Gets version of the current webGL context
  95830. */
  95831. readonly webGLVersion: number;
  95832. /**
  95833. * Gets a string idenfifying the name of the class
  95834. * @returns "Engine" string
  95835. */
  95836. getClassName(): string;
  95837. /**
  95838. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95839. */
  95840. readonly isStencilEnable: boolean;
  95841. /** @hidden */
  95842. _prepareWorkingCanvas(): void;
  95843. /**
  95844. * Reset the texture cache to empty state
  95845. */
  95846. resetTextureCache(): void;
  95847. /**
  95848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95850. * @returns true if engine is in deterministic lock step mode
  95851. */
  95852. isDeterministicLockStep(): boolean;
  95853. /**
  95854. * Gets the max steps when engine is running in deterministic lock step
  95855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95856. * @returns the max steps
  95857. */
  95858. getLockstepMaxSteps(): number;
  95859. /**
  95860. * Gets an object containing information about the current webGL context
  95861. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95862. */
  95863. getGlInfo(): {
  95864. vendor: string;
  95865. renderer: string;
  95866. version: string;
  95867. };
  95868. /**
  95869. * Gets current aspect ratio
  95870. * @param viewportOwner defines the camera to use to get the aspect ratio
  95871. * @param useScreen defines if screen size must be used (or the current render target if any)
  95872. * @returns a number defining the aspect ratio
  95873. */
  95874. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95875. /**
  95876. * Gets current screen aspect ratio
  95877. * @returns a number defining the aspect ratio
  95878. */
  95879. getScreenAspectRatio(): number;
  95880. /**
  95881. * Gets the current render width
  95882. * @param useScreen defines if screen size must be used (or the current render target if any)
  95883. * @returns a number defining the current render width
  95884. */
  95885. getRenderWidth(useScreen?: boolean): number;
  95886. /**
  95887. * Gets the current render height
  95888. * @param useScreen defines if screen size must be used (or the current render target if any)
  95889. * @returns a number defining the current render height
  95890. */
  95891. getRenderHeight(useScreen?: boolean): number;
  95892. /**
  95893. * Gets the HTML canvas attached with the current webGL context
  95894. * @returns a HTML canvas
  95895. */
  95896. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95897. /**
  95898. * Gets host window
  95899. * @returns the host window object
  95900. */
  95901. getHostWindow(): Window;
  95902. /**
  95903. * Gets host document
  95904. * @returns the host document object
  95905. */
  95906. getHostDocument(): Document;
  95907. /**
  95908. * Gets the client rect of the HTML canvas attached with the current webGL context
  95909. * @returns a client rectanglee
  95910. */
  95911. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95912. /**
  95913. * Defines the hardware scaling level.
  95914. * By default the hardware scaling level is computed from the window device ratio.
  95915. * 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.
  95916. * @param level defines the level to use
  95917. */
  95918. setHardwareScalingLevel(level: number): void;
  95919. /**
  95920. * Gets the current hardware scaling level.
  95921. * By default the hardware scaling level is computed from the window device ratio.
  95922. * 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.
  95923. * @returns a number indicating the current hardware scaling level
  95924. */
  95925. getHardwareScalingLevel(): number;
  95926. /**
  95927. * Gets the list of loaded textures
  95928. * @returns an array containing all loaded textures
  95929. */
  95930. getLoadedTexturesCache(): InternalTexture[];
  95931. /**
  95932. * Gets the object containing all engine capabilities
  95933. * @returns the EngineCapabilities object
  95934. */
  95935. getCaps(): EngineCapabilities;
  95936. /**
  95937. * Gets the current depth function
  95938. * @returns a number defining the depth function
  95939. */
  95940. getDepthFunction(): Nullable<number>;
  95941. /**
  95942. * Sets the current depth function
  95943. * @param depthFunc defines the function to use
  95944. */
  95945. setDepthFunction(depthFunc: number): void;
  95946. /**
  95947. * Sets the current depth function to GREATER
  95948. */
  95949. setDepthFunctionToGreater(): void;
  95950. /**
  95951. * Sets the current depth function to GEQUAL
  95952. */
  95953. setDepthFunctionToGreaterOrEqual(): void;
  95954. /**
  95955. * Sets the current depth function to LESS
  95956. */
  95957. setDepthFunctionToLess(): void;
  95958. private _cachedStencilBuffer;
  95959. private _cachedStencilFunction;
  95960. private _cachedStencilMask;
  95961. private _cachedStencilOperationPass;
  95962. private _cachedStencilOperationFail;
  95963. private _cachedStencilOperationDepthFail;
  95964. private _cachedStencilReference;
  95965. /**
  95966. * Caches the the state of the stencil buffer
  95967. */
  95968. cacheStencilState(): void;
  95969. /**
  95970. * Restores the state of the stencil buffer
  95971. */
  95972. restoreStencilState(): void;
  95973. /**
  95974. * Sets the current depth function to LEQUAL
  95975. */
  95976. setDepthFunctionToLessOrEqual(): void;
  95977. /**
  95978. * Gets a boolean indicating if stencil buffer is enabled
  95979. * @returns the current stencil buffer state
  95980. */
  95981. getStencilBuffer(): boolean;
  95982. /**
  95983. * Enable or disable the stencil buffer
  95984. * @param enable defines if the stencil buffer must be enabled or disabled
  95985. */
  95986. setStencilBuffer(enable: boolean): void;
  95987. /**
  95988. * Gets the current stencil mask
  95989. * @returns a number defining the new stencil mask to use
  95990. */
  95991. getStencilMask(): number;
  95992. /**
  95993. * Sets the current stencil mask
  95994. * @param mask defines the new stencil mask to use
  95995. */
  95996. setStencilMask(mask: number): void;
  95997. /**
  95998. * Gets the current stencil function
  95999. * @returns a number defining the stencil function to use
  96000. */
  96001. getStencilFunction(): number;
  96002. /**
  96003. * Gets the current stencil reference value
  96004. * @returns a number defining the stencil reference value to use
  96005. */
  96006. getStencilFunctionReference(): number;
  96007. /**
  96008. * Gets the current stencil mask
  96009. * @returns a number defining the stencil mask to use
  96010. */
  96011. getStencilFunctionMask(): number;
  96012. /**
  96013. * Sets the current stencil function
  96014. * @param stencilFunc defines the new stencil function to use
  96015. */
  96016. setStencilFunction(stencilFunc: number): void;
  96017. /**
  96018. * Sets the current stencil reference
  96019. * @param reference defines the new stencil reference to use
  96020. */
  96021. setStencilFunctionReference(reference: number): void;
  96022. /**
  96023. * Sets the current stencil mask
  96024. * @param mask defines the new stencil mask to use
  96025. */
  96026. setStencilFunctionMask(mask: number): void;
  96027. /**
  96028. * Gets the current stencil operation when stencil fails
  96029. * @returns a number defining stencil operation to use when stencil fails
  96030. */
  96031. getStencilOperationFail(): number;
  96032. /**
  96033. * Gets the current stencil operation when depth fails
  96034. * @returns a number defining stencil operation to use when depth fails
  96035. */
  96036. getStencilOperationDepthFail(): number;
  96037. /**
  96038. * Gets the current stencil operation when stencil passes
  96039. * @returns a number defining stencil operation to use when stencil passes
  96040. */
  96041. getStencilOperationPass(): number;
  96042. /**
  96043. * Sets the stencil operation to use when stencil fails
  96044. * @param operation defines the stencil operation to use when stencil fails
  96045. */
  96046. setStencilOperationFail(operation: number): void;
  96047. /**
  96048. * Sets the stencil operation to use when depth fails
  96049. * @param operation defines the stencil operation to use when depth fails
  96050. */
  96051. setStencilOperationDepthFail(operation: number): void;
  96052. /**
  96053. * Sets the stencil operation to use when stencil passes
  96054. * @param operation defines the stencil operation to use when stencil passes
  96055. */
  96056. setStencilOperationPass(operation: number): void;
  96057. /**
  96058. * Sets a boolean indicating if the dithering state is enabled or disabled
  96059. * @param value defines the dithering state
  96060. */
  96061. setDitheringState(value: boolean): void;
  96062. /**
  96063. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96064. * @param value defines the rasterizer state
  96065. */
  96066. setRasterizerState(value: boolean): void;
  96067. /**
  96068. * stop executing a render loop function and remove it from the execution array
  96069. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96070. */
  96071. stopRenderLoop(renderFunction?: () => void): void;
  96072. /** @hidden */
  96073. _renderLoop(): void;
  96074. /**
  96075. * Can be used to override the current requestAnimationFrame requester.
  96076. * @hidden
  96077. */
  96078. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96079. /**
  96080. * Register and execute a render loop. The engine can have more than one render function
  96081. * @param renderFunction defines the function to continuously execute
  96082. */
  96083. runRenderLoop(renderFunction: () => void): void;
  96084. /**
  96085. * Toggle full screen mode
  96086. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96087. */
  96088. switchFullscreen(requestPointerLock: boolean): void;
  96089. /**
  96090. * Enters full screen mode
  96091. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96092. */
  96093. enterFullscreen(requestPointerLock: boolean): void;
  96094. /**
  96095. * Exits full screen mode
  96096. */
  96097. exitFullscreen(): void;
  96098. /**
  96099. * Enters Pointerlock mode
  96100. */
  96101. enterPointerlock(): void;
  96102. /**
  96103. * Exits Pointerlock mode
  96104. */
  96105. exitPointerlock(): void;
  96106. /**
  96107. * Clear the current render buffer or the current render target (if any is set up)
  96108. * @param color defines the color to use
  96109. * @param backBuffer defines if the back buffer must be cleared
  96110. * @param depth defines if the depth buffer must be cleared
  96111. * @param stencil defines if the stencil buffer must be cleared
  96112. */
  96113. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96114. /**
  96115. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96116. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96117. * @param y defines the y-coordinate of the corner of the clear rectangle
  96118. * @param width defines the width of the clear rectangle
  96119. * @param height defines the height of the clear rectangle
  96120. * @param clearColor defines the clear color
  96121. */
  96122. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96123. /**
  96124. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96125. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96126. * @param y defines the y-coordinate of the corner of the clear rectangle
  96127. * @param width defines the width of the clear rectangle
  96128. * @param height defines the height of the clear rectangle
  96129. */
  96130. enableScissor(x: number, y: number, width: number, height: number): void;
  96131. /**
  96132. * Disable previously set scissor test rectangle
  96133. */
  96134. disableScissor(): void;
  96135. private _viewportCached;
  96136. /** @hidden */
  96137. _viewport(x: number, y: number, width: number, height: number): void;
  96138. /**
  96139. * Set the WebGL's viewport
  96140. * @param viewport defines the viewport element to be used
  96141. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96142. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96143. */
  96144. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96145. /**
  96146. * Directly set the WebGL Viewport
  96147. * @param x defines the x coordinate of the viewport (in screen space)
  96148. * @param y defines the y coordinate of the viewport (in screen space)
  96149. * @param width defines the width of the viewport (in screen space)
  96150. * @param height defines the height of the viewport (in screen space)
  96151. * @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
  96152. */
  96153. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96154. /**
  96155. * Begin a new frame
  96156. */
  96157. beginFrame(): void;
  96158. /**
  96159. * Enf the current frame
  96160. */
  96161. endFrame(): void;
  96162. /**
  96163. * Resize the view according to the canvas' size
  96164. */
  96165. resize(): void;
  96166. /**
  96167. * Force a specific size of the canvas
  96168. * @param width defines the new canvas' width
  96169. * @param height defines the new canvas' height
  96170. */
  96171. setSize(width: number, height: number): void;
  96172. /**
  96173. * Binds the frame buffer to the specified texture.
  96174. * @param texture The texture to render to or null for the default canvas
  96175. * @param faceIndex The face of the texture to render to in case of cube texture
  96176. * @param requiredWidth The width of the target to render to
  96177. * @param requiredHeight The height of the target to render to
  96178. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96179. * @param depthStencilTexture The depth stencil texture to use to render
  96180. * @param lodLevel defines le lod level to bind to the frame buffer
  96181. */
  96182. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96183. /** @hidden */
  96184. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96185. /**
  96186. * Unbind the current render target texture from the webGL context
  96187. * @param texture defines the render target texture to unbind
  96188. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96189. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96190. */
  96191. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96192. /**
  96193. * Force the mipmap generation for the given render target texture
  96194. * @param texture defines the render target texture to use
  96195. */
  96196. generateMipMapsForCubemap(texture: InternalTexture): void;
  96197. /**
  96198. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96199. */
  96200. flushFramebuffer(): void;
  96201. /**
  96202. * Unbind the current render target and bind the default framebuffer
  96203. */
  96204. restoreDefaultFramebuffer(): void;
  96205. /**
  96206. * Create an uniform buffer
  96207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96208. * @param elements defines the content of the uniform buffer
  96209. * @returns the webGL uniform buffer
  96210. */
  96211. createUniformBuffer(elements: FloatArray): DataBuffer;
  96212. /**
  96213. * Create a dynamic uniform buffer
  96214. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96215. * @param elements defines the content of the uniform buffer
  96216. * @returns the webGL uniform buffer
  96217. */
  96218. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96219. /**
  96220. * Update an existing uniform buffer
  96221. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96222. * @param uniformBuffer defines the target uniform buffer
  96223. * @param elements defines the content to update
  96224. * @param offset defines the offset in the uniform buffer where update should start
  96225. * @param count defines the size of the data to update
  96226. */
  96227. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96228. private _resetVertexBufferBinding;
  96229. /**
  96230. * Creates a vertex buffer
  96231. * @param data the data for the vertex buffer
  96232. * @returns the new WebGL static buffer
  96233. */
  96234. createVertexBuffer(data: DataArray): DataBuffer;
  96235. /**
  96236. * Creates a dynamic vertex buffer
  96237. * @param data the data for the dynamic vertex buffer
  96238. * @returns the new WebGL dynamic buffer
  96239. */
  96240. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96241. /**
  96242. * Update a dynamic index buffer
  96243. * @param indexBuffer defines the target index buffer
  96244. * @param indices defines the data to update
  96245. * @param offset defines the offset in the target index buffer where update should start
  96246. */
  96247. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96248. /**
  96249. * Updates a dynamic vertex buffer.
  96250. * @param vertexBuffer the vertex buffer to update
  96251. * @param data the data used to update the vertex buffer
  96252. * @param byteOffset the byte offset of the data
  96253. * @param byteLength the byte length of the data
  96254. */
  96255. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96256. private _resetIndexBufferBinding;
  96257. /**
  96258. * Creates a new index buffer
  96259. * @param indices defines the content of the index buffer
  96260. * @param updatable defines if the index buffer must be updatable
  96261. * @returns a new webGL buffer
  96262. */
  96263. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96264. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96265. /**
  96266. * Bind a webGL buffer to the webGL context
  96267. * @param buffer defines the buffer to bind
  96268. */
  96269. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96270. /**
  96271. * Bind an uniform buffer to the current webGL context
  96272. * @param buffer defines the buffer to bind
  96273. */
  96274. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96275. /**
  96276. * Bind a buffer to the current webGL context at a given location
  96277. * @param buffer defines the buffer to bind
  96278. * @param location defines the index where to bind the buffer
  96279. */
  96280. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96281. /**
  96282. * Bind a specific block at a given index in a specific shader program
  96283. * @param pipelineContext defines the pipeline context to use
  96284. * @param blockName defines the block name
  96285. * @param index defines the index where to bind the block
  96286. */
  96287. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96288. private bindIndexBuffer;
  96289. private bindBuffer;
  96290. /**
  96291. * update the bound buffer with the given data
  96292. * @param data defines the data to update
  96293. */
  96294. updateArrayBuffer(data: Float32Array): void;
  96295. private _vertexAttribPointer;
  96296. private _bindIndexBufferWithCache;
  96297. private _bindVertexBuffersAttributes;
  96298. /**
  96299. * Records a vertex array object
  96300. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96301. * @param vertexBuffers defines the list of vertex buffers to store
  96302. * @param indexBuffer defines the index buffer to store
  96303. * @param effect defines the effect to store
  96304. * @returns the new vertex array object
  96305. */
  96306. recordVertexArrayObject(vertexBuffers: {
  96307. [key: string]: VertexBuffer;
  96308. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96309. /**
  96310. * Bind a specific vertex array object
  96311. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96312. * @param vertexArrayObject defines the vertex array object to bind
  96313. * @param indexBuffer defines the index buffer to bind
  96314. */
  96315. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96316. /**
  96317. * Bind webGl buffers directly to the webGL context
  96318. * @param vertexBuffer defines the vertex buffer to bind
  96319. * @param indexBuffer defines the index buffer to bind
  96320. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96321. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96322. * @param effect defines the effect associated with the vertex buffer
  96323. */
  96324. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96325. private _unbindVertexArrayObject;
  96326. /**
  96327. * Bind a list of vertex buffers to the webGL context
  96328. * @param vertexBuffers defines the list of vertex buffers to bind
  96329. * @param indexBuffer defines the index buffer to bind
  96330. * @param effect defines the effect associated with the vertex buffers
  96331. */
  96332. bindBuffers(vertexBuffers: {
  96333. [key: string]: Nullable<VertexBuffer>;
  96334. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96335. /**
  96336. * Unbind all instance attributes
  96337. */
  96338. unbindInstanceAttributes(): void;
  96339. /**
  96340. * Release and free the memory of a vertex array object
  96341. * @param vao defines the vertex array object to delete
  96342. */
  96343. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96344. /** @hidden */
  96345. _releaseBuffer(buffer: DataBuffer): boolean;
  96346. protected _deleteBuffer(buffer: DataBuffer): void;
  96347. /**
  96348. * Creates a webGL buffer to use with instanciation
  96349. * @param capacity defines the size of the buffer
  96350. * @returns the webGL buffer
  96351. */
  96352. createInstancesBuffer(capacity: number): DataBuffer;
  96353. /**
  96354. * Delete a webGL buffer used with instanciation
  96355. * @param buffer defines the webGL buffer to delete
  96356. */
  96357. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96358. /**
  96359. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96360. * @param instancesBuffer defines the webGL buffer to update and bind
  96361. * @param data defines the data to store in the buffer
  96362. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96363. */
  96364. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96365. /**
  96366. * Apply all cached states (depth, culling, stencil and alpha)
  96367. */
  96368. applyStates(): void;
  96369. /**
  96370. * Send a draw order
  96371. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96372. * @param indexStart defines the starting index
  96373. * @param indexCount defines the number of index to draw
  96374. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96375. */
  96376. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96377. /**
  96378. * Draw a list of points
  96379. * @param verticesStart defines the index of first vertex to draw
  96380. * @param verticesCount defines the count of vertices to draw
  96381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96382. */
  96383. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96384. /**
  96385. * Draw a list of unindexed primitives
  96386. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96387. * @param verticesStart defines the index of first vertex to draw
  96388. * @param verticesCount defines the count of vertices to draw
  96389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96390. */
  96391. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96392. /**
  96393. * Draw a list of indexed primitives
  96394. * @param fillMode defines the primitive to use
  96395. * @param indexStart defines the starting index
  96396. * @param indexCount defines the number of index to draw
  96397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96398. */
  96399. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96400. /**
  96401. * Draw a list of unindexed primitives
  96402. * @param fillMode defines the primitive to use
  96403. * @param verticesStart defines the index of first vertex to draw
  96404. * @param verticesCount defines the count of vertices to draw
  96405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96406. */
  96407. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96408. private _drawMode;
  96409. /** @hidden */
  96410. _releaseEffect(effect: Effect): void;
  96411. /** @hidden */
  96412. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96413. /**
  96414. * Create a new effect (used to store vertex/fragment shaders)
  96415. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96416. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96417. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96418. * @param samplers defines an array of string used to represent textures
  96419. * @param defines defines the string containing the defines to use to compile the shaders
  96420. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96421. * @param onCompiled defines a function to call when the effect creation is successful
  96422. * @param onError defines a function to call when the effect creation has failed
  96423. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96424. * @returns the new Effect
  96425. */
  96426. 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;
  96427. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96428. private _compileShader;
  96429. private _compileRawShader;
  96430. /**
  96431. * Directly creates a webGL program
  96432. * @param pipelineContext defines the pipeline context to attach to
  96433. * @param vertexCode defines the vertex shader code to use
  96434. * @param fragmentCode defines the fragment shader code to use
  96435. * @param context defines the webGL context to use (if not set, the current one will be used)
  96436. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96437. * @returns the new webGL program
  96438. */
  96439. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96440. /**
  96441. * Creates a webGL program
  96442. * @param pipelineContext defines the pipeline context to attach to
  96443. * @param vertexCode defines the vertex shader code to use
  96444. * @param fragmentCode defines the fragment shader code to use
  96445. * @param defines defines the string containing the defines to use to compile the shaders
  96446. * @param context defines the webGL context to use (if not set, the current one will be used)
  96447. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96448. * @returns the new webGL program
  96449. */
  96450. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96451. /**
  96452. * Creates a new pipeline context
  96453. * @returns the new pipeline
  96454. */
  96455. createPipelineContext(): IPipelineContext;
  96456. private _createShaderProgram;
  96457. private _finalizePipelineContext;
  96458. /** @hidden */
  96459. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96460. /** @hidden */
  96461. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96462. /** @hidden */
  96463. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96464. /**
  96465. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96466. * @param pipelineContext defines the pipeline context to use
  96467. * @param uniformsNames defines the list of uniform names
  96468. * @returns an array of webGL uniform locations
  96469. */
  96470. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96471. /**
  96472. * Gets the lsit of active attributes for a given webGL program
  96473. * @param pipelineContext defines the pipeline context to use
  96474. * @param attributesNames defines the list of attribute names to get
  96475. * @returns an array of indices indicating the offset of each attribute
  96476. */
  96477. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96478. /**
  96479. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96480. * @param effect defines the effect to activate
  96481. */
  96482. enableEffect(effect: Nullable<Effect>): void;
  96483. /**
  96484. * Set the value of an uniform to an array of int32
  96485. * @param uniform defines the webGL uniform location where to store the value
  96486. * @param array defines the array of int32 to store
  96487. */
  96488. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96489. /**
  96490. * Set the value of an uniform to an array of int32 (stored as vec2)
  96491. * @param uniform defines the webGL uniform location where to store the value
  96492. * @param array defines the array of int32 to store
  96493. */
  96494. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96495. /**
  96496. * Set the value of an uniform to an array of int32 (stored as vec3)
  96497. * @param uniform defines the webGL uniform location where to store the value
  96498. * @param array defines the array of int32 to store
  96499. */
  96500. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96501. /**
  96502. * Set the value of an uniform to an array of int32 (stored as vec4)
  96503. * @param uniform defines the webGL uniform location where to store the value
  96504. * @param array defines the array of int32 to store
  96505. */
  96506. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96507. /**
  96508. * Set the value of an uniform to an array of float32
  96509. * @param uniform defines the webGL uniform location where to store the value
  96510. * @param array defines the array of float32 to store
  96511. */
  96512. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96513. /**
  96514. * Set the value of an uniform to an array of float32 (stored as vec2)
  96515. * @param uniform defines the webGL uniform location where to store the value
  96516. * @param array defines the array of float32 to store
  96517. */
  96518. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96519. /**
  96520. * Set the value of an uniform to an array of float32 (stored as vec3)
  96521. * @param uniform defines the webGL uniform location where to store the value
  96522. * @param array defines the array of float32 to store
  96523. */
  96524. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96525. /**
  96526. * Set the value of an uniform to an array of float32 (stored as vec4)
  96527. * @param uniform defines the webGL uniform location where to store the value
  96528. * @param array defines the array of float32 to store
  96529. */
  96530. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96531. /**
  96532. * Set the value of an uniform to an array of number
  96533. * @param uniform defines the webGL uniform location where to store the value
  96534. * @param array defines the array of number to store
  96535. */
  96536. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96537. /**
  96538. * Set the value of an uniform to an array of number (stored as vec2)
  96539. * @param uniform defines the webGL uniform location where to store the value
  96540. * @param array defines the array of number to store
  96541. */
  96542. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96543. /**
  96544. * Set the value of an uniform to an array of number (stored as vec3)
  96545. * @param uniform defines the webGL uniform location where to store the value
  96546. * @param array defines the array of number to store
  96547. */
  96548. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96549. /**
  96550. * Set the value of an uniform to an array of number (stored as vec4)
  96551. * @param uniform defines the webGL uniform location where to store the value
  96552. * @param array defines the array of number to store
  96553. */
  96554. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96555. /**
  96556. * Set the value of an uniform to an array of float32 (stored as matrices)
  96557. * @param uniform defines the webGL uniform location where to store the value
  96558. * @param matrices defines the array of float32 to store
  96559. */
  96560. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96561. /**
  96562. * Set the value of an uniform to a matrix (3x3)
  96563. * @param uniform defines the webGL uniform location where to store the value
  96564. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96565. */
  96566. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96567. /**
  96568. * Set the value of an uniform to a matrix (2x2)
  96569. * @param uniform defines the webGL uniform location where to store the value
  96570. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96571. */
  96572. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96573. /**
  96574. * Set the value of an uniform to a number (int)
  96575. * @param uniform defines the webGL uniform location where to store the value
  96576. * @param value defines the int number to store
  96577. */
  96578. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96579. /**
  96580. * Set the value of an uniform to a number (float)
  96581. * @param uniform defines the webGL uniform location where to store the value
  96582. * @param value defines the float number to store
  96583. */
  96584. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96585. /**
  96586. * Set the value of an uniform to a vec2
  96587. * @param uniform defines the webGL uniform location where to store the value
  96588. * @param x defines the 1st component of the value
  96589. * @param y defines the 2nd component of the value
  96590. */
  96591. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96592. /**
  96593. * Set the value of an uniform to a vec3
  96594. * @param uniform defines the webGL uniform location where to store the value
  96595. * @param x defines the 1st component of the value
  96596. * @param y defines the 2nd component of the value
  96597. * @param z defines the 3rd component of the value
  96598. */
  96599. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96600. /**
  96601. * Set the value of an uniform to a boolean
  96602. * @param uniform defines the webGL uniform location where to store the value
  96603. * @param bool defines the boolean to store
  96604. */
  96605. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96606. /**
  96607. * Set the value of an uniform to a vec4
  96608. * @param uniform defines the webGL uniform location where to store the value
  96609. * @param x defines the 1st component of the value
  96610. * @param y defines the 2nd component of the value
  96611. * @param z defines the 3rd component of the value
  96612. * @param w defines the 4th component of the value
  96613. */
  96614. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96615. /**
  96616. * Sets a Color4 on a uniform variable
  96617. * @param uniform defines the uniform location
  96618. * @param color4 defines the value to be set
  96619. */
  96620. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96621. /**
  96622. * Set various states to the webGL context
  96623. * @param culling defines backface culling state
  96624. * @param zOffset defines the value to apply to zOffset (0 by default)
  96625. * @param force defines if states must be applied even if cache is up to date
  96626. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96627. */
  96628. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96629. /**
  96630. * Set the z offset to apply to current rendering
  96631. * @param value defines the offset to apply
  96632. */
  96633. setZOffset(value: number): void;
  96634. /**
  96635. * Gets the current value of the zOffset
  96636. * @returns the current zOffset state
  96637. */
  96638. getZOffset(): number;
  96639. /**
  96640. * Enable or disable depth buffering
  96641. * @param enable defines the state to set
  96642. */
  96643. setDepthBuffer(enable: boolean): void;
  96644. /**
  96645. * Gets a boolean indicating if depth writing is enabled
  96646. * @returns the current depth writing state
  96647. */
  96648. getDepthWrite(): boolean;
  96649. /**
  96650. * Enable or disable depth writing
  96651. * @param enable defines the state to set
  96652. */
  96653. setDepthWrite(enable: boolean): void;
  96654. /**
  96655. * Enable or disable color writing
  96656. * @param enable defines the state to set
  96657. */
  96658. setColorWrite(enable: boolean): void;
  96659. /**
  96660. * Gets a boolean indicating if color writing is enabled
  96661. * @returns the current color writing state
  96662. */
  96663. getColorWrite(): boolean;
  96664. /**
  96665. * Sets alpha constants used by some alpha blending modes
  96666. * @param r defines the red component
  96667. * @param g defines the green component
  96668. * @param b defines the blue component
  96669. * @param a defines the alpha component
  96670. */
  96671. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96672. /**
  96673. * Sets the current alpha mode
  96674. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96675. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96677. */
  96678. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96679. /**
  96680. * Gets the current alpha mode
  96681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96682. * @returns the current alpha mode
  96683. */
  96684. getAlphaMode(): number;
  96685. /**
  96686. * Clears the list of texture accessible through engine.
  96687. * This can help preventing texture load conflict due to name collision.
  96688. */
  96689. clearInternalTexturesCache(): void;
  96690. /**
  96691. * Force the entire cache to be cleared
  96692. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96693. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96694. */
  96695. wipeCaches(bruteForce?: boolean): void;
  96696. /**
  96697. * Set the compressed texture format to use, based on the formats you have, and the formats
  96698. * supported by the hardware / browser.
  96699. *
  96700. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96701. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96702. * to API arguments needed to compressed textures. This puts the burden on the container
  96703. * generator to house the arcane code for determining these for current & future formats.
  96704. *
  96705. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96706. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96707. *
  96708. * Note: The result of this call is not taken into account when a texture is base64.
  96709. *
  96710. * @param formatsAvailable defines the list of those format families you have created
  96711. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96712. *
  96713. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96714. * @returns The extension selected.
  96715. */
  96716. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96717. /** @hidden */
  96718. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96719. min: number;
  96720. mag: number;
  96721. };
  96722. /** @hidden */
  96723. _createTexture(): WebGLTexture;
  96724. /**
  96725. * Usually called from Texture.ts.
  96726. * Passed information to create a WebGLTexture
  96727. * @param urlArg defines a value which contains one of the following:
  96728. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96729. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96730. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96732. * @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)
  96733. * @param scene needed for loading to the correct scene
  96734. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96735. * @param onLoad optional callback to be called upon successful completion
  96736. * @param onError optional callback to be called upon failure
  96737. * @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
  96738. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96739. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96740. * @param forcedExtension defines the extension to use to pick the right loader
  96741. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96742. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96743. */
  96744. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96745. /**
  96746. * @hidden
  96747. * Rescales a texture
  96748. * @param source input texutre
  96749. * @param destination destination texture
  96750. * @param scene scene to use to render the resize
  96751. * @param internalFormat format to use when resizing
  96752. * @param onComplete callback to be called when resize has completed
  96753. */
  96754. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96755. private _unpackFlipYCached;
  96756. /**
  96757. * In case you are sharing the context with other applications, it might
  96758. * be interested to not cache the unpack flip y state to ensure a consistent
  96759. * value would be set.
  96760. */
  96761. enableUnpackFlipYCached: boolean;
  96762. /** @hidden */
  96763. _unpackFlipY(value: boolean): void;
  96764. /** @hidden */
  96765. _getUnpackAlignement(): number;
  96766. /**
  96767. * Creates a dynamic texture
  96768. * @param width defines the width of the texture
  96769. * @param height defines the height of the texture
  96770. * @param generateMipMaps defines if the engine should generate the mip levels
  96771. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96772. * @returns the dynamic texture inside an InternalTexture
  96773. */
  96774. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96775. /**
  96776. * Update the sampling mode of a given texture
  96777. * @param samplingMode defines the required sampling mode
  96778. * @param texture defines the texture to update
  96779. */
  96780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96781. /**
  96782. * Update the content of a dynamic texture
  96783. * @param texture defines the texture to update
  96784. * @param canvas defines the canvas containing the source
  96785. * @param invertY defines if data must be stored with Y axis inverted
  96786. * @param premulAlpha defines if alpha is stored as premultiplied
  96787. * @param format defines the format of the data
  96788. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96789. */
  96790. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96791. /**
  96792. * Update a video texture
  96793. * @param texture defines the texture to update
  96794. * @param video defines the video element to use
  96795. * @param invertY defines if data must be stored with Y axis inverted
  96796. */
  96797. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96798. /**
  96799. * Updates a depth texture Comparison Mode and Function.
  96800. * If the comparison Function is equal to 0, the mode will be set to none.
  96801. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96802. * @param texture The texture to set the comparison function for
  96803. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96804. */
  96805. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96806. /** @hidden */
  96807. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96808. width: number;
  96809. height: number;
  96810. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96811. /**
  96812. * Creates a depth stencil texture.
  96813. * This is only available in WebGL 2 or with the depth texture extension available.
  96814. * @param size The size of face edge in the texture.
  96815. * @param options The options defining the texture.
  96816. * @returns The texture
  96817. */
  96818. createDepthStencilTexture(size: number | {
  96819. width: number;
  96820. height: number;
  96821. }, options: DepthTextureCreationOptions): InternalTexture;
  96822. /**
  96823. * Creates a depth stencil texture.
  96824. * This is only available in WebGL 2 or with the depth texture extension available.
  96825. * @param size The size of face edge in the texture.
  96826. * @param options The options defining the texture.
  96827. * @returns The texture
  96828. */
  96829. private _createDepthStencilTexture;
  96830. /**
  96831. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96832. * @param renderTarget The render target to set the frame buffer for
  96833. */
  96834. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96835. /**
  96836. * Creates a new render target texture
  96837. * @param size defines the size of the texture
  96838. * @param options defines the options used to create the texture
  96839. * @returns a new render target texture stored in an InternalTexture
  96840. */
  96841. createRenderTargetTexture(size: number | {
  96842. width: number;
  96843. height: number;
  96844. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96845. /** @hidden */
  96846. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96847. /**
  96848. * Updates the sample count of a render target texture
  96849. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96850. * @param texture defines the texture to update
  96851. * @param samples defines the sample count to set
  96852. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96853. */
  96854. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96855. /** @hidden */
  96856. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96857. /** @hidden */
  96858. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96859. /** @hidden */
  96860. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96861. /** @hidden */
  96862. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96863. /**
  96864. * @hidden
  96865. */
  96866. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96867. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96868. private _prepareWebGLTexture;
  96869. /** @hidden */
  96870. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96871. /** @hidden */
  96872. _releaseFramebufferObjects(texture: InternalTexture): void;
  96873. /** @hidden */
  96874. _releaseTexture(texture: InternalTexture): void;
  96875. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96876. protected _setProgram(program: WebGLProgram): void;
  96877. protected _boundUniforms: {
  96878. [key: number]: WebGLUniformLocation;
  96879. };
  96880. /**
  96881. * Binds an effect to the webGL context
  96882. * @param effect defines the effect to bind
  96883. */
  96884. bindSamplers(effect: Effect): void;
  96885. private _activateCurrentTexture;
  96886. /** @hidden */
  96887. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96888. /** @hidden */
  96889. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96890. /**
  96891. * Sets a texture to the webGL context from a postprocess
  96892. * @param channel defines the channel to use
  96893. * @param postProcess defines the source postprocess
  96894. */
  96895. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96896. /**
  96897. * Binds the output of the passed in post process to the texture channel specified
  96898. * @param channel The channel the texture should be bound to
  96899. * @param postProcess The post process which's output should be bound
  96900. */
  96901. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96902. /**
  96903. * Unbind all textures from the webGL context
  96904. */
  96905. unbindAllTextures(): void;
  96906. /**
  96907. * Sets a texture to the according uniform.
  96908. * @param channel The texture channel
  96909. * @param uniform The uniform to set
  96910. * @param texture The texture to apply
  96911. */
  96912. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96913. /**
  96914. * Sets a depth stencil texture from a render target to the according uniform.
  96915. * @param channel The texture channel
  96916. * @param uniform The uniform to set
  96917. * @param texture The render target texture containing the depth stencil texture to apply
  96918. */
  96919. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96920. private _bindSamplerUniformToChannel;
  96921. private _getTextureWrapMode;
  96922. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96923. /**
  96924. * Sets an array of texture to the webGL context
  96925. * @param channel defines the channel where the texture array must be set
  96926. * @param uniform defines the associated uniform location
  96927. * @param textures defines the array of textures to bind
  96928. */
  96929. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96930. /** @hidden */
  96931. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96932. private _setTextureParameterFloat;
  96933. private _setTextureParameterInteger;
  96934. /**
  96935. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96936. * @param x defines the x coordinate of the rectangle where pixels must be read
  96937. * @param y defines the y coordinate of the rectangle where pixels must be read
  96938. * @param width defines the width of the rectangle where pixels must be read
  96939. * @param height defines the height of the rectangle where pixels must be read
  96940. * @returns a Uint8Array containing RGBA colors
  96941. */
  96942. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96943. /**
  96944. * Add an externaly attached data from its key.
  96945. * This method call will fail and return false, if such key already exists.
  96946. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96947. * @param key the unique key that identifies the data
  96948. * @param data the data object to associate to the key for this Engine instance
  96949. * @return true if no such key were already present and the data was added successfully, false otherwise
  96950. */
  96951. addExternalData<T>(key: string, data: T): boolean;
  96952. /**
  96953. * Get an externaly attached data from its key
  96954. * @param key the unique key that identifies the data
  96955. * @return the associated data, if present (can be null), or undefined if not present
  96956. */
  96957. getExternalData<T>(key: string): T;
  96958. /**
  96959. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96960. * @param key the unique key that identifies the data
  96961. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96962. * @return the associated data, can be null if the factory returned null.
  96963. */
  96964. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96965. /**
  96966. * Remove an externaly attached data from the Engine instance
  96967. * @param key the unique key that identifies the data
  96968. * @return true if the data was successfully removed, false if it doesn't exist
  96969. */
  96970. removeExternalData(key: string): boolean;
  96971. /**
  96972. * Unbind all vertex attributes from the webGL context
  96973. */
  96974. unbindAllAttributes(): void;
  96975. /**
  96976. * 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
  96977. */
  96978. releaseEffects(): void;
  96979. /**
  96980. * Dispose and release all associated resources
  96981. */
  96982. dispose(): void;
  96983. /**
  96984. * Display the loading screen
  96985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96986. */
  96987. displayLoadingUI(): void;
  96988. /**
  96989. * Hide the loading screen
  96990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96991. */
  96992. hideLoadingUI(): void;
  96993. /**
  96994. * Gets the current loading screen object
  96995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96996. */
  96997. /**
  96998. * Sets the current loading screen object
  96999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97000. */
  97001. loadingScreen: ILoadingScreen;
  97002. /**
  97003. * Sets the current loading screen text
  97004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97005. */
  97006. loadingUIText: string;
  97007. /**
  97008. * Sets the current loading screen background color
  97009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97010. */
  97011. loadingUIBackgroundColor: string;
  97012. /**
  97013. * Attach a new callback raised when context lost event is fired
  97014. * @param callback defines the callback to call
  97015. */
  97016. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97017. /**
  97018. * Attach a new callback raised when context restored event is fired
  97019. * @param callback defines the callback to call
  97020. */
  97021. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97022. /**
  97023. * Gets the source code of the vertex shader associated with a specific webGL program
  97024. * @param program defines the program to use
  97025. * @returns a string containing the source code of the vertex shader associated with the program
  97026. */
  97027. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97028. /**
  97029. * Gets the source code of the fragment shader associated with a specific webGL program
  97030. * @param program defines the program to use
  97031. * @returns a string containing the source code of the fragment shader associated with the program
  97032. */
  97033. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97034. /**
  97035. * Get the current error code of the webGL context
  97036. * @returns the error code
  97037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97038. */
  97039. getError(): number;
  97040. /**
  97041. * Gets the current framerate
  97042. * @returns a number representing the framerate
  97043. */
  97044. getFps(): number;
  97045. /**
  97046. * Gets the time spent between current and previous frame
  97047. * @returns a number representing the delta time in ms
  97048. */
  97049. getDeltaTime(): number;
  97050. private _measureFps;
  97051. /** @hidden */
  97052. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97053. private _canRenderToFloatFramebuffer;
  97054. private _canRenderToHalfFloatFramebuffer;
  97055. private _canRenderToFramebuffer;
  97056. /** @hidden */
  97057. _getWebGLTextureType(type: number): number;
  97058. /** @hidden */
  97059. _getInternalFormat(format: number): number;
  97060. /** @hidden */
  97061. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97062. /** @hidden */
  97063. _getRGBAMultiSampleBufferFormat(type: number): number;
  97064. /** @hidden */
  97065. _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;
  97066. /** @hidden */
  97067. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97068. /**
  97069. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97070. * @returns true if the engine can be created
  97071. * @ignorenaming
  97072. */
  97073. static isSupported(): boolean;
  97074. /**
  97075. * Find the next highest power of two.
  97076. * @param x Number to start search from.
  97077. * @return Next highest power of two.
  97078. */
  97079. static CeilingPOT(x: number): number;
  97080. /**
  97081. * Find the next lowest power of two.
  97082. * @param x Number to start search from.
  97083. * @return Next lowest power of two.
  97084. */
  97085. static FloorPOT(x: number): number;
  97086. /**
  97087. * Find the nearest power of two.
  97088. * @param x Number to start search from.
  97089. * @return Next nearest power of two.
  97090. */
  97091. static NearestPOT(x: number): number;
  97092. /**
  97093. * Get the closest exponent of two
  97094. * @param value defines the value to approximate
  97095. * @param max defines the maximum value to return
  97096. * @param mode defines how to define the closest value
  97097. * @returns closest exponent of two of the given value
  97098. */
  97099. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97100. /**
  97101. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97102. * @param func - the function to be called
  97103. * @param requester - the object that will request the next frame. Falls back to window.
  97104. * @returns frame number
  97105. */
  97106. static QueueNewFrame(func: () => void, requester?: any): number;
  97107. /**
  97108. * Ask the browser to promote the current element to pointerlock mode
  97109. * @param element defines the DOM element to promote
  97110. */
  97111. static _RequestPointerlock(element: HTMLElement): void;
  97112. /**
  97113. * Asks the browser to exit pointerlock mode
  97114. */
  97115. static _ExitPointerlock(): void;
  97116. /**
  97117. * Ask the browser to promote the current element to fullscreen rendering mode
  97118. * @param element defines the DOM element to promote
  97119. */
  97120. static _RequestFullscreen(element: HTMLElement): void;
  97121. /**
  97122. * Asks the browser to exit fullscreen mode
  97123. */
  97124. static _ExitFullscreen(): void;
  97125. }
  97126. }
  97127. declare module BABYLON {
  97128. /**
  97129. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97130. * during the life time of the application.
  97131. */
  97132. export class EngineStore {
  97133. /** Gets the list of created engines */
  97134. static Instances: Engine[];
  97135. /** @hidden */
  97136. static _LastCreatedScene: Nullable<Scene>;
  97137. /**
  97138. * Gets the latest created engine
  97139. */
  97140. static readonly LastCreatedEngine: Nullable<Engine>;
  97141. /**
  97142. * Gets the latest created scene
  97143. */
  97144. static readonly LastCreatedScene: Nullable<Scene>;
  97145. /**
  97146. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97147. * @ignorenaming
  97148. */
  97149. static UseFallbackTexture: boolean;
  97150. /**
  97151. * Texture content used if a texture cannot loaded
  97152. * @ignorenaming
  97153. */
  97154. static FallbackTexture: string;
  97155. }
  97156. }
  97157. declare module BABYLON {
  97158. /**
  97159. * Helper class that provides a small promise polyfill
  97160. */
  97161. export class PromisePolyfill {
  97162. /**
  97163. * Static function used to check if the polyfill is required
  97164. * If this is the case then the function will inject the polyfill to window.Promise
  97165. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97166. */
  97167. static Apply(force?: boolean): void;
  97168. }
  97169. }
  97170. declare module BABYLON {
  97171. /**
  97172. * Interface for screenshot methods with describe argument called `size` as object with options
  97173. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97174. */
  97175. export interface IScreenshotSize {
  97176. /**
  97177. * number in pixels for canvas height
  97178. */
  97179. height?: number;
  97180. /**
  97181. * multiplier allowing render at a higher or lower resolution
  97182. * If value is defined then height and width will be ignored and taken from camera
  97183. */
  97184. precision?: number;
  97185. /**
  97186. * number in pixels for canvas width
  97187. */
  97188. width?: number;
  97189. }
  97190. }
  97191. declare module BABYLON {
  97192. interface IColor4Like {
  97193. r: float;
  97194. g: float;
  97195. b: float;
  97196. a: float;
  97197. }
  97198. /**
  97199. * Class containing a set of static utilities functions
  97200. */
  97201. export class Tools {
  97202. /**
  97203. * Gets or sets the base URL to use to load assets
  97204. */
  97205. static BaseUrl: string;
  97206. /**
  97207. * Enable/Disable Custom HTTP Request Headers globally.
  97208. * default = false
  97209. * @see CustomRequestHeaders
  97210. */
  97211. static UseCustomRequestHeaders: boolean;
  97212. /**
  97213. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97214. * i.e. when loading files, where the server/service expects an Authorization header
  97215. */
  97216. static CustomRequestHeaders: {
  97217. [key: string]: string;
  97218. };
  97219. /**
  97220. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97221. */
  97222. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97223. /**
  97224. * Default behaviour for cors in the application.
  97225. * It can be a string if the expected behavior is identical in the entire app.
  97226. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97227. */
  97228. static CorsBehavior: string | ((url: string | string[]) => string);
  97229. /**
  97230. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97231. * @ignorenaming
  97232. */
  97233. static UseFallbackTexture: boolean;
  97234. /**
  97235. * Use this object to register external classes like custom textures or material
  97236. * to allow the laoders to instantiate them
  97237. */
  97238. static RegisteredExternalClasses: {
  97239. [key: string]: Object;
  97240. };
  97241. /**
  97242. * Texture content used if a texture cannot loaded
  97243. * @ignorenaming
  97244. */
  97245. static fallbackTexture: string;
  97246. /**
  97247. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97248. * @param u defines the coordinate on X axis
  97249. * @param v defines the coordinate on Y axis
  97250. * @param width defines the width of the source data
  97251. * @param height defines the height of the source data
  97252. * @param pixels defines the source byte array
  97253. * @param color defines the output color
  97254. */
  97255. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97256. /**
  97257. * Interpolates between a and b via alpha
  97258. * @param a The lower value (returned when alpha = 0)
  97259. * @param b The upper value (returned when alpha = 1)
  97260. * @param alpha The interpolation-factor
  97261. * @return The mixed value
  97262. */
  97263. static Mix(a: number, b: number, alpha: number): number;
  97264. /**
  97265. * Tries to instantiate a new object from a given class name
  97266. * @param className defines the class name to instantiate
  97267. * @returns the new object or null if the system was not able to do the instantiation
  97268. */
  97269. static Instantiate(className: string): any;
  97270. /**
  97271. * Provides a slice function that will work even on IE
  97272. * @param data defines the array to slice
  97273. * @param start defines the start of the data (optional)
  97274. * @param end defines the end of the data (optional)
  97275. * @returns the new sliced array
  97276. */
  97277. static Slice<T>(data: T, start?: number, end?: number): T;
  97278. /**
  97279. * Polyfill for setImmediate
  97280. * @param action defines the action to execute after the current execution block
  97281. */
  97282. static SetImmediate(action: () => void): void;
  97283. /**
  97284. * Function indicating if a number is an exponent of 2
  97285. * @param value defines the value to test
  97286. * @returns true if the value is an exponent of 2
  97287. */
  97288. static IsExponentOfTwo(value: number): boolean;
  97289. private static _tmpFloatArray;
  97290. /**
  97291. * Returns the nearest 32-bit single precision float representation of a Number
  97292. * @param value A Number. If the parameter is of a different type, it will get converted
  97293. * to a number or to NaN if it cannot be converted
  97294. * @returns number
  97295. */
  97296. static FloatRound(value: number): number;
  97297. /**
  97298. * Extracts the filename from a path
  97299. * @param path defines the path to use
  97300. * @returns the filename
  97301. */
  97302. static GetFilename(path: string): string;
  97303. /**
  97304. * Extracts the "folder" part of a path (everything before the filename).
  97305. * @param uri The URI to extract the info from
  97306. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97307. * @returns The "folder" part of the path
  97308. */
  97309. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97310. /**
  97311. * Extracts text content from a DOM element hierarchy
  97312. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97313. */
  97314. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97315. /**
  97316. * Convert an angle in radians to degrees
  97317. * @param angle defines the angle to convert
  97318. * @returns the angle in degrees
  97319. */
  97320. static ToDegrees(angle: number): number;
  97321. /**
  97322. * Convert an angle in degrees to radians
  97323. * @param angle defines the angle to convert
  97324. * @returns the angle in radians
  97325. */
  97326. static ToRadians(angle: number): number;
  97327. /**
  97328. * Encode a buffer to a base64 string
  97329. * @param buffer defines the buffer to encode
  97330. * @returns the encoded string
  97331. */
  97332. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97333. /**
  97334. * Returns an array if obj is not an array
  97335. * @param obj defines the object to evaluate as an array
  97336. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97337. * @returns either obj directly if obj is an array or a new array containing obj
  97338. */
  97339. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97340. /**
  97341. * Gets the pointer prefix to use
  97342. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97343. */
  97344. static GetPointerPrefix(): string;
  97345. /**
  97346. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97347. * @param url define the url we are trying
  97348. * @param element define the dom element where to configure the cors policy
  97349. */
  97350. static SetCorsBehavior(url: string | string[], element: {
  97351. crossOrigin: string | null;
  97352. }): void;
  97353. /**
  97354. * Removes unwanted characters from an url
  97355. * @param url defines the url to clean
  97356. * @returns the cleaned url
  97357. */
  97358. static CleanUrl(url: string): string;
  97359. /**
  97360. * Gets or sets a function used to pre-process url before using them to load assets
  97361. */
  97362. static PreprocessUrl: (url: string) => string;
  97363. /**
  97364. * Loads an image as an HTMLImageElement.
  97365. * @param input url string, ArrayBuffer, or Blob to load
  97366. * @param onLoad callback called when the image successfully loads
  97367. * @param onError callback called when the image fails to load
  97368. * @param offlineProvider offline provider for caching
  97369. * @returns the HTMLImageElement of the loaded image
  97370. */
  97371. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97372. /**
  97373. * Loads a file
  97374. * @param url url string, ArrayBuffer, or Blob to load
  97375. * @param onSuccess callback called when the file successfully loads
  97376. * @param onProgress callback called while file is loading (if the server supports this mode)
  97377. * @param offlineProvider defines the offline provider for caching
  97378. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97379. * @param onError callback called when the file fails to load
  97380. * @returns a file request object
  97381. */
  97382. 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;
  97383. /**
  97384. * Loads a file from a url
  97385. * @param url the file url to load
  97386. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97387. */
  97388. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97389. /**
  97390. * Load a script (identified by an url). When the url returns, the
  97391. * content of this file is added into a new script element, attached to the DOM (body element)
  97392. * @param scriptUrl defines the url of the script to laod
  97393. * @param onSuccess defines the callback called when the script is loaded
  97394. * @param onError defines the callback to call if an error occurs
  97395. * @param scriptId defines the id of the script element
  97396. */
  97397. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97398. /**
  97399. * Load an asynchronous script (identified by an url). When the url returns, the
  97400. * content of this file is added into a new script element, attached to the DOM (body element)
  97401. * @param scriptUrl defines the url of the script to laod
  97402. * @param scriptId defines the id of the script element
  97403. * @returns a promise request object
  97404. */
  97405. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97406. /**
  97407. * Loads a file from a blob
  97408. * @param fileToLoad defines the blob to use
  97409. * @param callback defines the callback to call when data is loaded
  97410. * @param progressCallback defines the callback to call during loading process
  97411. * @returns a file request object
  97412. */
  97413. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97414. /**
  97415. * Loads a file
  97416. * @param fileToLoad defines the file to load
  97417. * @param callback defines the callback to call when data is loaded
  97418. * @param progressCallBack defines the callback to call during loading process
  97419. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97420. * @returns a file request object
  97421. */
  97422. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97423. /**
  97424. * Creates a data url from a given string content
  97425. * @param content defines the content to convert
  97426. * @returns the new data url link
  97427. */
  97428. static FileAsURL(content: string): string;
  97429. /**
  97430. * Format the given number to a specific decimal format
  97431. * @param value defines the number to format
  97432. * @param decimals defines the number of decimals to use
  97433. * @returns the formatted string
  97434. */
  97435. static Format(value: number, decimals?: number): string;
  97436. /**
  97437. * Tries to copy an object by duplicating every property
  97438. * @param source defines the source object
  97439. * @param destination defines the target object
  97440. * @param doNotCopyList defines a list of properties to avoid
  97441. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97442. */
  97443. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97444. /**
  97445. * Gets a boolean indicating if the given object has no own property
  97446. * @param obj defines the object to test
  97447. * @returns true if object has no own property
  97448. */
  97449. static IsEmpty(obj: any): boolean;
  97450. /**
  97451. * Function used to register events at window level
  97452. * @param windowElement defines the Window object to use
  97453. * @param events defines the events to register
  97454. */
  97455. static RegisterTopRootEvents(windowElement: Window, events: {
  97456. name: string;
  97457. handler: Nullable<(e: FocusEvent) => any>;
  97458. }[]): void;
  97459. /**
  97460. * Function used to unregister events from window level
  97461. * @param windowElement defines the Window object to use
  97462. * @param events defines the events to unregister
  97463. */
  97464. static UnregisterTopRootEvents(windowElement: Window, events: {
  97465. name: string;
  97466. handler: Nullable<(e: FocusEvent) => any>;
  97467. }[]): void;
  97468. /**
  97469. * @ignore
  97470. */
  97471. static _ScreenshotCanvas: HTMLCanvasElement;
  97472. /**
  97473. * Dumps the current bound framebuffer
  97474. * @param width defines the rendering width
  97475. * @param height defines the rendering height
  97476. * @param engine defines the hosting engine
  97477. * @param successCallback defines the callback triggered once the data are available
  97478. * @param mimeType defines the mime type of the result
  97479. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97480. */
  97481. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97482. /**
  97483. * Converts the canvas data to blob.
  97484. * This acts as a polyfill for browsers not supporting the to blob function.
  97485. * @param canvas Defines the canvas to extract the data from
  97486. * @param successCallback Defines the callback triggered once the data are available
  97487. * @param mimeType Defines the mime type of the result
  97488. */
  97489. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97490. /**
  97491. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97492. * @param successCallback defines the callback triggered once the data are available
  97493. * @param mimeType defines the mime type of the result
  97494. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97495. */
  97496. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97497. /**
  97498. * Downloads a blob in the browser
  97499. * @param blob defines the blob to download
  97500. * @param fileName defines the name of the downloaded file
  97501. */
  97502. static Download(blob: Blob, fileName: string): void;
  97503. /**
  97504. * Captures a screenshot of the current rendering
  97505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97506. * @param engine defines the rendering engine
  97507. * @param camera defines the source camera
  97508. * @param size This parameter can be set to a single number or to an object with the
  97509. * following (optional) properties: precision, width, height. If a single number is passed,
  97510. * it will be used for both width and height. If an object is passed, the screenshot size
  97511. * will be derived from the parameters. The precision property is a multiplier allowing
  97512. * rendering at a higher or lower resolution
  97513. * @param successCallback defines the callback receives a single parameter which contains the
  97514. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97515. * src parameter of an <img> to display it
  97516. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97517. * Check your browser for supported MIME types
  97518. */
  97519. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97520. /**
  97521. * Captures a screenshot of the current rendering
  97522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97523. * @param engine defines the rendering engine
  97524. * @param camera defines the source camera
  97525. * @param size This parameter can be set to a single number or to an object with the
  97526. * following (optional) properties: precision, width, height. If a single number is passed,
  97527. * it will be used for both width and height. If an object is passed, the screenshot size
  97528. * will be derived from the parameters. The precision property is a multiplier allowing
  97529. * rendering at a higher or lower resolution
  97530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97531. * Check your browser for supported MIME types
  97532. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97533. * to the src parameter of an <img> to display it
  97534. */
  97535. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97536. /**
  97537. * Generates an image screenshot from the specified camera.
  97538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97539. * @param engine The engine to use for rendering
  97540. * @param camera The camera to use for rendering
  97541. * @param size This parameter can be set to a single number or to an object with the
  97542. * following (optional) properties: precision, width, height. If a single number is passed,
  97543. * it will be used for both width and height. If an object is passed, the screenshot size
  97544. * will be derived from the parameters. The precision property is a multiplier allowing
  97545. * rendering at a higher or lower resolution
  97546. * @param successCallback The callback receives a single parameter which contains the
  97547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97548. * src parameter of an <img> to display it
  97549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97550. * Check your browser for supported MIME types
  97551. * @param samples Texture samples (default: 1)
  97552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97553. * @param fileName A name for for the downloaded file.
  97554. */
  97555. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97556. /**
  97557. * Generates an image screenshot from the specified camera.
  97558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97559. * @param engine The engine to use for rendering
  97560. * @param camera The camera to use for rendering
  97561. * @param size This parameter can be set to a single number or to an object with the
  97562. * following (optional) properties: precision, width, height. If a single number is passed,
  97563. * it will be used for both width and height. If an object is passed, the screenshot size
  97564. * will be derived from the parameters. The precision property is a multiplier allowing
  97565. * rendering at a higher or lower resolution
  97566. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97567. * Check your browser for supported MIME types
  97568. * @param samples Texture samples (default: 1)
  97569. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97570. * @param fileName A name for for the downloaded file.
  97571. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97572. * to the src parameter of an <img> to display it
  97573. */
  97574. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97575. /**
  97576. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97577. * Be aware Math.random() could cause collisions, but:
  97578. * "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"
  97579. * @returns a pseudo random id
  97580. */
  97581. static RandomId(): string;
  97582. /**
  97583. * Test if the given uri is a base64 string
  97584. * @param uri The uri to test
  97585. * @return True if the uri is a base64 string or false otherwise
  97586. */
  97587. static IsBase64(uri: string): boolean;
  97588. /**
  97589. * Decode the given base64 uri.
  97590. * @param uri The uri to decode
  97591. * @return The decoded base64 data.
  97592. */
  97593. static DecodeBase64(uri: string): ArrayBuffer;
  97594. /**
  97595. * Gets the absolute url.
  97596. * @param url the input url
  97597. * @return the absolute url
  97598. */
  97599. static GetAbsoluteUrl(url: string): string;
  97600. /**
  97601. * No log
  97602. */
  97603. static readonly NoneLogLevel: number;
  97604. /**
  97605. * Only message logs
  97606. */
  97607. static readonly MessageLogLevel: number;
  97608. /**
  97609. * Only warning logs
  97610. */
  97611. static readonly WarningLogLevel: number;
  97612. /**
  97613. * Only error logs
  97614. */
  97615. static readonly ErrorLogLevel: number;
  97616. /**
  97617. * All logs
  97618. */
  97619. static readonly AllLogLevel: number;
  97620. /**
  97621. * Gets a value indicating the number of loading errors
  97622. * @ignorenaming
  97623. */
  97624. static readonly errorsCount: number;
  97625. /**
  97626. * Callback called when a new log is added
  97627. */
  97628. static OnNewCacheEntry: (entry: string) => void;
  97629. /**
  97630. * Log a message to the console
  97631. * @param message defines the message to log
  97632. */
  97633. static Log(message: string): void;
  97634. /**
  97635. * Write a warning message to the console
  97636. * @param message defines the message to log
  97637. */
  97638. static Warn(message: string): void;
  97639. /**
  97640. * Write an error message to the console
  97641. * @param message defines the message to log
  97642. */
  97643. static Error(message: string): void;
  97644. /**
  97645. * Gets current log cache (list of logs)
  97646. */
  97647. static readonly LogCache: string;
  97648. /**
  97649. * Clears the log cache
  97650. */
  97651. static ClearLogCache(): void;
  97652. /**
  97653. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97654. */
  97655. static LogLevels: number;
  97656. /**
  97657. * Checks if the window object exists
  97658. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97659. */
  97660. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97661. /**
  97662. * No performance log
  97663. */
  97664. static readonly PerformanceNoneLogLevel: number;
  97665. /**
  97666. * Use user marks to log performance
  97667. */
  97668. static readonly PerformanceUserMarkLogLevel: number;
  97669. /**
  97670. * Log performance to the console
  97671. */
  97672. static readonly PerformanceConsoleLogLevel: number;
  97673. private static _performance;
  97674. /**
  97675. * Sets the current performance log level
  97676. */
  97677. static PerformanceLogLevel: number;
  97678. private static _StartPerformanceCounterDisabled;
  97679. private static _EndPerformanceCounterDisabled;
  97680. private static _StartUserMark;
  97681. private static _EndUserMark;
  97682. private static _StartPerformanceConsole;
  97683. private static _EndPerformanceConsole;
  97684. /**
  97685. * Starts a performance counter
  97686. */
  97687. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97688. /**
  97689. * Ends a specific performance coutner
  97690. */
  97691. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97692. /**
  97693. * Gets either window.performance.now() if supported or Date.now() else
  97694. */
  97695. static readonly Now: number;
  97696. /**
  97697. * This method will return the name of the class used to create the instance of the given object.
  97698. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97699. * @param object the object to get the class name from
  97700. * @param isType defines if the object is actually a type
  97701. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97702. */
  97703. static GetClassName(object: any, isType?: boolean): string;
  97704. /**
  97705. * Gets the first element of an array satisfying a given predicate
  97706. * @param array defines the array to browse
  97707. * @param predicate defines the predicate to use
  97708. * @returns null if not found or the element
  97709. */
  97710. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97711. /**
  97712. * This method will return the name of the full name of the class, including its owning module (if any).
  97713. * 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).
  97714. * @param object the object to get the class name from
  97715. * @param isType defines if the object is actually a type
  97716. * @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.
  97717. * @ignorenaming
  97718. */
  97719. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97720. /**
  97721. * Returns a promise that resolves after the given amount of time.
  97722. * @param delay Number of milliseconds to delay
  97723. * @returns Promise that resolves after the given amount of time
  97724. */
  97725. static DelayAsync(delay: number): Promise<void>;
  97726. }
  97727. /**
  97728. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97729. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97730. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97731. * @param name The name of the class, case should be preserved
  97732. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97733. */
  97734. export function className(name: string, module?: string): (target: Object) => void;
  97735. /**
  97736. * An implementation of a loop for asynchronous functions.
  97737. */
  97738. export class AsyncLoop {
  97739. /**
  97740. * Defines the number of iterations for the loop
  97741. */
  97742. iterations: number;
  97743. /**
  97744. * Defines the current index of the loop.
  97745. */
  97746. index: number;
  97747. private _done;
  97748. private _fn;
  97749. private _successCallback;
  97750. /**
  97751. * Constructor.
  97752. * @param iterations the number of iterations.
  97753. * @param func the function to run each iteration
  97754. * @param successCallback the callback that will be called upon succesful execution
  97755. * @param offset starting offset.
  97756. */
  97757. constructor(
  97758. /**
  97759. * Defines the number of iterations for the loop
  97760. */
  97761. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97762. /**
  97763. * Execute the next iteration. Must be called after the last iteration was finished.
  97764. */
  97765. executeNext(): void;
  97766. /**
  97767. * Break the loop and run the success callback.
  97768. */
  97769. breakLoop(): void;
  97770. /**
  97771. * Create and run an async loop.
  97772. * @param iterations the number of iterations.
  97773. * @param fn the function to run each iteration
  97774. * @param successCallback the callback that will be called upon succesful execution
  97775. * @param offset starting offset.
  97776. * @returns the created async loop object
  97777. */
  97778. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97779. /**
  97780. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97781. * @param iterations total number of iterations
  97782. * @param syncedIterations number of synchronous iterations in each async iteration.
  97783. * @param fn the function to call each iteration.
  97784. * @param callback a success call back that will be called when iterating stops.
  97785. * @param breakFunction a break condition (optional)
  97786. * @param timeout timeout settings for the setTimeout function. default - 0.
  97787. * @returns the created async loop object
  97788. */
  97789. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97790. }
  97791. }
  97792. declare module BABYLON {
  97793. /** @hidden */
  97794. export interface ICollisionCoordinator {
  97795. createCollider(): Collider;
  97796. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97797. init(scene: Scene): void;
  97798. }
  97799. /** @hidden */
  97800. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97801. private _scene;
  97802. private _scaledPosition;
  97803. private _scaledVelocity;
  97804. private _finalPosition;
  97805. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97806. createCollider(): Collider;
  97807. init(scene: Scene): void;
  97808. private _collideWithWorld;
  97809. }
  97810. }
  97811. declare module BABYLON {
  97812. /**
  97813. * Class used to manage all inputs for the scene.
  97814. */
  97815. export class InputManager {
  97816. /** The distance in pixel that you have to move to prevent some events */
  97817. static DragMovementThreshold: number;
  97818. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97819. static LongPressDelay: number;
  97820. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97821. static DoubleClickDelay: number;
  97822. /** If you need to check double click without raising a single click at first click, enable this flag */
  97823. static ExclusiveDoubleClickMode: boolean;
  97824. private _wheelEventName;
  97825. private _onPointerMove;
  97826. private _onPointerDown;
  97827. private _onPointerUp;
  97828. private _initClickEvent;
  97829. private _initActionManager;
  97830. private _delayedSimpleClick;
  97831. private _delayedSimpleClickTimeout;
  97832. private _previousDelayedSimpleClickTimeout;
  97833. private _meshPickProceed;
  97834. private _previousButtonPressed;
  97835. private _currentPickResult;
  97836. private _previousPickResult;
  97837. private _totalPointersPressed;
  97838. private _doubleClickOccured;
  97839. private _pointerOverMesh;
  97840. private _pickedDownMesh;
  97841. private _pickedUpMesh;
  97842. private _pointerX;
  97843. private _pointerY;
  97844. private _unTranslatedPointerX;
  97845. private _unTranslatedPointerY;
  97846. private _startingPointerPosition;
  97847. private _previousStartingPointerPosition;
  97848. private _startingPointerTime;
  97849. private _previousStartingPointerTime;
  97850. private _pointerCaptures;
  97851. private _onKeyDown;
  97852. private _onKeyUp;
  97853. private _onCanvasFocusObserver;
  97854. private _onCanvasBlurObserver;
  97855. private _scene;
  97856. /**
  97857. * Creates a new InputManager
  97858. * @param scene defines the hosting scene
  97859. */
  97860. constructor(scene: Scene);
  97861. /**
  97862. * Gets the mesh that is currently under the pointer
  97863. */
  97864. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97865. /**
  97866. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97867. */
  97868. readonly unTranslatedPointer: Vector2;
  97869. /**
  97870. * Gets or sets the current on-screen X position of the pointer
  97871. */
  97872. pointerX: number;
  97873. /**
  97874. * Gets or sets the current on-screen Y position of the pointer
  97875. */
  97876. pointerY: number;
  97877. private _updatePointerPosition;
  97878. private _processPointerMove;
  97879. private _setRayOnPointerInfo;
  97880. private _checkPrePointerObservable;
  97881. /**
  97882. * Use this method to simulate a pointer move on a mesh
  97883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97886. */
  97887. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97888. /**
  97889. * Use this method to simulate a pointer down on a mesh
  97890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97893. */
  97894. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97895. private _processPointerDown;
  97896. /** @hidden */
  97897. _isPointerSwiping(): boolean;
  97898. /**
  97899. * Use this method to simulate a pointer up on a mesh
  97900. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97901. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97902. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97903. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97904. */
  97905. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97906. private _processPointerUp;
  97907. /**
  97908. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97909. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97910. * @returns true if the pointer was captured
  97911. */
  97912. isPointerCaptured(pointerId?: number): boolean;
  97913. /**
  97914. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97915. * @param attachUp defines if you want to attach events to pointerup
  97916. * @param attachDown defines if you want to attach events to pointerdown
  97917. * @param attachMove defines if you want to attach events to pointermove
  97918. */
  97919. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97920. /**
  97921. * Detaches all event handlers
  97922. */
  97923. detachControl(): void;
  97924. /**
  97925. * Force the value of meshUnderPointer
  97926. * @param mesh defines the mesh to use
  97927. */
  97928. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97929. /**
  97930. * Gets the mesh under the pointer
  97931. * @returns a Mesh or null if no mesh is under the pointer
  97932. */
  97933. getPointerOverMesh(): Nullable<AbstractMesh>;
  97934. }
  97935. }
  97936. declare module BABYLON {
  97937. /**
  97938. * Helper class used to generate session unique ID
  97939. */
  97940. export class UniqueIdGenerator {
  97941. private static _UniqueIdCounter;
  97942. /**
  97943. * Gets an unique (relatively to the current scene) Id
  97944. */
  97945. static readonly UniqueId: number;
  97946. }
  97947. }
  97948. declare module BABYLON {
  97949. /**
  97950. * This class defines the direct association between an animation and a target
  97951. */
  97952. export class TargetedAnimation {
  97953. /**
  97954. * Animation to perform
  97955. */
  97956. animation: Animation;
  97957. /**
  97958. * Target to animate
  97959. */
  97960. target: any;
  97961. /**
  97962. * Serialize the object
  97963. * @returns the JSON object representing the current entity
  97964. */
  97965. serialize(): any;
  97966. }
  97967. /**
  97968. * Use this class to create coordinated animations on multiple targets
  97969. */
  97970. export class AnimationGroup implements IDisposable {
  97971. /** The name of the animation group */
  97972. name: string;
  97973. private _scene;
  97974. private _targetedAnimations;
  97975. private _animatables;
  97976. private _from;
  97977. private _to;
  97978. private _isStarted;
  97979. private _isPaused;
  97980. private _speedRatio;
  97981. private _loopAnimation;
  97982. /**
  97983. * Gets or sets the unique id of the node
  97984. */
  97985. uniqueId: number;
  97986. /**
  97987. * This observable will notify when one animation have ended
  97988. */
  97989. onAnimationEndObservable: Observable<TargetedAnimation>;
  97990. /**
  97991. * Observer raised when one animation loops
  97992. */
  97993. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97994. /**
  97995. * This observable will notify when all animations have ended.
  97996. */
  97997. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97998. /**
  97999. * This observable will notify when all animations have paused.
  98000. */
  98001. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98002. /**
  98003. * This observable will notify when all animations are playing.
  98004. */
  98005. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98006. /**
  98007. * Gets the first frame
  98008. */
  98009. readonly from: number;
  98010. /**
  98011. * Gets the last frame
  98012. */
  98013. readonly to: number;
  98014. /**
  98015. * Define if the animations are started
  98016. */
  98017. readonly isStarted: boolean;
  98018. /**
  98019. * Gets a value indicating that the current group is playing
  98020. */
  98021. readonly isPlaying: boolean;
  98022. /**
  98023. * Gets or sets the speed ratio to use for all animations
  98024. */
  98025. /**
  98026. * Gets or sets the speed ratio to use for all animations
  98027. */
  98028. speedRatio: number;
  98029. /**
  98030. * Gets or sets if all animations should loop or not
  98031. */
  98032. loopAnimation: boolean;
  98033. /**
  98034. * Gets the targeted animations for this animation group
  98035. */
  98036. readonly targetedAnimations: Array<TargetedAnimation>;
  98037. /**
  98038. * returning the list of animatables controlled by this animation group.
  98039. */
  98040. readonly animatables: Array<Animatable>;
  98041. /**
  98042. * Instantiates a new Animation Group.
  98043. * This helps managing several animations at once.
  98044. * @see http://doc.babylonjs.com/how_to/group
  98045. * @param name Defines the name of the group
  98046. * @param scene Defines the scene the group belongs to
  98047. */
  98048. constructor(
  98049. /** The name of the animation group */
  98050. name: string, scene?: Nullable<Scene>);
  98051. /**
  98052. * Add an animation (with its target) in the group
  98053. * @param animation defines the animation we want to add
  98054. * @param target defines the target of the animation
  98055. * @returns the TargetedAnimation object
  98056. */
  98057. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98058. /**
  98059. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98060. * It can add constant keys at begin or end
  98061. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98062. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98063. * @returns the animation group
  98064. */
  98065. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98066. /**
  98067. * Start all animations on given targets
  98068. * @param loop defines if animations must loop
  98069. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98070. * @param from defines the from key (optional)
  98071. * @param to defines the to key (optional)
  98072. * @returns the current animation group
  98073. */
  98074. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98075. /**
  98076. * Pause all animations
  98077. * @returns the animation group
  98078. */
  98079. pause(): AnimationGroup;
  98080. /**
  98081. * Play all animations to initial state
  98082. * This function will start() the animations if they were not started or will restart() them if they were paused
  98083. * @param loop defines if animations must loop
  98084. * @returns the animation group
  98085. */
  98086. play(loop?: boolean): AnimationGroup;
  98087. /**
  98088. * Reset all animations to initial state
  98089. * @returns the animation group
  98090. */
  98091. reset(): AnimationGroup;
  98092. /**
  98093. * Restart animations from key 0
  98094. * @returns the animation group
  98095. */
  98096. restart(): AnimationGroup;
  98097. /**
  98098. * Stop all animations
  98099. * @returns the animation group
  98100. */
  98101. stop(): AnimationGroup;
  98102. /**
  98103. * Set animation weight for all animatables
  98104. * @param weight defines the weight to use
  98105. * @return the animationGroup
  98106. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98107. */
  98108. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98109. /**
  98110. * Synchronize and normalize all animatables with a source animatable
  98111. * @param root defines the root animatable to synchronize with
  98112. * @return the animationGroup
  98113. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98114. */
  98115. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98116. /**
  98117. * Goes to a specific frame in this animation group
  98118. * @param frame the frame number to go to
  98119. * @return the animationGroup
  98120. */
  98121. goToFrame(frame: number): AnimationGroup;
  98122. /**
  98123. * Dispose all associated resources
  98124. */
  98125. dispose(): void;
  98126. private _checkAnimationGroupEnded;
  98127. /**
  98128. * Clone the current animation group and returns a copy
  98129. * @param newName defines the name of the new group
  98130. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98131. * @returns the new aniamtion group
  98132. */
  98133. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98134. /**
  98135. * Serializes the animationGroup to an object
  98136. * @returns Serialized object
  98137. */
  98138. serialize(): any;
  98139. /**
  98140. * Returns a new AnimationGroup object parsed from the source provided.
  98141. * @param parsedAnimationGroup defines the source
  98142. * @param scene defines the scene that will receive the animationGroup
  98143. * @returns a new AnimationGroup
  98144. */
  98145. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98146. /**
  98147. * Returns the string "AnimationGroup"
  98148. * @returns "AnimationGroup"
  98149. */
  98150. getClassName(): string;
  98151. /**
  98152. * Creates a detailled string about the object
  98153. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98154. * @returns a string representing the object
  98155. */
  98156. toString(fullDetails?: boolean): string;
  98157. }
  98158. }
  98159. declare module BABYLON {
  98160. /**
  98161. * Define an interface for all classes that will hold resources
  98162. */
  98163. export interface IDisposable {
  98164. /**
  98165. * Releases all held resources
  98166. */
  98167. dispose(): void;
  98168. }
  98169. /** Interface defining initialization parameters for Scene class */
  98170. export interface SceneOptions {
  98171. /**
  98172. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98173. * It will improve performance when the number of geometries becomes important.
  98174. */
  98175. useGeometryUniqueIdsMap?: boolean;
  98176. /**
  98177. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98178. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98179. */
  98180. useMaterialMeshMap?: boolean;
  98181. /**
  98182. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98183. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98184. */
  98185. useClonedMeshhMap?: boolean;
  98186. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98187. virtual?: boolean;
  98188. }
  98189. /**
  98190. * Represents a scene to be rendered by the engine.
  98191. * @see http://doc.babylonjs.com/features/scene
  98192. */
  98193. export class Scene extends AbstractScene implements IAnimatable {
  98194. /** The fog is deactivated */
  98195. static readonly FOGMODE_NONE: number;
  98196. /** The fog density is following an exponential function */
  98197. static readonly FOGMODE_EXP: number;
  98198. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98199. static readonly FOGMODE_EXP2: number;
  98200. /** The fog density is following a linear function. */
  98201. static readonly FOGMODE_LINEAR: number;
  98202. /**
  98203. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98204. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98205. */
  98206. static MinDeltaTime: number;
  98207. /**
  98208. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98210. */
  98211. static MaxDeltaTime: number;
  98212. /**
  98213. * Factory used to create the default material.
  98214. * @param name The name of the material to create
  98215. * @param scene The scene to create the material for
  98216. * @returns The default material
  98217. */
  98218. static DefaultMaterialFactory(scene: Scene): Material;
  98219. /**
  98220. * Factory used to create the a collision coordinator.
  98221. * @returns The collision coordinator
  98222. */
  98223. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98224. /** @hidden */
  98225. _inputManager: InputManager;
  98226. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98227. cameraToUseForPointers: Nullable<Camera>;
  98228. /** @hidden */
  98229. readonly _isScene: boolean;
  98230. /**
  98231. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98232. */
  98233. autoClear: boolean;
  98234. /**
  98235. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98236. */
  98237. autoClearDepthAndStencil: boolean;
  98238. /**
  98239. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98240. */
  98241. clearColor: Color4;
  98242. /**
  98243. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98244. */
  98245. ambientColor: Color3;
  98246. /**
  98247. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98248. * It should only be one of the following (if not the default embedded one):
  98249. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98250. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98251. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98252. * The material properties need to be setup according to the type of texture in use.
  98253. */
  98254. environmentBRDFTexture: BaseTexture;
  98255. /** @hidden */
  98256. protected _environmentTexture: Nullable<BaseTexture>;
  98257. /**
  98258. * Texture used in all pbr material as the reflection texture.
  98259. * As in the majority of the scene they are the same (exception for multi room and so on),
  98260. * this is easier to reference from here than from all the materials.
  98261. */
  98262. /**
  98263. * Texture used in all pbr material as the reflection texture.
  98264. * As in the majority of the scene they are the same (exception for multi room and so on),
  98265. * this is easier to set here than in all the materials.
  98266. */
  98267. environmentTexture: Nullable<BaseTexture>;
  98268. /** @hidden */
  98269. protected _environmentIntensity: number;
  98270. /**
  98271. * Intensity of the environment in all pbr material.
  98272. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98273. * As in the majority of the scene they are the same (exception for multi room and so on),
  98274. * this is easier to reference from here than from all the materials.
  98275. */
  98276. /**
  98277. * Intensity of the environment in all pbr material.
  98278. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98279. * As in the majority of the scene they are the same (exception for multi room and so on),
  98280. * this is easier to set here than in all the materials.
  98281. */
  98282. environmentIntensity: number;
  98283. /** @hidden */
  98284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98285. /**
  98286. * Default image processing configuration used either in the rendering
  98287. * Forward main pass or through the imageProcessingPostProcess if present.
  98288. * As in the majority of the scene they are the same (exception for multi camera),
  98289. * this is easier to reference from here than from all the materials and post process.
  98290. *
  98291. * No setter as we it is a shared configuration, you can set the values instead.
  98292. */
  98293. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98294. private _forceWireframe;
  98295. /**
  98296. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98297. */
  98298. forceWireframe: boolean;
  98299. private _forcePointsCloud;
  98300. /**
  98301. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98302. */
  98303. forcePointsCloud: boolean;
  98304. /**
  98305. * Gets or sets the active clipplane 1
  98306. */
  98307. clipPlane: Nullable<Plane>;
  98308. /**
  98309. * Gets or sets the active clipplane 2
  98310. */
  98311. clipPlane2: Nullable<Plane>;
  98312. /**
  98313. * Gets or sets the active clipplane 3
  98314. */
  98315. clipPlane3: Nullable<Plane>;
  98316. /**
  98317. * Gets or sets the active clipplane 4
  98318. */
  98319. clipPlane4: Nullable<Plane>;
  98320. /**
  98321. * Gets or sets a boolean indicating if animations are enabled
  98322. */
  98323. animationsEnabled: boolean;
  98324. private _animationPropertiesOverride;
  98325. /**
  98326. * Gets or sets the animation properties override
  98327. */
  98328. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98329. /**
  98330. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98331. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98332. */
  98333. useConstantAnimationDeltaTime: boolean;
  98334. /**
  98335. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98336. * Please note that it requires to run a ray cast through the scene on every frame
  98337. */
  98338. constantlyUpdateMeshUnderPointer: boolean;
  98339. /**
  98340. * Defines the HTML cursor to use when hovering over interactive elements
  98341. */
  98342. hoverCursor: string;
  98343. /**
  98344. * Defines the HTML default cursor to use (empty by default)
  98345. */
  98346. defaultCursor: string;
  98347. /**
  98348. * This is used to call preventDefault() on pointer down
  98349. * in order to block unwanted artifacts like system double clicks
  98350. */
  98351. preventDefaultOnPointerDown: boolean;
  98352. /**
  98353. * This is used to call preventDefault() on pointer up
  98354. * in order to block unwanted artifacts like system double clicks
  98355. */
  98356. preventDefaultOnPointerUp: boolean;
  98357. /**
  98358. * Gets or sets user defined metadata
  98359. */
  98360. metadata: any;
  98361. /**
  98362. * For internal use only. Please do not use.
  98363. */
  98364. reservedDataStore: any;
  98365. /**
  98366. * Gets the name of the plugin used to load this scene (null by default)
  98367. */
  98368. loadingPluginName: string;
  98369. /**
  98370. * Use this array to add regular expressions used to disable offline support for specific urls
  98371. */
  98372. disableOfflineSupportExceptionRules: RegExp[];
  98373. /**
  98374. * An event triggered when the scene is disposed.
  98375. */
  98376. onDisposeObservable: Observable<Scene>;
  98377. private _onDisposeObserver;
  98378. /** Sets a function to be executed when this scene is disposed. */
  98379. onDispose: () => void;
  98380. /**
  98381. * An event triggered before rendering the scene (right after animations and physics)
  98382. */
  98383. onBeforeRenderObservable: Observable<Scene>;
  98384. private _onBeforeRenderObserver;
  98385. /** Sets a function to be executed before rendering this scene */
  98386. beforeRender: Nullable<() => void>;
  98387. /**
  98388. * An event triggered after rendering the scene
  98389. */
  98390. onAfterRenderObservable: Observable<Scene>;
  98391. /**
  98392. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98393. */
  98394. onAfterRenderCameraObservable: Observable<Camera>;
  98395. private _onAfterRenderObserver;
  98396. /** Sets a function to be executed after rendering this scene */
  98397. afterRender: Nullable<() => void>;
  98398. /**
  98399. * An event triggered before animating the scene
  98400. */
  98401. onBeforeAnimationsObservable: Observable<Scene>;
  98402. /**
  98403. * An event triggered after animations processing
  98404. */
  98405. onAfterAnimationsObservable: Observable<Scene>;
  98406. /**
  98407. * An event triggered before draw calls are ready to be sent
  98408. */
  98409. onBeforeDrawPhaseObservable: Observable<Scene>;
  98410. /**
  98411. * An event triggered after draw calls have been sent
  98412. */
  98413. onAfterDrawPhaseObservable: Observable<Scene>;
  98414. /**
  98415. * An event triggered when the scene is ready
  98416. */
  98417. onReadyObservable: Observable<Scene>;
  98418. /**
  98419. * An event triggered before rendering a camera
  98420. */
  98421. onBeforeCameraRenderObservable: Observable<Camera>;
  98422. private _onBeforeCameraRenderObserver;
  98423. /** Sets a function to be executed before rendering a camera*/
  98424. beforeCameraRender: () => void;
  98425. /**
  98426. * An event triggered after rendering a camera
  98427. */
  98428. onAfterCameraRenderObservable: Observable<Camera>;
  98429. private _onAfterCameraRenderObserver;
  98430. /** Sets a function to be executed after rendering a camera*/
  98431. afterCameraRender: () => void;
  98432. /**
  98433. * An event triggered when active meshes evaluation is about to start
  98434. */
  98435. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98436. /**
  98437. * An event triggered when active meshes evaluation is done
  98438. */
  98439. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98440. /**
  98441. * An event triggered when particles rendering is about to start
  98442. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98443. */
  98444. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98445. /**
  98446. * An event triggered when particles rendering is done
  98447. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98448. */
  98449. onAfterParticlesRenderingObservable: Observable<Scene>;
  98450. /**
  98451. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98452. */
  98453. onDataLoadedObservable: Observable<Scene>;
  98454. /**
  98455. * An event triggered when a camera is created
  98456. */
  98457. onNewCameraAddedObservable: Observable<Camera>;
  98458. /**
  98459. * An event triggered when a camera is removed
  98460. */
  98461. onCameraRemovedObservable: Observable<Camera>;
  98462. /**
  98463. * An event triggered when a light is created
  98464. */
  98465. onNewLightAddedObservable: Observable<Light>;
  98466. /**
  98467. * An event triggered when a light is removed
  98468. */
  98469. onLightRemovedObservable: Observable<Light>;
  98470. /**
  98471. * An event triggered when a geometry is created
  98472. */
  98473. onNewGeometryAddedObservable: Observable<Geometry>;
  98474. /**
  98475. * An event triggered when a geometry is removed
  98476. */
  98477. onGeometryRemovedObservable: Observable<Geometry>;
  98478. /**
  98479. * An event triggered when a transform node is created
  98480. */
  98481. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98482. /**
  98483. * An event triggered when a transform node is removed
  98484. */
  98485. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98486. /**
  98487. * An event triggered when a mesh is created
  98488. */
  98489. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98490. /**
  98491. * An event triggered when a mesh is removed
  98492. */
  98493. onMeshRemovedObservable: Observable<AbstractMesh>;
  98494. /**
  98495. * An event triggered when a skeleton is created
  98496. */
  98497. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98498. /**
  98499. * An event triggered when a skeleton is removed
  98500. */
  98501. onSkeletonRemovedObservable: Observable<Skeleton>;
  98502. /**
  98503. * An event triggered when a material is created
  98504. */
  98505. onNewMaterialAddedObservable: Observable<Material>;
  98506. /**
  98507. * An event triggered when a material is removed
  98508. */
  98509. onMaterialRemovedObservable: Observable<Material>;
  98510. /**
  98511. * An event triggered when a texture is created
  98512. */
  98513. onNewTextureAddedObservable: Observable<BaseTexture>;
  98514. /**
  98515. * An event triggered when a texture is removed
  98516. */
  98517. onTextureRemovedObservable: Observable<BaseTexture>;
  98518. /**
  98519. * An event triggered when render targets are about to be rendered
  98520. * Can happen multiple times per frame.
  98521. */
  98522. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98523. /**
  98524. * An event triggered when render targets were rendered.
  98525. * Can happen multiple times per frame.
  98526. */
  98527. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98528. /**
  98529. * An event triggered before calculating deterministic simulation step
  98530. */
  98531. onBeforeStepObservable: Observable<Scene>;
  98532. /**
  98533. * An event triggered after calculating deterministic simulation step
  98534. */
  98535. onAfterStepObservable: Observable<Scene>;
  98536. /**
  98537. * An event triggered when the activeCamera property is updated
  98538. */
  98539. onActiveCameraChanged: Observable<Scene>;
  98540. /**
  98541. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98542. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98543. * 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)
  98544. */
  98545. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98546. /**
  98547. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98548. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98549. * 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)
  98550. */
  98551. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98552. /**
  98553. * This Observable will when a mesh has been imported into the scene.
  98554. */
  98555. onMeshImportedObservable: Observable<AbstractMesh>;
  98556. /**
  98557. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98558. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98559. */
  98560. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98561. /** @hidden */
  98562. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98563. /**
  98564. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98565. */
  98566. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98567. /**
  98568. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98569. */
  98570. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98571. /**
  98572. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98573. */
  98574. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98575. /** Callback called when a pointer move is detected */
  98576. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98577. /** Callback called when a pointer down is detected */
  98578. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98579. /** Callback called when a pointer up is detected */
  98580. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98581. /** Callback called when a pointer pick is detected */
  98582. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98583. /**
  98584. * 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).
  98585. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98586. */
  98587. onPrePointerObservable: Observable<PointerInfoPre>;
  98588. /**
  98589. * Observable event triggered each time an input event is received from the rendering canvas
  98590. */
  98591. onPointerObservable: Observable<PointerInfo>;
  98592. /**
  98593. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98594. */
  98595. readonly unTranslatedPointer: Vector2;
  98596. /**
  98597. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98598. */
  98599. static DragMovementThreshold: number;
  98600. /**
  98601. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98602. */
  98603. static LongPressDelay: number;
  98604. /**
  98605. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98606. */
  98607. static DoubleClickDelay: number;
  98608. /** If you need to check double click without raising a single click at first click, enable this flag */
  98609. static ExclusiveDoubleClickMode: boolean;
  98610. /** @hidden */
  98611. _mirroredCameraPosition: Nullable<Vector3>;
  98612. /**
  98613. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98614. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98615. */
  98616. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98617. /**
  98618. * Observable event triggered each time an keyboard event is received from the hosting window
  98619. */
  98620. onKeyboardObservable: Observable<KeyboardInfo>;
  98621. private _useRightHandedSystem;
  98622. /**
  98623. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98624. */
  98625. useRightHandedSystem: boolean;
  98626. private _timeAccumulator;
  98627. private _currentStepId;
  98628. private _currentInternalStep;
  98629. /**
  98630. * Sets the step Id used by deterministic lock step
  98631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98632. * @param newStepId defines the step Id
  98633. */
  98634. setStepId(newStepId: number): void;
  98635. /**
  98636. * Gets the step Id used by deterministic lock step
  98637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98638. * @returns the step Id
  98639. */
  98640. getStepId(): number;
  98641. /**
  98642. * Gets the internal step used by deterministic lock step
  98643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98644. * @returns the internal step
  98645. */
  98646. getInternalStep(): number;
  98647. private _fogEnabled;
  98648. /**
  98649. * Gets or sets a boolean indicating if fog is enabled on this scene
  98650. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98651. * (Default is true)
  98652. */
  98653. fogEnabled: boolean;
  98654. private _fogMode;
  98655. /**
  98656. * Gets or sets the fog mode to use
  98657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98658. * | mode | value |
  98659. * | --- | --- |
  98660. * | FOGMODE_NONE | 0 |
  98661. * | FOGMODE_EXP | 1 |
  98662. * | FOGMODE_EXP2 | 2 |
  98663. * | FOGMODE_LINEAR | 3 |
  98664. */
  98665. fogMode: number;
  98666. /**
  98667. * Gets or sets the fog color to use
  98668. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98669. * (Default is Color3(0.2, 0.2, 0.3))
  98670. */
  98671. fogColor: Color3;
  98672. /**
  98673. * Gets or sets the fog density to use
  98674. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98675. * (Default is 0.1)
  98676. */
  98677. fogDensity: number;
  98678. /**
  98679. * Gets or sets the fog start distance to use
  98680. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98681. * (Default is 0)
  98682. */
  98683. fogStart: number;
  98684. /**
  98685. * Gets or sets the fog end distance to use
  98686. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98687. * (Default is 1000)
  98688. */
  98689. fogEnd: number;
  98690. private _shadowsEnabled;
  98691. /**
  98692. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98693. */
  98694. shadowsEnabled: boolean;
  98695. private _lightsEnabled;
  98696. /**
  98697. * Gets or sets a boolean indicating if lights are enabled on this scene
  98698. */
  98699. lightsEnabled: boolean;
  98700. /** All of the active cameras added to this scene. */
  98701. activeCameras: Camera[];
  98702. /** @hidden */
  98703. _activeCamera: Nullable<Camera>;
  98704. /** Gets or sets the current active camera */
  98705. activeCamera: Nullable<Camera>;
  98706. private _defaultMaterial;
  98707. /** The default material used on meshes when no material is affected */
  98708. /** The default material used on meshes when no material is affected */
  98709. defaultMaterial: Material;
  98710. private _texturesEnabled;
  98711. /**
  98712. * Gets or sets a boolean indicating if textures are enabled on this scene
  98713. */
  98714. texturesEnabled: boolean;
  98715. /**
  98716. * Gets or sets a boolean indicating if particles are enabled on this scene
  98717. */
  98718. particlesEnabled: boolean;
  98719. /**
  98720. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98721. */
  98722. spritesEnabled: boolean;
  98723. private _skeletonsEnabled;
  98724. /**
  98725. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98726. */
  98727. skeletonsEnabled: boolean;
  98728. /**
  98729. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98730. */
  98731. lensFlaresEnabled: boolean;
  98732. /**
  98733. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98735. */
  98736. collisionsEnabled: boolean;
  98737. private _collisionCoordinator;
  98738. /** @hidden */
  98739. readonly collisionCoordinator: ICollisionCoordinator;
  98740. /**
  98741. * Defines the gravity applied to this scene (used only for collisions)
  98742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98743. */
  98744. gravity: Vector3;
  98745. /**
  98746. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98747. */
  98748. postProcessesEnabled: boolean;
  98749. /**
  98750. * The list of postprocesses added to the scene
  98751. */
  98752. postProcesses: PostProcess[];
  98753. /**
  98754. * Gets the current postprocess manager
  98755. */
  98756. postProcessManager: PostProcessManager;
  98757. /**
  98758. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98759. */
  98760. renderTargetsEnabled: boolean;
  98761. /**
  98762. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98763. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98764. */
  98765. dumpNextRenderTargets: boolean;
  98766. /**
  98767. * The list of user defined render targets added to the scene
  98768. */
  98769. customRenderTargets: RenderTargetTexture[];
  98770. /**
  98771. * Defines if texture loading must be delayed
  98772. * If true, textures will only be loaded when they need to be rendered
  98773. */
  98774. useDelayedTextureLoading: boolean;
  98775. /**
  98776. * Gets the list of meshes imported to the scene through SceneLoader
  98777. */
  98778. importedMeshesFiles: String[];
  98779. /**
  98780. * Gets or sets a boolean indicating if probes are enabled on this scene
  98781. */
  98782. probesEnabled: boolean;
  98783. /**
  98784. * Gets or sets the current offline provider to use to store scene data
  98785. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98786. */
  98787. offlineProvider: IOfflineProvider;
  98788. /**
  98789. * Gets or sets the action manager associated with the scene
  98790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98791. */
  98792. actionManager: AbstractActionManager;
  98793. private _meshesForIntersections;
  98794. /**
  98795. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98796. */
  98797. proceduralTexturesEnabled: boolean;
  98798. private _engine;
  98799. private _totalVertices;
  98800. /** @hidden */
  98801. _activeIndices: PerfCounter;
  98802. /** @hidden */
  98803. _activeParticles: PerfCounter;
  98804. /** @hidden */
  98805. _activeBones: PerfCounter;
  98806. private _animationRatio;
  98807. /** @hidden */
  98808. _animationTimeLast: number;
  98809. /** @hidden */
  98810. _animationTime: number;
  98811. /**
  98812. * Gets or sets a general scale for animation speed
  98813. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98814. */
  98815. animationTimeScale: number;
  98816. /** @hidden */
  98817. _cachedMaterial: Nullable<Material>;
  98818. /** @hidden */
  98819. _cachedEffect: Nullable<Effect>;
  98820. /** @hidden */
  98821. _cachedVisibility: Nullable<number>;
  98822. private _renderId;
  98823. private _frameId;
  98824. private _executeWhenReadyTimeoutId;
  98825. private _intermediateRendering;
  98826. private _viewUpdateFlag;
  98827. private _projectionUpdateFlag;
  98828. /** @hidden */
  98829. _toBeDisposed: Nullable<IDisposable>[];
  98830. private _activeRequests;
  98831. /** @hidden */
  98832. _pendingData: any[];
  98833. private _isDisposed;
  98834. /**
  98835. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98836. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98837. */
  98838. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98839. private _activeMeshes;
  98840. private _processedMaterials;
  98841. private _renderTargets;
  98842. /** @hidden */
  98843. _activeParticleSystems: SmartArray<IParticleSystem>;
  98844. private _activeSkeletons;
  98845. private _softwareSkinnedMeshes;
  98846. private _renderingManager;
  98847. /** @hidden */
  98848. _activeAnimatables: Animatable[];
  98849. private _transformMatrix;
  98850. private _sceneUbo;
  98851. /** @hidden */
  98852. _viewMatrix: Matrix;
  98853. private _projectionMatrix;
  98854. /** @hidden */
  98855. _forcedViewPosition: Nullable<Vector3>;
  98856. /** @hidden */
  98857. _frustumPlanes: Plane[];
  98858. /**
  98859. * Gets the list of frustum planes (built from the active camera)
  98860. */
  98861. readonly frustumPlanes: Plane[];
  98862. /**
  98863. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98864. * This is useful if there are more lights that the maximum simulteanous authorized
  98865. */
  98866. requireLightSorting: boolean;
  98867. /** @hidden */
  98868. readonly useMaterialMeshMap: boolean;
  98869. /** @hidden */
  98870. readonly useClonedMeshhMap: boolean;
  98871. private _externalData;
  98872. private _uid;
  98873. /**
  98874. * @hidden
  98875. * Backing store of defined scene components.
  98876. */
  98877. _components: ISceneComponent[];
  98878. /**
  98879. * @hidden
  98880. * Backing store of defined scene components.
  98881. */
  98882. _serializableComponents: ISceneSerializableComponent[];
  98883. /**
  98884. * List of components to register on the next registration step.
  98885. */
  98886. private _transientComponents;
  98887. /**
  98888. * Registers the transient components if needed.
  98889. */
  98890. private _registerTransientComponents;
  98891. /**
  98892. * @hidden
  98893. * Add a component to the scene.
  98894. * Note that the ccomponent could be registered on th next frame if this is called after
  98895. * the register component stage.
  98896. * @param component Defines the component to add to the scene
  98897. */
  98898. _addComponent(component: ISceneComponent): void;
  98899. /**
  98900. * @hidden
  98901. * Gets a component from the scene.
  98902. * @param name defines the name of the component to retrieve
  98903. * @returns the component or null if not present
  98904. */
  98905. _getComponent(name: string): Nullable<ISceneComponent>;
  98906. /**
  98907. * @hidden
  98908. * Defines the actions happening before camera updates.
  98909. */
  98910. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98911. /**
  98912. * @hidden
  98913. * Defines the actions happening before clear the canvas.
  98914. */
  98915. _beforeClearStage: Stage<SimpleStageAction>;
  98916. /**
  98917. * @hidden
  98918. * Defines the actions when collecting render targets for the frame.
  98919. */
  98920. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98921. /**
  98922. * @hidden
  98923. * Defines the actions happening for one camera in the frame.
  98924. */
  98925. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98926. /**
  98927. * @hidden
  98928. * Defines the actions happening during the per mesh ready checks.
  98929. */
  98930. _isReadyForMeshStage: Stage<MeshStageAction>;
  98931. /**
  98932. * @hidden
  98933. * Defines the actions happening before evaluate active mesh checks.
  98934. */
  98935. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98936. /**
  98937. * @hidden
  98938. * Defines the actions happening during the evaluate sub mesh checks.
  98939. */
  98940. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98941. /**
  98942. * @hidden
  98943. * Defines the actions happening during the active mesh stage.
  98944. */
  98945. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98946. /**
  98947. * @hidden
  98948. * Defines the actions happening during the per camera render target step.
  98949. */
  98950. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98951. /**
  98952. * @hidden
  98953. * Defines the actions happening just before the active camera is drawing.
  98954. */
  98955. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98956. /**
  98957. * @hidden
  98958. * Defines the actions happening just before a render target is drawing.
  98959. */
  98960. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98961. /**
  98962. * @hidden
  98963. * Defines the actions happening just before a rendering group is drawing.
  98964. */
  98965. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98966. /**
  98967. * @hidden
  98968. * Defines the actions happening just before a mesh is drawing.
  98969. */
  98970. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98971. /**
  98972. * @hidden
  98973. * Defines the actions happening just after a mesh has been drawn.
  98974. */
  98975. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98976. /**
  98977. * @hidden
  98978. * Defines the actions happening just after a rendering group has been drawn.
  98979. */
  98980. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98981. /**
  98982. * @hidden
  98983. * Defines the actions happening just after the active camera has been drawn.
  98984. */
  98985. _afterCameraDrawStage: Stage<CameraStageAction>;
  98986. /**
  98987. * @hidden
  98988. * Defines the actions happening just after a render target has been drawn.
  98989. */
  98990. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98991. /**
  98992. * @hidden
  98993. * Defines the actions happening just after rendering all cameras and computing intersections.
  98994. */
  98995. _afterRenderStage: Stage<SimpleStageAction>;
  98996. /**
  98997. * @hidden
  98998. * Defines the actions happening when a pointer move event happens.
  98999. */
  99000. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99001. /**
  99002. * @hidden
  99003. * Defines the actions happening when a pointer down event happens.
  99004. */
  99005. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99006. /**
  99007. * @hidden
  99008. * Defines the actions happening when a pointer up event happens.
  99009. */
  99010. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99011. /**
  99012. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99013. */
  99014. private geometriesByUniqueId;
  99015. /**
  99016. * Creates a new Scene
  99017. * @param engine defines the engine to use to render this scene
  99018. * @param options defines the scene options
  99019. */
  99020. constructor(engine: Engine, options?: SceneOptions);
  99021. /**
  99022. * Gets a string idenfifying the name of the class
  99023. * @returns "Scene" string
  99024. */
  99025. getClassName(): string;
  99026. private _defaultMeshCandidates;
  99027. /**
  99028. * @hidden
  99029. */
  99030. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99031. private _defaultSubMeshCandidates;
  99032. /**
  99033. * @hidden
  99034. */
  99035. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99036. /**
  99037. * Sets the default candidate providers for the scene.
  99038. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99039. * and getCollidingSubMeshCandidates to their default function
  99040. */
  99041. setDefaultCandidateProviders(): void;
  99042. /**
  99043. * Gets the mesh that is currently under the pointer
  99044. */
  99045. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99046. /**
  99047. * Gets or sets the current on-screen X position of the pointer
  99048. */
  99049. pointerX: number;
  99050. /**
  99051. * Gets or sets the current on-screen Y position of the pointer
  99052. */
  99053. pointerY: number;
  99054. /**
  99055. * Gets the cached material (ie. the latest rendered one)
  99056. * @returns the cached material
  99057. */
  99058. getCachedMaterial(): Nullable<Material>;
  99059. /**
  99060. * Gets the cached effect (ie. the latest rendered one)
  99061. * @returns the cached effect
  99062. */
  99063. getCachedEffect(): Nullable<Effect>;
  99064. /**
  99065. * Gets the cached visibility state (ie. the latest rendered one)
  99066. * @returns the cached visibility state
  99067. */
  99068. getCachedVisibility(): Nullable<number>;
  99069. /**
  99070. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99071. * @param material defines the current material
  99072. * @param effect defines the current effect
  99073. * @param visibility defines the current visibility state
  99074. * @returns true if one parameter is not cached
  99075. */
  99076. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99077. /**
  99078. * Gets the engine associated with the scene
  99079. * @returns an Engine
  99080. */
  99081. getEngine(): Engine;
  99082. /**
  99083. * Gets the total number of vertices rendered per frame
  99084. * @returns the total number of vertices rendered per frame
  99085. */
  99086. getTotalVertices(): number;
  99087. /**
  99088. * Gets the performance counter for total vertices
  99089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99090. */
  99091. readonly totalVerticesPerfCounter: PerfCounter;
  99092. /**
  99093. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99094. * @returns the total number of active indices rendered per frame
  99095. */
  99096. getActiveIndices(): number;
  99097. /**
  99098. * Gets the performance counter for active indices
  99099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99100. */
  99101. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99102. /**
  99103. * Gets the total number of active particles rendered per frame
  99104. * @returns the total number of active particles rendered per frame
  99105. */
  99106. getActiveParticles(): number;
  99107. /**
  99108. * Gets the performance counter for active particles
  99109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99110. */
  99111. readonly activeParticlesPerfCounter: PerfCounter;
  99112. /**
  99113. * Gets the total number of active bones rendered per frame
  99114. * @returns the total number of active bones rendered per frame
  99115. */
  99116. getActiveBones(): number;
  99117. /**
  99118. * Gets the performance counter for active bones
  99119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99120. */
  99121. readonly activeBonesPerfCounter: PerfCounter;
  99122. /**
  99123. * Gets the array of active meshes
  99124. * @returns an array of AbstractMesh
  99125. */
  99126. getActiveMeshes(): SmartArray<AbstractMesh>;
  99127. /**
  99128. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99129. * @returns a number
  99130. */
  99131. getAnimationRatio(): number;
  99132. /**
  99133. * Gets an unique Id for the current render phase
  99134. * @returns a number
  99135. */
  99136. getRenderId(): number;
  99137. /**
  99138. * Gets an unique Id for the current frame
  99139. * @returns a number
  99140. */
  99141. getFrameId(): number;
  99142. /** Call this function if you want to manually increment the render Id*/
  99143. incrementRenderId(): void;
  99144. private _createUbo;
  99145. /**
  99146. * Use this method to simulate a pointer move on a mesh
  99147. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99148. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99149. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99150. * @returns the current scene
  99151. */
  99152. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99153. /**
  99154. * Use this method to simulate a pointer down on a mesh
  99155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99158. * @returns the current scene
  99159. */
  99160. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99161. /**
  99162. * Use this method to simulate a pointer up on a mesh
  99163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99166. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99167. * @returns the current scene
  99168. */
  99169. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99170. /**
  99171. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99172. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99173. * @returns true if the pointer was captured
  99174. */
  99175. isPointerCaptured(pointerId?: number): boolean;
  99176. /**
  99177. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99178. * @param attachUp defines if you want to attach events to pointerup
  99179. * @param attachDown defines if you want to attach events to pointerdown
  99180. * @param attachMove defines if you want to attach events to pointermove
  99181. */
  99182. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99183. /** Detaches all event handlers*/
  99184. detachControl(): void;
  99185. /**
  99186. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99187. * Delay loaded resources are not taking in account
  99188. * @return true if all required resources are ready
  99189. */
  99190. isReady(): boolean;
  99191. /** Resets all cached information relative to material (including effect and visibility) */
  99192. resetCachedMaterial(): void;
  99193. /**
  99194. * Registers a function to be called before every frame render
  99195. * @param func defines the function to register
  99196. */
  99197. registerBeforeRender(func: () => void): void;
  99198. /**
  99199. * Unregisters a function called before every frame render
  99200. * @param func defines the function to unregister
  99201. */
  99202. unregisterBeforeRender(func: () => void): void;
  99203. /**
  99204. * Registers a function to be called after every frame render
  99205. * @param func defines the function to register
  99206. */
  99207. registerAfterRender(func: () => void): void;
  99208. /**
  99209. * Unregisters a function called after every frame render
  99210. * @param func defines the function to unregister
  99211. */
  99212. unregisterAfterRender(func: () => void): void;
  99213. private _executeOnceBeforeRender;
  99214. /**
  99215. * The provided function will run before render once and will be disposed afterwards.
  99216. * A timeout delay can be provided so that the function will be executed in N ms.
  99217. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99218. * @param func The function to be executed.
  99219. * @param timeout optional delay in ms
  99220. */
  99221. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99222. /** @hidden */
  99223. _addPendingData(data: any): void;
  99224. /** @hidden */
  99225. _removePendingData(data: any): void;
  99226. /**
  99227. * Returns the number of items waiting to be loaded
  99228. * @returns the number of items waiting to be loaded
  99229. */
  99230. getWaitingItemsCount(): number;
  99231. /**
  99232. * Returns a boolean indicating if the scene is still loading data
  99233. */
  99234. readonly isLoading: boolean;
  99235. /**
  99236. * Registers a function to be executed when the scene is ready
  99237. * @param {Function} func - the function to be executed
  99238. */
  99239. executeWhenReady(func: () => void): void;
  99240. /**
  99241. * Returns a promise that resolves when the scene is ready
  99242. * @returns A promise that resolves when the scene is ready
  99243. */
  99244. whenReadyAsync(): Promise<void>;
  99245. /** @hidden */
  99246. _checkIsReady(): void;
  99247. /**
  99248. * Gets all animatable attached to the scene
  99249. */
  99250. readonly animatables: Animatable[];
  99251. /**
  99252. * Resets the last animation time frame.
  99253. * Useful to override when animations start running when loading a scene for the first time.
  99254. */
  99255. resetLastAnimationTimeFrame(): void;
  99256. /**
  99257. * Gets the current view matrix
  99258. * @returns a Matrix
  99259. */
  99260. getViewMatrix(): Matrix;
  99261. /**
  99262. * Gets the current projection matrix
  99263. * @returns a Matrix
  99264. */
  99265. getProjectionMatrix(): Matrix;
  99266. /**
  99267. * Gets the current transform matrix
  99268. * @returns a Matrix made of View * Projection
  99269. */
  99270. getTransformMatrix(): Matrix;
  99271. /**
  99272. * Sets the current transform matrix
  99273. * @param viewL defines the View matrix to use
  99274. * @param projectionL defines the Projection matrix to use
  99275. * @param viewR defines the right View matrix to use (if provided)
  99276. * @param projectionR defines the right Projection matrix to use (if provided)
  99277. */
  99278. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99279. /**
  99280. * Gets the uniform buffer used to store scene data
  99281. * @returns a UniformBuffer
  99282. */
  99283. getSceneUniformBuffer(): UniformBuffer;
  99284. /**
  99285. * Gets an unique (relatively to the current scene) Id
  99286. * @returns an unique number for the scene
  99287. */
  99288. getUniqueId(): number;
  99289. /**
  99290. * Add a mesh to the list of scene's meshes
  99291. * @param newMesh defines the mesh to add
  99292. * @param recursive if all child meshes should also be added to the scene
  99293. */
  99294. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99295. /**
  99296. * Remove a mesh for the list of scene's meshes
  99297. * @param toRemove defines the mesh to remove
  99298. * @param recursive if all child meshes should also be removed from the scene
  99299. * @returns the index where the mesh was in the mesh list
  99300. */
  99301. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99302. /**
  99303. * Add a transform node to the list of scene's transform nodes
  99304. * @param newTransformNode defines the transform node to add
  99305. */
  99306. addTransformNode(newTransformNode: TransformNode): void;
  99307. /**
  99308. * Remove a transform node for the list of scene's transform nodes
  99309. * @param toRemove defines the transform node to remove
  99310. * @returns the index where the transform node was in the transform node list
  99311. */
  99312. removeTransformNode(toRemove: TransformNode): number;
  99313. /**
  99314. * Remove a skeleton for the list of scene's skeletons
  99315. * @param toRemove defines the skeleton to remove
  99316. * @returns the index where the skeleton was in the skeleton list
  99317. */
  99318. removeSkeleton(toRemove: Skeleton): number;
  99319. /**
  99320. * Remove a morph target for the list of scene's morph targets
  99321. * @param toRemove defines the morph target to remove
  99322. * @returns the index where the morph target was in the morph target list
  99323. */
  99324. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99325. /**
  99326. * Remove a light for the list of scene's lights
  99327. * @param toRemove defines the light to remove
  99328. * @returns the index where the light was in the light list
  99329. */
  99330. removeLight(toRemove: Light): number;
  99331. /**
  99332. * Remove a camera for the list of scene's cameras
  99333. * @param toRemove defines the camera to remove
  99334. * @returns the index where the camera was in the camera list
  99335. */
  99336. removeCamera(toRemove: Camera): number;
  99337. /**
  99338. * Remove a particle system for the list of scene's particle systems
  99339. * @param toRemove defines the particle system to remove
  99340. * @returns the index where the particle system was in the particle system list
  99341. */
  99342. removeParticleSystem(toRemove: IParticleSystem): number;
  99343. /**
  99344. * Remove a animation for the list of scene's animations
  99345. * @param toRemove defines the animation to remove
  99346. * @returns the index where the animation was in the animation list
  99347. */
  99348. removeAnimation(toRemove: Animation): number;
  99349. /**
  99350. * Will stop the animation of the given target
  99351. * @param target - the target
  99352. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99353. * @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)
  99354. */
  99355. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99356. /**
  99357. * Removes the given animation group from this scene.
  99358. * @param toRemove The animation group to remove
  99359. * @returns The index of the removed animation group
  99360. */
  99361. removeAnimationGroup(toRemove: AnimationGroup): number;
  99362. /**
  99363. * Removes the given multi-material from this scene.
  99364. * @param toRemove The multi-material to remove
  99365. * @returns The index of the removed multi-material
  99366. */
  99367. removeMultiMaterial(toRemove: MultiMaterial): number;
  99368. /**
  99369. * Removes the given material from this scene.
  99370. * @param toRemove The material to remove
  99371. * @returns The index of the removed material
  99372. */
  99373. removeMaterial(toRemove: Material): number;
  99374. /**
  99375. * Removes the given action manager from this scene.
  99376. * @param toRemove The action manager to remove
  99377. * @returns The index of the removed action manager
  99378. */
  99379. removeActionManager(toRemove: AbstractActionManager): number;
  99380. /**
  99381. * Removes the given texture from this scene.
  99382. * @param toRemove The texture to remove
  99383. * @returns The index of the removed texture
  99384. */
  99385. removeTexture(toRemove: BaseTexture): number;
  99386. /**
  99387. * Adds the given light to this scene
  99388. * @param newLight The light to add
  99389. */
  99390. addLight(newLight: Light): void;
  99391. /**
  99392. * Sorts the list list based on light priorities
  99393. */
  99394. sortLightsByPriority(): void;
  99395. /**
  99396. * Adds the given camera to this scene
  99397. * @param newCamera The camera to add
  99398. */
  99399. addCamera(newCamera: Camera): void;
  99400. /**
  99401. * Adds the given skeleton to this scene
  99402. * @param newSkeleton The skeleton to add
  99403. */
  99404. addSkeleton(newSkeleton: Skeleton): void;
  99405. /**
  99406. * Adds the given particle system to this scene
  99407. * @param newParticleSystem The particle system to add
  99408. */
  99409. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99410. /**
  99411. * Adds the given animation to this scene
  99412. * @param newAnimation The animation to add
  99413. */
  99414. addAnimation(newAnimation: Animation): void;
  99415. /**
  99416. * Adds the given animation group to this scene.
  99417. * @param newAnimationGroup The animation group to add
  99418. */
  99419. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99420. /**
  99421. * Adds the given multi-material to this scene
  99422. * @param newMultiMaterial The multi-material to add
  99423. */
  99424. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99425. /**
  99426. * Adds the given material to this scene
  99427. * @param newMaterial The material to add
  99428. */
  99429. addMaterial(newMaterial: Material): void;
  99430. /**
  99431. * Adds the given morph target to this scene
  99432. * @param newMorphTargetManager The morph target to add
  99433. */
  99434. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99435. /**
  99436. * Adds the given geometry to this scene
  99437. * @param newGeometry The geometry to add
  99438. */
  99439. addGeometry(newGeometry: Geometry): void;
  99440. /**
  99441. * Adds the given action manager to this scene
  99442. * @param newActionManager The action manager to add
  99443. */
  99444. addActionManager(newActionManager: AbstractActionManager): void;
  99445. /**
  99446. * Adds the given texture to this scene.
  99447. * @param newTexture The texture to add
  99448. */
  99449. addTexture(newTexture: BaseTexture): void;
  99450. /**
  99451. * Switch active camera
  99452. * @param newCamera defines the new active camera
  99453. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99454. */
  99455. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99456. /**
  99457. * sets the active camera of the scene using its ID
  99458. * @param id defines the camera's ID
  99459. * @return the new active camera or null if none found.
  99460. */
  99461. setActiveCameraByID(id: string): Nullable<Camera>;
  99462. /**
  99463. * sets the active camera of the scene using its name
  99464. * @param name defines the camera's name
  99465. * @returns the new active camera or null if none found.
  99466. */
  99467. setActiveCameraByName(name: string): Nullable<Camera>;
  99468. /**
  99469. * get an animation group using its name
  99470. * @param name defines the material's name
  99471. * @return the animation group or null if none found.
  99472. */
  99473. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99474. /**
  99475. * Get a material using its unique id
  99476. * @param uniqueId defines the material's unique id
  99477. * @return the material or null if none found.
  99478. */
  99479. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99480. /**
  99481. * get a material using its id
  99482. * @param id defines the material's ID
  99483. * @return the material or null if none found.
  99484. */
  99485. getMaterialByID(id: string): Nullable<Material>;
  99486. /**
  99487. * Gets a the last added material using a given id
  99488. * @param id defines the material's ID
  99489. * @return the last material with the given id or null if none found.
  99490. */
  99491. getLastMaterialByID(id: string): Nullable<Material>;
  99492. /**
  99493. * Gets a material using its name
  99494. * @param name defines the material's name
  99495. * @return the material or null if none found.
  99496. */
  99497. getMaterialByName(name: string): Nullable<Material>;
  99498. /**
  99499. * Get a texture using its unique id
  99500. * @param uniqueId defines the texture's unique id
  99501. * @return the texture or null if none found.
  99502. */
  99503. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99504. /**
  99505. * Gets a camera using its id
  99506. * @param id defines the id to look for
  99507. * @returns the camera or null if not found
  99508. */
  99509. getCameraByID(id: string): Nullable<Camera>;
  99510. /**
  99511. * Gets a camera using its unique id
  99512. * @param uniqueId defines the unique id to look for
  99513. * @returns the camera or null if not found
  99514. */
  99515. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99516. /**
  99517. * Gets a camera using its name
  99518. * @param name defines the camera's name
  99519. * @return the camera or null if none found.
  99520. */
  99521. getCameraByName(name: string): Nullable<Camera>;
  99522. /**
  99523. * Gets a bone using its id
  99524. * @param id defines the bone's id
  99525. * @return the bone or null if not found
  99526. */
  99527. getBoneByID(id: string): Nullable<Bone>;
  99528. /**
  99529. * Gets a bone using its id
  99530. * @param name defines the bone's name
  99531. * @return the bone or null if not found
  99532. */
  99533. getBoneByName(name: string): Nullable<Bone>;
  99534. /**
  99535. * Gets a light node using its name
  99536. * @param name defines the the light's name
  99537. * @return the light or null if none found.
  99538. */
  99539. getLightByName(name: string): Nullable<Light>;
  99540. /**
  99541. * Gets a light node using its id
  99542. * @param id defines the light's id
  99543. * @return the light or null if none found.
  99544. */
  99545. getLightByID(id: string): Nullable<Light>;
  99546. /**
  99547. * Gets a light node using its scene-generated unique ID
  99548. * @param uniqueId defines the light's unique id
  99549. * @return the light or null if none found.
  99550. */
  99551. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99552. /**
  99553. * Gets a particle system by id
  99554. * @param id defines the particle system id
  99555. * @return the corresponding system or null if none found
  99556. */
  99557. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99558. /**
  99559. * Gets a geometry using its ID
  99560. * @param id defines the geometry's id
  99561. * @return the geometry or null if none found.
  99562. */
  99563. getGeometryByID(id: string): Nullable<Geometry>;
  99564. private _getGeometryByUniqueID;
  99565. /**
  99566. * Add a new geometry to this scene
  99567. * @param geometry defines the geometry to be added to the scene.
  99568. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99569. * @return a boolean defining if the geometry was added or not
  99570. */
  99571. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99572. /**
  99573. * Removes an existing geometry
  99574. * @param geometry defines the geometry to be removed from the scene
  99575. * @return a boolean defining if the geometry was removed or not
  99576. */
  99577. removeGeometry(geometry: Geometry): boolean;
  99578. /**
  99579. * Gets the list of geometries attached to the scene
  99580. * @returns an array of Geometry
  99581. */
  99582. getGeometries(): Geometry[];
  99583. /**
  99584. * Gets the first added mesh found of a given ID
  99585. * @param id defines the id to search for
  99586. * @return the mesh found or null if not found at all
  99587. */
  99588. getMeshByID(id: string): Nullable<AbstractMesh>;
  99589. /**
  99590. * Gets a list of meshes using their id
  99591. * @param id defines the id to search for
  99592. * @returns a list of meshes
  99593. */
  99594. getMeshesByID(id: string): Array<AbstractMesh>;
  99595. /**
  99596. * Gets the first added transform node found of a given ID
  99597. * @param id defines the id to search for
  99598. * @return the found transform node or null if not found at all.
  99599. */
  99600. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99601. /**
  99602. * Gets a transform node with its auto-generated unique id
  99603. * @param uniqueId efines the unique id to search for
  99604. * @return the found transform node or null if not found at all.
  99605. */
  99606. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99607. /**
  99608. * Gets a list of transform nodes using their id
  99609. * @param id defines the id to search for
  99610. * @returns a list of transform nodes
  99611. */
  99612. getTransformNodesByID(id: string): Array<TransformNode>;
  99613. /**
  99614. * Gets a mesh with its auto-generated unique id
  99615. * @param uniqueId defines the unique id to search for
  99616. * @return the found mesh or null if not found at all.
  99617. */
  99618. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99619. /**
  99620. * Gets a the last added mesh using a given id
  99621. * @param id defines the id to search for
  99622. * @return the found mesh or null if not found at all.
  99623. */
  99624. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99625. /**
  99626. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99627. * @param id defines the id to search for
  99628. * @return the found node or null if not found at all
  99629. */
  99630. getLastEntryByID(id: string): Nullable<Node>;
  99631. /**
  99632. * Gets a node (Mesh, Camera, Light) using a given id
  99633. * @param id defines the id to search for
  99634. * @return the found node or null if not found at all
  99635. */
  99636. getNodeByID(id: string): Nullable<Node>;
  99637. /**
  99638. * Gets a node (Mesh, Camera, Light) using a given name
  99639. * @param name defines the name to search for
  99640. * @return the found node or null if not found at all.
  99641. */
  99642. getNodeByName(name: string): Nullable<Node>;
  99643. /**
  99644. * Gets a mesh using a given name
  99645. * @param name defines the name to search for
  99646. * @return the found mesh or null if not found at all.
  99647. */
  99648. getMeshByName(name: string): Nullable<AbstractMesh>;
  99649. /**
  99650. * Gets a transform node using a given name
  99651. * @param name defines the name to search for
  99652. * @return the found transform node or null if not found at all.
  99653. */
  99654. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99655. /**
  99656. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99657. * @param id defines the id to search for
  99658. * @return the found skeleton or null if not found at all.
  99659. */
  99660. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99661. /**
  99662. * Gets a skeleton using a given auto generated unique id
  99663. * @param uniqueId defines the unique id to search for
  99664. * @return the found skeleton or null if not found at all.
  99665. */
  99666. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99667. /**
  99668. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99669. * @param id defines the id to search for
  99670. * @return the found skeleton or null if not found at all.
  99671. */
  99672. getSkeletonById(id: string): Nullable<Skeleton>;
  99673. /**
  99674. * Gets a skeleton using a given name
  99675. * @param name defines the name to search for
  99676. * @return the found skeleton or null if not found at all.
  99677. */
  99678. getSkeletonByName(name: string): Nullable<Skeleton>;
  99679. /**
  99680. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99681. * @param id defines the id to search for
  99682. * @return the found morph target manager or null if not found at all.
  99683. */
  99684. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99685. /**
  99686. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99687. * @param id defines the id to search for
  99688. * @return the found morph target or null if not found at all.
  99689. */
  99690. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99691. /**
  99692. * Gets a boolean indicating if the given mesh is active
  99693. * @param mesh defines the mesh to look for
  99694. * @returns true if the mesh is in the active list
  99695. */
  99696. isActiveMesh(mesh: AbstractMesh): boolean;
  99697. /**
  99698. * Return a unique id as a string which can serve as an identifier for the scene
  99699. */
  99700. readonly uid: string;
  99701. /**
  99702. * Add an externaly attached data from its key.
  99703. * This method call will fail and return false, if such key already exists.
  99704. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99705. * @param key the unique key that identifies the data
  99706. * @param data the data object to associate to the key for this Engine instance
  99707. * @return true if no such key were already present and the data was added successfully, false otherwise
  99708. */
  99709. addExternalData<T>(key: string, data: T): boolean;
  99710. /**
  99711. * Get an externaly attached data from its key
  99712. * @param key the unique key that identifies the data
  99713. * @return the associated data, if present (can be null), or undefined if not present
  99714. */
  99715. getExternalData<T>(key: string): Nullable<T>;
  99716. /**
  99717. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99718. * @param key the unique key that identifies the data
  99719. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99720. * @return the associated data, can be null if the factory returned null.
  99721. */
  99722. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99723. /**
  99724. * Remove an externaly attached data from the Engine instance
  99725. * @param key the unique key that identifies the data
  99726. * @return true if the data was successfully removed, false if it doesn't exist
  99727. */
  99728. removeExternalData(key: string): boolean;
  99729. private _evaluateSubMesh;
  99730. /**
  99731. * Clear the processed materials smart array preventing retention point in material dispose.
  99732. */
  99733. freeProcessedMaterials(): void;
  99734. private _preventFreeActiveMeshesAndRenderingGroups;
  99735. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99736. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99737. * when disposing several meshes in a row or a hierarchy of meshes.
  99738. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99739. */
  99740. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99741. /**
  99742. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99743. */
  99744. freeActiveMeshes(): void;
  99745. /**
  99746. * Clear the info related to rendering groups preventing retention points during dispose.
  99747. */
  99748. freeRenderingGroups(): void;
  99749. /** @hidden */
  99750. _isInIntermediateRendering(): boolean;
  99751. /**
  99752. * Lambda returning the list of potentially active meshes.
  99753. */
  99754. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99755. /**
  99756. * Lambda returning the list of potentially active sub meshes.
  99757. */
  99758. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99759. /**
  99760. * Lambda returning the list of potentially intersecting sub meshes.
  99761. */
  99762. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99763. /**
  99764. * Lambda returning the list of potentially colliding sub meshes.
  99765. */
  99766. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99767. private _activeMeshesFrozen;
  99768. /**
  99769. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99770. * @returns the current scene
  99771. */
  99772. freezeActiveMeshes(): Scene;
  99773. /**
  99774. * Use this function to restart evaluating active meshes on every frame
  99775. * @returns the current scene
  99776. */
  99777. unfreezeActiveMeshes(): Scene;
  99778. private _evaluateActiveMeshes;
  99779. private _activeMesh;
  99780. /**
  99781. * Update the transform matrix to update from the current active camera
  99782. * @param force defines a boolean used to force the update even if cache is up to date
  99783. */
  99784. updateTransformMatrix(force?: boolean): void;
  99785. private _bindFrameBuffer;
  99786. /** @hidden */
  99787. _allowPostProcessClearColor: boolean;
  99788. /** @hidden */
  99789. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99790. private _processSubCameras;
  99791. private _checkIntersections;
  99792. /** @hidden */
  99793. _advancePhysicsEngineStep(step: number): void;
  99794. /**
  99795. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99796. */
  99797. getDeterministicFrameTime: () => number;
  99798. /** @hidden */
  99799. _animate(): void;
  99800. /** Execute all animations (for a frame) */
  99801. animate(): void;
  99802. /**
  99803. * Render the scene
  99804. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99805. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99806. */
  99807. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99808. /**
  99809. * Freeze all materials
  99810. * A frozen material will not be updatable but should be faster to render
  99811. */
  99812. freezeMaterials(): void;
  99813. /**
  99814. * Unfreeze all materials
  99815. * A frozen material will not be updatable but should be faster to render
  99816. */
  99817. unfreezeMaterials(): void;
  99818. /**
  99819. * Releases all held ressources
  99820. */
  99821. dispose(): void;
  99822. /**
  99823. * Gets if the scene is already disposed
  99824. */
  99825. readonly isDisposed: boolean;
  99826. /**
  99827. * Call this function to reduce memory footprint of the scene.
  99828. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99829. */
  99830. clearCachedVertexData(): void;
  99831. /**
  99832. * This function will remove the local cached buffer data from texture.
  99833. * It will save memory but will prevent the texture from being rebuilt
  99834. */
  99835. cleanCachedTextureBuffer(): void;
  99836. /**
  99837. * Get the world extend vectors with an optional filter
  99838. *
  99839. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99840. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99841. */
  99842. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99843. min: Vector3;
  99844. max: Vector3;
  99845. };
  99846. /**
  99847. * Creates a ray that can be used to pick in the scene
  99848. * @param x defines the x coordinate of the origin (on-screen)
  99849. * @param y defines the y coordinate of the origin (on-screen)
  99850. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99851. * @param camera defines the camera to use for the picking
  99852. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99853. * @returns a Ray
  99854. */
  99855. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99856. /**
  99857. * Creates a ray that can be used to pick in the scene
  99858. * @param x defines the x coordinate of the origin (on-screen)
  99859. * @param y defines the y coordinate of the origin (on-screen)
  99860. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99861. * @param result defines the ray where to store the picking ray
  99862. * @param camera defines the camera to use for the picking
  99863. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99864. * @returns the current scene
  99865. */
  99866. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99867. /**
  99868. * Creates a ray that can be used to pick in the scene
  99869. * @param x defines the x coordinate of the origin (on-screen)
  99870. * @param y defines the y coordinate of the origin (on-screen)
  99871. * @param camera defines the camera to use for the picking
  99872. * @returns a Ray
  99873. */
  99874. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99875. /**
  99876. * Creates a ray that can be used to pick in the scene
  99877. * @param x defines the x coordinate of the origin (on-screen)
  99878. * @param y defines the y coordinate of the origin (on-screen)
  99879. * @param result defines the ray where to store the picking ray
  99880. * @param camera defines the camera to use for the picking
  99881. * @returns the current scene
  99882. */
  99883. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99884. /** Launch a ray to try to pick a mesh in the scene
  99885. * @param x position on screen
  99886. * @param y position on screen
  99887. * @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
  99888. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99889. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99890. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99891. * @returns a PickingInfo
  99892. */
  99893. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99894. /** Use the given ray to pick a mesh in the scene
  99895. * @param ray The ray to use to pick meshes
  99896. * @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
  99897. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99898. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99899. * @returns a PickingInfo
  99900. */
  99901. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99902. /**
  99903. * Launch a ray to try to pick a mesh in the scene
  99904. * @param x X position on screen
  99905. * @param y Y position on screen
  99906. * @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
  99907. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99909. * @returns an array of PickingInfo
  99910. */
  99911. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99912. /**
  99913. * Launch a ray to try to pick a mesh in the scene
  99914. * @param ray Ray to use
  99915. * @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
  99916. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99917. * @returns an array of PickingInfo
  99918. */
  99919. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99920. /**
  99921. * Force the value of meshUnderPointer
  99922. * @param mesh defines the mesh to use
  99923. */
  99924. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99925. /**
  99926. * Gets the mesh under the pointer
  99927. * @returns a Mesh or null if no mesh is under the pointer
  99928. */
  99929. getPointerOverMesh(): Nullable<AbstractMesh>;
  99930. /** @hidden */
  99931. _rebuildGeometries(): void;
  99932. /** @hidden */
  99933. _rebuildTextures(): void;
  99934. private _getByTags;
  99935. /**
  99936. * Get a list of meshes by tags
  99937. * @param tagsQuery defines the tags query to use
  99938. * @param forEach defines a predicate used to filter results
  99939. * @returns an array of Mesh
  99940. */
  99941. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99942. /**
  99943. * Get a list of cameras by tags
  99944. * @param tagsQuery defines the tags query to use
  99945. * @param forEach defines a predicate used to filter results
  99946. * @returns an array of Camera
  99947. */
  99948. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99949. /**
  99950. * Get a list of lights by tags
  99951. * @param tagsQuery defines the tags query to use
  99952. * @param forEach defines a predicate used to filter results
  99953. * @returns an array of Light
  99954. */
  99955. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99956. /**
  99957. * Get a list of materials by tags
  99958. * @param tagsQuery defines the tags query to use
  99959. * @param forEach defines a predicate used to filter results
  99960. * @returns an array of Material
  99961. */
  99962. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99963. /**
  99964. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99965. * This allowed control for front to back rendering or reversly depending of the special needs.
  99966. *
  99967. * @param renderingGroupId The rendering group id corresponding to its index
  99968. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99969. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99970. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99971. */
  99972. 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;
  99973. /**
  99974. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99975. *
  99976. * @param renderingGroupId The rendering group id corresponding to its index
  99977. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99978. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99979. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99980. */
  99981. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99982. /**
  99983. * Gets the current auto clear configuration for one rendering group of the rendering
  99984. * manager.
  99985. * @param index the rendering group index to get the information for
  99986. * @returns The auto clear setup for the requested rendering group
  99987. */
  99988. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99989. private _blockMaterialDirtyMechanism;
  99990. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99991. blockMaterialDirtyMechanism: boolean;
  99992. /**
  99993. * Will flag all materials as dirty to trigger new shader compilation
  99994. * @param flag defines the flag used to specify which material part must be marked as dirty
  99995. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99996. */
  99997. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99998. /** @hidden */
  99999. _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;
  100000. /** @hidden */
  100001. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100002. }
  100003. }
  100004. declare module BABYLON {
  100005. /**
  100006. * Set of assets to keep when moving a scene into an asset container.
  100007. */
  100008. export class KeepAssets extends AbstractScene {
  100009. }
  100010. /**
  100011. * Container with a set of assets that can be added or removed from a scene.
  100012. */
  100013. export class AssetContainer extends AbstractScene {
  100014. /**
  100015. * The scene the AssetContainer belongs to.
  100016. */
  100017. scene: Scene;
  100018. /**
  100019. * Instantiates an AssetContainer.
  100020. * @param scene The scene the AssetContainer belongs to.
  100021. */
  100022. constructor(scene: Scene);
  100023. /**
  100024. * Adds all the assets from the container to the scene.
  100025. */
  100026. addAllToScene(): void;
  100027. /**
  100028. * Removes all the assets in the container from the scene
  100029. */
  100030. removeAllFromScene(): void;
  100031. /**
  100032. * Disposes all the assets in the container
  100033. */
  100034. dispose(): void;
  100035. private _moveAssets;
  100036. /**
  100037. * Removes all the assets contained in the scene and adds them to the container.
  100038. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100039. */
  100040. moveAllFromScene(keepAssets?: KeepAssets): void;
  100041. /**
  100042. * 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.
  100043. * @returns the root mesh
  100044. */
  100045. createRootMesh(): Mesh;
  100046. }
  100047. }
  100048. declare module BABYLON {
  100049. /**
  100050. * Defines how the parser contract is defined.
  100051. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100052. */
  100053. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100054. /**
  100055. * Defines how the individual parser contract is defined.
  100056. * These parser can parse an individual asset
  100057. */
  100058. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100059. /**
  100060. * Base class of the scene acting as a container for the different elements composing a scene.
  100061. * This class is dynamically extended by the different components of the scene increasing
  100062. * flexibility and reducing coupling
  100063. */
  100064. export abstract class AbstractScene {
  100065. /**
  100066. * Stores the list of available parsers in the application.
  100067. */
  100068. private static _BabylonFileParsers;
  100069. /**
  100070. * Stores the list of available individual parsers in the application.
  100071. */
  100072. private static _IndividualBabylonFileParsers;
  100073. /**
  100074. * Adds a parser in the list of available ones
  100075. * @param name Defines the name of the parser
  100076. * @param parser Defines the parser to add
  100077. */
  100078. static AddParser(name: string, parser: BabylonFileParser): void;
  100079. /**
  100080. * Gets a general parser from the list of avaialble ones
  100081. * @param name Defines the name of the parser
  100082. * @returns the requested parser or null
  100083. */
  100084. static GetParser(name: string): Nullable<BabylonFileParser>;
  100085. /**
  100086. * Adds n individual parser in the list of available ones
  100087. * @param name Defines the name of the parser
  100088. * @param parser Defines the parser to add
  100089. */
  100090. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100091. /**
  100092. * Gets an individual parser from the list of avaialble ones
  100093. * @param name Defines the name of the parser
  100094. * @returns the requested parser or null
  100095. */
  100096. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100097. /**
  100098. * Parser json data and populate both a scene and its associated container object
  100099. * @param jsonData Defines the data to parse
  100100. * @param scene Defines the scene to parse the data for
  100101. * @param container Defines the container attached to the parsing sequence
  100102. * @param rootUrl Defines the root url of the data
  100103. */
  100104. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100105. /**
  100106. * Gets the list of root nodes (ie. nodes with no parent)
  100107. */
  100108. rootNodes: Node[];
  100109. /** All of the cameras added to this scene
  100110. * @see http://doc.babylonjs.com/babylon101/cameras
  100111. */
  100112. cameras: Camera[];
  100113. /**
  100114. * All of the lights added to this scene
  100115. * @see http://doc.babylonjs.com/babylon101/lights
  100116. */
  100117. lights: Light[];
  100118. /**
  100119. * All of the (abstract) meshes added to this scene
  100120. */
  100121. meshes: AbstractMesh[];
  100122. /**
  100123. * The list of skeletons added to the scene
  100124. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100125. */
  100126. skeletons: Skeleton[];
  100127. /**
  100128. * All of the particle systems added to this scene
  100129. * @see http://doc.babylonjs.com/babylon101/particles
  100130. */
  100131. particleSystems: IParticleSystem[];
  100132. /**
  100133. * Gets a list of Animations associated with the scene
  100134. */
  100135. animations: Animation[];
  100136. /**
  100137. * All of the animation groups added to this scene
  100138. * @see http://doc.babylonjs.com/how_to/group
  100139. */
  100140. animationGroups: AnimationGroup[];
  100141. /**
  100142. * All of the multi-materials added to this scene
  100143. * @see http://doc.babylonjs.com/how_to/multi_materials
  100144. */
  100145. multiMaterials: MultiMaterial[];
  100146. /**
  100147. * All of the materials added to this scene
  100148. * In the context of a Scene, it is not supposed to be modified manually.
  100149. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100150. * Note also that the order of the Material wihin the array is not significant and might change.
  100151. * @see http://doc.babylonjs.com/babylon101/materials
  100152. */
  100153. materials: Material[];
  100154. /**
  100155. * The list of morph target managers added to the scene
  100156. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100157. */
  100158. morphTargetManagers: MorphTargetManager[];
  100159. /**
  100160. * The list of geometries used in the scene.
  100161. */
  100162. geometries: Geometry[];
  100163. /**
  100164. * All of the tranform nodes added to this scene
  100165. * In the context of a Scene, it is not supposed to be modified manually.
  100166. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100167. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100168. * @see http://doc.babylonjs.com/how_to/transformnode
  100169. */
  100170. transformNodes: TransformNode[];
  100171. /**
  100172. * ActionManagers available on the scene.
  100173. */
  100174. actionManagers: AbstractActionManager[];
  100175. /**
  100176. * Textures to keep.
  100177. */
  100178. textures: BaseTexture[];
  100179. /**
  100180. * Environment texture for the scene
  100181. */
  100182. environmentTexture: Nullable<BaseTexture>;
  100183. }
  100184. }
  100185. declare module BABYLON {
  100186. /**
  100187. * Interface used to define options for Sound class
  100188. */
  100189. export interface ISoundOptions {
  100190. /**
  100191. * Does the sound autoplay once loaded.
  100192. */
  100193. autoplay?: boolean;
  100194. /**
  100195. * Does the sound loop after it finishes playing once.
  100196. */
  100197. loop?: boolean;
  100198. /**
  100199. * Sound's volume
  100200. */
  100201. volume?: number;
  100202. /**
  100203. * Is it a spatial sound?
  100204. */
  100205. spatialSound?: boolean;
  100206. /**
  100207. * Maximum distance to hear that sound
  100208. */
  100209. maxDistance?: number;
  100210. /**
  100211. * Uses user defined attenuation function
  100212. */
  100213. useCustomAttenuation?: boolean;
  100214. /**
  100215. * Define the roll off factor of spatial sounds.
  100216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100217. */
  100218. rolloffFactor?: number;
  100219. /**
  100220. * Define the reference distance the sound should be heard perfectly.
  100221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100222. */
  100223. refDistance?: number;
  100224. /**
  100225. * Define the distance attenuation model the sound will follow.
  100226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100227. */
  100228. distanceModel?: string;
  100229. /**
  100230. * Defines the playback speed (1 by default)
  100231. */
  100232. playbackRate?: number;
  100233. /**
  100234. * Defines if the sound is from a streaming source
  100235. */
  100236. streaming?: boolean;
  100237. /**
  100238. * Defines an optional length (in seconds) inside the sound file
  100239. */
  100240. length?: number;
  100241. /**
  100242. * Defines an optional offset (in seconds) inside the sound file
  100243. */
  100244. offset?: number;
  100245. /**
  100246. * If true, URLs will not be required to state the audio file codec to use.
  100247. */
  100248. skipCodecCheck?: boolean;
  100249. }
  100250. /**
  100251. * Defines a sound that can be played in the application.
  100252. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100254. */
  100255. export class Sound {
  100256. /**
  100257. * The name of the sound in the scene.
  100258. */
  100259. name: string;
  100260. /**
  100261. * Does the sound autoplay once loaded.
  100262. */
  100263. autoplay: boolean;
  100264. /**
  100265. * Does the sound loop after it finishes playing once.
  100266. */
  100267. loop: boolean;
  100268. /**
  100269. * Does the sound use a custom attenuation curve to simulate the falloff
  100270. * happening when the source gets further away from the camera.
  100271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100272. */
  100273. useCustomAttenuation: boolean;
  100274. /**
  100275. * The sound track id this sound belongs to.
  100276. */
  100277. soundTrackId: number;
  100278. /**
  100279. * Is this sound currently played.
  100280. */
  100281. isPlaying: boolean;
  100282. /**
  100283. * Is this sound currently paused.
  100284. */
  100285. isPaused: boolean;
  100286. /**
  100287. * Does this sound enables spatial sound.
  100288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100289. */
  100290. spatialSound: boolean;
  100291. /**
  100292. * Define the reference distance the sound should be heard perfectly.
  100293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100294. */
  100295. refDistance: number;
  100296. /**
  100297. * Define the roll off factor of spatial sounds.
  100298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100299. */
  100300. rolloffFactor: number;
  100301. /**
  100302. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100304. */
  100305. maxDistance: number;
  100306. /**
  100307. * Define the distance attenuation model the sound will follow.
  100308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100309. */
  100310. distanceModel: string;
  100311. /**
  100312. * @hidden
  100313. * Back Compat
  100314. **/
  100315. onended: () => any;
  100316. /**
  100317. * Observable event when the current playing sound finishes.
  100318. */
  100319. onEndedObservable: Observable<Sound>;
  100320. private _panningModel;
  100321. private _playbackRate;
  100322. private _streaming;
  100323. private _startTime;
  100324. private _startOffset;
  100325. private _position;
  100326. /** @hidden */
  100327. _positionInEmitterSpace: boolean;
  100328. private _localDirection;
  100329. private _volume;
  100330. private _isReadyToPlay;
  100331. private _isDirectional;
  100332. private _readyToPlayCallback;
  100333. private _audioBuffer;
  100334. private _soundSource;
  100335. private _streamingSource;
  100336. private _soundPanner;
  100337. private _soundGain;
  100338. private _inputAudioNode;
  100339. private _outputAudioNode;
  100340. private _coneInnerAngle;
  100341. private _coneOuterAngle;
  100342. private _coneOuterGain;
  100343. private _scene;
  100344. private _connectedTransformNode;
  100345. private _customAttenuationFunction;
  100346. private _registerFunc;
  100347. private _isOutputConnected;
  100348. private _htmlAudioElement;
  100349. private _urlType;
  100350. private _length?;
  100351. private _offset?;
  100352. /** @hidden */
  100353. static _SceneComponentInitialization: (scene: Scene) => void;
  100354. /**
  100355. * Create a sound and attach it to a scene
  100356. * @param name Name of your sound
  100357. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100358. * @param scene defines the scene the sound belongs to
  100359. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100360. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100361. */
  100362. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100363. /**
  100364. * Release the sound and its associated resources
  100365. */
  100366. dispose(): void;
  100367. /**
  100368. * Gets if the sounds is ready to be played or not.
  100369. * @returns true if ready, otherwise false
  100370. */
  100371. isReady(): boolean;
  100372. private _soundLoaded;
  100373. /**
  100374. * Sets the data of the sound from an audiobuffer
  100375. * @param audioBuffer The audioBuffer containing the data
  100376. */
  100377. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100378. /**
  100379. * Updates the current sounds options such as maxdistance, loop...
  100380. * @param options A JSON object containing values named as the object properties
  100381. */
  100382. updateOptions(options: ISoundOptions): void;
  100383. private _createSpatialParameters;
  100384. private _updateSpatialParameters;
  100385. /**
  100386. * Switch the panning model to HRTF:
  100387. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100389. */
  100390. switchPanningModelToHRTF(): void;
  100391. /**
  100392. * Switch the panning model to Equal Power:
  100393. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100395. */
  100396. switchPanningModelToEqualPower(): void;
  100397. private _switchPanningModel;
  100398. /**
  100399. * Connect this sound to a sound track audio node like gain...
  100400. * @param soundTrackAudioNode the sound track audio node to connect to
  100401. */
  100402. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100403. /**
  100404. * Transform this sound into a directional source
  100405. * @param coneInnerAngle Size of the inner cone in degree
  100406. * @param coneOuterAngle Size of the outer cone in degree
  100407. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100408. */
  100409. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100410. /**
  100411. * Gets or sets the inner angle for the directional cone.
  100412. */
  100413. /**
  100414. * Gets or sets the inner angle for the directional cone.
  100415. */
  100416. directionalConeInnerAngle: number;
  100417. /**
  100418. * Gets or sets the outer angle for the directional cone.
  100419. */
  100420. /**
  100421. * Gets or sets the outer angle for the directional cone.
  100422. */
  100423. directionalConeOuterAngle: number;
  100424. /**
  100425. * Sets the position of the emitter if spatial sound is enabled
  100426. * @param newPosition Defines the new posisiton
  100427. */
  100428. setPosition(newPosition: Vector3): void;
  100429. /**
  100430. * Sets the local direction of the emitter if spatial sound is enabled
  100431. * @param newLocalDirection Defines the new local direction
  100432. */
  100433. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100434. private _updateDirection;
  100435. /** @hidden */
  100436. updateDistanceFromListener(): void;
  100437. /**
  100438. * Sets a new custom attenuation function for the sound.
  100439. * @param callback Defines the function used for the attenuation
  100440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100441. */
  100442. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100443. /**
  100444. * Play the sound
  100445. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100446. * @param offset (optional) Start the sound at a specific time in seconds
  100447. * @param length (optional) Sound duration (in seconds)
  100448. */
  100449. play(time?: number, offset?: number, length?: number): void;
  100450. private _onended;
  100451. /**
  100452. * Stop the sound
  100453. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100454. */
  100455. stop(time?: number): void;
  100456. /**
  100457. * Put the sound in pause
  100458. */
  100459. pause(): void;
  100460. /**
  100461. * Sets a dedicated volume for this sounds
  100462. * @param newVolume Define the new volume of the sound
  100463. * @param time Define time for gradual change to new volume
  100464. */
  100465. setVolume(newVolume: number, time?: number): void;
  100466. /**
  100467. * Set the sound play back rate
  100468. * @param newPlaybackRate Define the playback rate the sound should be played at
  100469. */
  100470. setPlaybackRate(newPlaybackRate: number): void;
  100471. /**
  100472. * Gets the volume of the sound.
  100473. * @returns the volume of the sound
  100474. */
  100475. getVolume(): number;
  100476. /**
  100477. * Attach the sound to a dedicated mesh
  100478. * @param transformNode The transform node to connect the sound with
  100479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100480. */
  100481. attachToMesh(transformNode: TransformNode): void;
  100482. /**
  100483. * Detach the sound from the previously attached mesh
  100484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100485. */
  100486. detachFromMesh(): void;
  100487. private _onRegisterAfterWorldMatrixUpdate;
  100488. /**
  100489. * Clone the current sound in the scene.
  100490. * @returns the new sound clone
  100491. */
  100492. clone(): Nullable<Sound>;
  100493. /**
  100494. * Gets the current underlying audio buffer containing the data
  100495. * @returns the audio buffer
  100496. */
  100497. getAudioBuffer(): Nullable<AudioBuffer>;
  100498. /**
  100499. * Serializes the Sound in a JSON representation
  100500. * @returns the JSON representation of the sound
  100501. */
  100502. serialize(): any;
  100503. /**
  100504. * Parse a JSON representation of a sound to innstantiate in a given scene
  100505. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100506. * @param scene Define the scene the new parsed sound should be created in
  100507. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100508. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100509. * @returns the newly parsed sound
  100510. */
  100511. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100512. }
  100513. }
  100514. declare module BABYLON {
  100515. /**
  100516. * This defines an action helpful to play a defined sound on a triggered action.
  100517. */
  100518. export class PlaySoundAction extends Action {
  100519. private _sound;
  100520. /**
  100521. * Instantiate the action
  100522. * @param triggerOptions defines the trigger options
  100523. * @param sound defines the sound to play
  100524. * @param condition defines the trigger related conditions
  100525. */
  100526. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100527. /** @hidden */
  100528. _prepare(): void;
  100529. /**
  100530. * Execute the action and play the sound.
  100531. */
  100532. execute(): void;
  100533. /**
  100534. * Serializes the actions and its related information.
  100535. * @param parent defines the object to serialize in
  100536. * @returns the serialized object
  100537. */
  100538. serialize(parent: any): any;
  100539. }
  100540. /**
  100541. * This defines an action helpful to stop a defined sound on a triggered action.
  100542. */
  100543. export class StopSoundAction extends Action {
  100544. private _sound;
  100545. /**
  100546. * Instantiate the action
  100547. * @param triggerOptions defines the trigger options
  100548. * @param sound defines the sound to stop
  100549. * @param condition defines the trigger related conditions
  100550. */
  100551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100552. /** @hidden */
  100553. _prepare(): void;
  100554. /**
  100555. * Execute the action and stop the sound.
  100556. */
  100557. execute(): void;
  100558. /**
  100559. * Serializes the actions and its related information.
  100560. * @param parent defines the object to serialize in
  100561. * @returns the serialized object
  100562. */
  100563. serialize(parent: any): any;
  100564. }
  100565. }
  100566. declare module BABYLON {
  100567. /**
  100568. * This defines an action responsible to change the value of a property
  100569. * by interpolating between its current value and the newly set one once triggered.
  100570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100571. */
  100572. export class InterpolateValueAction extends Action {
  100573. /**
  100574. * Defines the path of the property where the value should be interpolated
  100575. */
  100576. propertyPath: string;
  100577. /**
  100578. * Defines the target value at the end of the interpolation.
  100579. */
  100580. value: any;
  100581. /**
  100582. * Defines the time it will take for the property to interpolate to the value.
  100583. */
  100584. duration: number;
  100585. /**
  100586. * Defines if the other scene animations should be stopped when the action has been triggered
  100587. */
  100588. stopOtherAnimations?: boolean;
  100589. /**
  100590. * Defines a callback raised once the interpolation animation has been done.
  100591. */
  100592. onInterpolationDone?: () => void;
  100593. /**
  100594. * Observable triggered once the interpolation animation has been done.
  100595. */
  100596. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100597. private _target;
  100598. private _effectiveTarget;
  100599. private _property;
  100600. /**
  100601. * Instantiate the action
  100602. * @param triggerOptions defines the trigger options
  100603. * @param target defines the object containing the value to interpolate
  100604. * @param propertyPath defines the path to the property in the target object
  100605. * @param value defines the target value at the end of the interpolation
  100606. * @param duration deines the time it will take for the property to interpolate to the value.
  100607. * @param condition defines the trigger related conditions
  100608. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100609. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100610. */
  100611. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100612. /** @hidden */
  100613. _prepare(): void;
  100614. /**
  100615. * Execute the action starts the value interpolation.
  100616. */
  100617. execute(): void;
  100618. /**
  100619. * Serializes the actions and its related information.
  100620. * @param parent defines the object to serialize in
  100621. * @returns the serialized object
  100622. */
  100623. serialize(parent: any): any;
  100624. }
  100625. }
  100626. declare module BABYLON {
  100627. /**
  100628. * Options allowed during the creation of a sound track.
  100629. */
  100630. export interface ISoundTrackOptions {
  100631. /**
  100632. * The volume the sound track should take during creation
  100633. */
  100634. volume?: number;
  100635. /**
  100636. * Define if the sound track is the main sound track of the scene
  100637. */
  100638. mainTrack?: boolean;
  100639. }
  100640. /**
  100641. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100642. * It will be also used in a future release to apply effects on a specific track.
  100643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100644. */
  100645. export class SoundTrack {
  100646. /**
  100647. * The unique identifier of the sound track in the scene.
  100648. */
  100649. id: number;
  100650. /**
  100651. * The list of sounds included in the sound track.
  100652. */
  100653. soundCollection: Array<Sound>;
  100654. private _outputAudioNode;
  100655. private _scene;
  100656. private _isMainTrack;
  100657. private _connectedAnalyser;
  100658. private _options;
  100659. private _isInitialized;
  100660. /**
  100661. * Creates a new sound track.
  100662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100663. * @param scene Define the scene the sound track belongs to
  100664. * @param options
  100665. */
  100666. constructor(scene: Scene, options?: ISoundTrackOptions);
  100667. private _initializeSoundTrackAudioGraph;
  100668. /**
  100669. * Release the sound track and its associated resources
  100670. */
  100671. dispose(): void;
  100672. /**
  100673. * Adds a sound to this sound track
  100674. * @param sound define the cound to add
  100675. * @ignoreNaming
  100676. */
  100677. AddSound(sound: Sound): void;
  100678. /**
  100679. * Removes a sound to this sound track
  100680. * @param sound define the cound to remove
  100681. * @ignoreNaming
  100682. */
  100683. RemoveSound(sound: Sound): void;
  100684. /**
  100685. * Set a global volume for the full sound track.
  100686. * @param newVolume Define the new volume of the sound track
  100687. */
  100688. setVolume(newVolume: number): void;
  100689. /**
  100690. * Switch the panning model to HRTF:
  100691. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100693. */
  100694. switchPanningModelToHRTF(): void;
  100695. /**
  100696. * Switch the panning model to Equal Power:
  100697. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100699. */
  100700. switchPanningModelToEqualPower(): void;
  100701. /**
  100702. * Connect the sound track to an audio analyser allowing some amazing
  100703. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100705. * @param analyser The analyser to connect to the engine
  100706. */
  100707. connectToAnalyser(analyser: Analyser): void;
  100708. }
  100709. }
  100710. declare module BABYLON {
  100711. interface AbstractScene {
  100712. /**
  100713. * The list of sounds used in the scene.
  100714. */
  100715. sounds: Nullable<Array<Sound>>;
  100716. }
  100717. interface Scene {
  100718. /**
  100719. * @hidden
  100720. * Backing field
  100721. */
  100722. _mainSoundTrack: SoundTrack;
  100723. /**
  100724. * The main sound track played by the scene.
  100725. * It cotains your primary collection of sounds.
  100726. */
  100727. mainSoundTrack: SoundTrack;
  100728. /**
  100729. * The list of sound tracks added to the scene
  100730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100731. */
  100732. soundTracks: Nullable<Array<SoundTrack>>;
  100733. /**
  100734. * Gets a sound using a given name
  100735. * @param name defines the name to search for
  100736. * @return the found sound or null if not found at all.
  100737. */
  100738. getSoundByName(name: string): Nullable<Sound>;
  100739. /**
  100740. * Gets or sets if audio support is enabled
  100741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100742. */
  100743. audioEnabled: boolean;
  100744. /**
  100745. * Gets or sets if audio will be output to headphones
  100746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100747. */
  100748. headphone: boolean;
  100749. /**
  100750. * Gets or sets custom audio listener position provider
  100751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100752. */
  100753. audioListenerPositionProvider: Nullable<() => Vector3>;
  100754. }
  100755. /**
  100756. * Defines the sound scene component responsible to manage any sounds
  100757. * in a given scene.
  100758. */
  100759. export class AudioSceneComponent implements ISceneSerializableComponent {
  100760. /**
  100761. * The component name helpfull to identify the component in the list of scene components.
  100762. */
  100763. readonly name: string;
  100764. /**
  100765. * The scene the component belongs to.
  100766. */
  100767. scene: Scene;
  100768. private _audioEnabled;
  100769. /**
  100770. * Gets whether audio is enabled or not.
  100771. * Please use related enable/disable method to switch state.
  100772. */
  100773. readonly audioEnabled: boolean;
  100774. private _headphone;
  100775. /**
  100776. * Gets whether audio is outputing to headphone or not.
  100777. * Please use the according Switch methods to change output.
  100778. */
  100779. readonly headphone: boolean;
  100780. private _audioListenerPositionProvider;
  100781. /**
  100782. * Gets the current audio listener position provider
  100783. */
  100784. /**
  100785. * Sets a custom listener position for all sounds in the scene
  100786. * By default, this is the position of the first active camera
  100787. */
  100788. audioListenerPositionProvider: Nullable<() => Vector3>;
  100789. /**
  100790. * Creates a new instance of the component for the given scene
  100791. * @param scene Defines the scene to register the component in
  100792. */
  100793. constructor(scene: Scene);
  100794. /**
  100795. * Registers the component in a given scene
  100796. */
  100797. register(): void;
  100798. /**
  100799. * Rebuilds the elements related to this component in case of
  100800. * context lost for instance.
  100801. */
  100802. rebuild(): void;
  100803. /**
  100804. * Serializes the component data to the specified json object
  100805. * @param serializationObject The object to serialize to
  100806. */
  100807. serialize(serializationObject: any): void;
  100808. /**
  100809. * Adds all the elements from the container to the scene
  100810. * @param container the container holding the elements
  100811. */
  100812. addFromContainer(container: AbstractScene): void;
  100813. /**
  100814. * Removes all the elements in the container from the scene
  100815. * @param container contains the elements to remove
  100816. * @param dispose if the removed element should be disposed (default: false)
  100817. */
  100818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100819. /**
  100820. * Disposes the component and the associated ressources.
  100821. */
  100822. dispose(): void;
  100823. /**
  100824. * Disables audio in the associated scene.
  100825. */
  100826. disableAudio(): void;
  100827. /**
  100828. * Enables audio in the associated scene.
  100829. */
  100830. enableAudio(): void;
  100831. /**
  100832. * Switch audio to headphone output.
  100833. */
  100834. switchAudioModeForHeadphones(): void;
  100835. /**
  100836. * Switch audio to normal speakers.
  100837. */
  100838. switchAudioModeForNormalSpeakers(): void;
  100839. private _afterRender;
  100840. }
  100841. }
  100842. declare module BABYLON {
  100843. /**
  100844. * Wraps one or more Sound objects and selects one with random weight for playback.
  100845. */
  100846. export class WeightedSound {
  100847. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100848. loop: boolean;
  100849. private _coneInnerAngle;
  100850. private _coneOuterAngle;
  100851. private _volume;
  100852. /** A Sound is currently playing. */
  100853. isPlaying: boolean;
  100854. /** A Sound is currently paused. */
  100855. isPaused: boolean;
  100856. private _sounds;
  100857. private _weights;
  100858. private _currentIndex?;
  100859. /**
  100860. * Creates a new WeightedSound from the list of sounds given.
  100861. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100862. * @param sounds Array of Sounds that will be selected from.
  100863. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100864. */
  100865. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100866. /**
  100867. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100868. */
  100869. /**
  100870. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100871. */
  100872. directionalConeInnerAngle: number;
  100873. /**
  100874. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100875. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100876. */
  100877. /**
  100878. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100879. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100880. */
  100881. directionalConeOuterAngle: number;
  100882. /**
  100883. * Playback volume.
  100884. */
  100885. /**
  100886. * Playback volume.
  100887. */
  100888. volume: number;
  100889. private _onended;
  100890. /**
  100891. * Suspend playback
  100892. */
  100893. pause(): void;
  100894. /**
  100895. * Stop playback
  100896. */
  100897. stop(): void;
  100898. /**
  100899. * Start playback.
  100900. * @param startOffset Position the clip head at a specific time in seconds.
  100901. */
  100902. play(startOffset?: number): void;
  100903. }
  100904. }
  100905. declare module BABYLON {
  100906. /**
  100907. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100908. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100909. */
  100910. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100911. /**
  100912. * Gets the name of the behavior.
  100913. */
  100914. readonly name: string;
  100915. /**
  100916. * The easing function used by animations
  100917. */
  100918. static EasingFunction: BackEase;
  100919. /**
  100920. * The easing mode used by animations
  100921. */
  100922. static EasingMode: number;
  100923. /**
  100924. * The duration of the animation, in milliseconds
  100925. */
  100926. transitionDuration: number;
  100927. /**
  100928. * Length of the distance animated by the transition when lower radius is reached
  100929. */
  100930. lowerRadiusTransitionRange: number;
  100931. /**
  100932. * Length of the distance animated by the transition when upper radius is reached
  100933. */
  100934. upperRadiusTransitionRange: number;
  100935. private _autoTransitionRange;
  100936. /**
  100937. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100938. */
  100939. /**
  100940. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100941. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100942. */
  100943. autoTransitionRange: boolean;
  100944. private _attachedCamera;
  100945. private _onAfterCheckInputsObserver;
  100946. private _onMeshTargetChangedObserver;
  100947. /**
  100948. * Initializes the behavior.
  100949. */
  100950. init(): void;
  100951. /**
  100952. * Attaches the behavior to its arc rotate camera.
  100953. * @param camera Defines the camera to attach the behavior to
  100954. */
  100955. attach(camera: ArcRotateCamera): void;
  100956. /**
  100957. * Detaches the behavior from its current arc rotate camera.
  100958. */
  100959. detach(): void;
  100960. private _radiusIsAnimating;
  100961. private _radiusBounceTransition;
  100962. private _animatables;
  100963. private _cachedWheelPrecision;
  100964. /**
  100965. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100966. * @param radiusLimit The limit to check against.
  100967. * @return Bool to indicate if at limit.
  100968. */
  100969. private _isRadiusAtLimit;
  100970. /**
  100971. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100972. * @param radiusDelta The delta by which to animate to. Can be negative.
  100973. */
  100974. private _applyBoundRadiusAnimation;
  100975. /**
  100976. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100977. */
  100978. protected _clearAnimationLocks(): void;
  100979. /**
  100980. * Stops and removes all animations that have been applied to the camera
  100981. */
  100982. stopAllAnimations(): void;
  100983. }
  100984. }
  100985. declare module BABYLON {
  100986. /**
  100987. * 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.
  100988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100989. */
  100990. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100991. /**
  100992. * Gets the name of the behavior.
  100993. */
  100994. readonly name: string;
  100995. private _mode;
  100996. private _radiusScale;
  100997. private _positionScale;
  100998. private _defaultElevation;
  100999. private _elevationReturnTime;
  101000. private _elevationReturnWaitTime;
  101001. private _zoomStopsAnimation;
  101002. private _framingTime;
  101003. /**
  101004. * The easing function used by animations
  101005. */
  101006. static EasingFunction: ExponentialEase;
  101007. /**
  101008. * The easing mode used by animations
  101009. */
  101010. static EasingMode: number;
  101011. /**
  101012. * Sets the current mode used by the behavior
  101013. */
  101014. /**
  101015. * Gets current mode used by the behavior.
  101016. */
  101017. mode: number;
  101018. /**
  101019. * Sets the scale applied to the radius (1 by default)
  101020. */
  101021. /**
  101022. * Gets the scale applied to the radius
  101023. */
  101024. radiusScale: number;
  101025. /**
  101026. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101027. */
  101028. /**
  101029. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101030. */
  101031. positionScale: number;
  101032. /**
  101033. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101034. * behaviour is triggered, in radians.
  101035. */
  101036. /**
  101037. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101038. * behaviour is triggered, in radians.
  101039. */
  101040. defaultElevation: number;
  101041. /**
  101042. * Sets the time (in milliseconds) taken to return to the default beta position.
  101043. * Negative value indicates camera should not return to default.
  101044. */
  101045. /**
  101046. * Gets the time (in milliseconds) taken to return to the default beta position.
  101047. * Negative value indicates camera should not return to default.
  101048. */
  101049. elevationReturnTime: number;
  101050. /**
  101051. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101052. */
  101053. /**
  101054. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101055. */
  101056. elevationReturnWaitTime: number;
  101057. /**
  101058. * Sets the flag that indicates if user zooming should stop animation.
  101059. */
  101060. /**
  101061. * Gets the flag that indicates if user zooming should stop animation.
  101062. */
  101063. zoomStopsAnimation: boolean;
  101064. /**
  101065. * Sets the transition time when framing the mesh, in milliseconds
  101066. */
  101067. /**
  101068. * Gets the transition time when framing the mesh, in milliseconds
  101069. */
  101070. framingTime: number;
  101071. /**
  101072. * Define if the behavior should automatically change the configured
  101073. * camera limits and sensibilities.
  101074. */
  101075. autoCorrectCameraLimitsAndSensibility: boolean;
  101076. private _onPrePointerObservableObserver;
  101077. private _onAfterCheckInputsObserver;
  101078. private _onMeshTargetChangedObserver;
  101079. private _attachedCamera;
  101080. private _isPointerDown;
  101081. private _lastInteractionTime;
  101082. /**
  101083. * Initializes the behavior.
  101084. */
  101085. init(): void;
  101086. /**
  101087. * Attaches the behavior to its arc rotate camera.
  101088. * @param camera Defines the camera to attach the behavior to
  101089. */
  101090. attach(camera: ArcRotateCamera): void;
  101091. /**
  101092. * Detaches the behavior from its current arc rotate camera.
  101093. */
  101094. detach(): void;
  101095. private _animatables;
  101096. private _betaIsAnimating;
  101097. private _betaTransition;
  101098. private _radiusTransition;
  101099. private _vectorTransition;
  101100. /**
  101101. * Targets the given mesh and updates zoom level accordingly.
  101102. * @param mesh The mesh to target.
  101103. * @param radius Optional. If a cached radius position already exists, overrides default.
  101104. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101105. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101106. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101107. */
  101108. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101109. /**
  101110. * Targets the given mesh with its children and updates zoom level accordingly.
  101111. * @param mesh The mesh to target.
  101112. * @param radius Optional. If a cached radius position already exists, overrides default.
  101113. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101116. */
  101117. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101118. /**
  101119. * Targets the given meshes with their children and updates zoom level accordingly.
  101120. * @param meshes The mesh to target.
  101121. * @param radius Optional. If a cached radius position already exists, overrides default.
  101122. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101125. */
  101126. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101127. /**
  101128. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101129. * @param minimumWorld Determines the smaller position of the bounding box extend
  101130. * @param maximumWorld Determines the bigger position of the bounding box extend
  101131. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101132. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101133. */
  101134. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101135. /**
  101136. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101137. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101138. * frustum width.
  101139. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101140. * to fully enclose the mesh in the viewing frustum.
  101141. */
  101142. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101143. /**
  101144. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101145. * is automatically returned to its default position (expected to be above ground plane).
  101146. */
  101147. private _maintainCameraAboveGround;
  101148. /**
  101149. * Returns the frustum slope based on the canvas ratio and camera FOV
  101150. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101151. */
  101152. private _getFrustumSlope;
  101153. /**
  101154. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101155. */
  101156. private _clearAnimationLocks;
  101157. /**
  101158. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101159. */
  101160. private _applyUserInteraction;
  101161. /**
  101162. * Stops and removes all animations that have been applied to the camera
  101163. */
  101164. stopAllAnimations(): void;
  101165. /**
  101166. * Gets a value indicating if the user is moving the camera
  101167. */
  101168. readonly isUserIsMoving: boolean;
  101169. /**
  101170. * The camera can move all the way towards the mesh.
  101171. */
  101172. static IgnoreBoundsSizeMode: number;
  101173. /**
  101174. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101175. */
  101176. static FitFrustumSidesMode: number;
  101177. }
  101178. }
  101179. declare module BABYLON {
  101180. /**
  101181. * Base class for Camera Pointer Inputs.
  101182. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101183. * for example usage.
  101184. */
  101185. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101186. /**
  101187. * Defines the camera the input is attached to.
  101188. */
  101189. abstract camera: Camera;
  101190. /**
  101191. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101192. */
  101193. protected _altKey: boolean;
  101194. protected _ctrlKey: boolean;
  101195. protected _metaKey: boolean;
  101196. protected _shiftKey: boolean;
  101197. /**
  101198. * Which mouse buttons were pressed at time of last mouse event.
  101199. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101200. */
  101201. protected _buttonsPressed: number;
  101202. /**
  101203. * Defines the buttons associated with the input to handle camera move.
  101204. */
  101205. buttons: number[];
  101206. /**
  101207. * Attach the input controls to a specific dom element to get the input from.
  101208. * @param element Defines the element the controls should be listened from
  101209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101210. */
  101211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101212. /**
  101213. * Detach the current controls from the specified dom element.
  101214. * @param element Defines the element to stop listening the inputs from
  101215. */
  101216. detachControl(element: Nullable<HTMLElement>): void;
  101217. /**
  101218. * Gets the class name of the current input.
  101219. * @returns the class name
  101220. */
  101221. getClassName(): string;
  101222. /**
  101223. * Get the friendly name associated with the input class.
  101224. * @returns the input friendly name
  101225. */
  101226. getSimpleName(): string;
  101227. /**
  101228. * Called on pointer POINTERDOUBLETAP event.
  101229. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101230. */
  101231. protected onDoubleTap(type: string): void;
  101232. /**
  101233. * Called on pointer POINTERMOVE event if only a single touch is active.
  101234. * Override this method to provide functionality.
  101235. */
  101236. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101237. /**
  101238. * Called on pointer POINTERMOVE event if multiple touches are active.
  101239. * Override this method to provide functionality.
  101240. */
  101241. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101242. /**
  101243. * Called on JS contextmenu event.
  101244. * Override this method to provide functionality.
  101245. */
  101246. protected onContextMenu(evt: PointerEvent): void;
  101247. /**
  101248. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101249. * press.
  101250. * Override this method to provide functionality.
  101251. */
  101252. protected onButtonDown(evt: PointerEvent): void;
  101253. /**
  101254. * Called each time a new POINTERUP event occurs. Ie, for each button
  101255. * release.
  101256. * Override this method to provide functionality.
  101257. */
  101258. protected onButtonUp(evt: PointerEvent): void;
  101259. /**
  101260. * Called when window becomes inactive.
  101261. * Override this method to provide functionality.
  101262. */
  101263. protected onLostFocus(): void;
  101264. private _pointerInput;
  101265. private _observer;
  101266. private _onLostFocus;
  101267. private pointA;
  101268. private pointB;
  101269. }
  101270. }
  101271. declare module BABYLON {
  101272. /**
  101273. * Manage the pointers inputs to control an arc rotate camera.
  101274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101275. */
  101276. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101277. /**
  101278. * Defines the camera the input is attached to.
  101279. */
  101280. camera: ArcRotateCamera;
  101281. /**
  101282. * Gets the class name of the current input.
  101283. * @returns the class name
  101284. */
  101285. getClassName(): string;
  101286. /**
  101287. * Defines the buttons associated with the input to handle camera move.
  101288. */
  101289. buttons: number[];
  101290. /**
  101291. * Defines the pointer angular sensibility along the X axis or how fast is
  101292. * the camera rotating.
  101293. */
  101294. angularSensibilityX: number;
  101295. /**
  101296. * Defines the pointer angular sensibility along the Y axis or how fast is
  101297. * the camera rotating.
  101298. */
  101299. angularSensibilityY: number;
  101300. /**
  101301. * Defines the pointer pinch precision or how fast is the camera zooming.
  101302. */
  101303. pinchPrecision: number;
  101304. /**
  101305. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101306. * from 0.
  101307. * It defines the percentage of current camera.radius to use as delta when
  101308. * pinch zoom is used.
  101309. */
  101310. pinchDeltaPercentage: number;
  101311. /**
  101312. * Defines the pointer panning sensibility or how fast is the camera moving.
  101313. */
  101314. panningSensibility: number;
  101315. /**
  101316. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101317. */
  101318. multiTouchPanning: boolean;
  101319. /**
  101320. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101321. * zoom (pinch) through multitouch.
  101322. */
  101323. multiTouchPanAndZoom: boolean;
  101324. /**
  101325. * Revers pinch action direction.
  101326. */
  101327. pinchInwards: boolean;
  101328. private _isPanClick;
  101329. private _twoFingerActivityCount;
  101330. private _isPinching;
  101331. /**
  101332. * Called on pointer POINTERMOVE event if only a single touch is active.
  101333. */
  101334. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101335. /**
  101336. * Called on pointer POINTERDOUBLETAP event.
  101337. */
  101338. protected onDoubleTap(type: string): void;
  101339. /**
  101340. * Called on pointer POINTERMOVE event if multiple touches are active.
  101341. */
  101342. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101343. /**
  101344. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101345. * press.
  101346. */
  101347. protected onButtonDown(evt: PointerEvent): void;
  101348. /**
  101349. * Called each time a new POINTERUP event occurs. Ie, for each button
  101350. * release.
  101351. */
  101352. protected onButtonUp(evt: PointerEvent): void;
  101353. /**
  101354. * Called when window becomes inactive.
  101355. */
  101356. protected onLostFocus(): void;
  101357. }
  101358. }
  101359. declare module BABYLON {
  101360. /**
  101361. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101363. */
  101364. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101365. /**
  101366. * Defines the camera the input is attached to.
  101367. */
  101368. camera: ArcRotateCamera;
  101369. /**
  101370. * Defines the list of key codes associated with the up action (increase alpha)
  101371. */
  101372. keysUp: number[];
  101373. /**
  101374. * Defines the list of key codes associated with the down action (decrease alpha)
  101375. */
  101376. keysDown: number[];
  101377. /**
  101378. * Defines the list of key codes associated with the left action (increase beta)
  101379. */
  101380. keysLeft: number[];
  101381. /**
  101382. * Defines the list of key codes associated with the right action (decrease beta)
  101383. */
  101384. keysRight: number[];
  101385. /**
  101386. * Defines the list of key codes associated with the reset action.
  101387. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101388. */
  101389. keysReset: number[];
  101390. /**
  101391. * Defines the panning sensibility of the inputs.
  101392. * (How fast is the camera paning)
  101393. */
  101394. panningSensibility: number;
  101395. /**
  101396. * Defines the zooming sensibility of the inputs.
  101397. * (How fast is the camera zooming)
  101398. */
  101399. zoomingSensibility: number;
  101400. /**
  101401. * Defines wether maintaining the alt key down switch the movement mode from
  101402. * orientation to zoom.
  101403. */
  101404. useAltToZoom: boolean;
  101405. /**
  101406. * Rotation speed of the camera
  101407. */
  101408. angularSpeed: number;
  101409. private _keys;
  101410. private _ctrlPressed;
  101411. private _altPressed;
  101412. private _onCanvasBlurObserver;
  101413. private _onKeyboardObserver;
  101414. private _engine;
  101415. private _scene;
  101416. /**
  101417. * Attach the input controls to a specific dom element to get the input from.
  101418. * @param element Defines the element the controls should be listened from
  101419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101420. */
  101421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101422. /**
  101423. * Detach the current controls from the specified dom element.
  101424. * @param element Defines the element to stop listening the inputs from
  101425. */
  101426. detachControl(element: Nullable<HTMLElement>): void;
  101427. /**
  101428. * Update the current camera state depending on the inputs that have been used this frame.
  101429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101430. */
  101431. checkInputs(): void;
  101432. /**
  101433. * Gets the class name of the current intput.
  101434. * @returns the class name
  101435. */
  101436. getClassName(): string;
  101437. /**
  101438. * Get the friendly name associated with the input class.
  101439. * @returns the input friendly name
  101440. */
  101441. getSimpleName(): string;
  101442. }
  101443. }
  101444. declare module BABYLON {
  101445. /**
  101446. * Manage the mouse wheel inputs to control an arc rotate camera.
  101447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101448. */
  101449. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101450. /**
  101451. * Defines the camera the input is attached to.
  101452. */
  101453. camera: ArcRotateCamera;
  101454. /**
  101455. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101456. */
  101457. wheelPrecision: number;
  101458. /**
  101459. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101460. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101461. */
  101462. wheelDeltaPercentage: number;
  101463. private _wheel;
  101464. private _observer;
  101465. private computeDeltaFromMouseWheelLegacyEvent;
  101466. /**
  101467. * Attach the input controls to a specific dom element to get the input from.
  101468. * @param element Defines the element the controls should be listened from
  101469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101470. */
  101471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101472. /**
  101473. * Detach the current controls from the specified dom element.
  101474. * @param element Defines the element to stop listening the inputs from
  101475. */
  101476. detachControl(element: Nullable<HTMLElement>): void;
  101477. /**
  101478. * Gets the class name of the current intput.
  101479. * @returns the class name
  101480. */
  101481. getClassName(): string;
  101482. /**
  101483. * Get the friendly name associated with the input class.
  101484. * @returns the input friendly name
  101485. */
  101486. getSimpleName(): string;
  101487. }
  101488. }
  101489. declare module BABYLON {
  101490. /**
  101491. * Default Inputs manager for the ArcRotateCamera.
  101492. * It groups all the default supported inputs for ease of use.
  101493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101494. */
  101495. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101496. /**
  101497. * Instantiates a new ArcRotateCameraInputsManager.
  101498. * @param camera Defines the camera the inputs belong to
  101499. */
  101500. constructor(camera: ArcRotateCamera);
  101501. /**
  101502. * Add mouse wheel input support to the input manager.
  101503. * @returns the current input manager
  101504. */
  101505. addMouseWheel(): ArcRotateCameraInputsManager;
  101506. /**
  101507. * Add pointers input support to the input manager.
  101508. * @returns the current input manager
  101509. */
  101510. addPointers(): ArcRotateCameraInputsManager;
  101511. /**
  101512. * Add keyboard input support to the input manager.
  101513. * @returns the current input manager
  101514. */
  101515. addKeyboard(): ArcRotateCameraInputsManager;
  101516. }
  101517. }
  101518. declare module BABYLON {
  101519. /**
  101520. * This represents an orbital type of camera.
  101521. *
  101522. * 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.
  101523. * 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.
  101524. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101525. */
  101526. export class ArcRotateCamera extends TargetCamera {
  101527. /**
  101528. * Defines the rotation angle of the camera along the longitudinal axis.
  101529. */
  101530. alpha: number;
  101531. /**
  101532. * Defines the rotation angle of the camera along the latitudinal axis.
  101533. */
  101534. beta: number;
  101535. /**
  101536. * Defines the radius of the camera from it s target point.
  101537. */
  101538. radius: number;
  101539. protected _target: Vector3;
  101540. protected _targetHost: Nullable<AbstractMesh>;
  101541. /**
  101542. * Defines the target point of the camera.
  101543. * The camera looks towards it form the radius distance.
  101544. */
  101545. target: Vector3;
  101546. /**
  101547. * Define the current local position of the camera in the scene
  101548. */
  101549. position: Vector3;
  101550. protected _upVector: Vector3;
  101551. protected _upToYMatrix: Matrix;
  101552. protected _YToUpMatrix: Matrix;
  101553. /**
  101554. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101555. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101556. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101557. */
  101558. upVector: Vector3;
  101559. /**
  101560. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101561. */
  101562. setMatUp(): void;
  101563. /**
  101564. * Current inertia value on the longitudinal axis.
  101565. * The bigger this number the longer it will take for the camera to stop.
  101566. */
  101567. inertialAlphaOffset: number;
  101568. /**
  101569. * Current inertia value on the latitudinal axis.
  101570. * The bigger this number the longer it will take for the camera to stop.
  101571. */
  101572. inertialBetaOffset: number;
  101573. /**
  101574. * Current inertia value on the radius axis.
  101575. * The bigger this number the longer it will take for the camera to stop.
  101576. */
  101577. inertialRadiusOffset: number;
  101578. /**
  101579. * Minimum allowed angle on the longitudinal axis.
  101580. * This can help limiting how the Camera is able to move in the scene.
  101581. */
  101582. lowerAlphaLimit: Nullable<number>;
  101583. /**
  101584. * Maximum allowed angle on the longitudinal axis.
  101585. * This can help limiting how the Camera is able to move in the scene.
  101586. */
  101587. upperAlphaLimit: Nullable<number>;
  101588. /**
  101589. * Minimum allowed angle on the latitudinal axis.
  101590. * This can help limiting how the Camera is able to move in the scene.
  101591. */
  101592. lowerBetaLimit: number;
  101593. /**
  101594. * Maximum allowed angle on the latitudinal axis.
  101595. * This can help limiting how the Camera is able to move in the scene.
  101596. */
  101597. upperBetaLimit: number;
  101598. /**
  101599. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101600. * This can help limiting how the Camera is able to move in the scene.
  101601. */
  101602. lowerRadiusLimit: Nullable<number>;
  101603. /**
  101604. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101605. * This can help limiting how the Camera is able to move in the scene.
  101606. */
  101607. upperRadiusLimit: Nullable<number>;
  101608. /**
  101609. * Defines the current inertia value used during panning of the camera along the X axis.
  101610. */
  101611. inertialPanningX: number;
  101612. /**
  101613. * Defines the current inertia value used during panning of the camera along the Y axis.
  101614. */
  101615. inertialPanningY: number;
  101616. /**
  101617. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101618. * Basically if your fingers moves away from more than this distance you will be considered
  101619. * in pinch mode.
  101620. */
  101621. pinchToPanMaxDistance: number;
  101622. /**
  101623. * Defines the maximum distance the camera can pan.
  101624. * This could help keeping the cammera always in your scene.
  101625. */
  101626. panningDistanceLimit: Nullable<number>;
  101627. /**
  101628. * Defines the target of the camera before paning.
  101629. */
  101630. panningOriginTarget: Vector3;
  101631. /**
  101632. * Defines the value of the inertia used during panning.
  101633. * 0 would mean stop inertia and one would mean no decelleration at all.
  101634. */
  101635. panningInertia: number;
  101636. /**
  101637. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101638. */
  101639. angularSensibilityX: number;
  101640. /**
  101641. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101642. */
  101643. angularSensibilityY: number;
  101644. /**
  101645. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101646. */
  101647. pinchPrecision: number;
  101648. /**
  101649. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101650. * It will be used instead of pinchDeltaPrecision if different from 0.
  101651. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101652. */
  101653. pinchDeltaPercentage: number;
  101654. /**
  101655. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101656. */
  101657. panningSensibility: number;
  101658. /**
  101659. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101660. */
  101661. keysUp: number[];
  101662. /**
  101663. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101664. */
  101665. keysDown: number[];
  101666. /**
  101667. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101668. */
  101669. keysLeft: number[];
  101670. /**
  101671. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101672. */
  101673. keysRight: number[];
  101674. /**
  101675. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101676. */
  101677. wheelPrecision: number;
  101678. /**
  101679. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101680. * It will be used instead of pinchDeltaPrecision if different from 0.
  101681. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101682. */
  101683. wheelDeltaPercentage: number;
  101684. /**
  101685. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101686. */
  101687. zoomOnFactor: number;
  101688. /**
  101689. * Defines a screen offset for the camera position.
  101690. */
  101691. targetScreenOffset: Vector2;
  101692. /**
  101693. * Allows the camera to be completely reversed.
  101694. * If false the camera can not arrive upside down.
  101695. */
  101696. allowUpsideDown: boolean;
  101697. /**
  101698. * Define if double tap/click is used to restore the previously saved state of the camera.
  101699. */
  101700. useInputToRestoreState: boolean;
  101701. /** @hidden */
  101702. _viewMatrix: Matrix;
  101703. /** @hidden */
  101704. _useCtrlForPanning: boolean;
  101705. /** @hidden */
  101706. _panningMouseButton: number;
  101707. /**
  101708. * Defines the input associated to the camera.
  101709. */
  101710. inputs: ArcRotateCameraInputsManager;
  101711. /** @hidden */
  101712. _reset: () => void;
  101713. /**
  101714. * Defines the allowed panning axis.
  101715. */
  101716. panningAxis: Vector3;
  101717. protected _localDirection: Vector3;
  101718. protected _transformedDirection: Vector3;
  101719. private _bouncingBehavior;
  101720. /**
  101721. * Gets the bouncing behavior of the camera if it has been enabled.
  101722. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101723. */
  101724. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101725. /**
  101726. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101727. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101728. */
  101729. useBouncingBehavior: boolean;
  101730. private _framingBehavior;
  101731. /**
  101732. * Gets the framing behavior of the camera if it has been enabled.
  101733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101734. */
  101735. readonly framingBehavior: Nullable<FramingBehavior>;
  101736. /**
  101737. * Defines if the framing behavior of the camera is enabled on the camera.
  101738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101739. */
  101740. useFramingBehavior: boolean;
  101741. private _autoRotationBehavior;
  101742. /**
  101743. * Gets the auto rotation behavior of the camera if it has been enabled.
  101744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101745. */
  101746. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101747. /**
  101748. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101750. */
  101751. useAutoRotationBehavior: boolean;
  101752. /**
  101753. * Observable triggered when the mesh target has been changed on the camera.
  101754. */
  101755. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101756. /**
  101757. * Event raised when the camera is colliding with a mesh.
  101758. */
  101759. onCollide: (collidedMesh: AbstractMesh) => void;
  101760. /**
  101761. * Defines whether the camera should check collision with the objects oh the scene.
  101762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101763. */
  101764. checkCollisions: boolean;
  101765. /**
  101766. * Defines the collision radius of the camera.
  101767. * This simulates a sphere around the camera.
  101768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101769. */
  101770. collisionRadius: Vector3;
  101771. protected _collider: Collider;
  101772. protected _previousPosition: Vector3;
  101773. protected _collisionVelocity: Vector3;
  101774. protected _newPosition: Vector3;
  101775. protected _previousAlpha: number;
  101776. protected _previousBeta: number;
  101777. protected _previousRadius: number;
  101778. protected _collisionTriggered: boolean;
  101779. protected _targetBoundingCenter: Nullable<Vector3>;
  101780. private _computationVector;
  101781. /**
  101782. * Instantiates a new ArcRotateCamera in a given scene
  101783. * @param name Defines the name of the camera
  101784. * @param alpha Defines the camera rotation along the logitudinal axis
  101785. * @param beta Defines the camera rotation along the latitudinal axis
  101786. * @param radius Defines the camera distance from its target
  101787. * @param target Defines the camera target
  101788. * @param scene Defines the scene the camera belongs to
  101789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101790. */
  101791. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101792. /** @hidden */
  101793. _initCache(): void;
  101794. /** @hidden */
  101795. _updateCache(ignoreParentClass?: boolean): void;
  101796. protected _getTargetPosition(): Vector3;
  101797. private _storedAlpha;
  101798. private _storedBeta;
  101799. private _storedRadius;
  101800. private _storedTarget;
  101801. private _storedTargetScreenOffset;
  101802. /**
  101803. * Stores the current state of the camera (alpha, beta, radius and target)
  101804. * @returns the camera itself
  101805. */
  101806. storeState(): Camera;
  101807. /**
  101808. * @hidden
  101809. * Restored camera state. You must call storeState() first
  101810. */
  101811. _restoreStateValues(): boolean;
  101812. /** @hidden */
  101813. _isSynchronizedViewMatrix(): boolean;
  101814. /**
  101815. * Attached controls to the current camera.
  101816. * @param element Defines the element the controls should be listened from
  101817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101818. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101819. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101820. */
  101821. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101822. /**
  101823. * Detach the current controls from the camera.
  101824. * The camera will stop reacting to inputs.
  101825. * @param element Defines the element to stop listening the inputs from
  101826. */
  101827. detachControl(element: HTMLElement): void;
  101828. /** @hidden */
  101829. _checkInputs(): void;
  101830. protected _checkLimits(): void;
  101831. /**
  101832. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101833. */
  101834. rebuildAnglesAndRadius(): void;
  101835. /**
  101836. * Use a position to define the current camera related information like aplha, beta and radius
  101837. * @param position Defines the position to set the camera at
  101838. */
  101839. setPosition(position: Vector3): void;
  101840. /**
  101841. * Defines the target the camera should look at.
  101842. * This will automatically adapt alpha beta and radius to fit within the new target.
  101843. * @param target Defines the new target as a Vector or a mesh
  101844. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101845. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101846. */
  101847. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101848. /** @hidden */
  101849. _getViewMatrix(): Matrix;
  101850. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101851. /**
  101852. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101853. * @param meshes Defines the mesh to zoom on
  101854. * @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)
  101855. */
  101856. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101857. /**
  101858. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101859. * The target will be changed but the radius
  101860. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101861. * @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)
  101862. */
  101863. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101864. min: Vector3;
  101865. max: Vector3;
  101866. distance: number;
  101867. }, doNotUpdateMaxZ?: boolean): void;
  101868. /**
  101869. * @override
  101870. * Override Camera.createRigCamera
  101871. */
  101872. createRigCamera(name: string, cameraIndex: number): Camera;
  101873. /**
  101874. * @hidden
  101875. * @override
  101876. * Override Camera._updateRigCameras
  101877. */
  101878. _updateRigCameras(): void;
  101879. /**
  101880. * Destroy the camera and release the current resources hold by it.
  101881. */
  101882. dispose(): void;
  101883. /**
  101884. * Gets the current object class name.
  101885. * @return the class name
  101886. */
  101887. getClassName(): string;
  101888. }
  101889. }
  101890. declare module BABYLON {
  101891. /**
  101892. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101893. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101894. */
  101895. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101896. /**
  101897. * Gets the name of the behavior.
  101898. */
  101899. readonly name: string;
  101900. private _zoomStopsAnimation;
  101901. private _idleRotationSpeed;
  101902. private _idleRotationWaitTime;
  101903. private _idleRotationSpinupTime;
  101904. /**
  101905. * Sets the flag that indicates if user zooming should stop animation.
  101906. */
  101907. /**
  101908. * Gets the flag that indicates if user zooming should stop animation.
  101909. */
  101910. zoomStopsAnimation: boolean;
  101911. /**
  101912. * Sets the default speed at which the camera rotates around the model.
  101913. */
  101914. /**
  101915. * Gets the default speed at which the camera rotates around the model.
  101916. */
  101917. idleRotationSpeed: number;
  101918. /**
  101919. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101920. */
  101921. /**
  101922. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101923. */
  101924. idleRotationWaitTime: number;
  101925. /**
  101926. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101927. */
  101928. /**
  101929. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101930. */
  101931. idleRotationSpinupTime: number;
  101932. /**
  101933. * Gets a value indicating if the camera is currently rotating because of this behavior
  101934. */
  101935. readonly rotationInProgress: boolean;
  101936. private _onPrePointerObservableObserver;
  101937. private _onAfterCheckInputsObserver;
  101938. private _attachedCamera;
  101939. private _isPointerDown;
  101940. private _lastFrameTime;
  101941. private _lastInteractionTime;
  101942. private _cameraRotationSpeed;
  101943. /**
  101944. * Initializes the behavior.
  101945. */
  101946. init(): void;
  101947. /**
  101948. * Attaches the behavior to its arc rotate camera.
  101949. * @param camera Defines the camera to attach the behavior to
  101950. */
  101951. attach(camera: ArcRotateCamera): void;
  101952. /**
  101953. * Detaches the behavior from its current arc rotate camera.
  101954. */
  101955. detach(): void;
  101956. /**
  101957. * Returns true if user is scrolling.
  101958. * @return true if user is scrolling.
  101959. */
  101960. private _userIsZooming;
  101961. private _lastFrameRadius;
  101962. private _shouldAnimationStopForInteraction;
  101963. /**
  101964. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101965. */
  101966. private _applyUserInteraction;
  101967. private _userIsMoving;
  101968. }
  101969. }
  101970. declare module BABYLON {
  101971. /**
  101972. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101973. */
  101974. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101975. private ui;
  101976. /**
  101977. * The name of the behavior
  101978. */
  101979. name: string;
  101980. /**
  101981. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101982. */
  101983. distanceAwayFromFace: number;
  101984. /**
  101985. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101986. */
  101987. distanceAwayFromBottomOfFace: number;
  101988. private _faceVectors;
  101989. private _target;
  101990. private _scene;
  101991. private _onRenderObserver;
  101992. private _tmpMatrix;
  101993. private _tmpVector;
  101994. /**
  101995. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101996. * @param ui The transform node that should be attched to the mesh
  101997. */
  101998. constructor(ui: TransformNode);
  101999. /**
  102000. * Initializes the behavior
  102001. */
  102002. init(): void;
  102003. private _closestFace;
  102004. private _zeroVector;
  102005. private _lookAtTmpMatrix;
  102006. private _lookAtToRef;
  102007. /**
  102008. * Attaches the AttachToBoxBehavior to the passed in mesh
  102009. * @param target The mesh that the specified node will be attached to
  102010. */
  102011. attach(target: Mesh): void;
  102012. /**
  102013. * Detaches the behavior from the mesh
  102014. */
  102015. detach(): void;
  102016. }
  102017. }
  102018. declare module BABYLON {
  102019. /**
  102020. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102021. */
  102022. export class FadeInOutBehavior implements Behavior<Mesh> {
  102023. /**
  102024. * Time in milliseconds to delay before fading in (Default: 0)
  102025. */
  102026. delay: number;
  102027. /**
  102028. * Time in milliseconds for the mesh to fade in (Default: 300)
  102029. */
  102030. fadeInTime: number;
  102031. private _millisecondsPerFrame;
  102032. private _hovered;
  102033. private _hoverValue;
  102034. private _ownerNode;
  102035. /**
  102036. * Instatiates the FadeInOutBehavior
  102037. */
  102038. constructor();
  102039. /**
  102040. * The name of the behavior
  102041. */
  102042. readonly name: string;
  102043. /**
  102044. * Initializes the behavior
  102045. */
  102046. init(): void;
  102047. /**
  102048. * Attaches the fade behavior on the passed in mesh
  102049. * @param ownerNode The mesh that will be faded in/out once attached
  102050. */
  102051. attach(ownerNode: Mesh): void;
  102052. /**
  102053. * Detaches the behavior from the mesh
  102054. */
  102055. detach(): void;
  102056. /**
  102057. * Triggers the mesh to begin fading in or out
  102058. * @param value if the object should fade in or out (true to fade in)
  102059. */
  102060. fadeIn(value: boolean): void;
  102061. private _update;
  102062. private _setAllVisibility;
  102063. }
  102064. }
  102065. declare module BABYLON {
  102066. /**
  102067. * Class containing a set of static utilities functions for managing Pivots
  102068. * @hidden
  102069. */
  102070. export class PivotTools {
  102071. private static _PivotCached;
  102072. private static _OldPivotPoint;
  102073. private static _PivotTranslation;
  102074. private static _PivotTmpVector;
  102075. /** @hidden */
  102076. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102077. /** @hidden */
  102078. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102079. }
  102080. }
  102081. declare module BABYLON {
  102082. /**
  102083. * Class containing static functions to help procedurally build meshes
  102084. */
  102085. export class PlaneBuilder {
  102086. /**
  102087. * Creates a plane mesh
  102088. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102089. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102090. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102094. * @param name defines the name of the mesh
  102095. * @param options defines the options used to create the mesh
  102096. * @param scene defines the hosting scene
  102097. * @returns the plane mesh
  102098. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102099. */
  102100. static CreatePlane(name: string, options: {
  102101. size?: number;
  102102. width?: number;
  102103. height?: number;
  102104. sideOrientation?: number;
  102105. frontUVs?: Vector4;
  102106. backUVs?: Vector4;
  102107. updatable?: boolean;
  102108. sourcePlane?: Plane;
  102109. }, scene?: Nullable<Scene>): Mesh;
  102110. }
  102111. }
  102112. declare module BABYLON {
  102113. /**
  102114. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102115. */
  102116. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102117. private static _AnyMouseID;
  102118. /**
  102119. * Abstract mesh the behavior is set on
  102120. */
  102121. attachedNode: AbstractMesh;
  102122. private _dragPlane;
  102123. private _scene;
  102124. private _pointerObserver;
  102125. private _beforeRenderObserver;
  102126. private static _planeScene;
  102127. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102128. /**
  102129. * 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)
  102130. */
  102131. maxDragAngle: number;
  102132. /**
  102133. * @hidden
  102134. */
  102135. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102136. /**
  102137. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102138. */
  102139. currentDraggingPointerID: number;
  102140. /**
  102141. * The last position where the pointer hit the drag plane in world space
  102142. */
  102143. lastDragPosition: Vector3;
  102144. /**
  102145. * If the behavior is currently in a dragging state
  102146. */
  102147. dragging: boolean;
  102148. /**
  102149. * 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)
  102150. */
  102151. dragDeltaRatio: number;
  102152. /**
  102153. * If the drag plane orientation should be updated during the dragging (Default: true)
  102154. */
  102155. updateDragPlane: boolean;
  102156. private _debugMode;
  102157. private _moving;
  102158. /**
  102159. * Fires each time the attached mesh is dragged with the pointer
  102160. * * delta between last drag position and current drag position in world space
  102161. * * dragDistance along the drag axis
  102162. * * dragPlaneNormal normal of the current drag plane used during the drag
  102163. * * dragPlanePoint in world space where the drag intersects the drag plane
  102164. */
  102165. onDragObservable: Observable<{
  102166. delta: Vector3;
  102167. dragPlanePoint: Vector3;
  102168. dragPlaneNormal: Vector3;
  102169. dragDistance: number;
  102170. pointerId: number;
  102171. }>;
  102172. /**
  102173. * Fires each time a drag begins (eg. mouse down on mesh)
  102174. */
  102175. onDragStartObservable: Observable<{
  102176. dragPlanePoint: Vector3;
  102177. pointerId: number;
  102178. }>;
  102179. /**
  102180. * Fires each time a drag ends (eg. mouse release after drag)
  102181. */
  102182. onDragEndObservable: Observable<{
  102183. dragPlanePoint: Vector3;
  102184. pointerId: number;
  102185. }>;
  102186. /**
  102187. * If the attached mesh should be moved when dragged
  102188. */
  102189. moveAttached: boolean;
  102190. /**
  102191. * If the drag behavior will react to drag events (Default: true)
  102192. */
  102193. enabled: boolean;
  102194. /**
  102195. * If pointer events should start and release the drag (Default: true)
  102196. */
  102197. startAndReleaseDragOnPointerEvents: boolean;
  102198. /**
  102199. * If camera controls should be detached during the drag
  102200. */
  102201. detachCameraControls: boolean;
  102202. /**
  102203. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102204. */
  102205. useObjectOrienationForDragging: boolean;
  102206. private _options;
  102207. /**
  102208. * Creates a pointer drag behavior that can be attached to a mesh
  102209. * @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)
  102210. */
  102211. constructor(options?: {
  102212. dragAxis?: Vector3;
  102213. dragPlaneNormal?: Vector3;
  102214. });
  102215. /**
  102216. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102217. */
  102218. validateDrag: (targetPosition: Vector3) => boolean;
  102219. /**
  102220. * The name of the behavior
  102221. */
  102222. readonly name: string;
  102223. /**
  102224. * Initializes the behavior
  102225. */
  102226. init(): void;
  102227. private _tmpVector;
  102228. private _alternatePickedPoint;
  102229. private _worldDragAxis;
  102230. private _targetPosition;
  102231. private _attachedElement;
  102232. /**
  102233. * Attaches the drag behavior the passed in mesh
  102234. * @param ownerNode The mesh that will be dragged around once attached
  102235. */
  102236. attach(ownerNode: AbstractMesh): void;
  102237. /**
  102238. * Force relase the drag action by code.
  102239. */
  102240. releaseDrag(): void;
  102241. private _startDragRay;
  102242. private _lastPointerRay;
  102243. /**
  102244. * Simulates the start of a pointer drag event on the behavior
  102245. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102246. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102247. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102248. */
  102249. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102250. private _startDrag;
  102251. private _dragDelta;
  102252. private _moveDrag;
  102253. private _pickWithRayOnDragPlane;
  102254. private _pointA;
  102255. private _pointB;
  102256. private _pointC;
  102257. private _lineA;
  102258. private _lineB;
  102259. private _localAxis;
  102260. private _lookAt;
  102261. private _updateDragPlanePosition;
  102262. /**
  102263. * Detaches the behavior from the mesh
  102264. */
  102265. detach(): void;
  102266. }
  102267. }
  102268. declare module BABYLON {
  102269. /**
  102270. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102271. */
  102272. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102273. private _dragBehaviorA;
  102274. private _dragBehaviorB;
  102275. private _startDistance;
  102276. private _initialScale;
  102277. private _targetScale;
  102278. private _ownerNode;
  102279. private _sceneRenderObserver;
  102280. /**
  102281. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102282. */
  102283. constructor();
  102284. /**
  102285. * The name of the behavior
  102286. */
  102287. readonly name: string;
  102288. /**
  102289. * Initializes the behavior
  102290. */
  102291. init(): void;
  102292. private _getCurrentDistance;
  102293. /**
  102294. * Attaches the scale behavior the passed in mesh
  102295. * @param ownerNode The mesh that will be scaled around once attached
  102296. */
  102297. attach(ownerNode: Mesh): void;
  102298. /**
  102299. * Detaches the behavior from the mesh
  102300. */
  102301. detach(): void;
  102302. }
  102303. }
  102304. declare module BABYLON {
  102305. /**
  102306. * 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
  102307. */
  102308. export class SixDofDragBehavior implements Behavior<Mesh> {
  102309. private static _virtualScene;
  102310. private _ownerNode;
  102311. private _sceneRenderObserver;
  102312. private _scene;
  102313. private _targetPosition;
  102314. private _virtualOriginMesh;
  102315. private _virtualDragMesh;
  102316. private _pointerObserver;
  102317. private _moving;
  102318. private _startingOrientation;
  102319. /**
  102320. * 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)
  102321. */
  102322. private zDragFactor;
  102323. /**
  102324. * If the object should rotate to face the drag origin
  102325. */
  102326. rotateDraggedObject: boolean;
  102327. /**
  102328. * If the behavior is currently in a dragging state
  102329. */
  102330. dragging: boolean;
  102331. /**
  102332. * 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)
  102333. */
  102334. dragDeltaRatio: number;
  102335. /**
  102336. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102337. */
  102338. currentDraggingPointerID: number;
  102339. /**
  102340. * If camera controls should be detached during the drag
  102341. */
  102342. detachCameraControls: boolean;
  102343. /**
  102344. * Fires each time a drag starts
  102345. */
  102346. onDragStartObservable: Observable<{}>;
  102347. /**
  102348. * Fires each time a drag ends (eg. mouse release after drag)
  102349. */
  102350. onDragEndObservable: Observable<{}>;
  102351. /**
  102352. * 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
  102353. */
  102354. constructor();
  102355. /**
  102356. * The name of the behavior
  102357. */
  102358. readonly name: string;
  102359. /**
  102360. * Initializes the behavior
  102361. */
  102362. init(): void;
  102363. /**
  102364. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102365. */
  102366. private readonly _pointerCamera;
  102367. /**
  102368. * Attaches the scale behavior the passed in mesh
  102369. * @param ownerNode The mesh that will be scaled around once attached
  102370. */
  102371. attach(ownerNode: Mesh): void;
  102372. /**
  102373. * Detaches the behavior from the mesh
  102374. */
  102375. detach(): void;
  102376. }
  102377. }
  102378. declare module BABYLON {
  102379. /**
  102380. * Class used to apply inverse kinematics to bones
  102381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102382. */
  102383. export class BoneIKController {
  102384. private static _tmpVecs;
  102385. private static _tmpQuat;
  102386. private static _tmpMats;
  102387. /**
  102388. * Gets or sets the target mesh
  102389. */
  102390. targetMesh: AbstractMesh;
  102391. /** Gets or sets the mesh used as pole */
  102392. poleTargetMesh: AbstractMesh;
  102393. /**
  102394. * Gets or sets the bone used as pole
  102395. */
  102396. poleTargetBone: Nullable<Bone>;
  102397. /**
  102398. * Gets or sets the target position
  102399. */
  102400. targetPosition: Vector3;
  102401. /**
  102402. * Gets or sets the pole target position
  102403. */
  102404. poleTargetPosition: Vector3;
  102405. /**
  102406. * Gets or sets the pole target local offset
  102407. */
  102408. poleTargetLocalOffset: Vector3;
  102409. /**
  102410. * Gets or sets the pole angle
  102411. */
  102412. poleAngle: number;
  102413. /**
  102414. * Gets or sets the mesh associated with the controller
  102415. */
  102416. mesh: AbstractMesh;
  102417. /**
  102418. * 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)
  102419. */
  102420. slerpAmount: number;
  102421. private _bone1Quat;
  102422. private _bone1Mat;
  102423. private _bone2Ang;
  102424. private _bone1;
  102425. private _bone2;
  102426. private _bone1Length;
  102427. private _bone2Length;
  102428. private _maxAngle;
  102429. private _maxReach;
  102430. private _rightHandedSystem;
  102431. private _bendAxis;
  102432. private _slerping;
  102433. private _adjustRoll;
  102434. /**
  102435. * Gets or sets maximum allowed angle
  102436. */
  102437. maxAngle: number;
  102438. /**
  102439. * Creates a new BoneIKController
  102440. * @param mesh defines the mesh to control
  102441. * @param bone defines the bone to control
  102442. * @param options defines options to set up the controller
  102443. */
  102444. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102445. targetMesh?: AbstractMesh;
  102446. poleTargetMesh?: AbstractMesh;
  102447. poleTargetBone?: Bone;
  102448. poleTargetLocalOffset?: Vector3;
  102449. poleAngle?: number;
  102450. bendAxis?: Vector3;
  102451. maxAngle?: number;
  102452. slerpAmount?: number;
  102453. });
  102454. private _setMaxAngle;
  102455. /**
  102456. * Force the controller to update the bones
  102457. */
  102458. update(): void;
  102459. }
  102460. }
  102461. declare module BABYLON {
  102462. /**
  102463. * Class used to make a bone look toward a point in space
  102464. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102465. */
  102466. export class BoneLookController {
  102467. private static _tmpVecs;
  102468. private static _tmpQuat;
  102469. private static _tmpMats;
  102470. /**
  102471. * The target Vector3 that the bone will look at
  102472. */
  102473. target: Vector3;
  102474. /**
  102475. * The mesh that the bone is attached to
  102476. */
  102477. mesh: AbstractMesh;
  102478. /**
  102479. * The bone that will be looking to the target
  102480. */
  102481. bone: Bone;
  102482. /**
  102483. * The up axis of the coordinate system that is used when the bone is rotated
  102484. */
  102485. upAxis: Vector3;
  102486. /**
  102487. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102488. */
  102489. upAxisSpace: Space;
  102490. /**
  102491. * Used to make an adjustment to the yaw of the bone
  102492. */
  102493. adjustYaw: number;
  102494. /**
  102495. * Used to make an adjustment to the pitch of the bone
  102496. */
  102497. adjustPitch: number;
  102498. /**
  102499. * Used to make an adjustment to the roll of the bone
  102500. */
  102501. adjustRoll: number;
  102502. /**
  102503. * 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)
  102504. */
  102505. slerpAmount: number;
  102506. private _minYaw;
  102507. private _maxYaw;
  102508. private _minPitch;
  102509. private _maxPitch;
  102510. private _minYawSin;
  102511. private _minYawCos;
  102512. private _maxYawSin;
  102513. private _maxYawCos;
  102514. private _midYawConstraint;
  102515. private _minPitchTan;
  102516. private _maxPitchTan;
  102517. private _boneQuat;
  102518. private _slerping;
  102519. private _transformYawPitch;
  102520. private _transformYawPitchInv;
  102521. private _firstFrameSkipped;
  102522. private _yawRange;
  102523. private _fowardAxis;
  102524. /**
  102525. * Gets or sets the minimum yaw angle that the bone can look to
  102526. */
  102527. minYaw: number;
  102528. /**
  102529. * Gets or sets the maximum yaw angle that the bone can look to
  102530. */
  102531. maxYaw: number;
  102532. /**
  102533. * Gets or sets the minimum pitch angle that the bone can look to
  102534. */
  102535. minPitch: number;
  102536. /**
  102537. * Gets or sets the maximum pitch angle that the bone can look to
  102538. */
  102539. maxPitch: number;
  102540. /**
  102541. * Create a BoneLookController
  102542. * @param mesh the mesh that the bone belongs to
  102543. * @param bone the bone that will be looking to the target
  102544. * @param target the target Vector3 to look at
  102545. * @param options optional settings:
  102546. * * maxYaw: the maximum angle the bone will yaw to
  102547. * * minYaw: the minimum angle the bone will yaw to
  102548. * * maxPitch: the maximum angle the bone will pitch to
  102549. * * minPitch: the minimum angle the bone will yaw to
  102550. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102551. * * upAxis: the up axis of the coordinate system
  102552. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102553. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102554. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102555. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102556. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102557. * * adjustRoll: used to make an adjustment to the roll of the bone
  102558. **/
  102559. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102560. maxYaw?: number;
  102561. minYaw?: number;
  102562. maxPitch?: number;
  102563. minPitch?: number;
  102564. slerpAmount?: number;
  102565. upAxis?: Vector3;
  102566. upAxisSpace?: Space;
  102567. yawAxis?: Vector3;
  102568. pitchAxis?: Vector3;
  102569. adjustYaw?: number;
  102570. adjustPitch?: number;
  102571. adjustRoll?: number;
  102572. });
  102573. /**
  102574. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102575. */
  102576. update(): void;
  102577. private _getAngleDiff;
  102578. private _getAngleBetween;
  102579. private _isAngleBetween;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Manage the gamepad inputs to control an arc rotate camera.
  102585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102586. */
  102587. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102588. /**
  102589. * Defines the camera the input is attached to.
  102590. */
  102591. camera: ArcRotateCamera;
  102592. /**
  102593. * Defines the gamepad the input is gathering event from.
  102594. */
  102595. gamepad: Nullable<Gamepad>;
  102596. /**
  102597. * Defines the gamepad rotation sensiblity.
  102598. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102599. */
  102600. gamepadRotationSensibility: number;
  102601. /**
  102602. * Defines the gamepad move sensiblity.
  102603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102604. */
  102605. gamepadMoveSensibility: number;
  102606. private _onGamepadConnectedObserver;
  102607. private _onGamepadDisconnectedObserver;
  102608. /**
  102609. * Attach the input controls to a specific dom element to get the input from.
  102610. * @param element Defines the element the controls should be listened from
  102611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102612. */
  102613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102614. /**
  102615. * Detach the current controls from the specified dom element.
  102616. * @param element Defines the element to stop listening the inputs from
  102617. */
  102618. detachControl(element: Nullable<HTMLElement>): void;
  102619. /**
  102620. * Update the current camera state depending on the inputs that have been used this frame.
  102621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102622. */
  102623. checkInputs(): void;
  102624. /**
  102625. * Gets the class name of the current intput.
  102626. * @returns the class name
  102627. */
  102628. getClassName(): string;
  102629. /**
  102630. * Get the friendly name associated with the input class.
  102631. * @returns the input friendly name
  102632. */
  102633. getSimpleName(): string;
  102634. }
  102635. }
  102636. declare module BABYLON {
  102637. interface ArcRotateCameraInputsManager {
  102638. /**
  102639. * Add orientation input support to the input manager.
  102640. * @returns the current input manager
  102641. */
  102642. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102643. }
  102644. /**
  102645. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102647. */
  102648. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102649. /**
  102650. * Defines the camera the input is attached to.
  102651. */
  102652. camera: ArcRotateCamera;
  102653. /**
  102654. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102655. */
  102656. alphaCorrection: number;
  102657. /**
  102658. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102659. */
  102660. gammaCorrection: number;
  102661. private _alpha;
  102662. private _gamma;
  102663. private _dirty;
  102664. private _deviceOrientationHandler;
  102665. /**
  102666. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102667. */
  102668. constructor();
  102669. /**
  102670. * Attach the input controls to a specific dom element to get the input from.
  102671. * @param element Defines the element the controls should be listened from
  102672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102673. */
  102674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102675. /** @hidden */
  102676. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102677. /**
  102678. * Update the current camera state depending on the inputs that have been used this frame.
  102679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102680. */
  102681. checkInputs(): void;
  102682. /**
  102683. * Detach the current controls from the specified dom element.
  102684. * @param element Defines the element to stop listening the inputs from
  102685. */
  102686. detachControl(element: Nullable<HTMLElement>): void;
  102687. /**
  102688. * Gets the class name of the current intput.
  102689. * @returns the class name
  102690. */
  102691. getClassName(): string;
  102692. /**
  102693. * Get the friendly name associated with the input class.
  102694. * @returns the input friendly name
  102695. */
  102696. getSimpleName(): string;
  102697. }
  102698. }
  102699. declare module BABYLON {
  102700. /**
  102701. * Listen to mouse events to control the camera.
  102702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102703. */
  102704. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102705. /**
  102706. * Defines the camera the input is attached to.
  102707. */
  102708. camera: FlyCamera;
  102709. /**
  102710. * Defines if touch is enabled. (Default is true.)
  102711. */
  102712. touchEnabled: boolean;
  102713. /**
  102714. * Defines the buttons associated with the input to handle camera rotation.
  102715. */
  102716. buttons: number[];
  102717. /**
  102718. * Assign buttons for Yaw control.
  102719. */
  102720. buttonsYaw: number[];
  102721. /**
  102722. * Assign buttons for Pitch control.
  102723. */
  102724. buttonsPitch: number[];
  102725. /**
  102726. * Assign buttons for Roll control.
  102727. */
  102728. buttonsRoll: number[];
  102729. /**
  102730. * Detect if any button is being pressed while mouse is moved.
  102731. * -1 = Mouse locked.
  102732. * 0 = Left button.
  102733. * 1 = Middle Button.
  102734. * 2 = Right Button.
  102735. */
  102736. activeButton: number;
  102737. /**
  102738. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102739. * Higher values reduce its sensitivity.
  102740. */
  102741. angularSensibility: number;
  102742. private _mousemoveCallback;
  102743. private _observer;
  102744. private _rollObserver;
  102745. private previousPosition;
  102746. private noPreventDefault;
  102747. private element;
  102748. /**
  102749. * Listen to mouse events to control the camera.
  102750. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102752. */
  102753. constructor(touchEnabled?: boolean);
  102754. /**
  102755. * Attach the mouse control to the HTML DOM element.
  102756. * @param element Defines the element that listens to the input events.
  102757. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102758. */
  102759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102760. /**
  102761. * Detach the current controls from the specified dom element.
  102762. * @param element Defines the element to stop listening the inputs from
  102763. */
  102764. detachControl(element: Nullable<HTMLElement>): void;
  102765. /**
  102766. * Gets the class name of the current input.
  102767. * @returns the class name.
  102768. */
  102769. getClassName(): string;
  102770. /**
  102771. * Get the friendly name associated with the input class.
  102772. * @returns the input's friendly name.
  102773. */
  102774. getSimpleName(): string;
  102775. private _pointerInput;
  102776. private _onMouseMove;
  102777. /**
  102778. * Rotate camera by mouse offset.
  102779. */
  102780. private rotateCamera;
  102781. }
  102782. }
  102783. declare module BABYLON {
  102784. /**
  102785. * Default Inputs manager for the FlyCamera.
  102786. * It groups all the default supported inputs for ease of use.
  102787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102788. */
  102789. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102790. /**
  102791. * Instantiates a new FlyCameraInputsManager.
  102792. * @param camera Defines the camera the inputs belong to.
  102793. */
  102794. constructor(camera: FlyCamera);
  102795. /**
  102796. * Add keyboard input support to the input manager.
  102797. * @returns the new FlyCameraKeyboardMoveInput().
  102798. */
  102799. addKeyboard(): FlyCameraInputsManager;
  102800. /**
  102801. * Add mouse input support to the input manager.
  102802. * @param touchEnabled Enable touch screen support.
  102803. * @returns the new FlyCameraMouseInput().
  102804. */
  102805. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102806. }
  102807. }
  102808. declare module BABYLON {
  102809. /**
  102810. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102811. * such as in a 3D Space Shooter or a Flight Simulator.
  102812. */
  102813. export class FlyCamera extends TargetCamera {
  102814. /**
  102815. * Define the collision ellipsoid of the camera.
  102816. * This is helpful for simulating a camera body, like a player's body.
  102817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102818. */
  102819. ellipsoid: Vector3;
  102820. /**
  102821. * Define an offset for the position of the ellipsoid around the camera.
  102822. * This can be helpful if the camera is attached away from the player's body center,
  102823. * such as at its head.
  102824. */
  102825. ellipsoidOffset: Vector3;
  102826. /**
  102827. * Enable or disable collisions of the camera with the rest of the scene objects.
  102828. */
  102829. checkCollisions: boolean;
  102830. /**
  102831. * Enable or disable gravity on the camera.
  102832. */
  102833. applyGravity: boolean;
  102834. /**
  102835. * Define the current direction the camera is moving to.
  102836. */
  102837. cameraDirection: Vector3;
  102838. /**
  102839. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102840. * This overrides and empties cameraRotation.
  102841. */
  102842. rotationQuaternion: Quaternion;
  102843. /**
  102844. * Track Roll to maintain the wanted Rolling when looking around.
  102845. */
  102846. _trackRoll: number;
  102847. /**
  102848. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102849. */
  102850. rollCorrect: number;
  102851. /**
  102852. * Mimic a banked turn, Rolling the camera when Yawing.
  102853. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102854. */
  102855. bankedTurn: boolean;
  102856. /**
  102857. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102858. */
  102859. bankedTurnLimit: number;
  102860. /**
  102861. * Value of 0 disables the banked Roll.
  102862. * Value of 1 is equal to the Yaw angle in radians.
  102863. */
  102864. bankedTurnMultiplier: number;
  102865. /**
  102866. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102867. */
  102868. inputs: FlyCameraInputsManager;
  102869. /**
  102870. * Gets the input sensibility for mouse input.
  102871. * Higher values reduce sensitivity.
  102872. */
  102873. /**
  102874. * Sets the input sensibility for a mouse input.
  102875. * Higher values reduce sensitivity.
  102876. */
  102877. angularSensibility: number;
  102878. /**
  102879. * Get the keys for camera movement forward.
  102880. */
  102881. /**
  102882. * Set the keys for camera movement forward.
  102883. */
  102884. keysForward: number[];
  102885. /**
  102886. * Get the keys for camera movement backward.
  102887. */
  102888. keysBackward: number[];
  102889. /**
  102890. * Get the keys for camera movement up.
  102891. */
  102892. /**
  102893. * Set the keys for camera movement up.
  102894. */
  102895. keysUp: number[];
  102896. /**
  102897. * Get the keys for camera movement down.
  102898. */
  102899. /**
  102900. * Set the keys for camera movement down.
  102901. */
  102902. keysDown: number[];
  102903. /**
  102904. * Get the keys for camera movement left.
  102905. */
  102906. /**
  102907. * Set the keys for camera movement left.
  102908. */
  102909. keysLeft: number[];
  102910. /**
  102911. * Set the keys for camera movement right.
  102912. */
  102913. /**
  102914. * Set the keys for camera movement right.
  102915. */
  102916. keysRight: number[];
  102917. /**
  102918. * Event raised when the camera collides with a mesh in the scene.
  102919. */
  102920. onCollide: (collidedMesh: AbstractMesh) => void;
  102921. private _collider;
  102922. private _needMoveForGravity;
  102923. private _oldPosition;
  102924. private _diffPosition;
  102925. private _newPosition;
  102926. /** @hidden */
  102927. _localDirection: Vector3;
  102928. /** @hidden */
  102929. _transformedDirection: Vector3;
  102930. /**
  102931. * Instantiates a FlyCamera.
  102932. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102933. * such as in a 3D Space Shooter or a Flight Simulator.
  102934. * @param name Define the name of the camera in the scene.
  102935. * @param position Define the starting position of the camera in the scene.
  102936. * @param scene Define the scene the camera belongs to.
  102937. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102938. */
  102939. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102940. /**
  102941. * Attach a control to the HTML DOM element.
  102942. * @param element Defines the element that listens to the input events.
  102943. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102944. */
  102945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102946. /**
  102947. * Detach a control from the HTML DOM element.
  102948. * The camera will stop reacting to that input.
  102949. * @param element Defines the element that listens to the input events.
  102950. */
  102951. detachControl(element: HTMLElement): void;
  102952. private _collisionMask;
  102953. /**
  102954. * Get the mask that the camera ignores in collision events.
  102955. */
  102956. /**
  102957. * Set the mask that the camera ignores in collision events.
  102958. */
  102959. collisionMask: number;
  102960. /** @hidden */
  102961. _collideWithWorld(displacement: Vector3): void;
  102962. /** @hidden */
  102963. private _onCollisionPositionChange;
  102964. /** @hidden */
  102965. _checkInputs(): void;
  102966. /** @hidden */
  102967. _decideIfNeedsToMove(): boolean;
  102968. /** @hidden */
  102969. _updatePosition(): void;
  102970. /**
  102971. * Restore the Roll to its target value at the rate specified.
  102972. * @param rate - Higher means slower restoring.
  102973. * @hidden
  102974. */
  102975. restoreRoll(rate: number): void;
  102976. /**
  102977. * Destroy the camera and release the current resources held by it.
  102978. */
  102979. dispose(): void;
  102980. /**
  102981. * Get the current object class name.
  102982. * @returns the class name.
  102983. */
  102984. getClassName(): string;
  102985. }
  102986. }
  102987. declare module BABYLON {
  102988. /**
  102989. * Listen to keyboard events to control the camera.
  102990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102991. */
  102992. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102993. /**
  102994. * Defines the camera the input is attached to.
  102995. */
  102996. camera: FlyCamera;
  102997. /**
  102998. * The list of keyboard keys used to control the forward move of the camera.
  102999. */
  103000. keysForward: number[];
  103001. /**
  103002. * The list of keyboard keys used to control the backward move of the camera.
  103003. */
  103004. keysBackward: number[];
  103005. /**
  103006. * The list of keyboard keys used to control the forward move of the camera.
  103007. */
  103008. keysUp: number[];
  103009. /**
  103010. * The list of keyboard keys used to control the backward move of the camera.
  103011. */
  103012. keysDown: number[];
  103013. /**
  103014. * The list of keyboard keys used to control the right strafe move of the camera.
  103015. */
  103016. keysRight: number[];
  103017. /**
  103018. * The list of keyboard keys used to control the left strafe move of the camera.
  103019. */
  103020. keysLeft: number[];
  103021. private _keys;
  103022. private _onCanvasBlurObserver;
  103023. private _onKeyboardObserver;
  103024. private _engine;
  103025. private _scene;
  103026. /**
  103027. * Attach the input controls to a specific dom element to get the input from.
  103028. * @param element Defines the element the controls should be listened from
  103029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103030. */
  103031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103032. /**
  103033. * Detach the current controls from the specified dom element.
  103034. * @param element Defines the element to stop listening the inputs from
  103035. */
  103036. detachControl(element: Nullable<HTMLElement>): void;
  103037. /**
  103038. * Gets the class name of the current intput.
  103039. * @returns the class name
  103040. */
  103041. getClassName(): string;
  103042. /** @hidden */
  103043. _onLostFocus(e: FocusEvent): void;
  103044. /**
  103045. * Get the friendly name associated with the input class.
  103046. * @returns the input friendly name
  103047. */
  103048. getSimpleName(): string;
  103049. /**
  103050. * Update the current camera state depending on the inputs that have been used this frame.
  103051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103052. */
  103053. checkInputs(): void;
  103054. }
  103055. }
  103056. declare module BABYLON {
  103057. /**
  103058. * Manage the mouse wheel inputs to control a follow camera.
  103059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103060. */
  103061. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103062. /**
  103063. * Defines the camera the input is attached to.
  103064. */
  103065. camera: FollowCamera;
  103066. /**
  103067. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103068. */
  103069. axisControlRadius: boolean;
  103070. /**
  103071. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103072. */
  103073. axisControlHeight: boolean;
  103074. /**
  103075. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103076. */
  103077. axisControlRotation: boolean;
  103078. /**
  103079. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103080. * relation to mouseWheel events.
  103081. */
  103082. wheelPrecision: number;
  103083. /**
  103084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103086. */
  103087. wheelDeltaPercentage: number;
  103088. private _wheel;
  103089. private _observer;
  103090. /**
  103091. * Attach the input controls to a specific dom element to get the input from.
  103092. * @param element Defines the element the controls should be listened from
  103093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103094. */
  103095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103096. /**
  103097. * Detach the current controls from the specified dom element.
  103098. * @param element Defines the element to stop listening the inputs from
  103099. */
  103100. detachControl(element: Nullable<HTMLElement>): void;
  103101. /**
  103102. * Gets the class name of the current intput.
  103103. * @returns the class name
  103104. */
  103105. getClassName(): string;
  103106. /**
  103107. * Get the friendly name associated with the input class.
  103108. * @returns the input friendly name
  103109. */
  103110. getSimpleName(): string;
  103111. }
  103112. }
  103113. declare module BABYLON {
  103114. /**
  103115. * Manage the pointers inputs to control an follow camera.
  103116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103117. */
  103118. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103119. /**
  103120. * Defines the camera the input is attached to.
  103121. */
  103122. camera: FollowCamera;
  103123. /**
  103124. * Gets the class name of the current input.
  103125. * @returns the class name
  103126. */
  103127. getClassName(): string;
  103128. /**
  103129. * Defines the pointer angular sensibility along the X axis or how fast is
  103130. * the camera rotating.
  103131. * A negative number will reverse the axis direction.
  103132. */
  103133. angularSensibilityX: number;
  103134. /**
  103135. * Defines the pointer angular sensibility along the Y axis or how fast is
  103136. * the camera rotating.
  103137. * A negative number will reverse the axis direction.
  103138. */
  103139. angularSensibilityY: number;
  103140. /**
  103141. * Defines the pointer pinch precision or how fast is the camera zooming.
  103142. * A negative number will reverse the axis direction.
  103143. */
  103144. pinchPrecision: number;
  103145. /**
  103146. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103147. * from 0.
  103148. * It defines the percentage of current camera.radius to use as delta when
  103149. * pinch zoom is used.
  103150. */
  103151. pinchDeltaPercentage: number;
  103152. /**
  103153. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103154. */
  103155. axisXControlRadius: boolean;
  103156. /**
  103157. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103158. */
  103159. axisXControlHeight: boolean;
  103160. /**
  103161. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103162. */
  103163. axisXControlRotation: boolean;
  103164. /**
  103165. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103166. */
  103167. axisYControlRadius: boolean;
  103168. /**
  103169. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103170. */
  103171. axisYControlHeight: boolean;
  103172. /**
  103173. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103174. */
  103175. axisYControlRotation: boolean;
  103176. /**
  103177. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103178. */
  103179. axisPinchControlRadius: boolean;
  103180. /**
  103181. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103182. */
  103183. axisPinchControlHeight: boolean;
  103184. /**
  103185. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103186. */
  103187. axisPinchControlRotation: boolean;
  103188. /**
  103189. * Log error messages if basic misconfiguration has occurred.
  103190. */
  103191. warningEnable: boolean;
  103192. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103193. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103194. private _warningCounter;
  103195. private _warning;
  103196. }
  103197. }
  103198. declare module BABYLON {
  103199. /**
  103200. * Default Inputs manager for the FollowCamera.
  103201. * It groups all the default supported inputs for ease of use.
  103202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103203. */
  103204. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103205. /**
  103206. * Instantiates a new FollowCameraInputsManager.
  103207. * @param camera Defines the camera the inputs belong to
  103208. */
  103209. constructor(camera: FollowCamera);
  103210. /**
  103211. * Add keyboard input support to the input manager.
  103212. * @returns the current input manager
  103213. */
  103214. addKeyboard(): FollowCameraInputsManager;
  103215. /**
  103216. * Add mouse wheel input support to the input manager.
  103217. * @returns the current input manager
  103218. */
  103219. addMouseWheel(): FollowCameraInputsManager;
  103220. /**
  103221. * Add pointers input support to the input manager.
  103222. * @returns the current input manager
  103223. */
  103224. addPointers(): FollowCameraInputsManager;
  103225. /**
  103226. * Add orientation input support to the input manager.
  103227. * @returns the current input manager
  103228. */
  103229. addVRDeviceOrientation(): FollowCameraInputsManager;
  103230. }
  103231. }
  103232. declare module BABYLON {
  103233. /**
  103234. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103235. * an arc rotate version arcFollowCamera are available.
  103236. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103237. */
  103238. export class FollowCamera extends TargetCamera {
  103239. /**
  103240. * Distance the follow camera should follow an object at
  103241. */
  103242. radius: number;
  103243. /**
  103244. * Minimum allowed distance of the camera to the axis of rotation
  103245. * (The camera can not get closer).
  103246. * This can help limiting how the Camera is able to move in the scene.
  103247. */
  103248. lowerRadiusLimit: Nullable<number>;
  103249. /**
  103250. * Maximum allowed distance of the camera to the axis of rotation
  103251. * (The camera can not get further).
  103252. * This can help limiting how the Camera is able to move in the scene.
  103253. */
  103254. upperRadiusLimit: Nullable<number>;
  103255. /**
  103256. * Define a rotation offset between the camera and the object it follows
  103257. */
  103258. rotationOffset: number;
  103259. /**
  103260. * Minimum allowed angle to camera position relative to target object.
  103261. * This can help limiting how the Camera is able to move in the scene.
  103262. */
  103263. lowerRotationOffsetLimit: Nullable<number>;
  103264. /**
  103265. * Maximum allowed angle to camera position relative to target object.
  103266. * This can help limiting how the Camera is able to move in the scene.
  103267. */
  103268. upperRotationOffsetLimit: Nullable<number>;
  103269. /**
  103270. * Define a height offset between the camera and the object it follows.
  103271. * It can help following an object from the top (like a car chaing a plane)
  103272. */
  103273. heightOffset: number;
  103274. /**
  103275. * Minimum allowed height of camera position relative to target object.
  103276. * This can help limiting how the Camera is able to move in the scene.
  103277. */
  103278. lowerHeightOffsetLimit: Nullable<number>;
  103279. /**
  103280. * Maximum allowed height of camera position relative to target object.
  103281. * This can help limiting how the Camera is able to move in the scene.
  103282. */
  103283. upperHeightOffsetLimit: Nullable<number>;
  103284. /**
  103285. * Define how fast the camera can accelerate to follow it s target.
  103286. */
  103287. cameraAcceleration: number;
  103288. /**
  103289. * Define the speed limit of the camera following an object.
  103290. */
  103291. maxCameraSpeed: number;
  103292. /**
  103293. * Define the target of the camera.
  103294. */
  103295. lockedTarget: Nullable<AbstractMesh>;
  103296. /**
  103297. * Defines the input associated with the camera.
  103298. */
  103299. inputs: FollowCameraInputsManager;
  103300. /**
  103301. * Instantiates the follow camera.
  103302. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103303. * @param name Define the name of the camera in the scene
  103304. * @param position Define the position of the camera
  103305. * @param scene Define the scene the camera belong to
  103306. * @param lockedTarget Define the target of the camera
  103307. */
  103308. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103309. private _follow;
  103310. /**
  103311. * Attached controls to the current camera.
  103312. * @param element Defines the element the controls should be listened from
  103313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103314. */
  103315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103316. /**
  103317. * Detach the current controls from the camera.
  103318. * The camera will stop reacting to inputs.
  103319. * @param element Defines the element to stop listening the inputs from
  103320. */
  103321. detachControl(element: HTMLElement): void;
  103322. /** @hidden */
  103323. _checkInputs(): void;
  103324. private _checkLimits;
  103325. /**
  103326. * Gets the camera class name.
  103327. * @returns the class name
  103328. */
  103329. getClassName(): string;
  103330. }
  103331. /**
  103332. * Arc Rotate version of the follow camera.
  103333. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103334. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103335. */
  103336. export class ArcFollowCamera extends TargetCamera {
  103337. /** The longitudinal angle of the camera */
  103338. alpha: number;
  103339. /** The latitudinal angle of the camera */
  103340. beta: number;
  103341. /** The radius of the camera from its target */
  103342. radius: number;
  103343. /** Define the camera target (the messh it should follow) */
  103344. target: Nullable<AbstractMesh>;
  103345. private _cartesianCoordinates;
  103346. /**
  103347. * Instantiates a new ArcFollowCamera
  103348. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103349. * @param name Define the name of the camera
  103350. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103351. * @param beta Define the rotation angle of the camera around the elevation axis
  103352. * @param radius Define the radius of the camera from its target point
  103353. * @param target Define the target of the camera
  103354. * @param scene Define the scene the camera belongs to
  103355. */
  103356. constructor(name: string,
  103357. /** The longitudinal angle of the camera */
  103358. alpha: number,
  103359. /** The latitudinal angle of the camera */
  103360. beta: number,
  103361. /** The radius of the camera from its target */
  103362. radius: number,
  103363. /** Define the camera target (the messh it should follow) */
  103364. target: Nullable<AbstractMesh>, scene: Scene);
  103365. private _follow;
  103366. /** @hidden */
  103367. _checkInputs(): void;
  103368. /**
  103369. * Returns the class name of the object.
  103370. * It is mostly used internally for serialization purposes.
  103371. */
  103372. getClassName(): string;
  103373. }
  103374. }
  103375. declare module BABYLON {
  103376. /**
  103377. * Manage the keyboard inputs to control the movement of a follow camera.
  103378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103379. */
  103380. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103381. /**
  103382. * Defines the camera the input is attached to.
  103383. */
  103384. camera: FollowCamera;
  103385. /**
  103386. * Defines the list of key codes associated with the up action (increase heightOffset)
  103387. */
  103388. keysHeightOffsetIncr: number[];
  103389. /**
  103390. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103391. */
  103392. keysHeightOffsetDecr: number[];
  103393. /**
  103394. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103395. */
  103396. keysHeightOffsetModifierAlt: boolean;
  103397. /**
  103398. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103399. */
  103400. keysHeightOffsetModifierCtrl: boolean;
  103401. /**
  103402. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103403. */
  103404. keysHeightOffsetModifierShift: boolean;
  103405. /**
  103406. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103407. */
  103408. keysRotationOffsetIncr: number[];
  103409. /**
  103410. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103411. */
  103412. keysRotationOffsetDecr: number[];
  103413. /**
  103414. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103415. */
  103416. keysRotationOffsetModifierAlt: boolean;
  103417. /**
  103418. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103419. */
  103420. keysRotationOffsetModifierCtrl: boolean;
  103421. /**
  103422. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103423. */
  103424. keysRotationOffsetModifierShift: boolean;
  103425. /**
  103426. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103427. */
  103428. keysRadiusIncr: number[];
  103429. /**
  103430. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103431. */
  103432. keysRadiusDecr: number[];
  103433. /**
  103434. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103435. */
  103436. keysRadiusModifierAlt: boolean;
  103437. /**
  103438. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103439. */
  103440. keysRadiusModifierCtrl: boolean;
  103441. /**
  103442. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103443. */
  103444. keysRadiusModifierShift: boolean;
  103445. /**
  103446. * Defines the rate of change of heightOffset.
  103447. */
  103448. heightSensibility: number;
  103449. /**
  103450. * Defines the rate of change of rotationOffset.
  103451. */
  103452. rotationSensibility: number;
  103453. /**
  103454. * Defines the rate of change of radius.
  103455. */
  103456. radiusSensibility: number;
  103457. private _keys;
  103458. private _ctrlPressed;
  103459. private _altPressed;
  103460. private _shiftPressed;
  103461. private _onCanvasBlurObserver;
  103462. private _onKeyboardObserver;
  103463. private _engine;
  103464. private _scene;
  103465. /**
  103466. * Attach the input controls to a specific dom element to get the input from.
  103467. * @param element Defines the element the controls should be listened from
  103468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103469. */
  103470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103471. /**
  103472. * Detach the current controls from the specified dom element.
  103473. * @param element Defines the element to stop listening the inputs from
  103474. */
  103475. detachControl(element: Nullable<HTMLElement>): void;
  103476. /**
  103477. * Update the current camera state depending on the inputs that have been used this frame.
  103478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103479. */
  103480. checkInputs(): void;
  103481. /**
  103482. * Gets the class name of the current input.
  103483. * @returns the class name
  103484. */
  103485. getClassName(): string;
  103486. /**
  103487. * Get the friendly name associated with the input class.
  103488. * @returns the input friendly name
  103489. */
  103490. getSimpleName(): string;
  103491. /**
  103492. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103493. * allow modification of the heightOffset value.
  103494. */
  103495. private _modifierHeightOffset;
  103496. /**
  103497. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103498. * allow modification of the rotationOffset value.
  103499. */
  103500. private _modifierRotationOffset;
  103501. /**
  103502. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103503. * allow modification of the radius value.
  103504. */
  103505. private _modifierRadius;
  103506. }
  103507. }
  103508. declare module BABYLON {
  103509. interface FreeCameraInputsManager {
  103510. /**
  103511. * @hidden
  103512. */
  103513. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103514. /**
  103515. * Add orientation input support to the input manager.
  103516. * @returns the current input manager
  103517. */
  103518. addDeviceOrientation(): FreeCameraInputsManager;
  103519. }
  103520. /**
  103521. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103522. * Screen rotation is taken into account.
  103523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103524. */
  103525. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103526. private _camera;
  103527. private _screenOrientationAngle;
  103528. private _constantTranform;
  103529. private _screenQuaternion;
  103530. private _alpha;
  103531. private _beta;
  103532. private _gamma;
  103533. /**
  103534. * Can be used to detect if a device orientation sensor is availible on a device
  103535. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103536. * @returns a promise that will resolve on orientation change
  103537. */
  103538. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103539. /**
  103540. * @hidden
  103541. */
  103542. _onDeviceOrientationChangedObservable: Observable<void>;
  103543. /**
  103544. * Instantiates a new input
  103545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103546. */
  103547. constructor();
  103548. /**
  103549. * Define the camera controlled by the input.
  103550. */
  103551. camera: FreeCamera;
  103552. /**
  103553. * Attach the input controls to a specific dom element to get the input from.
  103554. * @param element Defines the element the controls should be listened from
  103555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103556. */
  103557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103558. private _orientationChanged;
  103559. private _deviceOrientation;
  103560. /**
  103561. * Detach the current controls from the specified dom element.
  103562. * @param element Defines the element to stop listening the inputs from
  103563. */
  103564. detachControl(element: Nullable<HTMLElement>): void;
  103565. /**
  103566. * Update the current camera state depending on the inputs that have been used this frame.
  103567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103568. */
  103569. checkInputs(): void;
  103570. /**
  103571. * Gets the class name of the current intput.
  103572. * @returns the class name
  103573. */
  103574. getClassName(): string;
  103575. /**
  103576. * Get the friendly name associated with the input class.
  103577. * @returns the input friendly name
  103578. */
  103579. getSimpleName(): string;
  103580. }
  103581. }
  103582. declare module BABYLON {
  103583. /**
  103584. * Manage the gamepad inputs to control a free camera.
  103585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103586. */
  103587. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103588. /**
  103589. * Define the camera the input is attached to.
  103590. */
  103591. camera: FreeCamera;
  103592. /**
  103593. * Define the Gamepad controlling the input
  103594. */
  103595. gamepad: Nullable<Gamepad>;
  103596. /**
  103597. * Defines the gamepad rotation sensiblity.
  103598. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103599. */
  103600. gamepadAngularSensibility: number;
  103601. /**
  103602. * Defines the gamepad move sensiblity.
  103603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103604. */
  103605. gamepadMoveSensibility: number;
  103606. private _onGamepadConnectedObserver;
  103607. private _onGamepadDisconnectedObserver;
  103608. private _cameraTransform;
  103609. private _deltaTransform;
  103610. private _vector3;
  103611. private _vector2;
  103612. /**
  103613. * Attach the input controls to a specific dom element to get the input from.
  103614. * @param element Defines the element the controls should be listened from
  103615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103616. */
  103617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103618. /**
  103619. * Detach the current controls from the specified dom element.
  103620. * @param element Defines the element to stop listening the inputs from
  103621. */
  103622. detachControl(element: Nullable<HTMLElement>): void;
  103623. /**
  103624. * Update the current camera state depending on the inputs that have been used this frame.
  103625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103626. */
  103627. checkInputs(): void;
  103628. /**
  103629. * Gets the class name of the current intput.
  103630. * @returns the class name
  103631. */
  103632. getClassName(): string;
  103633. /**
  103634. * Get the friendly name associated with the input class.
  103635. * @returns the input friendly name
  103636. */
  103637. getSimpleName(): string;
  103638. }
  103639. }
  103640. declare module BABYLON {
  103641. /**
  103642. * Defines the potential axis of a Joystick
  103643. */
  103644. export enum JoystickAxis {
  103645. /** X axis */
  103646. X = 0,
  103647. /** Y axis */
  103648. Y = 1,
  103649. /** Z axis */
  103650. Z = 2
  103651. }
  103652. /**
  103653. * Class used to define virtual joystick (used in touch mode)
  103654. */
  103655. export class VirtualJoystick {
  103656. /**
  103657. * Gets or sets a boolean indicating that left and right values must be inverted
  103658. */
  103659. reverseLeftRight: boolean;
  103660. /**
  103661. * Gets or sets a boolean indicating that up and down values must be inverted
  103662. */
  103663. reverseUpDown: boolean;
  103664. /**
  103665. * Gets the offset value for the position (ie. the change of the position value)
  103666. */
  103667. deltaPosition: Vector3;
  103668. /**
  103669. * Gets a boolean indicating if the virtual joystick was pressed
  103670. */
  103671. pressed: boolean;
  103672. /**
  103673. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103674. */
  103675. static Canvas: Nullable<HTMLCanvasElement>;
  103676. private static _globalJoystickIndex;
  103677. private static vjCanvasContext;
  103678. private static vjCanvasWidth;
  103679. private static vjCanvasHeight;
  103680. private static halfWidth;
  103681. private _action;
  103682. private _axisTargetedByLeftAndRight;
  103683. private _axisTargetedByUpAndDown;
  103684. private _joystickSensibility;
  103685. private _inversedSensibility;
  103686. private _joystickPointerID;
  103687. private _joystickColor;
  103688. private _joystickPointerPos;
  103689. private _joystickPreviousPointerPos;
  103690. private _joystickPointerStartPos;
  103691. private _deltaJoystickVector;
  103692. private _leftJoystick;
  103693. private _touches;
  103694. private _onPointerDownHandlerRef;
  103695. private _onPointerMoveHandlerRef;
  103696. private _onPointerUpHandlerRef;
  103697. private _onResize;
  103698. /**
  103699. * Creates a new virtual joystick
  103700. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103701. */
  103702. constructor(leftJoystick?: boolean);
  103703. /**
  103704. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103705. * @param newJoystickSensibility defines the new sensibility
  103706. */
  103707. setJoystickSensibility(newJoystickSensibility: number): void;
  103708. private _onPointerDown;
  103709. private _onPointerMove;
  103710. private _onPointerUp;
  103711. /**
  103712. * Change the color of the virtual joystick
  103713. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103714. */
  103715. setJoystickColor(newColor: string): void;
  103716. /**
  103717. * Defines a callback to call when the joystick is touched
  103718. * @param action defines the callback
  103719. */
  103720. setActionOnTouch(action: () => any): void;
  103721. /**
  103722. * Defines which axis you'd like to control for left & right
  103723. * @param axis defines the axis to use
  103724. */
  103725. setAxisForLeftRight(axis: JoystickAxis): void;
  103726. /**
  103727. * Defines which axis you'd like to control for up & down
  103728. * @param axis defines the axis to use
  103729. */
  103730. setAxisForUpDown(axis: JoystickAxis): void;
  103731. private _drawVirtualJoystick;
  103732. /**
  103733. * Release internal HTML canvas
  103734. */
  103735. releaseCanvas(): void;
  103736. }
  103737. }
  103738. declare module BABYLON {
  103739. interface FreeCameraInputsManager {
  103740. /**
  103741. * Add virtual joystick input support to the input manager.
  103742. * @returns the current input manager
  103743. */
  103744. addVirtualJoystick(): FreeCameraInputsManager;
  103745. }
  103746. /**
  103747. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103749. */
  103750. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103751. /**
  103752. * Defines the camera the input is attached to.
  103753. */
  103754. camera: FreeCamera;
  103755. private _leftjoystick;
  103756. private _rightjoystick;
  103757. /**
  103758. * Gets the left stick of the virtual joystick.
  103759. * @returns The virtual Joystick
  103760. */
  103761. getLeftJoystick(): VirtualJoystick;
  103762. /**
  103763. * Gets the right stick of the virtual joystick.
  103764. * @returns The virtual Joystick
  103765. */
  103766. getRightJoystick(): VirtualJoystick;
  103767. /**
  103768. * Update the current camera state depending on the inputs that have been used this frame.
  103769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103770. */
  103771. checkInputs(): void;
  103772. /**
  103773. * Attach the input controls to a specific dom element to get the input from.
  103774. * @param element Defines the element the controls should be listened from
  103775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103776. */
  103777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103778. /**
  103779. * Detach the current controls from the specified dom element.
  103780. * @param element Defines the element to stop listening the inputs from
  103781. */
  103782. detachControl(element: Nullable<HTMLElement>): void;
  103783. /**
  103784. * Gets the class name of the current intput.
  103785. * @returns the class name
  103786. */
  103787. getClassName(): string;
  103788. /**
  103789. * Get the friendly name associated with the input class.
  103790. * @returns the input friendly name
  103791. */
  103792. getSimpleName(): string;
  103793. }
  103794. }
  103795. declare module BABYLON {
  103796. /**
  103797. * This represents a FPS type of camera controlled by touch.
  103798. * This is like a universal camera minus the Gamepad controls.
  103799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103800. */
  103801. export class TouchCamera extends FreeCamera {
  103802. /**
  103803. * Defines the touch sensibility for rotation.
  103804. * The higher the faster.
  103805. */
  103806. touchAngularSensibility: number;
  103807. /**
  103808. * Defines the touch sensibility for move.
  103809. * The higher the faster.
  103810. */
  103811. touchMoveSensibility: number;
  103812. /**
  103813. * Instantiates a new touch camera.
  103814. * This represents a FPS type of camera controlled by touch.
  103815. * This is like a universal camera minus the Gamepad controls.
  103816. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103817. * @param name Define the name of the camera in the scene
  103818. * @param position Define the start position of the camera in the scene
  103819. * @param scene Define the scene the camera belongs to
  103820. */
  103821. constructor(name: string, position: Vector3, scene: Scene);
  103822. /**
  103823. * Gets the current object class name.
  103824. * @return the class name
  103825. */
  103826. getClassName(): string;
  103827. /** @hidden */
  103828. _setupInputs(): void;
  103829. }
  103830. }
  103831. declare module BABYLON {
  103832. /**
  103833. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103834. * being tilted forward or back and left or right.
  103835. */
  103836. export class DeviceOrientationCamera extends FreeCamera {
  103837. private _initialQuaternion;
  103838. private _quaternionCache;
  103839. private _tmpDragQuaternion;
  103840. private _disablePointerInputWhenUsingDeviceOrientation;
  103841. /**
  103842. * Creates a new device orientation camera
  103843. * @param name The name of the camera
  103844. * @param position The start position camera
  103845. * @param scene The scene the camera belongs to
  103846. */
  103847. constructor(name: string, position: Vector3, scene: Scene);
  103848. /**
  103849. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103850. */
  103851. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103852. private _dragFactor;
  103853. /**
  103854. * Enabled turning on the y axis when the orientation sensor is active
  103855. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103856. */
  103857. enableHorizontalDragging(dragFactor?: number): void;
  103858. /**
  103859. * Gets the current instance class name ("DeviceOrientationCamera").
  103860. * This helps avoiding instanceof at run time.
  103861. * @returns the class name
  103862. */
  103863. getClassName(): string;
  103864. /**
  103865. * @hidden
  103866. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103867. */
  103868. _checkInputs(): void;
  103869. /**
  103870. * Reset the camera to its default orientation on the specified axis only.
  103871. * @param axis The axis to reset
  103872. */
  103873. resetToCurrentRotation(axis?: Axis): void;
  103874. }
  103875. }
  103876. declare module BABYLON {
  103877. /**
  103878. * Defines supported buttons for XBox360 compatible gamepads
  103879. */
  103880. export enum Xbox360Button {
  103881. /** A */
  103882. A = 0,
  103883. /** B */
  103884. B = 1,
  103885. /** X */
  103886. X = 2,
  103887. /** Y */
  103888. Y = 3,
  103889. /** Start */
  103890. Start = 4,
  103891. /** Back */
  103892. Back = 5,
  103893. /** Left button */
  103894. LB = 6,
  103895. /** Right button */
  103896. RB = 7,
  103897. /** Left stick */
  103898. LeftStick = 8,
  103899. /** Right stick */
  103900. RightStick = 9
  103901. }
  103902. /** Defines values for XBox360 DPad */
  103903. export enum Xbox360Dpad {
  103904. /** Up */
  103905. Up = 0,
  103906. /** Down */
  103907. Down = 1,
  103908. /** Left */
  103909. Left = 2,
  103910. /** Right */
  103911. Right = 3
  103912. }
  103913. /**
  103914. * Defines a XBox360 gamepad
  103915. */
  103916. export class Xbox360Pad extends Gamepad {
  103917. private _leftTrigger;
  103918. private _rightTrigger;
  103919. private _onlefttriggerchanged;
  103920. private _onrighttriggerchanged;
  103921. private _onbuttondown;
  103922. private _onbuttonup;
  103923. private _ondpaddown;
  103924. private _ondpadup;
  103925. /** Observable raised when a button is pressed */
  103926. onButtonDownObservable: Observable<Xbox360Button>;
  103927. /** Observable raised when a button is released */
  103928. onButtonUpObservable: Observable<Xbox360Button>;
  103929. /** Observable raised when a pad is pressed */
  103930. onPadDownObservable: Observable<Xbox360Dpad>;
  103931. /** Observable raised when a pad is released */
  103932. onPadUpObservable: Observable<Xbox360Dpad>;
  103933. private _buttonA;
  103934. private _buttonB;
  103935. private _buttonX;
  103936. private _buttonY;
  103937. private _buttonBack;
  103938. private _buttonStart;
  103939. private _buttonLB;
  103940. private _buttonRB;
  103941. private _buttonLeftStick;
  103942. private _buttonRightStick;
  103943. private _dPadUp;
  103944. private _dPadDown;
  103945. private _dPadLeft;
  103946. private _dPadRight;
  103947. private _isXboxOnePad;
  103948. /**
  103949. * Creates a new XBox360 gamepad object
  103950. * @param id defines the id of this gamepad
  103951. * @param index defines its index
  103952. * @param gamepad defines the internal HTML gamepad object
  103953. * @param xboxOne defines if it is a XBox One gamepad
  103954. */
  103955. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103956. /**
  103957. * Defines the callback to call when left trigger is pressed
  103958. * @param callback defines the callback to use
  103959. */
  103960. onlefttriggerchanged(callback: (value: number) => void): void;
  103961. /**
  103962. * Defines the callback to call when right trigger is pressed
  103963. * @param callback defines the callback to use
  103964. */
  103965. onrighttriggerchanged(callback: (value: number) => void): void;
  103966. /**
  103967. * Gets the left trigger value
  103968. */
  103969. /**
  103970. * Sets the left trigger value
  103971. */
  103972. leftTrigger: number;
  103973. /**
  103974. * Gets the right trigger value
  103975. */
  103976. /**
  103977. * Sets the right trigger value
  103978. */
  103979. rightTrigger: number;
  103980. /**
  103981. * Defines the callback to call when a button is pressed
  103982. * @param callback defines the callback to use
  103983. */
  103984. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103985. /**
  103986. * Defines the callback to call when a button is released
  103987. * @param callback defines the callback to use
  103988. */
  103989. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103990. /**
  103991. * Defines the callback to call when a pad is pressed
  103992. * @param callback defines the callback to use
  103993. */
  103994. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103995. /**
  103996. * Defines the callback to call when a pad is released
  103997. * @param callback defines the callback to use
  103998. */
  103999. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104000. private _setButtonValue;
  104001. private _setDPadValue;
  104002. /**
  104003. * Gets the value of the `A` button
  104004. */
  104005. /**
  104006. * Sets the value of the `A` button
  104007. */
  104008. buttonA: number;
  104009. /**
  104010. * Gets the value of the `B` button
  104011. */
  104012. /**
  104013. * Sets the value of the `B` button
  104014. */
  104015. buttonB: number;
  104016. /**
  104017. * Gets the value of the `X` button
  104018. */
  104019. /**
  104020. * Sets the value of the `X` button
  104021. */
  104022. buttonX: number;
  104023. /**
  104024. * Gets the value of the `Y` button
  104025. */
  104026. /**
  104027. * Sets the value of the `Y` button
  104028. */
  104029. buttonY: number;
  104030. /**
  104031. * Gets the value of the `Start` button
  104032. */
  104033. /**
  104034. * Sets the value of the `Start` button
  104035. */
  104036. buttonStart: number;
  104037. /**
  104038. * Gets the value of the `Back` button
  104039. */
  104040. /**
  104041. * Sets the value of the `Back` button
  104042. */
  104043. buttonBack: number;
  104044. /**
  104045. * Gets the value of the `Left` button
  104046. */
  104047. /**
  104048. * Sets the value of the `Left` button
  104049. */
  104050. buttonLB: number;
  104051. /**
  104052. * Gets the value of the `Right` button
  104053. */
  104054. /**
  104055. * Sets the value of the `Right` button
  104056. */
  104057. buttonRB: number;
  104058. /**
  104059. * Gets the value of the Left joystick
  104060. */
  104061. /**
  104062. * Sets the value of the Left joystick
  104063. */
  104064. buttonLeftStick: number;
  104065. /**
  104066. * Gets the value of the Right joystick
  104067. */
  104068. /**
  104069. * Sets the value of the Right joystick
  104070. */
  104071. buttonRightStick: number;
  104072. /**
  104073. * Gets the value of D-pad up
  104074. */
  104075. /**
  104076. * Sets the value of D-pad up
  104077. */
  104078. dPadUp: number;
  104079. /**
  104080. * Gets the value of D-pad down
  104081. */
  104082. /**
  104083. * Sets the value of D-pad down
  104084. */
  104085. dPadDown: number;
  104086. /**
  104087. * Gets the value of D-pad left
  104088. */
  104089. /**
  104090. * Sets the value of D-pad left
  104091. */
  104092. dPadLeft: number;
  104093. /**
  104094. * Gets the value of D-pad right
  104095. */
  104096. /**
  104097. * Sets the value of D-pad right
  104098. */
  104099. dPadRight: number;
  104100. /**
  104101. * Force the gamepad to synchronize with device values
  104102. */
  104103. update(): void;
  104104. /**
  104105. * Disposes the gamepad
  104106. */
  104107. dispose(): void;
  104108. }
  104109. }
  104110. declare module BABYLON {
  104111. /**
  104112. * Defines supported buttons for DualShock compatible gamepads
  104113. */
  104114. export enum DualShockButton {
  104115. /** Cross */
  104116. Cross = 0,
  104117. /** Circle */
  104118. Circle = 1,
  104119. /** Square */
  104120. Square = 2,
  104121. /** Triangle */
  104122. Triangle = 3,
  104123. /** Options */
  104124. Options = 4,
  104125. /** Share */
  104126. Share = 5,
  104127. /** L1 */
  104128. L1 = 6,
  104129. /** R1 */
  104130. R1 = 7,
  104131. /** Left stick */
  104132. LeftStick = 8,
  104133. /** Right stick */
  104134. RightStick = 9
  104135. }
  104136. /** Defines values for DualShock DPad */
  104137. export enum DualShockDpad {
  104138. /** Up */
  104139. Up = 0,
  104140. /** Down */
  104141. Down = 1,
  104142. /** Left */
  104143. Left = 2,
  104144. /** Right */
  104145. Right = 3
  104146. }
  104147. /**
  104148. * Defines a DualShock gamepad
  104149. */
  104150. export class DualShockPad extends Gamepad {
  104151. private _leftTrigger;
  104152. private _rightTrigger;
  104153. private _onlefttriggerchanged;
  104154. private _onrighttriggerchanged;
  104155. private _onbuttondown;
  104156. private _onbuttonup;
  104157. private _ondpaddown;
  104158. private _ondpadup;
  104159. /** Observable raised when a button is pressed */
  104160. onButtonDownObservable: Observable<DualShockButton>;
  104161. /** Observable raised when a button is released */
  104162. onButtonUpObservable: Observable<DualShockButton>;
  104163. /** Observable raised when a pad is pressed */
  104164. onPadDownObservable: Observable<DualShockDpad>;
  104165. /** Observable raised when a pad is released */
  104166. onPadUpObservable: Observable<DualShockDpad>;
  104167. private _buttonCross;
  104168. private _buttonCircle;
  104169. private _buttonSquare;
  104170. private _buttonTriangle;
  104171. private _buttonShare;
  104172. private _buttonOptions;
  104173. private _buttonL1;
  104174. private _buttonR1;
  104175. private _buttonLeftStick;
  104176. private _buttonRightStick;
  104177. private _dPadUp;
  104178. private _dPadDown;
  104179. private _dPadLeft;
  104180. private _dPadRight;
  104181. /**
  104182. * Creates a new DualShock gamepad object
  104183. * @param id defines the id of this gamepad
  104184. * @param index defines its index
  104185. * @param gamepad defines the internal HTML gamepad object
  104186. */
  104187. constructor(id: string, index: number, gamepad: any);
  104188. /**
  104189. * Defines the callback to call when left trigger is pressed
  104190. * @param callback defines the callback to use
  104191. */
  104192. onlefttriggerchanged(callback: (value: number) => void): void;
  104193. /**
  104194. * Defines the callback to call when right trigger is pressed
  104195. * @param callback defines the callback to use
  104196. */
  104197. onrighttriggerchanged(callback: (value: number) => void): void;
  104198. /**
  104199. * Gets the left trigger value
  104200. */
  104201. /**
  104202. * Sets the left trigger value
  104203. */
  104204. leftTrigger: number;
  104205. /**
  104206. * Gets the right trigger value
  104207. */
  104208. /**
  104209. * Sets the right trigger value
  104210. */
  104211. rightTrigger: number;
  104212. /**
  104213. * Defines the callback to call when a button is pressed
  104214. * @param callback defines the callback to use
  104215. */
  104216. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104217. /**
  104218. * Defines the callback to call when a button is released
  104219. * @param callback defines the callback to use
  104220. */
  104221. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104222. /**
  104223. * Defines the callback to call when a pad is pressed
  104224. * @param callback defines the callback to use
  104225. */
  104226. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104227. /**
  104228. * Defines the callback to call when a pad is released
  104229. * @param callback defines the callback to use
  104230. */
  104231. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104232. private _setButtonValue;
  104233. private _setDPadValue;
  104234. /**
  104235. * Gets the value of the `Cross` button
  104236. */
  104237. /**
  104238. * Sets the value of the `Cross` button
  104239. */
  104240. buttonCross: number;
  104241. /**
  104242. * Gets the value of the `Circle` button
  104243. */
  104244. /**
  104245. * Sets the value of the `Circle` button
  104246. */
  104247. buttonCircle: number;
  104248. /**
  104249. * Gets the value of the `Square` button
  104250. */
  104251. /**
  104252. * Sets the value of the `Square` button
  104253. */
  104254. buttonSquare: number;
  104255. /**
  104256. * Gets the value of the `Triangle` button
  104257. */
  104258. /**
  104259. * Sets the value of the `Triangle` button
  104260. */
  104261. buttonTriangle: number;
  104262. /**
  104263. * Gets the value of the `Options` button
  104264. */
  104265. /**
  104266. * Sets the value of the `Options` button
  104267. */
  104268. buttonOptions: number;
  104269. /**
  104270. * Gets the value of the `Share` button
  104271. */
  104272. /**
  104273. * Sets the value of the `Share` button
  104274. */
  104275. buttonShare: number;
  104276. /**
  104277. * Gets the value of the `L1` button
  104278. */
  104279. /**
  104280. * Sets the value of the `L1` button
  104281. */
  104282. buttonL1: number;
  104283. /**
  104284. * Gets the value of the `R1` button
  104285. */
  104286. /**
  104287. * Sets the value of the `R1` button
  104288. */
  104289. buttonR1: number;
  104290. /**
  104291. * Gets the value of the Left joystick
  104292. */
  104293. /**
  104294. * Sets the value of the Left joystick
  104295. */
  104296. buttonLeftStick: number;
  104297. /**
  104298. * Gets the value of the Right joystick
  104299. */
  104300. /**
  104301. * Sets the value of the Right joystick
  104302. */
  104303. buttonRightStick: number;
  104304. /**
  104305. * Gets the value of D-pad up
  104306. */
  104307. /**
  104308. * Sets the value of D-pad up
  104309. */
  104310. dPadUp: number;
  104311. /**
  104312. * Gets the value of D-pad down
  104313. */
  104314. /**
  104315. * Sets the value of D-pad down
  104316. */
  104317. dPadDown: number;
  104318. /**
  104319. * Gets the value of D-pad left
  104320. */
  104321. /**
  104322. * Sets the value of D-pad left
  104323. */
  104324. dPadLeft: number;
  104325. /**
  104326. * Gets the value of D-pad right
  104327. */
  104328. /**
  104329. * Sets the value of D-pad right
  104330. */
  104331. dPadRight: number;
  104332. /**
  104333. * Force the gamepad to synchronize with device values
  104334. */
  104335. update(): void;
  104336. /**
  104337. * Disposes the gamepad
  104338. */
  104339. dispose(): void;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * Manager for handling gamepads
  104345. */
  104346. export class GamepadManager {
  104347. private _scene?;
  104348. private _babylonGamepads;
  104349. private _oneGamepadConnected;
  104350. /** @hidden */
  104351. _isMonitoring: boolean;
  104352. private _gamepadEventSupported;
  104353. private _gamepadSupport;
  104354. /**
  104355. * observable to be triggered when the gamepad controller has been connected
  104356. */
  104357. onGamepadConnectedObservable: Observable<Gamepad>;
  104358. /**
  104359. * observable to be triggered when the gamepad controller has been disconnected
  104360. */
  104361. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104362. private _onGamepadConnectedEvent;
  104363. private _onGamepadDisconnectedEvent;
  104364. /**
  104365. * Initializes the gamepad manager
  104366. * @param _scene BabylonJS scene
  104367. */
  104368. constructor(_scene?: Scene | undefined);
  104369. /**
  104370. * The gamepads in the game pad manager
  104371. */
  104372. readonly gamepads: Gamepad[];
  104373. /**
  104374. * Get the gamepad controllers based on type
  104375. * @param type The type of gamepad controller
  104376. * @returns Nullable gamepad
  104377. */
  104378. getGamepadByType(type?: number): Nullable<Gamepad>;
  104379. /**
  104380. * Disposes the gamepad manager
  104381. */
  104382. dispose(): void;
  104383. private _addNewGamepad;
  104384. private _startMonitoringGamepads;
  104385. private _stopMonitoringGamepads;
  104386. /** @hidden */
  104387. _checkGamepadsStatus(): void;
  104388. private _updateGamepadObjects;
  104389. }
  104390. }
  104391. declare module BABYLON {
  104392. interface Scene {
  104393. /** @hidden */
  104394. _gamepadManager: Nullable<GamepadManager>;
  104395. /**
  104396. * Gets the gamepad manager associated with the scene
  104397. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104398. */
  104399. gamepadManager: GamepadManager;
  104400. }
  104401. /**
  104402. * Interface representing a free camera inputs manager
  104403. */
  104404. interface FreeCameraInputsManager {
  104405. /**
  104406. * Adds gamepad input support to the FreeCameraInputsManager.
  104407. * @returns the FreeCameraInputsManager
  104408. */
  104409. addGamepad(): FreeCameraInputsManager;
  104410. }
  104411. /**
  104412. * Interface representing an arc rotate camera inputs manager
  104413. */
  104414. interface ArcRotateCameraInputsManager {
  104415. /**
  104416. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104417. * @returns the camera inputs manager
  104418. */
  104419. addGamepad(): ArcRotateCameraInputsManager;
  104420. }
  104421. /**
  104422. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104423. */
  104424. export class GamepadSystemSceneComponent implements ISceneComponent {
  104425. /**
  104426. * The component name helpfull to identify the component in the list of scene components.
  104427. */
  104428. readonly name: string;
  104429. /**
  104430. * The scene the component belongs to.
  104431. */
  104432. scene: Scene;
  104433. /**
  104434. * Creates a new instance of the component for the given scene
  104435. * @param scene Defines the scene to register the component in
  104436. */
  104437. constructor(scene: Scene);
  104438. /**
  104439. * Registers the component in a given scene
  104440. */
  104441. register(): void;
  104442. /**
  104443. * Rebuilds the elements related to this component in case of
  104444. * context lost for instance.
  104445. */
  104446. rebuild(): void;
  104447. /**
  104448. * Disposes the component and the associated ressources
  104449. */
  104450. dispose(): void;
  104451. private _beforeCameraUpdate;
  104452. }
  104453. }
  104454. declare module BABYLON {
  104455. /**
  104456. * 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,
  104457. * which still works and will still be found in many Playgrounds.
  104458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104459. */
  104460. export class UniversalCamera extends TouchCamera {
  104461. /**
  104462. * Defines the gamepad rotation sensiblity.
  104463. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104464. */
  104465. gamepadAngularSensibility: number;
  104466. /**
  104467. * Defines the gamepad move sensiblity.
  104468. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104469. */
  104470. gamepadMoveSensibility: number;
  104471. /**
  104472. * 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,
  104473. * which still works and will still be found in many Playgrounds.
  104474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104475. * @param name Define the name of the camera in the scene
  104476. * @param position Define the start position of the camera in the scene
  104477. * @param scene Define the scene the camera belongs to
  104478. */
  104479. constructor(name: string, position: Vector3, scene: Scene);
  104480. /**
  104481. * Gets the current object class name.
  104482. * @return the class name
  104483. */
  104484. getClassName(): string;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * This represents a FPS type of camera. This is only here for back compat purpose.
  104490. * Please use the UniversalCamera instead as both are identical.
  104491. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104492. */
  104493. export class GamepadCamera extends UniversalCamera {
  104494. /**
  104495. * Instantiates a new Gamepad Camera
  104496. * This represents a FPS type of camera. This is only here for back compat purpose.
  104497. * Please use the UniversalCamera instead as both are identical.
  104498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104499. * @param name Define the name of the camera in the scene
  104500. * @param position Define the start position of the camera in the scene
  104501. * @param scene Define the scene the camera belongs to
  104502. */
  104503. constructor(name: string, position: Vector3, scene: Scene);
  104504. /**
  104505. * Gets the current object class name.
  104506. * @return the class name
  104507. */
  104508. getClassName(): string;
  104509. }
  104510. }
  104511. declare module BABYLON {
  104512. /** @hidden */
  104513. export var passPixelShader: {
  104514. name: string;
  104515. shader: string;
  104516. };
  104517. }
  104518. declare module BABYLON {
  104519. /** @hidden */
  104520. export var passCubePixelShader: {
  104521. name: string;
  104522. shader: string;
  104523. };
  104524. }
  104525. declare module BABYLON {
  104526. /**
  104527. * PassPostProcess which produces an output the same as it's input
  104528. */
  104529. export class PassPostProcess extends PostProcess {
  104530. /**
  104531. * Creates the PassPostProcess
  104532. * @param name The name of the effect.
  104533. * @param options The required width/height ratio to downsize to before computing the render pass.
  104534. * @param camera The camera to apply the render pass to.
  104535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104536. * @param engine The engine which the post process will be applied. (default: current engine)
  104537. * @param reusable If the post process can be reused on the same frame. (default: false)
  104538. * @param textureType The type of texture to be used when performing the post processing.
  104539. * @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)
  104540. */
  104541. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104542. }
  104543. /**
  104544. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104545. */
  104546. export class PassCubePostProcess extends PostProcess {
  104547. private _face;
  104548. /**
  104549. * Gets or sets the cube face to display.
  104550. * * 0 is +X
  104551. * * 1 is -X
  104552. * * 2 is +Y
  104553. * * 3 is -Y
  104554. * * 4 is +Z
  104555. * * 5 is -Z
  104556. */
  104557. face: number;
  104558. /**
  104559. * Creates the PassCubePostProcess
  104560. * @param name The name of the effect.
  104561. * @param options The required width/height ratio to downsize to before computing the render pass.
  104562. * @param camera The camera to apply the render pass to.
  104563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104564. * @param engine The engine which the post process will be applied. (default: current engine)
  104565. * @param reusable If the post process can be reused on the same frame. (default: false)
  104566. * @param textureType The type of texture to be used when performing the post processing.
  104567. * @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)
  104568. */
  104569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104570. }
  104571. }
  104572. declare module BABYLON {
  104573. /** @hidden */
  104574. export var anaglyphPixelShader: {
  104575. name: string;
  104576. shader: string;
  104577. };
  104578. }
  104579. declare module BABYLON {
  104580. /**
  104581. * Postprocess used to generate anaglyphic rendering
  104582. */
  104583. export class AnaglyphPostProcess extends PostProcess {
  104584. private _passedProcess;
  104585. /**
  104586. * Creates a new AnaglyphPostProcess
  104587. * @param name defines postprocess name
  104588. * @param options defines creation options or target ratio scale
  104589. * @param rigCameras defines cameras using this postprocess
  104590. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104591. * @param engine defines hosting engine
  104592. * @param reusable defines if the postprocess will be reused multiple times per frame
  104593. */
  104594. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104595. }
  104596. }
  104597. declare module BABYLON {
  104598. /**
  104599. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104600. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104601. */
  104602. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104603. /**
  104604. * Creates a new AnaglyphArcRotateCamera
  104605. * @param name defines camera name
  104606. * @param alpha defines alpha angle (in radians)
  104607. * @param beta defines beta angle (in radians)
  104608. * @param radius defines radius
  104609. * @param target defines camera target
  104610. * @param interaxialDistance defines distance between each color axis
  104611. * @param scene defines the hosting scene
  104612. */
  104613. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104614. /**
  104615. * Gets camera class name
  104616. * @returns AnaglyphArcRotateCamera
  104617. */
  104618. getClassName(): string;
  104619. }
  104620. }
  104621. declare module BABYLON {
  104622. /**
  104623. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104624. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104625. */
  104626. export class AnaglyphFreeCamera extends FreeCamera {
  104627. /**
  104628. * Creates a new AnaglyphFreeCamera
  104629. * @param name defines camera name
  104630. * @param position defines initial position
  104631. * @param interaxialDistance defines distance between each color axis
  104632. * @param scene defines the hosting scene
  104633. */
  104634. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104635. /**
  104636. * Gets camera class name
  104637. * @returns AnaglyphFreeCamera
  104638. */
  104639. getClassName(): string;
  104640. }
  104641. }
  104642. declare module BABYLON {
  104643. /**
  104644. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104645. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104646. */
  104647. export class AnaglyphGamepadCamera extends GamepadCamera {
  104648. /**
  104649. * Creates a new AnaglyphGamepadCamera
  104650. * @param name defines camera name
  104651. * @param position defines initial position
  104652. * @param interaxialDistance defines distance between each color axis
  104653. * @param scene defines the hosting scene
  104654. */
  104655. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104656. /**
  104657. * Gets camera class name
  104658. * @returns AnaglyphGamepadCamera
  104659. */
  104660. getClassName(): string;
  104661. }
  104662. }
  104663. declare module BABYLON {
  104664. /**
  104665. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104666. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104667. */
  104668. export class AnaglyphUniversalCamera extends UniversalCamera {
  104669. /**
  104670. * Creates a new AnaglyphUniversalCamera
  104671. * @param name defines camera name
  104672. * @param position defines initial position
  104673. * @param interaxialDistance defines distance between each color axis
  104674. * @param scene defines the hosting scene
  104675. */
  104676. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104677. /**
  104678. * Gets camera class name
  104679. * @returns AnaglyphUniversalCamera
  104680. */
  104681. getClassName(): string;
  104682. }
  104683. }
  104684. declare module BABYLON {
  104685. /** @hidden */
  104686. export var stereoscopicInterlacePixelShader: {
  104687. name: string;
  104688. shader: string;
  104689. };
  104690. }
  104691. declare module BABYLON {
  104692. /**
  104693. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104694. */
  104695. export class StereoscopicInterlacePostProcess extends PostProcess {
  104696. private _stepSize;
  104697. private _passedProcess;
  104698. /**
  104699. * Initializes a StereoscopicInterlacePostProcess
  104700. * @param name The name of the effect.
  104701. * @param rigCameras The rig cameras to be appled to the post process
  104702. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104704. * @param engine The engine which the post process will be applied. (default: current engine)
  104705. * @param reusable If the post process can be reused on the same frame. (default: false)
  104706. */
  104707. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104708. }
  104709. }
  104710. declare module BABYLON {
  104711. /**
  104712. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104713. * @see http://doc.babylonjs.com/features/cameras
  104714. */
  104715. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104716. /**
  104717. * Creates a new StereoscopicArcRotateCamera
  104718. * @param name defines camera name
  104719. * @param alpha defines alpha angle (in radians)
  104720. * @param beta defines beta angle (in radians)
  104721. * @param radius defines radius
  104722. * @param target defines camera target
  104723. * @param interaxialDistance defines distance between each color axis
  104724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104725. * @param scene defines the hosting scene
  104726. */
  104727. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104728. /**
  104729. * Gets camera class name
  104730. * @returns StereoscopicArcRotateCamera
  104731. */
  104732. getClassName(): string;
  104733. }
  104734. }
  104735. declare module BABYLON {
  104736. /**
  104737. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104738. * @see http://doc.babylonjs.com/features/cameras
  104739. */
  104740. export class StereoscopicFreeCamera extends FreeCamera {
  104741. /**
  104742. * Creates a new StereoscopicFreeCamera
  104743. * @param name defines camera name
  104744. * @param position defines initial position
  104745. * @param interaxialDistance defines distance between each color axis
  104746. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104747. * @param scene defines the hosting scene
  104748. */
  104749. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104750. /**
  104751. * Gets camera class name
  104752. * @returns StereoscopicFreeCamera
  104753. */
  104754. getClassName(): string;
  104755. }
  104756. }
  104757. declare module BABYLON {
  104758. /**
  104759. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104760. * @see http://doc.babylonjs.com/features/cameras
  104761. */
  104762. export class StereoscopicGamepadCamera extends GamepadCamera {
  104763. /**
  104764. * Creates a new StereoscopicGamepadCamera
  104765. * @param name defines camera name
  104766. * @param position defines initial position
  104767. * @param interaxialDistance defines distance between each color axis
  104768. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104769. * @param scene defines the hosting scene
  104770. */
  104771. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104772. /**
  104773. * Gets camera class name
  104774. * @returns StereoscopicGamepadCamera
  104775. */
  104776. getClassName(): string;
  104777. }
  104778. }
  104779. declare module BABYLON {
  104780. /**
  104781. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104782. * @see http://doc.babylonjs.com/features/cameras
  104783. */
  104784. export class StereoscopicUniversalCamera extends UniversalCamera {
  104785. /**
  104786. * Creates a new StereoscopicUniversalCamera
  104787. * @param name defines camera name
  104788. * @param position defines initial position
  104789. * @param interaxialDistance defines distance between each color axis
  104790. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104791. * @param scene defines the hosting scene
  104792. */
  104793. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104794. /**
  104795. * Gets camera class name
  104796. * @returns StereoscopicUniversalCamera
  104797. */
  104798. getClassName(): string;
  104799. }
  104800. }
  104801. declare module BABYLON {
  104802. /**
  104803. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104804. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104805. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104806. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104807. */
  104808. export class VirtualJoysticksCamera extends FreeCamera {
  104809. /**
  104810. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104814. * @param name Define the name of the camera in the scene
  104815. * @param position Define the start position of the camera in the scene
  104816. * @param scene Define the scene the camera belongs to
  104817. */
  104818. constructor(name: string, position: Vector3, scene: Scene);
  104819. /**
  104820. * Gets the current object class name.
  104821. * @return the class name
  104822. */
  104823. getClassName(): string;
  104824. }
  104825. }
  104826. declare module BABYLON {
  104827. /**
  104828. * This represents all the required metrics to create a VR camera.
  104829. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104830. */
  104831. export class VRCameraMetrics {
  104832. /**
  104833. * Define the horizontal resolution off the screen.
  104834. */
  104835. hResolution: number;
  104836. /**
  104837. * Define the vertical resolution off the screen.
  104838. */
  104839. vResolution: number;
  104840. /**
  104841. * Define the horizontal screen size.
  104842. */
  104843. hScreenSize: number;
  104844. /**
  104845. * Define the vertical screen size.
  104846. */
  104847. vScreenSize: number;
  104848. /**
  104849. * Define the vertical screen center position.
  104850. */
  104851. vScreenCenter: number;
  104852. /**
  104853. * Define the distance of the eyes to the screen.
  104854. */
  104855. eyeToScreenDistance: number;
  104856. /**
  104857. * Define the distance between both lenses
  104858. */
  104859. lensSeparationDistance: number;
  104860. /**
  104861. * Define the distance between both viewer's eyes.
  104862. */
  104863. interpupillaryDistance: number;
  104864. /**
  104865. * Define the distortion factor of the VR postprocess.
  104866. * Please, touch with care.
  104867. */
  104868. distortionK: number[];
  104869. /**
  104870. * Define the chromatic aberration correction factors for the VR post process.
  104871. */
  104872. chromaAbCorrection: number[];
  104873. /**
  104874. * Define the scale factor of the post process.
  104875. * The smaller the better but the slower.
  104876. */
  104877. postProcessScaleFactor: number;
  104878. /**
  104879. * Define an offset for the lens center.
  104880. */
  104881. lensCenterOffset: number;
  104882. /**
  104883. * Define if the current vr camera should compensate the distortion of the lense or not.
  104884. */
  104885. compensateDistortion: boolean;
  104886. /**
  104887. * Defines if multiview should be enabled when rendering (Default: false)
  104888. */
  104889. multiviewEnabled: boolean;
  104890. /**
  104891. * Gets the rendering aspect ratio based on the provided resolutions.
  104892. */
  104893. readonly aspectRatio: number;
  104894. /**
  104895. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104896. */
  104897. readonly aspectRatioFov: number;
  104898. /**
  104899. * @hidden
  104900. */
  104901. readonly leftHMatrix: Matrix;
  104902. /**
  104903. * @hidden
  104904. */
  104905. readonly rightHMatrix: Matrix;
  104906. /**
  104907. * @hidden
  104908. */
  104909. readonly leftPreViewMatrix: Matrix;
  104910. /**
  104911. * @hidden
  104912. */
  104913. readonly rightPreViewMatrix: Matrix;
  104914. /**
  104915. * Get the default VRMetrics based on the most generic setup.
  104916. * @returns the default vr metrics
  104917. */
  104918. static GetDefault(): VRCameraMetrics;
  104919. }
  104920. }
  104921. declare module BABYLON {
  104922. /** @hidden */
  104923. export var vrDistortionCorrectionPixelShader: {
  104924. name: string;
  104925. shader: string;
  104926. };
  104927. }
  104928. declare module BABYLON {
  104929. /**
  104930. * VRDistortionCorrectionPostProcess used for mobile VR
  104931. */
  104932. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104933. private _isRightEye;
  104934. private _distortionFactors;
  104935. private _postProcessScaleFactor;
  104936. private _lensCenterOffset;
  104937. private _scaleIn;
  104938. private _scaleFactor;
  104939. private _lensCenter;
  104940. /**
  104941. * Initializes the VRDistortionCorrectionPostProcess
  104942. * @param name The name of the effect.
  104943. * @param camera The camera to apply the render pass to.
  104944. * @param isRightEye If this is for the right eye distortion
  104945. * @param vrMetrics All the required metrics for the VR camera
  104946. */
  104947. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104948. }
  104949. }
  104950. declare module BABYLON {
  104951. /**
  104952. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104953. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104954. */
  104955. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104956. /**
  104957. * Creates a new VRDeviceOrientationArcRotateCamera
  104958. * @param name defines camera name
  104959. * @param alpha defines the camera rotation along the logitudinal axis
  104960. * @param beta defines the camera rotation along the latitudinal axis
  104961. * @param radius defines the camera distance from its target
  104962. * @param target defines the camera target
  104963. * @param scene defines the scene the camera belongs to
  104964. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104965. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104966. */
  104967. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104968. /**
  104969. * Gets camera class name
  104970. * @returns VRDeviceOrientationArcRotateCamera
  104971. */
  104972. getClassName(): string;
  104973. }
  104974. }
  104975. declare module BABYLON {
  104976. /**
  104977. * Camera used to simulate VR rendering (based on FreeCamera)
  104978. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104979. */
  104980. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104981. /**
  104982. * Creates a new VRDeviceOrientationFreeCamera
  104983. * @param name defines camera name
  104984. * @param position defines the start position of the camera
  104985. * @param scene defines the scene the camera belongs to
  104986. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104987. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104988. */
  104989. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104990. /**
  104991. * Gets camera class name
  104992. * @returns VRDeviceOrientationFreeCamera
  104993. */
  104994. getClassName(): string;
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. /**
  104999. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105000. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105001. */
  105002. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105003. /**
  105004. * Creates a new VRDeviceOrientationGamepadCamera
  105005. * @param name defines camera name
  105006. * @param position defines the start position of the camera
  105007. * @param scene defines the scene the camera belongs to
  105008. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105009. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105010. */
  105011. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105012. /**
  105013. * Gets camera class name
  105014. * @returns VRDeviceOrientationGamepadCamera
  105015. */
  105016. getClassName(): string;
  105017. }
  105018. }
  105019. declare module BABYLON {
  105020. /**
  105021. * Base class of materials working in push mode in babylon JS
  105022. * @hidden
  105023. */
  105024. export class PushMaterial extends Material {
  105025. protected _activeEffect: Effect;
  105026. protected _normalMatrix: Matrix;
  105027. /**
  105028. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105029. * This means that the material can keep using a previous shader while a new one is being compiled.
  105030. * This is mostly used when shader parallel compilation is supported (true by default)
  105031. */
  105032. allowShaderHotSwapping: boolean;
  105033. constructor(name: string, scene: Scene);
  105034. getEffect(): Effect;
  105035. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105036. /**
  105037. * Binds the given world matrix to the active effect
  105038. *
  105039. * @param world the matrix to bind
  105040. */
  105041. bindOnlyWorldMatrix(world: Matrix): void;
  105042. /**
  105043. * Binds the given normal matrix to the active effect
  105044. *
  105045. * @param normalMatrix the matrix to bind
  105046. */
  105047. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105048. bind(world: Matrix, mesh?: Mesh): void;
  105049. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105050. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105051. }
  105052. }
  105053. declare module BABYLON {
  105054. /**
  105055. * This groups all the flags used to control the materials channel.
  105056. */
  105057. export class MaterialFlags {
  105058. private static _DiffuseTextureEnabled;
  105059. /**
  105060. * Are diffuse textures enabled in the application.
  105061. */
  105062. static DiffuseTextureEnabled: boolean;
  105063. private static _AmbientTextureEnabled;
  105064. /**
  105065. * Are ambient textures enabled in the application.
  105066. */
  105067. static AmbientTextureEnabled: boolean;
  105068. private static _OpacityTextureEnabled;
  105069. /**
  105070. * Are opacity textures enabled in the application.
  105071. */
  105072. static OpacityTextureEnabled: boolean;
  105073. private static _ReflectionTextureEnabled;
  105074. /**
  105075. * Are reflection textures enabled in the application.
  105076. */
  105077. static ReflectionTextureEnabled: boolean;
  105078. private static _EmissiveTextureEnabled;
  105079. /**
  105080. * Are emissive textures enabled in the application.
  105081. */
  105082. static EmissiveTextureEnabled: boolean;
  105083. private static _SpecularTextureEnabled;
  105084. /**
  105085. * Are specular textures enabled in the application.
  105086. */
  105087. static SpecularTextureEnabled: boolean;
  105088. private static _BumpTextureEnabled;
  105089. /**
  105090. * Are bump textures enabled in the application.
  105091. */
  105092. static BumpTextureEnabled: boolean;
  105093. private static _LightmapTextureEnabled;
  105094. /**
  105095. * Are lightmap textures enabled in the application.
  105096. */
  105097. static LightmapTextureEnabled: boolean;
  105098. private static _RefractionTextureEnabled;
  105099. /**
  105100. * Are refraction textures enabled in the application.
  105101. */
  105102. static RefractionTextureEnabled: boolean;
  105103. private static _ColorGradingTextureEnabled;
  105104. /**
  105105. * Are color grading textures enabled in the application.
  105106. */
  105107. static ColorGradingTextureEnabled: boolean;
  105108. private static _FresnelEnabled;
  105109. /**
  105110. * Are fresnels enabled in the application.
  105111. */
  105112. static FresnelEnabled: boolean;
  105113. private static _ClearCoatTextureEnabled;
  105114. /**
  105115. * Are clear coat textures enabled in the application.
  105116. */
  105117. static ClearCoatTextureEnabled: boolean;
  105118. private static _ClearCoatBumpTextureEnabled;
  105119. /**
  105120. * Are clear coat bump textures enabled in the application.
  105121. */
  105122. static ClearCoatBumpTextureEnabled: boolean;
  105123. private static _ClearCoatTintTextureEnabled;
  105124. /**
  105125. * Are clear coat tint textures enabled in the application.
  105126. */
  105127. static ClearCoatTintTextureEnabled: boolean;
  105128. private static _SheenTextureEnabled;
  105129. /**
  105130. * Are sheen textures enabled in the application.
  105131. */
  105132. static SheenTextureEnabled: boolean;
  105133. private static _AnisotropicTextureEnabled;
  105134. /**
  105135. * Are anisotropic textures enabled in the application.
  105136. */
  105137. static AnisotropicTextureEnabled: boolean;
  105138. private static _ThicknessTextureEnabled;
  105139. /**
  105140. * Are thickness textures enabled in the application.
  105141. */
  105142. static ThicknessTextureEnabled: boolean;
  105143. }
  105144. }
  105145. declare module BABYLON {
  105146. /** @hidden */
  105147. export var defaultFragmentDeclaration: {
  105148. name: string;
  105149. shader: string;
  105150. };
  105151. }
  105152. declare module BABYLON {
  105153. /** @hidden */
  105154. export var defaultUboDeclaration: {
  105155. name: string;
  105156. shader: string;
  105157. };
  105158. }
  105159. declare module BABYLON {
  105160. /** @hidden */
  105161. export var lightFragmentDeclaration: {
  105162. name: string;
  105163. shader: string;
  105164. };
  105165. }
  105166. declare module BABYLON {
  105167. /** @hidden */
  105168. export var lightUboDeclaration: {
  105169. name: string;
  105170. shader: string;
  105171. };
  105172. }
  105173. declare module BABYLON {
  105174. /** @hidden */
  105175. export var lightsFragmentFunctions: {
  105176. name: string;
  105177. shader: string;
  105178. };
  105179. }
  105180. declare module BABYLON {
  105181. /** @hidden */
  105182. export var shadowsFragmentFunctions: {
  105183. name: string;
  105184. shader: string;
  105185. };
  105186. }
  105187. declare module BABYLON {
  105188. /** @hidden */
  105189. export var fresnelFunction: {
  105190. name: string;
  105191. shader: string;
  105192. };
  105193. }
  105194. declare module BABYLON {
  105195. /** @hidden */
  105196. export var reflectionFunction: {
  105197. name: string;
  105198. shader: string;
  105199. };
  105200. }
  105201. declare module BABYLON {
  105202. /** @hidden */
  105203. export var bumpFragmentFunctions: {
  105204. name: string;
  105205. shader: string;
  105206. };
  105207. }
  105208. declare module BABYLON {
  105209. /** @hidden */
  105210. export var logDepthDeclaration: {
  105211. name: string;
  105212. shader: string;
  105213. };
  105214. }
  105215. declare module BABYLON {
  105216. /** @hidden */
  105217. export var bumpFragment: {
  105218. name: string;
  105219. shader: string;
  105220. };
  105221. }
  105222. declare module BABYLON {
  105223. /** @hidden */
  105224. export var depthPrePass: {
  105225. name: string;
  105226. shader: string;
  105227. };
  105228. }
  105229. declare module BABYLON {
  105230. /** @hidden */
  105231. export var lightFragment: {
  105232. name: string;
  105233. shader: string;
  105234. };
  105235. }
  105236. declare module BABYLON {
  105237. /** @hidden */
  105238. export var logDepthFragment: {
  105239. name: string;
  105240. shader: string;
  105241. };
  105242. }
  105243. declare module BABYLON {
  105244. /** @hidden */
  105245. export var defaultPixelShader: {
  105246. name: string;
  105247. shader: string;
  105248. };
  105249. }
  105250. declare module BABYLON {
  105251. /** @hidden */
  105252. export var defaultVertexDeclaration: {
  105253. name: string;
  105254. shader: string;
  105255. };
  105256. }
  105257. declare module BABYLON {
  105258. /** @hidden */
  105259. export var bumpVertexDeclaration: {
  105260. name: string;
  105261. shader: string;
  105262. };
  105263. }
  105264. declare module BABYLON {
  105265. /** @hidden */
  105266. export var bumpVertex: {
  105267. name: string;
  105268. shader: string;
  105269. };
  105270. }
  105271. declare module BABYLON {
  105272. /** @hidden */
  105273. export var fogVertex: {
  105274. name: string;
  105275. shader: string;
  105276. };
  105277. }
  105278. declare module BABYLON {
  105279. /** @hidden */
  105280. export var shadowsVertex: {
  105281. name: string;
  105282. shader: string;
  105283. };
  105284. }
  105285. declare module BABYLON {
  105286. /** @hidden */
  105287. export var pointCloudVertex: {
  105288. name: string;
  105289. shader: string;
  105290. };
  105291. }
  105292. declare module BABYLON {
  105293. /** @hidden */
  105294. export var logDepthVertex: {
  105295. name: string;
  105296. shader: string;
  105297. };
  105298. }
  105299. declare module BABYLON {
  105300. /** @hidden */
  105301. export var defaultVertexShader: {
  105302. name: string;
  105303. shader: string;
  105304. };
  105305. }
  105306. declare module BABYLON {
  105307. /** @hidden */
  105308. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105309. MAINUV1: boolean;
  105310. MAINUV2: boolean;
  105311. DIFFUSE: boolean;
  105312. DIFFUSEDIRECTUV: number;
  105313. AMBIENT: boolean;
  105314. AMBIENTDIRECTUV: number;
  105315. OPACITY: boolean;
  105316. OPACITYDIRECTUV: number;
  105317. OPACITYRGB: boolean;
  105318. REFLECTION: boolean;
  105319. EMISSIVE: boolean;
  105320. EMISSIVEDIRECTUV: number;
  105321. SPECULAR: boolean;
  105322. SPECULARDIRECTUV: number;
  105323. BUMP: boolean;
  105324. BUMPDIRECTUV: number;
  105325. PARALLAX: boolean;
  105326. PARALLAXOCCLUSION: boolean;
  105327. SPECULAROVERALPHA: boolean;
  105328. CLIPPLANE: boolean;
  105329. CLIPPLANE2: boolean;
  105330. CLIPPLANE3: boolean;
  105331. CLIPPLANE4: boolean;
  105332. ALPHATEST: boolean;
  105333. DEPTHPREPASS: boolean;
  105334. ALPHAFROMDIFFUSE: boolean;
  105335. POINTSIZE: boolean;
  105336. FOG: boolean;
  105337. SPECULARTERM: boolean;
  105338. DIFFUSEFRESNEL: boolean;
  105339. OPACITYFRESNEL: boolean;
  105340. REFLECTIONFRESNEL: boolean;
  105341. REFRACTIONFRESNEL: boolean;
  105342. EMISSIVEFRESNEL: boolean;
  105343. FRESNEL: boolean;
  105344. NORMAL: boolean;
  105345. UV1: boolean;
  105346. UV2: boolean;
  105347. VERTEXCOLOR: boolean;
  105348. VERTEXALPHA: boolean;
  105349. NUM_BONE_INFLUENCERS: number;
  105350. BonesPerMesh: number;
  105351. BONETEXTURE: boolean;
  105352. INSTANCES: boolean;
  105353. GLOSSINESS: boolean;
  105354. ROUGHNESS: boolean;
  105355. EMISSIVEASILLUMINATION: boolean;
  105356. LINKEMISSIVEWITHDIFFUSE: boolean;
  105357. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105358. LIGHTMAP: boolean;
  105359. LIGHTMAPDIRECTUV: number;
  105360. OBJECTSPACE_NORMALMAP: boolean;
  105361. USELIGHTMAPASSHADOWMAP: boolean;
  105362. REFLECTIONMAP_3D: boolean;
  105363. REFLECTIONMAP_SPHERICAL: boolean;
  105364. REFLECTIONMAP_PLANAR: boolean;
  105365. REFLECTIONMAP_CUBIC: boolean;
  105366. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105367. REFLECTIONMAP_PROJECTION: boolean;
  105368. REFLECTIONMAP_SKYBOX: boolean;
  105369. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105370. REFLECTIONMAP_EXPLICIT: boolean;
  105371. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105372. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105373. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105374. INVERTCUBICMAP: boolean;
  105375. LOGARITHMICDEPTH: boolean;
  105376. REFRACTION: boolean;
  105377. REFRACTIONMAP_3D: boolean;
  105378. REFLECTIONOVERALPHA: boolean;
  105379. TWOSIDEDLIGHTING: boolean;
  105380. SHADOWFLOAT: boolean;
  105381. MORPHTARGETS: boolean;
  105382. MORPHTARGETS_NORMAL: boolean;
  105383. MORPHTARGETS_TANGENT: boolean;
  105384. MORPHTARGETS_UV: boolean;
  105385. NUM_MORPH_INFLUENCERS: number;
  105386. NONUNIFORMSCALING: boolean;
  105387. PREMULTIPLYALPHA: boolean;
  105388. IMAGEPROCESSING: boolean;
  105389. VIGNETTE: boolean;
  105390. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105391. VIGNETTEBLENDMODEOPAQUE: boolean;
  105392. TONEMAPPING: boolean;
  105393. TONEMAPPING_ACES: boolean;
  105394. CONTRAST: boolean;
  105395. COLORCURVES: boolean;
  105396. COLORGRADING: boolean;
  105397. COLORGRADING3D: boolean;
  105398. SAMPLER3DGREENDEPTH: boolean;
  105399. SAMPLER3DBGRMAP: boolean;
  105400. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105401. MULTIVIEW: boolean;
  105402. /**
  105403. * If the reflection texture on this material is in linear color space
  105404. * @hidden
  105405. */
  105406. IS_REFLECTION_LINEAR: boolean;
  105407. /**
  105408. * If the refraction texture on this material is in linear color space
  105409. * @hidden
  105410. */
  105411. IS_REFRACTION_LINEAR: boolean;
  105412. EXPOSURE: boolean;
  105413. constructor();
  105414. setReflectionMode(modeToEnable: string): void;
  105415. }
  105416. /**
  105417. * This is the default material used in Babylon. It is the best trade off between quality
  105418. * and performances.
  105419. * @see http://doc.babylonjs.com/babylon101/materials
  105420. */
  105421. export class StandardMaterial extends PushMaterial {
  105422. private _diffuseTexture;
  105423. /**
  105424. * The basic texture of the material as viewed under a light.
  105425. */
  105426. diffuseTexture: Nullable<BaseTexture>;
  105427. private _ambientTexture;
  105428. /**
  105429. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105430. */
  105431. ambientTexture: Nullable<BaseTexture>;
  105432. private _opacityTexture;
  105433. /**
  105434. * Define the transparency of the material from a texture.
  105435. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105436. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105437. */
  105438. opacityTexture: Nullable<BaseTexture>;
  105439. private _reflectionTexture;
  105440. /**
  105441. * Define the texture used to display the reflection.
  105442. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105443. */
  105444. reflectionTexture: Nullable<BaseTexture>;
  105445. private _emissiveTexture;
  105446. /**
  105447. * Define texture of the material as if self lit.
  105448. * This will be mixed in the final result even in the absence of light.
  105449. */
  105450. emissiveTexture: Nullable<BaseTexture>;
  105451. private _specularTexture;
  105452. /**
  105453. * Define how the color and intensity of the highlight given by the light in the material.
  105454. */
  105455. specularTexture: Nullable<BaseTexture>;
  105456. private _bumpTexture;
  105457. /**
  105458. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105459. * 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.
  105460. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105461. */
  105462. bumpTexture: Nullable<BaseTexture>;
  105463. private _lightmapTexture;
  105464. /**
  105465. * Complex lighting can be computationally expensive to compute at runtime.
  105466. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105467. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105468. */
  105469. lightmapTexture: Nullable<BaseTexture>;
  105470. private _refractionTexture;
  105471. /**
  105472. * Define the texture used to display the refraction.
  105473. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105474. */
  105475. refractionTexture: Nullable<BaseTexture>;
  105476. /**
  105477. * The color of the material lit by the environmental background lighting.
  105478. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105479. */
  105480. ambientColor: Color3;
  105481. /**
  105482. * The basic color of the material as viewed under a light.
  105483. */
  105484. diffuseColor: Color3;
  105485. /**
  105486. * Define how the color and intensity of the highlight given by the light in the material.
  105487. */
  105488. specularColor: Color3;
  105489. /**
  105490. * Define the color of the material as if self lit.
  105491. * This will be mixed in the final result even in the absence of light.
  105492. */
  105493. emissiveColor: Color3;
  105494. /**
  105495. * Defines how sharp are the highlights in the material.
  105496. * The bigger the value the sharper giving a more glossy feeling to the result.
  105497. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105498. */
  105499. specularPower: number;
  105500. private _useAlphaFromDiffuseTexture;
  105501. /**
  105502. * Does the transparency come from the diffuse texture alpha channel.
  105503. */
  105504. useAlphaFromDiffuseTexture: boolean;
  105505. private _useEmissiveAsIllumination;
  105506. /**
  105507. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105508. */
  105509. useEmissiveAsIllumination: boolean;
  105510. private _linkEmissiveWithDiffuse;
  105511. /**
  105512. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105513. * the emissive level when the final color is close to one.
  105514. */
  105515. linkEmissiveWithDiffuse: boolean;
  105516. private _useSpecularOverAlpha;
  105517. /**
  105518. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105519. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105520. */
  105521. useSpecularOverAlpha: boolean;
  105522. private _useReflectionOverAlpha;
  105523. /**
  105524. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105525. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105526. */
  105527. useReflectionOverAlpha: boolean;
  105528. private _disableLighting;
  105529. /**
  105530. * Does lights from the scene impacts this material.
  105531. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105532. */
  105533. disableLighting: boolean;
  105534. private _useObjectSpaceNormalMap;
  105535. /**
  105536. * Allows using an object space normal map (instead of tangent space).
  105537. */
  105538. useObjectSpaceNormalMap: boolean;
  105539. private _useParallax;
  105540. /**
  105541. * Is parallax enabled or not.
  105542. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105543. */
  105544. useParallax: boolean;
  105545. private _useParallaxOcclusion;
  105546. /**
  105547. * Is parallax occlusion enabled or not.
  105548. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105549. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105550. */
  105551. useParallaxOcclusion: boolean;
  105552. /**
  105553. * 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.
  105554. */
  105555. parallaxScaleBias: number;
  105556. private _roughness;
  105557. /**
  105558. * Helps to define how blurry the reflections should appears in the material.
  105559. */
  105560. roughness: number;
  105561. /**
  105562. * In case of refraction, define the value of the index of refraction.
  105563. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105564. */
  105565. indexOfRefraction: number;
  105566. /**
  105567. * Invert the refraction texture alongside the y axis.
  105568. * It can be useful with procedural textures or probe for instance.
  105569. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105570. */
  105571. invertRefractionY: boolean;
  105572. /**
  105573. * Defines the alpha limits in alpha test mode.
  105574. */
  105575. alphaCutOff: number;
  105576. private _useLightmapAsShadowmap;
  105577. /**
  105578. * In case of light mapping, define whether the map contains light or shadow informations.
  105579. */
  105580. useLightmapAsShadowmap: boolean;
  105581. private _diffuseFresnelParameters;
  105582. /**
  105583. * Define the diffuse fresnel parameters of the material.
  105584. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105585. */
  105586. diffuseFresnelParameters: FresnelParameters;
  105587. private _opacityFresnelParameters;
  105588. /**
  105589. * Define the opacity fresnel parameters of the material.
  105590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105591. */
  105592. opacityFresnelParameters: FresnelParameters;
  105593. private _reflectionFresnelParameters;
  105594. /**
  105595. * Define the reflection fresnel parameters of the material.
  105596. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105597. */
  105598. reflectionFresnelParameters: FresnelParameters;
  105599. private _refractionFresnelParameters;
  105600. /**
  105601. * Define the refraction fresnel parameters of the material.
  105602. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105603. */
  105604. refractionFresnelParameters: FresnelParameters;
  105605. private _emissiveFresnelParameters;
  105606. /**
  105607. * Define the emissive fresnel parameters of the material.
  105608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105609. */
  105610. emissiveFresnelParameters: FresnelParameters;
  105611. private _useReflectionFresnelFromSpecular;
  105612. /**
  105613. * If true automatically deducts the fresnels values from the material specularity.
  105614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105615. */
  105616. useReflectionFresnelFromSpecular: boolean;
  105617. private _useGlossinessFromSpecularMapAlpha;
  105618. /**
  105619. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105620. */
  105621. useGlossinessFromSpecularMapAlpha: boolean;
  105622. private _maxSimultaneousLights;
  105623. /**
  105624. * Defines the maximum number of lights that can be used in the material
  105625. */
  105626. maxSimultaneousLights: number;
  105627. private _invertNormalMapX;
  105628. /**
  105629. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105630. */
  105631. invertNormalMapX: boolean;
  105632. private _invertNormalMapY;
  105633. /**
  105634. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105635. */
  105636. invertNormalMapY: boolean;
  105637. private _twoSidedLighting;
  105638. /**
  105639. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105640. */
  105641. twoSidedLighting: boolean;
  105642. /**
  105643. * Default configuration related to image processing available in the standard Material.
  105644. */
  105645. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105646. /**
  105647. * Gets the image processing configuration used either in this material.
  105648. */
  105649. /**
  105650. * Sets the Default image processing configuration used either in the this material.
  105651. *
  105652. * If sets to null, the scene one is in use.
  105653. */
  105654. imageProcessingConfiguration: ImageProcessingConfiguration;
  105655. /**
  105656. * Keep track of the image processing observer to allow dispose and replace.
  105657. */
  105658. private _imageProcessingObserver;
  105659. /**
  105660. * Attaches a new image processing configuration to the Standard Material.
  105661. * @param configuration
  105662. */
  105663. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105664. /**
  105665. * Gets wether the color curves effect is enabled.
  105666. */
  105667. /**
  105668. * Sets wether the color curves effect is enabled.
  105669. */
  105670. cameraColorCurvesEnabled: boolean;
  105671. /**
  105672. * Gets wether the color grading effect is enabled.
  105673. */
  105674. /**
  105675. * Gets wether the color grading effect is enabled.
  105676. */
  105677. cameraColorGradingEnabled: boolean;
  105678. /**
  105679. * Gets wether tonemapping is enabled or not.
  105680. */
  105681. /**
  105682. * Sets wether tonemapping is enabled or not
  105683. */
  105684. cameraToneMappingEnabled: boolean;
  105685. /**
  105686. * The camera exposure used on this material.
  105687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105688. * This corresponds to a photographic exposure.
  105689. */
  105690. /**
  105691. * The camera exposure used on this material.
  105692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105693. * This corresponds to a photographic exposure.
  105694. */
  105695. cameraExposure: number;
  105696. /**
  105697. * Gets The camera contrast used on this material.
  105698. */
  105699. /**
  105700. * Sets The camera contrast used on this material.
  105701. */
  105702. cameraContrast: number;
  105703. /**
  105704. * Gets the Color Grading 2D Lookup Texture.
  105705. */
  105706. /**
  105707. * Sets the Color Grading 2D Lookup Texture.
  105708. */
  105709. cameraColorGradingTexture: Nullable<BaseTexture>;
  105710. /**
  105711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105713. * 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;
  105714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105715. */
  105716. /**
  105717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105719. * 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;
  105720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105721. */
  105722. cameraColorCurves: Nullable<ColorCurves>;
  105723. /**
  105724. * Custom callback helping to override the default shader used in the material.
  105725. */
  105726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105727. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105728. protected _worldViewProjectionMatrix: Matrix;
  105729. protected _globalAmbientColor: Color3;
  105730. protected _useLogarithmicDepth: boolean;
  105731. protected _rebuildInParallel: boolean;
  105732. /**
  105733. * Instantiates a new standard material.
  105734. * This is the default material used in Babylon. It is the best trade off between quality
  105735. * and performances.
  105736. * @see http://doc.babylonjs.com/babylon101/materials
  105737. * @param name Define the name of the material in the scene
  105738. * @param scene Define the scene the material belong to
  105739. */
  105740. constructor(name: string, scene: Scene);
  105741. /**
  105742. * Gets a boolean indicating that current material needs to register RTT
  105743. */
  105744. readonly hasRenderTargetTextures: boolean;
  105745. /**
  105746. * Gets the current class name of the material e.g. "StandardMaterial"
  105747. * Mainly use in serialization.
  105748. * @returns the class name
  105749. */
  105750. getClassName(): string;
  105751. /**
  105752. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105753. * You can try switching to logarithmic depth.
  105754. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105755. */
  105756. useLogarithmicDepth: boolean;
  105757. /**
  105758. * Specifies if the material will require alpha blending
  105759. * @returns a boolean specifying if alpha blending is needed
  105760. */
  105761. needAlphaBlending(): boolean;
  105762. /**
  105763. * Specifies if this material should be rendered in alpha test mode
  105764. * @returns a boolean specifying if an alpha test is needed.
  105765. */
  105766. needAlphaTesting(): boolean;
  105767. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105768. /**
  105769. * Get the texture used for alpha test purpose.
  105770. * @returns the diffuse texture in case of the standard material.
  105771. */
  105772. getAlphaTestTexture(): Nullable<BaseTexture>;
  105773. /**
  105774. * Get if the submesh is ready to be used and all its information available.
  105775. * Child classes can use it to update shaders
  105776. * @param mesh defines the mesh to check
  105777. * @param subMesh defines which submesh to check
  105778. * @param useInstances specifies that instances should be used
  105779. * @returns a boolean indicating that the submesh is ready or not
  105780. */
  105781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105782. /**
  105783. * Builds the material UBO layouts.
  105784. * Used internally during the effect preparation.
  105785. */
  105786. buildUniformLayout(): void;
  105787. /**
  105788. * Unbinds the material from the mesh
  105789. */
  105790. unbind(): void;
  105791. /**
  105792. * Binds the submesh to this material by preparing the effect and shader to draw
  105793. * @param world defines the world transformation matrix
  105794. * @param mesh defines the mesh containing the submesh
  105795. * @param subMesh defines the submesh to bind the material to
  105796. */
  105797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105798. /**
  105799. * Get the list of animatables in the material.
  105800. * @returns the list of animatables object used in the material
  105801. */
  105802. getAnimatables(): IAnimatable[];
  105803. /**
  105804. * Gets the active textures from the material
  105805. * @returns an array of textures
  105806. */
  105807. getActiveTextures(): BaseTexture[];
  105808. /**
  105809. * Specifies if the material uses a texture
  105810. * @param texture defines the texture to check against the material
  105811. * @returns a boolean specifying if the material uses the texture
  105812. */
  105813. hasTexture(texture: BaseTexture): boolean;
  105814. /**
  105815. * Disposes the material
  105816. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105817. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105818. */
  105819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105820. /**
  105821. * Makes a duplicate of the material, and gives it a new name
  105822. * @param name defines the new name for the duplicated material
  105823. * @returns the cloned material
  105824. */
  105825. clone(name: string): StandardMaterial;
  105826. /**
  105827. * Serializes this material in a JSON representation
  105828. * @returns the serialized material object
  105829. */
  105830. serialize(): any;
  105831. /**
  105832. * Creates a standard material from parsed material data
  105833. * @param source defines the JSON representation of the material
  105834. * @param scene defines the hosting scene
  105835. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105836. * @returns a new standard material
  105837. */
  105838. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105839. /**
  105840. * Are diffuse textures enabled in the application.
  105841. */
  105842. static DiffuseTextureEnabled: boolean;
  105843. /**
  105844. * Are ambient textures enabled in the application.
  105845. */
  105846. static AmbientTextureEnabled: boolean;
  105847. /**
  105848. * Are opacity textures enabled in the application.
  105849. */
  105850. static OpacityTextureEnabled: boolean;
  105851. /**
  105852. * Are reflection textures enabled in the application.
  105853. */
  105854. static ReflectionTextureEnabled: boolean;
  105855. /**
  105856. * Are emissive textures enabled in the application.
  105857. */
  105858. static EmissiveTextureEnabled: boolean;
  105859. /**
  105860. * Are specular textures enabled in the application.
  105861. */
  105862. static SpecularTextureEnabled: boolean;
  105863. /**
  105864. * Are bump textures enabled in the application.
  105865. */
  105866. static BumpTextureEnabled: boolean;
  105867. /**
  105868. * Are lightmap textures enabled in the application.
  105869. */
  105870. static LightmapTextureEnabled: boolean;
  105871. /**
  105872. * Are refraction textures enabled in the application.
  105873. */
  105874. static RefractionTextureEnabled: boolean;
  105875. /**
  105876. * Are color grading textures enabled in the application.
  105877. */
  105878. static ColorGradingTextureEnabled: boolean;
  105879. /**
  105880. * Are fresnels enabled in the application.
  105881. */
  105882. static FresnelEnabled: boolean;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * A class extending Texture allowing drawing on a texture
  105888. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105889. */
  105890. export class DynamicTexture extends Texture {
  105891. private _generateMipMaps;
  105892. private _canvas;
  105893. private _context;
  105894. private _engine;
  105895. /**
  105896. * Creates a DynamicTexture
  105897. * @param name defines the name of the texture
  105898. * @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
  105899. * @param scene defines the scene where you want the texture
  105900. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105901. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105902. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105903. */
  105904. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105905. /**
  105906. * Get the current class name of the texture useful for serialization or dynamic coding.
  105907. * @returns "DynamicTexture"
  105908. */
  105909. getClassName(): string;
  105910. /**
  105911. * Gets the current state of canRescale
  105912. */
  105913. readonly canRescale: boolean;
  105914. private _recreate;
  105915. /**
  105916. * Scales the texture
  105917. * @param ratio the scale factor to apply to both width and height
  105918. */
  105919. scale(ratio: number): void;
  105920. /**
  105921. * Resizes the texture
  105922. * @param width the new width
  105923. * @param height the new height
  105924. */
  105925. scaleTo(width: number, height: number): void;
  105926. /**
  105927. * Gets the context of the canvas used by the texture
  105928. * @returns the canvas context of the dynamic texture
  105929. */
  105930. getContext(): CanvasRenderingContext2D;
  105931. /**
  105932. * Clears the texture
  105933. */
  105934. clear(): void;
  105935. /**
  105936. * Updates the texture
  105937. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105938. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105939. */
  105940. update(invertY?: boolean, premulAlpha?: boolean): void;
  105941. /**
  105942. * Draws text onto the texture
  105943. * @param text defines the text to be drawn
  105944. * @param x defines the placement of the text from the left
  105945. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105946. * @param font defines the font to be used with font-style, font-size, font-name
  105947. * @param color defines the color used for the text
  105948. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105949. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105950. * @param update defines whether texture is immediately update (default is true)
  105951. */
  105952. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105953. /**
  105954. * Clones the texture
  105955. * @returns the clone of the texture.
  105956. */
  105957. clone(): DynamicTexture;
  105958. /**
  105959. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105960. * @returns a serialized dynamic texture object
  105961. */
  105962. serialize(): any;
  105963. /** @hidden */
  105964. _rebuild(): void;
  105965. }
  105966. }
  105967. declare module BABYLON {
  105968. /** @hidden */
  105969. export var imageProcessingPixelShader: {
  105970. name: string;
  105971. shader: string;
  105972. };
  105973. }
  105974. declare module BABYLON {
  105975. /**
  105976. * ImageProcessingPostProcess
  105977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105978. */
  105979. export class ImageProcessingPostProcess extends PostProcess {
  105980. /**
  105981. * Default configuration related to image processing available in the PBR Material.
  105982. */
  105983. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105984. /**
  105985. * Gets the image processing configuration used either in this material.
  105986. */
  105987. /**
  105988. * Sets the Default image processing configuration used either in the this material.
  105989. *
  105990. * If sets to null, the scene one is in use.
  105991. */
  105992. imageProcessingConfiguration: ImageProcessingConfiguration;
  105993. /**
  105994. * Keep track of the image processing observer to allow dispose and replace.
  105995. */
  105996. private _imageProcessingObserver;
  105997. /**
  105998. * Attaches a new image processing configuration to the PBR Material.
  105999. * @param configuration
  106000. */
  106001. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106002. /**
  106003. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106004. */
  106005. /**
  106006. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106007. */
  106008. colorCurves: Nullable<ColorCurves>;
  106009. /**
  106010. * Gets wether the color curves effect is enabled.
  106011. */
  106012. /**
  106013. * Sets wether the color curves effect is enabled.
  106014. */
  106015. colorCurvesEnabled: boolean;
  106016. /**
  106017. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106018. */
  106019. /**
  106020. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106021. */
  106022. colorGradingTexture: Nullable<BaseTexture>;
  106023. /**
  106024. * Gets wether the color grading effect is enabled.
  106025. */
  106026. /**
  106027. * Gets wether the color grading effect is enabled.
  106028. */
  106029. colorGradingEnabled: boolean;
  106030. /**
  106031. * Gets exposure used in the effect.
  106032. */
  106033. /**
  106034. * Sets exposure used in the effect.
  106035. */
  106036. exposure: number;
  106037. /**
  106038. * Gets wether tonemapping is enabled or not.
  106039. */
  106040. /**
  106041. * Sets wether tonemapping is enabled or not
  106042. */
  106043. toneMappingEnabled: boolean;
  106044. /**
  106045. * Gets the type of tone mapping effect.
  106046. */
  106047. /**
  106048. * Sets the type of tone mapping effect.
  106049. */
  106050. toneMappingType: number;
  106051. /**
  106052. * Gets contrast used in the effect.
  106053. */
  106054. /**
  106055. * Sets contrast used in the effect.
  106056. */
  106057. contrast: number;
  106058. /**
  106059. * Gets Vignette stretch size.
  106060. */
  106061. /**
  106062. * Sets Vignette stretch size.
  106063. */
  106064. vignetteStretch: number;
  106065. /**
  106066. * Gets Vignette centre X Offset.
  106067. */
  106068. /**
  106069. * Sets Vignette centre X Offset.
  106070. */
  106071. vignetteCentreX: number;
  106072. /**
  106073. * Gets Vignette centre Y Offset.
  106074. */
  106075. /**
  106076. * Sets Vignette centre Y Offset.
  106077. */
  106078. vignetteCentreY: number;
  106079. /**
  106080. * Gets Vignette weight or intensity of the vignette effect.
  106081. */
  106082. /**
  106083. * Sets Vignette weight or intensity of the vignette effect.
  106084. */
  106085. vignetteWeight: number;
  106086. /**
  106087. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106088. * if vignetteEnabled is set to true.
  106089. */
  106090. /**
  106091. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106092. * if vignetteEnabled is set to true.
  106093. */
  106094. vignetteColor: Color4;
  106095. /**
  106096. * Gets Camera field of view used by the Vignette effect.
  106097. */
  106098. /**
  106099. * Sets Camera field of view used by the Vignette effect.
  106100. */
  106101. vignetteCameraFov: number;
  106102. /**
  106103. * Gets the vignette blend mode allowing different kind of effect.
  106104. */
  106105. /**
  106106. * Sets the vignette blend mode allowing different kind of effect.
  106107. */
  106108. vignetteBlendMode: number;
  106109. /**
  106110. * Gets wether the vignette effect is enabled.
  106111. */
  106112. /**
  106113. * Sets wether the vignette effect is enabled.
  106114. */
  106115. vignetteEnabled: boolean;
  106116. private _fromLinearSpace;
  106117. /**
  106118. * Gets wether the input of the processing is in Gamma or Linear Space.
  106119. */
  106120. /**
  106121. * Sets wether the input of the processing is in Gamma or Linear Space.
  106122. */
  106123. fromLinearSpace: boolean;
  106124. /**
  106125. * Defines cache preventing GC.
  106126. */
  106127. private _defines;
  106128. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106129. /**
  106130. * "ImageProcessingPostProcess"
  106131. * @returns "ImageProcessingPostProcess"
  106132. */
  106133. getClassName(): string;
  106134. protected _updateParameters(): void;
  106135. dispose(camera?: Camera): void;
  106136. }
  106137. }
  106138. declare module BABYLON {
  106139. /**
  106140. * Class containing static functions to help procedurally build meshes
  106141. */
  106142. export class GroundBuilder {
  106143. /**
  106144. * Creates a ground mesh
  106145. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106146. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106148. * @param name defines the name of the mesh
  106149. * @param options defines the options used to create the mesh
  106150. * @param scene defines the hosting scene
  106151. * @returns the ground mesh
  106152. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106153. */
  106154. static CreateGround(name: string, options: {
  106155. width?: number;
  106156. height?: number;
  106157. subdivisions?: number;
  106158. subdivisionsX?: number;
  106159. subdivisionsY?: number;
  106160. updatable?: boolean;
  106161. }, scene: any): Mesh;
  106162. /**
  106163. * Creates a tiled ground mesh
  106164. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106165. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106166. * * 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
  106167. * * 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
  106168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106169. * @param name defines the name of the mesh
  106170. * @param options defines the options used to create the mesh
  106171. * @param scene defines the hosting scene
  106172. * @returns the tiled ground mesh
  106173. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106174. */
  106175. static CreateTiledGround(name: string, options: {
  106176. xmin: number;
  106177. zmin: number;
  106178. xmax: number;
  106179. zmax: number;
  106180. subdivisions?: {
  106181. w: number;
  106182. h: number;
  106183. };
  106184. precision?: {
  106185. w: number;
  106186. h: number;
  106187. };
  106188. updatable?: boolean;
  106189. }, scene?: Nullable<Scene>): Mesh;
  106190. /**
  106191. * Creates a ground mesh from a height map
  106192. * * The parameter `url` sets the URL of the height map image resource.
  106193. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106194. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106195. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106196. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106197. * * 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.
  106198. * * 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).
  106199. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106201. * @param name defines the name of the mesh
  106202. * @param url defines the url to the height map
  106203. * @param options defines the options used to create the mesh
  106204. * @param scene defines the hosting scene
  106205. * @returns the ground mesh
  106206. * @see https://doc.babylonjs.com/babylon101/height_map
  106207. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106208. */
  106209. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106210. width?: number;
  106211. height?: number;
  106212. subdivisions?: number;
  106213. minHeight?: number;
  106214. maxHeight?: number;
  106215. colorFilter?: Color3;
  106216. alphaFilter?: number;
  106217. updatable?: boolean;
  106218. onReady?: (mesh: GroundMesh) => void;
  106219. }, scene?: Nullable<Scene>): GroundMesh;
  106220. }
  106221. }
  106222. declare module BABYLON {
  106223. /**
  106224. * Class containing static functions to help procedurally build meshes
  106225. */
  106226. export class TorusBuilder {
  106227. /**
  106228. * Creates a torus mesh
  106229. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106230. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106231. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106235. * @param name defines the name of the mesh
  106236. * @param options defines the options used to create the mesh
  106237. * @param scene defines the hosting scene
  106238. * @returns the torus mesh
  106239. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106240. */
  106241. static CreateTorus(name: string, options: {
  106242. diameter?: number;
  106243. thickness?: number;
  106244. tessellation?: number;
  106245. updatable?: boolean;
  106246. sideOrientation?: number;
  106247. frontUVs?: Vector4;
  106248. backUVs?: Vector4;
  106249. }, scene: any): Mesh;
  106250. }
  106251. }
  106252. declare module BABYLON {
  106253. /**
  106254. * Class containing static functions to help procedurally build meshes
  106255. */
  106256. export class CylinderBuilder {
  106257. /**
  106258. * Creates a cylinder or a cone mesh
  106259. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106260. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106261. * * 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.
  106262. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106263. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106264. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106265. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106266. * * 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).
  106267. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106268. * * 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).
  106269. * * 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
  106270. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106271. * * 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
  106272. * * 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.
  106273. * * If `enclose` is false, a ring surface is one element.
  106274. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106275. * * 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
  106276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106279. * @param name defines the name of the mesh
  106280. * @param options defines the options used to create the mesh
  106281. * @param scene defines the hosting scene
  106282. * @returns the cylinder mesh
  106283. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106284. */
  106285. static CreateCylinder(name: string, options: {
  106286. height?: number;
  106287. diameterTop?: number;
  106288. diameterBottom?: number;
  106289. diameter?: number;
  106290. tessellation?: number;
  106291. subdivisions?: number;
  106292. arc?: number;
  106293. faceColors?: Color4[];
  106294. faceUV?: Vector4[];
  106295. updatable?: boolean;
  106296. hasRings?: boolean;
  106297. enclose?: boolean;
  106298. cap?: number;
  106299. sideOrientation?: number;
  106300. frontUVs?: Vector4;
  106301. backUVs?: Vector4;
  106302. }, scene: any): Mesh;
  106303. }
  106304. }
  106305. declare module BABYLON {
  106306. /**
  106307. * Options to modify the vr teleportation behavior.
  106308. */
  106309. export interface VRTeleportationOptions {
  106310. /**
  106311. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106312. */
  106313. floorMeshName?: string;
  106314. /**
  106315. * A list of meshes to be used as the teleportation floor. (default: empty)
  106316. */
  106317. floorMeshes?: Mesh[];
  106318. }
  106319. /**
  106320. * Options to modify the vr experience helper's behavior.
  106321. */
  106322. export interface VRExperienceHelperOptions extends WebVROptions {
  106323. /**
  106324. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106325. */
  106326. createDeviceOrientationCamera?: boolean;
  106327. /**
  106328. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106329. */
  106330. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106331. /**
  106332. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106333. */
  106334. laserToggle?: boolean;
  106335. /**
  106336. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106337. */
  106338. floorMeshes?: Mesh[];
  106339. /**
  106340. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106341. */
  106342. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106343. }
  106344. /**
  106345. * Event containing information after VR has been entered
  106346. */
  106347. export class OnAfterEnteringVRObservableEvent {
  106348. /**
  106349. * If entering vr was successful
  106350. */
  106351. success: boolean;
  106352. }
  106353. /**
  106354. * Helps to quickly add VR support to an existing scene.
  106355. * See http://doc.babylonjs.com/how_to/webvr_helper
  106356. */
  106357. export class VRExperienceHelper {
  106358. /** Options to modify the vr experience helper's behavior. */
  106359. webVROptions: VRExperienceHelperOptions;
  106360. private _scene;
  106361. private _position;
  106362. private _btnVR;
  106363. private _btnVRDisplayed;
  106364. private _webVRsupported;
  106365. private _webVRready;
  106366. private _webVRrequesting;
  106367. private _webVRpresenting;
  106368. private _hasEnteredVR;
  106369. private _fullscreenVRpresenting;
  106370. private _canvas;
  106371. private _webVRCamera;
  106372. private _vrDeviceOrientationCamera;
  106373. private _deviceOrientationCamera;
  106374. private _existingCamera;
  106375. private _onKeyDown;
  106376. private _onVrDisplayPresentChange;
  106377. private _onVRDisplayChanged;
  106378. private _onVRRequestPresentStart;
  106379. private _onVRRequestPresentComplete;
  106380. /**
  106381. * 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)
  106382. */
  106383. enableGazeEvenWhenNoPointerLock: boolean;
  106384. /**
  106385. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106386. */
  106387. exitVROnDoubleTap: boolean;
  106388. /**
  106389. * Observable raised right before entering VR.
  106390. */
  106391. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106392. /**
  106393. * Observable raised when entering VR has completed.
  106394. */
  106395. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106396. /**
  106397. * Observable raised when exiting VR.
  106398. */
  106399. onExitingVRObservable: Observable<VRExperienceHelper>;
  106400. /**
  106401. * Observable raised when controller mesh is loaded.
  106402. */
  106403. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106404. /** Return this.onEnteringVRObservable
  106405. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106406. */
  106407. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106408. /** Return this.onExitingVRObservable
  106409. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106410. */
  106411. readonly onExitingVR: Observable<VRExperienceHelper>;
  106412. /** Return this.onControllerMeshLoadedObservable
  106413. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106414. */
  106415. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106416. private _rayLength;
  106417. private _useCustomVRButton;
  106418. private _teleportationRequested;
  106419. private _teleportActive;
  106420. private _floorMeshName;
  106421. private _floorMeshesCollection;
  106422. private _rotationAllowed;
  106423. private _teleportBackwardsVector;
  106424. private _teleportationTarget;
  106425. private _isDefaultTeleportationTarget;
  106426. private _postProcessMove;
  106427. private _teleportationFillColor;
  106428. private _teleportationBorderColor;
  106429. private _rotationAngle;
  106430. private _haloCenter;
  106431. private _cameraGazer;
  106432. private _padSensibilityUp;
  106433. private _padSensibilityDown;
  106434. private _leftController;
  106435. private _rightController;
  106436. /**
  106437. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106438. */
  106439. onNewMeshSelected: Observable<AbstractMesh>;
  106440. /**
  106441. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106442. * This observable will provide the mesh and the controller used to select the mesh
  106443. */
  106444. onMeshSelectedWithController: Observable<{
  106445. mesh: AbstractMesh;
  106446. controller: WebVRController;
  106447. }>;
  106448. /**
  106449. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106450. */
  106451. onNewMeshPicked: Observable<PickingInfo>;
  106452. private _circleEase;
  106453. /**
  106454. * Observable raised before camera teleportation
  106455. */
  106456. onBeforeCameraTeleport: Observable<Vector3>;
  106457. /**
  106458. * Observable raised after camera teleportation
  106459. */
  106460. onAfterCameraTeleport: Observable<Vector3>;
  106461. /**
  106462. * Observable raised when current selected mesh gets unselected
  106463. */
  106464. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106465. private _raySelectionPredicate;
  106466. /**
  106467. * To be optionaly changed by user to define custom ray selection
  106468. */
  106469. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106470. /**
  106471. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106472. */
  106473. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106474. /**
  106475. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106476. */
  106477. teleportationEnabled: boolean;
  106478. private _defaultHeight;
  106479. private _teleportationInitialized;
  106480. private _interactionsEnabled;
  106481. private _interactionsRequested;
  106482. private _displayGaze;
  106483. private _displayLaserPointer;
  106484. /**
  106485. * The mesh used to display where the user is going to teleport.
  106486. */
  106487. /**
  106488. * Sets the mesh to be used to display where the user is going to teleport.
  106489. */
  106490. teleportationTarget: Mesh;
  106491. /**
  106492. * 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
  106493. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106494. * See http://doc.babylonjs.com/resources/baking_transformations
  106495. */
  106496. gazeTrackerMesh: Mesh;
  106497. /**
  106498. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106499. */
  106500. updateGazeTrackerScale: boolean;
  106501. /**
  106502. * If the gaze trackers color should be updated when selecting meshes
  106503. */
  106504. updateGazeTrackerColor: boolean;
  106505. /**
  106506. * The gaze tracking mesh corresponding to the left controller
  106507. */
  106508. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106509. /**
  106510. * The gaze tracking mesh corresponding to the right controller
  106511. */
  106512. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106513. /**
  106514. * If the ray of the gaze should be displayed.
  106515. */
  106516. /**
  106517. * Sets if the ray of the gaze should be displayed.
  106518. */
  106519. displayGaze: boolean;
  106520. /**
  106521. * If the ray of the LaserPointer should be displayed.
  106522. */
  106523. /**
  106524. * Sets if the ray of the LaserPointer should be displayed.
  106525. */
  106526. displayLaserPointer: boolean;
  106527. /**
  106528. * The deviceOrientationCamera used as the camera when not in VR.
  106529. */
  106530. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106531. /**
  106532. * Based on the current WebVR support, returns the current VR camera used.
  106533. */
  106534. readonly currentVRCamera: Nullable<Camera>;
  106535. /**
  106536. * The webVRCamera which is used when in VR.
  106537. */
  106538. readonly webVRCamera: WebVRFreeCamera;
  106539. /**
  106540. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106541. */
  106542. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106543. /**
  106544. * The html button that is used to trigger entering into VR.
  106545. */
  106546. readonly vrButton: Nullable<HTMLButtonElement>;
  106547. private readonly _teleportationRequestInitiated;
  106548. /**
  106549. * Defines wether or not Pointer lock should be requested when switching to
  106550. * full screen.
  106551. */
  106552. requestPointerLockOnFullScreen: boolean;
  106553. /**
  106554. * Instantiates a VRExperienceHelper.
  106555. * Helps to quickly add VR support to an existing scene.
  106556. * @param scene The scene the VRExperienceHelper belongs to.
  106557. * @param webVROptions Options to modify the vr experience helper's behavior.
  106558. */
  106559. constructor(scene: Scene,
  106560. /** Options to modify the vr experience helper's behavior. */
  106561. webVROptions?: VRExperienceHelperOptions);
  106562. private _onDefaultMeshLoaded;
  106563. private _onResize;
  106564. private _onFullscreenChange;
  106565. /**
  106566. * Gets a value indicating if we are currently in VR mode.
  106567. */
  106568. readonly isInVRMode: boolean;
  106569. private onVrDisplayPresentChange;
  106570. private onVRDisplayChanged;
  106571. private moveButtonToBottomRight;
  106572. private displayVRButton;
  106573. private updateButtonVisibility;
  106574. private _cachedAngularSensibility;
  106575. /**
  106576. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106577. * Otherwise, will use the fullscreen API.
  106578. */
  106579. enterVR(): void;
  106580. /**
  106581. * Attempt to exit VR, or fullscreen.
  106582. */
  106583. exitVR(): void;
  106584. /**
  106585. * The position of the vr experience helper.
  106586. */
  106587. /**
  106588. * Sets the position of the vr experience helper.
  106589. */
  106590. position: Vector3;
  106591. /**
  106592. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106593. */
  106594. enableInteractions(): void;
  106595. private readonly _noControllerIsActive;
  106596. private beforeRender;
  106597. private _isTeleportationFloor;
  106598. /**
  106599. * Adds a floor mesh to be used for teleportation.
  106600. * @param floorMesh the mesh to be used for teleportation.
  106601. */
  106602. addFloorMesh(floorMesh: Mesh): void;
  106603. /**
  106604. * Removes a floor mesh from being used for teleportation.
  106605. * @param floorMesh the mesh to be removed.
  106606. */
  106607. removeFloorMesh(floorMesh: Mesh): void;
  106608. /**
  106609. * Enables interactions and teleportation using the VR controllers and gaze.
  106610. * @param vrTeleportationOptions options to modify teleportation behavior.
  106611. */
  106612. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106613. private _onNewGamepadConnected;
  106614. private _tryEnableInteractionOnController;
  106615. private _onNewGamepadDisconnected;
  106616. private _enableInteractionOnController;
  106617. private _checkTeleportWithRay;
  106618. private _checkRotate;
  106619. private _checkTeleportBackwards;
  106620. private _enableTeleportationOnController;
  106621. private _createTeleportationCircles;
  106622. private _displayTeleportationTarget;
  106623. private _hideTeleportationTarget;
  106624. private _rotateCamera;
  106625. private _moveTeleportationSelectorTo;
  106626. private _workingVector;
  106627. private _workingQuaternion;
  106628. private _workingMatrix;
  106629. /**
  106630. * Teleports the users feet to the desired location
  106631. * @param location The location where the user's feet should be placed
  106632. */
  106633. teleportCamera(location: Vector3): void;
  106634. private _convertNormalToDirectionOfRay;
  106635. private _castRayAndSelectObject;
  106636. private _notifySelectedMeshUnselected;
  106637. /**
  106638. * Sets the color of the laser ray from the vr controllers.
  106639. * @param color new color for the ray.
  106640. */
  106641. changeLaserColor(color: Color3): void;
  106642. /**
  106643. * Sets the color of the ray from the vr headsets gaze.
  106644. * @param color new color for the ray.
  106645. */
  106646. changeGazeColor(color: Color3): void;
  106647. /**
  106648. * Exits VR and disposes of the vr experience helper
  106649. */
  106650. dispose(): void;
  106651. /**
  106652. * Gets the name of the VRExperienceHelper class
  106653. * @returns "VRExperienceHelper"
  106654. */
  106655. getClassName(): string;
  106656. }
  106657. }
  106658. declare module BABYLON {
  106659. /**
  106660. * Manages an XRSession to work with Babylon's engine
  106661. * @see https://doc.babylonjs.com/how_to/webxr
  106662. */
  106663. export class WebXRSessionManager implements IDisposable {
  106664. private scene;
  106665. /**
  106666. * Fires every time a new xrFrame arrives which can be used to update the camera
  106667. */
  106668. onXRFrameObservable: Observable<any>;
  106669. /**
  106670. * Fires when the xr session is ended either by the device or manually done
  106671. */
  106672. onXRSessionEnded: Observable<any>;
  106673. /**
  106674. * Underlying xr session
  106675. */
  106676. session: XRSession;
  106677. /**
  106678. * Type of reference space used when creating the session
  106679. */
  106680. referenceSpace: XRReferenceSpace;
  106681. /** @hidden */
  106682. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106683. /**
  106684. * Current XR frame
  106685. */
  106686. currentFrame: Nullable<XRFrame>;
  106687. private _xrNavigator;
  106688. private baseLayer;
  106689. /**
  106690. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106691. * @param scene The scene which the session should be created for
  106692. */
  106693. constructor(scene: Scene);
  106694. /**
  106695. * Initializes the manager
  106696. * After initialization enterXR can be called to start an XR session
  106697. * @returns Promise which resolves after it is initialized
  106698. */
  106699. initializeAsync(): Promise<void>;
  106700. /**
  106701. * Initializes an xr session
  106702. * @param xrSessionMode mode to initialize
  106703. * @returns a promise which will resolve once the session has been initialized
  106704. */
  106705. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106706. /**
  106707. * Sets the reference space on the xr session
  106708. * @param referenceSpace space to set
  106709. * @returns a promise that will resolve once the reference space has been set
  106710. */
  106711. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106712. /**
  106713. * Updates the render state of the session
  106714. * @param state state to set
  106715. * @returns a promise that resolves once the render state has been updated
  106716. */
  106717. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106718. /**
  106719. * Starts rendering to the xr layer
  106720. * @returns a promise that will resolve once rendering has started
  106721. */
  106722. startRenderingToXRAsync(): Promise<void>;
  106723. /**
  106724. * Stops the xrSession and restores the renderloop
  106725. * @returns Promise which resolves after it exits XR
  106726. */
  106727. exitXRAsync(): Promise<unknown>;
  106728. /**
  106729. * Checks if a session would be supported for the creation options specified
  106730. * @param sessionMode session mode to check if supported eg. immersive-vr
  106731. * @returns true if supported
  106732. */
  106733. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106734. /**
  106735. * @hidden
  106736. * Converts the render layer of xrSession to a render target
  106737. * @param session session to create render target for
  106738. * @param scene scene the new render target should be created for
  106739. */
  106740. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106741. /**
  106742. * Disposes of the session manager
  106743. */
  106744. dispose(): void;
  106745. }
  106746. }
  106747. declare module BABYLON {
  106748. /**
  106749. * WebXR Camera which holds the views for the xrSession
  106750. * @see https://doc.babylonjs.com/how_to/webxr
  106751. */
  106752. export class WebXRCamera extends FreeCamera {
  106753. private static _TmpMatrix;
  106754. /**
  106755. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106756. * @param name the name of the camera
  106757. * @param scene the scene to add the camera to
  106758. */
  106759. constructor(name: string, scene: Scene);
  106760. private _updateNumberOfRigCameras;
  106761. /** @hidden */
  106762. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106763. /**
  106764. * Updates the cameras position from the current pose information of the XR session
  106765. * @param xrSessionManager the session containing pose information
  106766. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106767. */
  106768. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106769. }
  106770. }
  106771. declare module BABYLON {
  106772. /**
  106773. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106774. */
  106775. export class WebXRManagedOutputCanvas implements IDisposable {
  106776. private helper;
  106777. private _canvas;
  106778. /**
  106779. * xrpresent context of the canvas which can be used to display/mirror xr content
  106780. */
  106781. canvasContext: WebGLRenderingContext;
  106782. /**
  106783. * xr layer for the canvas
  106784. */
  106785. xrLayer: Nullable<XRWebGLLayer>;
  106786. /**
  106787. * Initializes the xr layer for the session
  106788. * @param xrSession xr session
  106789. * @returns a promise that will resolve once the XR Layer has been created
  106790. */
  106791. initializeXRLayerAsync(xrSession: any): any;
  106792. /**
  106793. * Initializes the canvas to be added/removed upon entering/exiting xr
  106794. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106795. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106796. */
  106797. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106798. /**
  106799. * Disposes of the object
  106800. */
  106801. dispose(): void;
  106802. private _setManagedOutputCanvas;
  106803. private _addCanvas;
  106804. private _removeCanvas;
  106805. }
  106806. }
  106807. declare module BABYLON {
  106808. /**
  106809. * States of the webXR experience
  106810. */
  106811. export enum WebXRState {
  106812. /**
  106813. * Transitioning to being in XR mode
  106814. */
  106815. ENTERING_XR = 0,
  106816. /**
  106817. * Transitioning to non XR mode
  106818. */
  106819. EXITING_XR = 1,
  106820. /**
  106821. * In XR mode and presenting
  106822. */
  106823. IN_XR = 2,
  106824. /**
  106825. * Not entered XR mode
  106826. */
  106827. NOT_IN_XR = 3
  106828. }
  106829. /**
  106830. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106831. * @see https://doc.babylonjs.com/how_to/webxr
  106832. */
  106833. export class WebXRExperienceHelper implements IDisposable {
  106834. private scene;
  106835. /**
  106836. * 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
  106837. */
  106838. container: AbstractMesh;
  106839. /**
  106840. * Camera used to render xr content
  106841. */
  106842. camera: WebXRCamera;
  106843. /**
  106844. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106845. */
  106846. state: WebXRState;
  106847. private _setState;
  106848. private static _TmpVector;
  106849. /**
  106850. * Fires when the state of the experience helper has changed
  106851. */
  106852. onStateChangedObservable: Observable<WebXRState>;
  106853. /** Session manager used to keep track of xr session */
  106854. sessionManager: WebXRSessionManager;
  106855. private _nonVRCamera;
  106856. private _originalSceneAutoClear;
  106857. private _supported;
  106858. /**
  106859. * Creates the experience helper
  106860. * @param scene the scene to attach the experience helper to
  106861. * @returns a promise for the experience helper
  106862. */
  106863. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106864. /**
  106865. * Creates a WebXRExperienceHelper
  106866. * @param scene The scene the helper should be created in
  106867. */
  106868. private constructor();
  106869. /**
  106870. * Exits XR mode and returns the scene to its original state
  106871. * @returns promise that resolves after xr mode has exited
  106872. */
  106873. exitXRAsync(): Promise<unknown>;
  106874. /**
  106875. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106876. * @param sessionCreationOptions options for the XR session
  106877. * @param referenceSpaceType frame of reference of the XR session
  106878. * @param outputCanvas the output canvas that will be used to enter XR mode
  106879. * @returns promise that resolves after xr mode has entered
  106880. */
  106881. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106882. /**
  106883. * Updates the global position of the camera by moving the camera's container
  106884. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106885. * @param position The desired global position of the camera
  106886. */
  106887. setPositionOfCameraUsingContainer(position: Vector3): void;
  106888. /**
  106889. * Rotates the xr camera by rotating the camera's container around the camera's position
  106890. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106891. * @param rotation the desired quaternion rotation to apply to the camera
  106892. */
  106893. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106894. /**
  106895. * Disposes of the experience helper
  106896. */
  106897. dispose(): void;
  106898. }
  106899. }
  106900. declare module BABYLON {
  106901. /**
  106902. * Button which can be used to enter a different mode of XR
  106903. */
  106904. export class WebXREnterExitUIButton {
  106905. /** button element */
  106906. element: HTMLElement;
  106907. /** XR initialization options for the button */
  106908. sessionMode: XRSessionMode;
  106909. /** Reference space type */
  106910. referenceSpaceType: XRReferenceSpaceType;
  106911. /**
  106912. * Creates a WebXREnterExitUIButton
  106913. * @param element button element
  106914. * @param sessionMode XR initialization session mode
  106915. * @param referenceSpaceType the type of reference space to be used
  106916. */
  106917. constructor(
  106918. /** button element */
  106919. element: HTMLElement,
  106920. /** XR initialization options for the button */
  106921. sessionMode: XRSessionMode,
  106922. /** Reference space type */
  106923. referenceSpaceType: XRReferenceSpaceType);
  106924. /**
  106925. * Overwritable function which can be used to update the button's visuals when the state changes
  106926. * @param activeButton the current active button in the UI
  106927. */
  106928. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106929. }
  106930. /**
  106931. * Options to create the webXR UI
  106932. */
  106933. export class WebXREnterExitUIOptions {
  106934. /**
  106935. * Context to enter xr with
  106936. */
  106937. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106938. /**
  106939. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106940. */
  106941. customButtons?: Array<WebXREnterExitUIButton>;
  106942. }
  106943. /**
  106944. * UI to allow the user to enter/exit XR mode
  106945. */
  106946. export class WebXREnterExitUI implements IDisposable {
  106947. private scene;
  106948. private _overlay;
  106949. private _buttons;
  106950. private _activeButton;
  106951. /**
  106952. * Fired every time the active button is changed.
  106953. *
  106954. * When xr is entered via a button that launches xr that button will be the callback parameter
  106955. *
  106956. * When exiting xr the callback parameter will be null)
  106957. */
  106958. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106959. /**
  106960. * Creates UI to allow the user to enter/exit XR mode
  106961. * @param scene the scene to add the ui to
  106962. * @param helper the xr experience helper to enter/exit xr with
  106963. * @param options options to configure the UI
  106964. * @returns the created ui
  106965. */
  106966. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106967. private constructor();
  106968. private _updateButtons;
  106969. /**
  106970. * Disposes of the object
  106971. */
  106972. dispose(): void;
  106973. }
  106974. }
  106975. declare module BABYLON {
  106976. /**
  106977. * Represents an XR input
  106978. */
  106979. export class WebXRController {
  106980. private scene;
  106981. /** The underlying input source for the controller */
  106982. inputSource: XRInputSource;
  106983. private parentContainer;
  106984. /**
  106985. * 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
  106986. */
  106987. grip?: AbstractMesh;
  106988. /**
  106989. * Pointer which can be used to select objects or attach a visible laser to
  106990. */
  106991. pointer: AbstractMesh;
  106992. /**
  106993. * Event that fires when the controller is removed/disposed
  106994. */
  106995. onDisposeObservable: Observable<{}>;
  106996. private _tmpMatrix;
  106997. private _tmpQuaternion;
  106998. private _tmpVector;
  106999. /**
  107000. * Creates the controller
  107001. * @see https://doc.babylonjs.com/how_to/webxr
  107002. * @param scene the scene which the controller should be associated to
  107003. * @param inputSource the underlying input source for the controller
  107004. * @param parentContainer parent that the controller meshes should be children of
  107005. */
  107006. constructor(scene: Scene,
  107007. /** The underlying input source for the controller */
  107008. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107009. /**
  107010. * Updates the controller pose based on the given XRFrame
  107011. * @param xrFrame xr frame to update the pose with
  107012. * @param referenceSpace reference space to use
  107013. */
  107014. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107015. /**
  107016. * Gets a world space ray coming from the controller
  107017. * @param result the resulting ray
  107018. */
  107019. getWorldPointerRayToRef(result: Ray): void;
  107020. /**
  107021. * Disposes of the object
  107022. */
  107023. dispose(): void;
  107024. }
  107025. }
  107026. declare module BABYLON {
  107027. /**
  107028. * XR input used to track XR inputs such as controllers/rays
  107029. */
  107030. export class WebXRInput implements IDisposable {
  107031. /**
  107032. * Base experience the input listens to
  107033. */
  107034. baseExperience: WebXRExperienceHelper;
  107035. /**
  107036. * XR controllers being tracked
  107037. */
  107038. controllers: Array<WebXRController>;
  107039. private _frameObserver;
  107040. private _stateObserver;
  107041. /**
  107042. * Event when a controller has been connected/added
  107043. */
  107044. onControllerAddedObservable: Observable<WebXRController>;
  107045. /**
  107046. * Event when a controller has been removed/disconnected
  107047. */
  107048. onControllerRemovedObservable: Observable<WebXRController>;
  107049. /**
  107050. * Initializes the WebXRInput
  107051. * @param baseExperience experience helper which the input should be created for
  107052. */
  107053. constructor(
  107054. /**
  107055. * Base experience the input listens to
  107056. */
  107057. baseExperience: WebXRExperienceHelper);
  107058. private _onInputSourcesChange;
  107059. private _addAndRemoveControllers;
  107060. /**
  107061. * Disposes of the object
  107062. */
  107063. dispose(): void;
  107064. }
  107065. }
  107066. declare module BABYLON {
  107067. /**
  107068. * Enables teleportation
  107069. */
  107070. export class WebXRControllerTeleportation {
  107071. private _teleportationFillColor;
  107072. private _teleportationBorderColor;
  107073. private _tmpRay;
  107074. private _tmpVector;
  107075. /**
  107076. * Creates a WebXRControllerTeleportation
  107077. * @param input input manager to add teleportation to
  107078. * @param floorMeshes floormeshes which can be teleported to
  107079. */
  107080. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107081. }
  107082. }
  107083. declare module BABYLON {
  107084. /**
  107085. * Handles pointer input automatically for the pointer of XR controllers
  107086. */
  107087. export class WebXRControllerPointerSelection {
  107088. private static _idCounter;
  107089. private _tmpRay;
  107090. /**
  107091. * Creates a WebXRControllerPointerSelection
  107092. * @param input input manager to setup pointer selection
  107093. */
  107094. constructor(input: WebXRInput);
  107095. private _convertNormalToDirectionOfRay;
  107096. private _updatePointerDistance;
  107097. }
  107098. }
  107099. declare module BABYLON {
  107100. /**
  107101. * Class used to represent data loading progression
  107102. */
  107103. export class SceneLoaderProgressEvent {
  107104. /** defines if data length to load can be evaluated */
  107105. readonly lengthComputable: boolean;
  107106. /** defines the loaded data length */
  107107. readonly loaded: number;
  107108. /** defines the data length to load */
  107109. readonly total: number;
  107110. /**
  107111. * Create a new progress event
  107112. * @param lengthComputable defines if data length to load can be evaluated
  107113. * @param loaded defines the loaded data length
  107114. * @param total defines the data length to load
  107115. */
  107116. constructor(
  107117. /** defines if data length to load can be evaluated */
  107118. lengthComputable: boolean,
  107119. /** defines the loaded data length */
  107120. loaded: number,
  107121. /** defines the data length to load */
  107122. total: number);
  107123. /**
  107124. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107125. * @param event defines the source event
  107126. * @returns a new SceneLoaderProgressEvent
  107127. */
  107128. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107129. }
  107130. /**
  107131. * Interface used by SceneLoader plugins to define supported file extensions
  107132. */
  107133. export interface ISceneLoaderPluginExtensions {
  107134. /**
  107135. * Defines the list of supported extensions
  107136. */
  107137. [extension: string]: {
  107138. isBinary: boolean;
  107139. };
  107140. }
  107141. /**
  107142. * Interface used by SceneLoader plugin factory
  107143. */
  107144. export interface ISceneLoaderPluginFactory {
  107145. /**
  107146. * Defines the name of the factory
  107147. */
  107148. name: string;
  107149. /**
  107150. * Function called to create a new plugin
  107151. * @return the new plugin
  107152. */
  107153. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107154. /**
  107155. * Boolean indicating if the plugin can direct load specific data
  107156. */
  107157. canDirectLoad?: (data: string) => boolean;
  107158. }
  107159. /**
  107160. * Interface used to define a SceneLoader plugin
  107161. */
  107162. export interface ISceneLoaderPlugin {
  107163. /**
  107164. * The friendly name of this plugin.
  107165. */
  107166. name: string;
  107167. /**
  107168. * The file extensions supported by this plugin.
  107169. */
  107170. extensions: string | ISceneLoaderPluginExtensions;
  107171. /**
  107172. * Import meshes into a scene.
  107173. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107174. * @param scene The scene to import into
  107175. * @param data The data to import
  107176. * @param rootUrl The root url for scene and resources
  107177. * @param meshes The meshes array to import into
  107178. * @param particleSystems The particle systems array to import into
  107179. * @param skeletons The skeletons array to import into
  107180. * @param onError The callback when import fails
  107181. * @returns True if successful or false otherwise
  107182. */
  107183. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107184. /**
  107185. * Load into a scene.
  107186. * @param scene The scene to load into
  107187. * @param data The data to import
  107188. * @param rootUrl The root url for scene and resources
  107189. * @param onError The callback when import fails
  107190. * @returns true if successful or false otherwise
  107191. */
  107192. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107193. /**
  107194. * The callback that returns true if the data can be directly loaded.
  107195. */
  107196. canDirectLoad?: (data: string) => boolean;
  107197. /**
  107198. * The callback that allows custom handling of the root url based on the response url.
  107199. */
  107200. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107201. /**
  107202. * Load into an asset container.
  107203. * @param scene The scene to load into
  107204. * @param data The data to import
  107205. * @param rootUrl The root url for scene and resources
  107206. * @param onError The callback when import fails
  107207. * @returns The loaded asset container
  107208. */
  107209. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107210. }
  107211. /**
  107212. * Interface used to define an async SceneLoader plugin
  107213. */
  107214. export interface ISceneLoaderPluginAsync {
  107215. /**
  107216. * The friendly name of this plugin.
  107217. */
  107218. name: string;
  107219. /**
  107220. * The file extensions supported by this plugin.
  107221. */
  107222. extensions: string | ISceneLoaderPluginExtensions;
  107223. /**
  107224. * Import meshes into a scene.
  107225. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107226. * @param scene The scene to import into
  107227. * @param data The data to import
  107228. * @param rootUrl The root url for scene and resources
  107229. * @param onProgress The callback when the load progresses
  107230. * @param fileName Defines the name of the file to load
  107231. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107232. */
  107233. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107234. meshes: AbstractMesh[];
  107235. particleSystems: IParticleSystem[];
  107236. skeletons: Skeleton[];
  107237. animationGroups: AnimationGroup[];
  107238. }>;
  107239. /**
  107240. * Load into a scene.
  107241. * @param scene The scene to load into
  107242. * @param data The data to import
  107243. * @param rootUrl The root url for scene and resources
  107244. * @param onProgress The callback when the load progresses
  107245. * @param fileName Defines the name of the file to load
  107246. * @returns Nothing
  107247. */
  107248. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107249. /**
  107250. * The callback that returns true if the data can be directly loaded.
  107251. */
  107252. canDirectLoad?: (data: string) => boolean;
  107253. /**
  107254. * The callback that allows custom handling of the root url based on the response url.
  107255. */
  107256. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107257. /**
  107258. * Load into an asset container.
  107259. * @param scene The scene to load into
  107260. * @param data The data to import
  107261. * @param rootUrl The root url for scene and resources
  107262. * @param onProgress The callback when the load progresses
  107263. * @param fileName Defines the name of the file to load
  107264. * @returns The loaded asset container
  107265. */
  107266. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107267. }
  107268. /**
  107269. * Class used to load scene from various file formats using registered plugins
  107270. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107271. */
  107272. export class SceneLoader {
  107273. /**
  107274. * No logging while loading
  107275. */
  107276. static readonly NO_LOGGING: number;
  107277. /**
  107278. * Minimal logging while loading
  107279. */
  107280. static readonly MINIMAL_LOGGING: number;
  107281. /**
  107282. * Summary logging while loading
  107283. */
  107284. static readonly SUMMARY_LOGGING: number;
  107285. /**
  107286. * Detailled logging while loading
  107287. */
  107288. static readonly DETAILED_LOGGING: number;
  107289. /**
  107290. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107291. */
  107292. static ForceFullSceneLoadingForIncremental: boolean;
  107293. /**
  107294. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107295. */
  107296. static ShowLoadingScreen: boolean;
  107297. /**
  107298. * Defines the current logging level (while loading the scene)
  107299. * @ignorenaming
  107300. */
  107301. static loggingLevel: number;
  107302. /**
  107303. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107304. */
  107305. static CleanBoneMatrixWeights: boolean;
  107306. /**
  107307. * Event raised when a plugin is used to load a scene
  107308. */
  107309. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107310. private static _registeredPlugins;
  107311. private static _getDefaultPlugin;
  107312. private static _getPluginForExtension;
  107313. private static _getPluginForDirectLoad;
  107314. private static _getPluginForFilename;
  107315. private static _getDirectLoad;
  107316. private static _loadData;
  107317. private static _getFileInfo;
  107318. /**
  107319. * Gets a plugin that can load the given extension
  107320. * @param extension defines the extension to load
  107321. * @returns a plugin or null if none works
  107322. */
  107323. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107324. /**
  107325. * Gets a boolean indicating that the given extension can be loaded
  107326. * @param extension defines the extension to load
  107327. * @returns true if the extension is supported
  107328. */
  107329. static IsPluginForExtensionAvailable(extension: string): boolean;
  107330. /**
  107331. * Adds a new plugin to the list of registered plugins
  107332. * @param plugin defines the plugin to add
  107333. */
  107334. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107335. /**
  107336. * Import meshes into a scene
  107337. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107338. * @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)
  107339. * @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)
  107340. * @param scene the instance of BABYLON.Scene to append to
  107341. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107342. * @param onProgress a callback with a progress event for each file being loaded
  107343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107344. * @param pluginExtension the extension used to determine the plugin
  107345. * @returns The loaded plugin
  107346. */
  107347. 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>;
  107348. /**
  107349. * Import meshes into a scene
  107350. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107351. * @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)
  107352. * @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)
  107353. * @param scene the instance of BABYLON.Scene to append to
  107354. * @param onProgress a callback with a progress event for each file being loaded
  107355. * @param pluginExtension the extension used to determine the plugin
  107356. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107357. */
  107358. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107359. meshes: AbstractMesh[];
  107360. particleSystems: IParticleSystem[];
  107361. skeletons: Skeleton[];
  107362. animationGroups: AnimationGroup[];
  107363. }>;
  107364. /**
  107365. * Load a scene
  107366. * @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)
  107367. * @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)
  107368. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107369. * @param onSuccess a callback with the scene when import succeeds
  107370. * @param onProgress a callback with a progress event for each file being loaded
  107371. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107372. * @param pluginExtension the extension used to determine the plugin
  107373. * @returns The loaded plugin
  107374. */
  107375. 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>;
  107376. /**
  107377. * Load a scene
  107378. * @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)
  107379. * @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)
  107380. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107381. * @param onProgress a callback with a progress event for each file being loaded
  107382. * @param pluginExtension the extension used to determine the plugin
  107383. * @returns The loaded scene
  107384. */
  107385. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107386. /**
  107387. * Append a scene
  107388. * @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)
  107389. * @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)
  107390. * @param scene is the instance of BABYLON.Scene to append to
  107391. * @param onSuccess a callback with the scene when import succeeds
  107392. * @param onProgress a callback with a progress event for each file being loaded
  107393. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107394. * @param pluginExtension the extension used to determine the plugin
  107395. * @returns The loaded plugin
  107396. */
  107397. 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>;
  107398. /**
  107399. * Append a scene
  107400. * @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)
  107401. * @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)
  107402. * @param scene is the instance of BABYLON.Scene to append to
  107403. * @param onProgress a callback with a progress event for each file being loaded
  107404. * @param pluginExtension the extension used to determine the plugin
  107405. * @returns The given scene
  107406. */
  107407. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107408. /**
  107409. * Load a scene into an asset container
  107410. * @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)
  107411. * @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)
  107412. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107413. * @param onSuccess a callback with the scene when import succeeds
  107414. * @param onProgress a callback with a progress event for each file being loaded
  107415. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107416. * @param pluginExtension the extension used to determine the plugin
  107417. * @returns The loaded plugin
  107418. */
  107419. 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>;
  107420. /**
  107421. * Load a scene into an asset container
  107422. * @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)
  107423. * @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)
  107424. * @param scene is the instance of Scene to append to
  107425. * @param onProgress a callback with a progress event for each file being loaded
  107426. * @param pluginExtension the extension used to determine the plugin
  107427. * @returns The loaded asset container
  107428. */
  107429. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107430. }
  107431. }
  107432. declare module BABYLON {
  107433. /**
  107434. * Generic Controller
  107435. */
  107436. export class GenericController extends WebVRController {
  107437. /**
  107438. * Base Url for the controller model.
  107439. */
  107440. static readonly MODEL_BASE_URL: string;
  107441. /**
  107442. * File name for the controller model.
  107443. */
  107444. static readonly MODEL_FILENAME: string;
  107445. /**
  107446. * Creates a new GenericController from a gamepad
  107447. * @param vrGamepad the gamepad that the controller should be created from
  107448. */
  107449. constructor(vrGamepad: any);
  107450. /**
  107451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107452. * @param scene scene in which to add meshes
  107453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107454. */
  107455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107456. /**
  107457. * Called once for each button that changed state since the last frame
  107458. * @param buttonIdx Which button index changed
  107459. * @param state New state of the button
  107460. * @param changes Which properties on the state changed since last frame
  107461. */
  107462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107463. }
  107464. }
  107465. declare module BABYLON {
  107466. /**
  107467. * Defines the WindowsMotionController object that the state of the windows motion controller
  107468. */
  107469. export class WindowsMotionController extends WebVRController {
  107470. /**
  107471. * The base url used to load the left and right controller models
  107472. */
  107473. static MODEL_BASE_URL: string;
  107474. /**
  107475. * The name of the left controller model file
  107476. */
  107477. static MODEL_LEFT_FILENAME: string;
  107478. /**
  107479. * The name of the right controller model file
  107480. */
  107481. static MODEL_RIGHT_FILENAME: string;
  107482. /**
  107483. * The controller name prefix for this controller type
  107484. */
  107485. static readonly GAMEPAD_ID_PREFIX: string;
  107486. /**
  107487. * The controller id pattern for this controller type
  107488. */
  107489. private static readonly GAMEPAD_ID_PATTERN;
  107490. private _loadedMeshInfo;
  107491. private readonly _mapping;
  107492. /**
  107493. * Fired when the trackpad on this controller is clicked
  107494. */
  107495. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107496. /**
  107497. * Fired when the trackpad on this controller is modified
  107498. */
  107499. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107500. /**
  107501. * The current x and y values of this controller's trackpad
  107502. */
  107503. trackpad: StickValues;
  107504. /**
  107505. * Creates a new WindowsMotionController from a gamepad
  107506. * @param vrGamepad the gamepad that the controller should be created from
  107507. */
  107508. constructor(vrGamepad: any);
  107509. /**
  107510. * Fired when the trigger on this controller is modified
  107511. */
  107512. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107513. /**
  107514. * Fired when the menu button on this controller is modified
  107515. */
  107516. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107517. /**
  107518. * Fired when the grip button on this controller is modified
  107519. */
  107520. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107521. /**
  107522. * Fired when the thumbstick button on this controller is modified
  107523. */
  107524. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107525. /**
  107526. * Fired when the touchpad button on this controller is modified
  107527. */
  107528. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107529. /**
  107530. * Fired when the touchpad values on this controller are modified
  107531. */
  107532. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107533. private _updateTrackpad;
  107534. /**
  107535. * Called once per frame by the engine.
  107536. */
  107537. update(): void;
  107538. /**
  107539. * Called once for each button that changed state since the last frame
  107540. * @param buttonIdx Which button index changed
  107541. * @param state New state of the button
  107542. * @param changes Which properties on the state changed since last frame
  107543. */
  107544. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107545. /**
  107546. * Moves the buttons on the controller mesh based on their current state
  107547. * @param buttonName the name of the button to move
  107548. * @param buttonValue the value of the button which determines the buttons new position
  107549. */
  107550. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107551. /**
  107552. * Moves the axis on the controller mesh based on its current state
  107553. * @param axis the index of the axis
  107554. * @param axisValue the value of the axis which determines the meshes new position
  107555. * @hidden
  107556. */
  107557. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107558. /**
  107559. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107560. * @param scene scene in which to add meshes
  107561. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107562. */
  107563. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107564. /**
  107565. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107566. * can be transformed by button presses and axes values, based on this._mapping.
  107567. *
  107568. * @param scene scene in which the meshes exist
  107569. * @param meshes list of meshes that make up the controller model to process
  107570. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107571. */
  107572. private processModel;
  107573. private createMeshInfo;
  107574. /**
  107575. * Gets the ray of the controller in the direction the controller is pointing
  107576. * @param length the length the resulting ray should be
  107577. * @returns a ray in the direction the controller is pointing
  107578. */
  107579. getForwardRay(length?: number): Ray;
  107580. /**
  107581. * Disposes of the controller
  107582. */
  107583. dispose(): void;
  107584. }
  107585. }
  107586. declare module BABYLON {
  107587. /**
  107588. * Oculus Touch Controller
  107589. */
  107590. export class OculusTouchController extends WebVRController {
  107591. /**
  107592. * Base Url for the controller model.
  107593. */
  107594. static MODEL_BASE_URL: string;
  107595. /**
  107596. * File name for the left controller model.
  107597. */
  107598. static MODEL_LEFT_FILENAME: string;
  107599. /**
  107600. * File name for the right controller model.
  107601. */
  107602. static MODEL_RIGHT_FILENAME: string;
  107603. /**
  107604. * Base Url for the Quest controller model.
  107605. */
  107606. static QUEST_MODEL_BASE_URL: string;
  107607. /**
  107608. * @hidden
  107609. * If the controllers are running on a device that needs the updated Quest controller models
  107610. */
  107611. static _IsQuest: boolean;
  107612. /**
  107613. * Fired when the secondary trigger on this controller is modified
  107614. */
  107615. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107616. /**
  107617. * Fired when the thumb rest on this controller is modified
  107618. */
  107619. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107620. /**
  107621. * Creates a new OculusTouchController from a gamepad
  107622. * @param vrGamepad the gamepad that the controller should be created from
  107623. */
  107624. constructor(vrGamepad: any);
  107625. /**
  107626. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107627. * @param scene scene in which to add meshes
  107628. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107629. */
  107630. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107631. /**
  107632. * Fired when the A button on this controller is modified
  107633. */
  107634. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107635. /**
  107636. * Fired when the B button on this controller is modified
  107637. */
  107638. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107639. /**
  107640. * Fired when the X button on this controller is modified
  107641. */
  107642. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107643. /**
  107644. * Fired when the Y button on this controller is modified
  107645. */
  107646. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107647. /**
  107648. * Called once for each button that changed state since the last frame
  107649. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107650. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107651. * 2) secondary trigger (same)
  107652. * 3) A (right) X (left), touch, pressed = value
  107653. * 4) B / Y
  107654. * 5) thumb rest
  107655. * @param buttonIdx Which button index changed
  107656. * @param state New state of the button
  107657. * @param changes Which properties on the state changed since last frame
  107658. */
  107659. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107660. }
  107661. }
  107662. declare module BABYLON {
  107663. /**
  107664. * Vive Controller
  107665. */
  107666. export class ViveController extends WebVRController {
  107667. /**
  107668. * Base Url for the controller model.
  107669. */
  107670. static MODEL_BASE_URL: string;
  107671. /**
  107672. * File name for the controller model.
  107673. */
  107674. static MODEL_FILENAME: string;
  107675. /**
  107676. * Creates a new ViveController from a gamepad
  107677. * @param vrGamepad the gamepad that the controller should be created from
  107678. */
  107679. constructor(vrGamepad: any);
  107680. /**
  107681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107682. * @param scene scene in which to add meshes
  107683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107684. */
  107685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107686. /**
  107687. * Fired when the left button on this controller is modified
  107688. */
  107689. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107690. /**
  107691. * Fired when the right button on this controller is modified
  107692. */
  107693. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107694. /**
  107695. * Fired when the menu button on this controller is modified
  107696. */
  107697. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107698. /**
  107699. * Called once for each button that changed state since the last frame
  107700. * Vive mapping:
  107701. * 0: touchpad
  107702. * 1: trigger
  107703. * 2: left AND right buttons
  107704. * 3: menu button
  107705. * @param buttonIdx Which button index changed
  107706. * @param state New state of the button
  107707. * @param changes Which properties on the state changed since last frame
  107708. */
  107709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107710. }
  107711. }
  107712. declare module BABYLON {
  107713. /**
  107714. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107715. */
  107716. export class WebXRControllerModelLoader {
  107717. /**
  107718. * Creates the WebXRControllerModelLoader
  107719. * @param input xr input that creates the controllers
  107720. */
  107721. constructor(input: WebXRInput);
  107722. }
  107723. }
  107724. declare module BABYLON {
  107725. /**
  107726. * Contains an array of blocks representing the octree
  107727. */
  107728. export interface IOctreeContainer<T> {
  107729. /**
  107730. * Blocks within the octree
  107731. */
  107732. blocks: Array<OctreeBlock<T>>;
  107733. }
  107734. /**
  107735. * Class used to store a cell in an octree
  107736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107737. */
  107738. export class OctreeBlock<T> {
  107739. /**
  107740. * Gets the content of the current block
  107741. */
  107742. entries: T[];
  107743. /**
  107744. * Gets the list of block children
  107745. */
  107746. blocks: Array<OctreeBlock<T>>;
  107747. private _depth;
  107748. private _maxDepth;
  107749. private _capacity;
  107750. private _minPoint;
  107751. private _maxPoint;
  107752. private _boundingVectors;
  107753. private _creationFunc;
  107754. /**
  107755. * Creates a new block
  107756. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107757. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107758. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107759. * @param depth defines the current depth of this block in the octree
  107760. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107761. * @param creationFunc defines a callback to call when an element is added to the block
  107762. */
  107763. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107764. /**
  107765. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107766. */
  107767. readonly capacity: number;
  107768. /**
  107769. * Gets the minimum vector (in world space) of the block's bounding box
  107770. */
  107771. readonly minPoint: Vector3;
  107772. /**
  107773. * Gets the maximum vector (in world space) of the block's bounding box
  107774. */
  107775. readonly maxPoint: Vector3;
  107776. /**
  107777. * Add a new element to this block
  107778. * @param entry defines the element to add
  107779. */
  107780. addEntry(entry: T): void;
  107781. /**
  107782. * Remove an element from this block
  107783. * @param entry defines the element to remove
  107784. */
  107785. removeEntry(entry: T): void;
  107786. /**
  107787. * Add an array of elements to this block
  107788. * @param entries defines the array of elements to add
  107789. */
  107790. addEntries(entries: T[]): void;
  107791. /**
  107792. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107793. * @param frustumPlanes defines the frustum planes to test
  107794. * @param selection defines the array to store current content if selection is positive
  107795. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107796. */
  107797. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107798. /**
  107799. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107800. * @param sphereCenter defines the bounding sphere center
  107801. * @param sphereRadius defines the bounding sphere radius
  107802. * @param selection defines the array to store current content if selection is positive
  107803. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107804. */
  107805. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107806. /**
  107807. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107808. * @param ray defines the ray to test with
  107809. * @param selection defines the array to store current content if selection is positive
  107810. */
  107811. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107812. /**
  107813. * Subdivide the content into child blocks (this block will then be empty)
  107814. */
  107815. createInnerBlocks(): void;
  107816. /**
  107817. * @hidden
  107818. */
  107819. 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;
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /**
  107824. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107826. */
  107827. export class Octree<T> {
  107828. /** 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.) */
  107829. maxDepth: number;
  107830. /**
  107831. * Blocks within the octree containing objects
  107832. */
  107833. blocks: Array<OctreeBlock<T>>;
  107834. /**
  107835. * Content stored in the octree
  107836. */
  107837. dynamicContent: T[];
  107838. private _maxBlockCapacity;
  107839. private _selectionContent;
  107840. private _creationFunc;
  107841. /**
  107842. * Creates a octree
  107843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107844. * @param creationFunc function to be used to instatiate the octree
  107845. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107846. * @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.)
  107847. */
  107848. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107849. /** 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.) */
  107850. maxDepth?: number);
  107851. /**
  107852. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107853. * @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);
  107854. * @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);
  107855. * @param entries meshes to be added to the octree blocks
  107856. */
  107857. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107858. /**
  107859. * Adds a mesh to the octree
  107860. * @param entry Mesh to add to the octree
  107861. */
  107862. addMesh(entry: T): void;
  107863. /**
  107864. * Remove an element from the octree
  107865. * @param entry defines the element to remove
  107866. */
  107867. removeMesh(entry: T): void;
  107868. /**
  107869. * Selects an array of meshes within the frustum
  107870. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107871. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107872. * @returns array of meshes within the frustum
  107873. */
  107874. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107875. /**
  107876. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107877. * @param sphereCenter defines the bounding sphere center
  107878. * @param sphereRadius defines the bounding sphere radius
  107879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107880. * @returns an array of objects that intersect the sphere
  107881. */
  107882. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107883. /**
  107884. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107885. * @param ray defines the ray to test with
  107886. * @returns array of intersected objects
  107887. */
  107888. intersectsRay(ray: Ray): SmartArray<T>;
  107889. /**
  107890. * Adds a mesh into the octree block if it intersects the block
  107891. */
  107892. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107893. /**
  107894. * Adds a submesh into the octree block if it intersects the block
  107895. */
  107896. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107897. }
  107898. }
  107899. declare module BABYLON {
  107900. interface Scene {
  107901. /**
  107902. * @hidden
  107903. * Backing Filed
  107904. */
  107905. _selectionOctree: Octree<AbstractMesh>;
  107906. /**
  107907. * Gets the octree used to boost mesh selection (picking)
  107908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107909. */
  107910. selectionOctree: Octree<AbstractMesh>;
  107911. /**
  107912. * Creates or updates the octree used to boost selection (picking)
  107913. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107914. * @param maxCapacity defines the maximum capacity per leaf
  107915. * @param maxDepth defines the maximum depth of the octree
  107916. * @returns an octree of AbstractMesh
  107917. */
  107918. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107919. }
  107920. interface AbstractMesh {
  107921. /**
  107922. * @hidden
  107923. * Backing Field
  107924. */
  107925. _submeshesOctree: Octree<SubMesh>;
  107926. /**
  107927. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107928. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107929. * @param maxCapacity defines the maximum size of each block (64 by default)
  107930. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107931. * @returns the new octree
  107932. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107934. */
  107935. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107936. }
  107937. /**
  107938. * Defines the octree scene component responsible to manage any octrees
  107939. * in a given scene.
  107940. */
  107941. export class OctreeSceneComponent {
  107942. /**
  107943. * The component name help to identify the component in the list of scene components.
  107944. */
  107945. readonly name: string;
  107946. /**
  107947. * The scene the component belongs to.
  107948. */
  107949. scene: Scene;
  107950. /**
  107951. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107952. */
  107953. readonly checksIsEnabled: boolean;
  107954. /**
  107955. * Creates a new instance of the component for the given scene
  107956. * @param scene Defines the scene to register the component in
  107957. */
  107958. constructor(scene: Scene);
  107959. /**
  107960. * Registers the component in a given scene
  107961. */
  107962. register(): void;
  107963. /**
  107964. * Return the list of active meshes
  107965. * @returns the list of active meshes
  107966. */
  107967. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107968. /**
  107969. * Return the list of active sub meshes
  107970. * @param mesh The mesh to get the candidates sub meshes from
  107971. * @returns the list of active sub meshes
  107972. */
  107973. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107974. private _tempRay;
  107975. /**
  107976. * Return the list of sub meshes intersecting with a given local ray
  107977. * @param mesh defines the mesh to find the submesh for
  107978. * @param localRay defines the ray in local space
  107979. * @returns the list of intersecting sub meshes
  107980. */
  107981. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107982. /**
  107983. * Return the list of sub meshes colliding with a collider
  107984. * @param mesh defines the mesh to find the submesh for
  107985. * @param collider defines the collider to evaluate the collision against
  107986. * @returns the list of colliding sub meshes
  107987. */
  107988. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107989. /**
  107990. * Rebuilds the elements related to this component in case of
  107991. * context lost for instance.
  107992. */
  107993. rebuild(): void;
  107994. /**
  107995. * Disposes the component and the associated ressources.
  107996. */
  107997. dispose(): void;
  107998. }
  107999. }
  108000. declare module BABYLON {
  108001. /**
  108002. * Renders a layer on top of an existing scene
  108003. */
  108004. export class UtilityLayerRenderer implements IDisposable {
  108005. /** the original scene that will be rendered on top of */
  108006. originalScene: Scene;
  108007. private _pointerCaptures;
  108008. private _lastPointerEvents;
  108009. private static _DefaultUtilityLayer;
  108010. private static _DefaultKeepDepthUtilityLayer;
  108011. private _sharedGizmoLight;
  108012. private _renderCamera;
  108013. /**
  108014. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108015. * @returns the camera that is used when rendering the utility layer
  108016. */
  108017. getRenderCamera(): Nullable<Camera>;
  108018. /**
  108019. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108020. * @param cam the camera that should be used when rendering the utility layer
  108021. */
  108022. setRenderCamera(cam: Nullable<Camera>): void;
  108023. /**
  108024. * @hidden
  108025. * Light which used by gizmos to get light shading
  108026. */
  108027. _getSharedGizmoLight(): HemisphericLight;
  108028. /**
  108029. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108030. */
  108031. pickUtilitySceneFirst: boolean;
  108032. /**
  108033. * 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)
  108034. */
  108035. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108036. /**
  108037. * 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)
  108038. */
  108039. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108040. /**
  108041. * The scene that is rendered on top of the original scene
  108042. */
  108043. utilityLayerScene: Scene;
  108044. /**
  108045. * If the utility layer should automatically be rendered on top of existing scene
  108046. */
  108047. shouldRender: boolean;
  108048. /**
  108049. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108050. */
  108051. onlyCheckPointerDownEvents: boolean;
  108052. /**
  108053. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108054. */
  108055. processAllEvents: boolean;
  108056. /**
  108057. * Observable raised when the pointer move from the utility layer scene to the main scene
  108058. */
  108059. onPointerOutObservable: Observable<number>;
  108060. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108061. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108062. private _afterRenderObserver;
  108063. private _sceneDisposeObserver;
  108064. private _originalPointerObserver;
  108065. /**
  108066. * Instantiates a UtilityLayerRenderer
  108067. * @param originalScene the original scene that will be rendered on top of
  108068. * @param handleEvents boolean indicating if the utility layer should handle events
  108069. */
  108070. constructor(
  108071. /** the original scene that will be rendered on top of */
  108072. originalScene: Scene, handleEvents?: boolean);
  108073. private _notifyObservers;
  108074. /**
  108075. * Renders the utility layers scene on top of the original scene
  108076. */
  108077. render(): void;
  108078. /**
  108079. * Disposes of the renderer
  108080. */
  108081. dispose(): void;
  108082. private _updateCamera;
  108083. }
  108084. }
  108085. declare module BABYLON {
  108086. /**
  108087. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108088. */
  108089. export class Gizmo implements IDisposable {
  108090. /** The utility layer the gizmo will be added to */
  108091. gizmoLayer: UtilityLayerRenderer;
  108092. /**
  108093. * The root mesh of the gizmo
  108094. */
  108095. _rootMesh: Mesh;
  108096. private _attachedMesh;
  108097. /**
  108098. * Ratio for the scale of the gizmo (Default: 1)
  108099. */
  108100. scaleRatio: number;
  108101. /**
  108102. * If a custom mesh has been set (Default: false)
  108103. */
  108104. protected _customMeshSet: boolean;
  108105. /**
  108106. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108107. * * When set, interactions will be enabled
  108108. */
  108109. attachedMesh: Nullable<AbstractMesh>;
  108110. /**
  108111. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108112. * @param mesh The mesh to replace the default mesh of the gizmo
  108113. */
  108114. setCustomMesh(mesh: Mesh): void;
  108115. /**
  108116. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108117. */
  108118. updateGizmoRotationToMatchAttachedMesh: boolean;
  108119. /**
  108120. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108121. */
  108122. updateGizmoPositionToMatchAttachedMesh: boolean;
  108123. /**
  108124. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108125. */
  108126. updateScale: boolean;
  108127. protected _interactionsEnabled: boolean;
  108128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108129. private _beforeRenderObserver;
  108130. private _tempVector;
  108131. /**
  108132. * Creates a gizmo
  108133. * @param gizmoLayer The utility layer the gizmo will be added to
  108134. */
  108135. constructor(
  108136. /** The utility layer the gizmo will be added to */
  108137. gizmoLayer?: UtilityLayerRenderer);
  108138. /**
  108139. * Updates the gizmo to match the attached mesh's position/rotation
  108140. */
  108141. protected _update(): void;
  108142. /**
  108143. * Disposes of the gizmo
  108144. */
  108145. dispose(): void;
  108146. }
  108147. }
  108148. declare module BABYLON {
  108149. /**
  108150. * Single plane drag gizmo
  108151. */
  108152. export class PlaneDragGizmo extends Gizmo {
  108153. /**
  108154. * Drag behavior responsible for the gizmos dragging interactions
  108155. */
  108156. dragBehavior: PointerDragBehavior;
  108157. private _pointerObserver;
  108158. /**
  108159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108160. */
  108161. snapDistance: number;
  108162. /**
  108163. * Event that fires each time the gizmo snaps to a new location.
  108164. * * snapDistance is the the change in distance
  108165. */
  108166. onSnapObservable: Observable<{
  108167. snapDistance: number;
  108168. }>;
  108169. private _plane;
  108170. private _coloredMaterial;
  108171. private _hoverMaterial;
  108172. private _isEnabled;
  108173. private _parent;
  108174. /** @hidden */
  108175. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108176. /** @hidden */
  108177. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108178. /**
  108179. * Creates a PlaneDragGizmo
  108180. * @param gizmoLayer The utility layer the gizmo will be added to
  108181. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108182. * @param color The color of the gizmo
  108183. */
  108184. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108185. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108186. /**
  108187. * If the gizmo is enabled
  108188. */
  108189. isEnabled: boolean;
  108190. /**
  108191. * Disposes of the gizmo
  108192. */
  108193. dispose(): void;
  108194. }
  108195. }
  108196. declare module BABYLON {
  108197. /**
  108198. * Gizmo that enables dragging a mesh along 3 axis
  108199. */
  108200. export class PositionGizmo extends Gizmo {
  108201. /**
  108202. * Internal gizmo used for interactions on the x axis
  108203. */
  108204. xGizmo: AxisDragGizmo;
  108205. /**
  108206. * Internal gizmo used for interactions on the y axis
  108207. */
  108208. yGizmo: AxisDragGizmo;
  108209. /**
  108210. * Internal gizmo used for interactions on the z axis
  108211. */
  108212. zGizmo: AxisDragGizmo;
  108213. /**
  108214. * Internal gizmo used for interactions on the yz plane
  108215. */
  108216. xPlaneGizmo: PlaneDragGizmo;
  108217. /**
  108218. * Internal gizmo used for interactions on the xz plane
  108219. */
  108220. yPlaneGizmo: PlaneDragGizmo;
  108221. /**
  108222. * Internal gizmo used for interactions on the xy plane
  108223. */
  108224. zPlaneGizmo: PlaneDragGizmo;
  108225. /**
  108226. * private variables
  108227. */
  108228. private _meshAttached;
  108229. private _updateGizmoRotationToMatchAttachedMesh;
  108230. private _snapDistance;
  108231. private _scaleRatio;
  108232. /** Fires an event when any of it's sub gizmos are dragged */
  108233. onDragStartObservable: Observable<unknown>;
  108234. /** Fires an event when any of it's sub gizmos are released from dragging */
  108235. onDragEndObservable: Observable<unknown>;
  108236. /**
  108237. * If set to true, planar drag is enabled
  108238. */
  108239. private _planarGizmoEnabled;
  108240. attachedMesh: Nullable<AbstractMesh>;
  108241. /**
  108242. * Creates a PositionGizmo
  108243. * @param gizmoLayer The utility layer the gizmo will be added to
  108244. */
  108245. constructor(gizmoLayer?: UtilityLayerRenderer);
  108246. /**
  108247. * If the planar drag gizmo is enabled
  108248. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108249. */
  108250. planarGizmoEnabled: boolean;
  108251. updateGizmoRotationToMatchAttachedMesh: boolean;
  108252. /**
  108253. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108254. */
  108255. snapDistance: number;
  108256. /**
  108257. * Ratio for the scale of the gizmo (Default: 1)
  108258. */
  108259. scaleRatio: number;
  108260. /**
  108261. * Disposes of the gizmo
  108262. */
  108263. dispose(): void;
  108264. /**
  108265. * CustomMeshes are not supported by this gizmo
  108266. * @param mesh The mesh to replace the default mesh of the gizmo
  108267. */
  108268. setCustomMesh(mesh: Mesh): void;
  108269. }
  108270. }
  108271. declare module BABYLON {
  108272. /**
  108273. * Single axis drag gizmo
  108274. */
  108275. export class AxisDragGizmo extends Gizmo {
  108276. /**
  108277. * Drag behavior responsible for the gizmos dragging interactions
  108278. */
  108279. dragBehavior: PointerDragBehavior;
  108280. private _pointerObserver;
  108281. /**
  108282. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108283. */
  108284. snapDistance: number;
  108285. /**
  108286. * Event that fires each time the gizmo snaps to a new location.
  108287. * * snapDistance is the the change in distance
  108288. */
  108289. onSnapObservable: Observable<{
  108290. snapDistance: number;
  108291. }>;
  108292. private _isEnabled;
  108293. private _parent;
  108294. private _arrow;
  108295. private _coloredMaterial;
  108296. private _hoverMaterial;
  108297. /** @hidden */
  108298. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108299. /** @hidden */
  108300. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108301. /**
  108302. * Creates an AxisDragGizmo
  108303. * @param gizmoLayer The utility layer the gizmo will be added to
  108304. * @param dragAxis The axis which the gizmo will be able to drag on
  108305. * @param color The color of the gizmo
  108306. */
  108307. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108308. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108309. /**
  108310. * If the gizmo is enabled
  108311. */
  108312. isEnabled: boolean;
  108313. /**
  108314. * Disposes of the gizmo
  108315. */
  108316. dispose(): void;
  108317. }
  108318. }
  108319. declare module BABYLON.Debug {
  108320. /**
  108321. * The Axes viewer will show 3 axes in a specific point in space
  108322. */
  108323. export class AxesViewer {
  108324. private _xAxis;
  108325. private _yAxis;
  108326. private _zAxis;
  108327. private _scaleLinesFactor;
  108328. private _instanced;
  108329. /**
  108330. * Gets the hosting scene
  108331. */
  108332. scene: Scene;
  108333. /**
  108334. * Gets or sets a number used to scale line length
  108335. */
  108336. scaleLines: number;
  108337. /** Gets the node hierarchy used to render x-axis */
  108338. readonly xAxis: TransformNode;
  108339. /** Gets the node hierarchy used to render y-axis */
  108340. readonly yAxis: TransformNode;
  108341. /** Gets the node hierarchy used to render z-axis */
  108342. readonly zAxis: TransformNode;
  108343. /**
  108344. * Creates a new AxesViewer
  108345. * @param scene defines the hosting scene
  108346. * @param scaleLines defines a number used to scale line length (1 by default)
  108347. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108348. * @param xAxis defines the node hierarchy used to render the x-axis
  108349. * @param yAxis defines the node hierarchy used to render the y-axis
  108350. * @param zAxis defines the node hierarchy used to render the z-axis
  108351. */
  108352. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108353. /**
  108354. * Force the viewer to update
  108355. * @param position defines the position of the viewer
  108356. * @param xaxis defines the x axis of the viewer
  108357. * @param yaxis defines the y axis of the viewer
  108358. * @param zaxis defines the z axis of the viewer
  108359. */
  108360. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108361. /**
  108362. * Creates an instance of this axes viewer.
  108363. * @returns a new axes viewer with instanced meshes
  108364. */
  108365. createInstance(): AxesViewer;
  108366. /** Releases resources */
  108367. dispose(): void;
  108368. private static _SetRenderingGroupId;
  108369. }
  108370. }
  108371. declare module BABYLON.Debug {
  108372. /**
  108373. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108374. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108375. */
  108376. export class BoneAxesViewer extends AxesViewer {
  108377. /**
  108378. * Gets or sets the target mesh where to display the axes viewer
  108379. */
  108380. mesh: Nullable<Mesh>;
  108381. /**
  108382. * Gets or sets the target bone where to display the axes viewer
  108383. */
  108384. bone: Nullable<Bone>;
  108385. /** Gets current position */
  108386. pos: Vector3;
  108387. /** Gets direction of X axis */
  108388. xaxis: Vector3;
  108389. /** Gets direction of Y axis */
  108390. yaxis: Vector3;
  108391. /** Gets direction of Z axis */
  108392. zaxis: Vector3;
  108393. /**
  108394. * Creates a new BoneAxesViewer
  108395. * @param scene defines the hosting scene
  108396. * @param bone defines the target bone
  108397. * @param mesh defines the target mesh
  108398. * @param scaleLines defines a scaling factor for line length (1 by default)
  108399. */
  108400. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108401. /**
  108402. * Force the viewer to update
  108403. */
  108404. update(): void;
  108405. /** Releases resources */
  108406. dispose(): void;
  108407. }
  108408. }
  108409. declare module BABYLON {
  108410. /**
  108411. * Interface used to define scene explorer extensibility option
  108412. */
  108413. export interface IExplorerExtensibilityOption {
  108414. /**
  108415. * Define the option label
  108416. */
  108417. label: string;
  108418. /**
  108419. * Defines the action to execute on click
  108420. */
  108421. action: (entity: any) => void;
  108422. }
  108423. /**
  108424. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108425. */
  108426. export interface IExplorerExtensibilityGroup {
  108427. /**
  108428. * Defines a predicate to test if a given type mut be extended
  108429. */
  108430. predicate: (entity: any) => boolean;
  108431. /**
  108432. * Gets the list of options added to a type
  108433. */
  108434. entries: IExplorerExtensibilityOption[];
  108435. }
  108436. /**
  108437. * Interface used to define the options to use to create the Inspector
  108438. */
  108439. export interface IInspectorOptions {
  108440. /**
  108441. * Display in overlay mode (default: false)
  108442. */
  108443. overlay?: boolean;
  108444. /**
  108445. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108446. */
  108447. globalRoot?: HTMLElement;
  108448. /**
  108449. * Display the Scene explorer
  108450. */
  108451. showExplorer?: boolean;
  108452. /**
  108453. * Display the property inspector
  108454. */
  108455. showInspector?: boolean;
  108456. /**
  108457. * Display in embed mode (both panes on the right)
  108458. */
  108459. embedMode?: boolean;
  108460. /**
  108461. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108462. */
  108463. handleResize?: boolean;
  108464. /**
  108465. * Allow the panes to popup (default: true)
  108466. */
  108467. enablePopup?: boolean;
  108468. /**
  108469. * Allow the panes to be closed by users (default: true)
  108470. */
  108471. enableClose?: boolean;
  108472. /**
  108473. * Optional list of extensibility entries
  108474. */
  108475. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108476. /**
  108477. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108478. */
  108479. inspectorURL?: string;
  108480. }
  108481. interface Scene {
  108482. /**
  108483. * @hidden
  108484. * Backing field
  108485. */
  108486. _debugLayer: DebugLayer;
  108487. /**
  108488. * Gets the debug layer (aka Inspector) associated with the scene
  108489. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108490. */
  108491. debugLayer: DebugLayer;
  108492. }
  108493. /**
  108494. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108495. * what is happening in your scene
  108496. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108497. */
  108498. export class DebugLayer {
  108499. /**
  108500. * Define the url to get the inspector script from.
  108501. * By default it uses the babylonjs CDN.
  108502. * @ignoreNaming
  108503. */
  108504. static InspectorURL: string;
  108505. private _scene;
  108506. private BJSINSPECTOR;
  108507. private _onPropertyChangedObservable?;
  108508. /**
  108509. * Observable triggered when a property is changed through the inspector.
  108510. */
  108511. readonly onPropertyChangedObservable: any;
  108512. /**
  108513. * Instantiates a new debug layer.
  108514. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108515. * what is happening in your scene
  108516. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108517. * @param scene Defines the scene to inspect
  108518. */
  108519. constructor(scene: Scene);
  108520. /** Creates the inspector window. */
  108521. private _createInspector;
  108522. /**
  108523. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108524. * @param entity defines the entity to select
  108525. * @param lineContainerTitle defines the specific block to highlight
  108526. */
  108527. select(entity: any, lineContainerTitle?: string): void;
  108528. /** Get the inspector from bundle or global */
  108529. private _getGlobalInspector;
  108530. /**
  108531. * Get if the inspector is visible or not.
  108532. * @returns true if visible otherwise, false
  108533. */
  108534. isVisible(): boolean;
  108535. /**
  108536. * Hide the inspector and close its window.
  108537. */
  108538. hide(): void;
  108539. /**
  108540. * Launch the debugLayer.
  108541. * @param config Define the configuration of the inspector
  108542. * @return a promise fulfilled when the debug layer is visible
  108543. */
  108544. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108545. }
  108546. }
  108547. declare module BABYLON {
  108548. /**
  108549. * Class containing static functions to help procedurally build meshes
  108550. */
  108551. export class BoxBuilder {
  108552. /**
  108553. * Creates a box mesh
  108554. * * The parameter `size` sets the size (float) of each box side (default 1)
  108555. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108556. * * 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)
  108557. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108561. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108562. * @param name defines the name of the mesh
  108563. * @param options defines the options used to create the mesh
  108564. * @param scene defines the hosting scene
  108565. * @returns the box mesh
  108566. */
  108567. static CreateBox(name: string, options: {
  108568. size?: number;
  108569. width?: number;
  108570. height?: number;
  108571. depth?: number;
  108572. faceUV?: Vector4[];
  108573. faceColors?: Color4[];
  108574. sideOrientation?: number;
  108575. frontUVs?: Vector4;
  108576. backUVs?: Vector4;
  108577. wrap?: boolean;
  108578. topBaseAt?: number;
  108579. bottomBaseAt?: number;
  108580. updatable?: boolean;
  108581. }, scene?: Nullable<Scene>): Mesh;
  108582. }
  108583. }
  108584. declare module BABYLON {
  108585. /**
  108586. * Class containing static functions to help procedurally build meshes
  108587. */
  108588. export class SphereBuilder {
  108589. /**
  108590. * Creates a sphere mesh
  108591. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108592. * * 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`)
  108593. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108594. * * 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
  108595. * * 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)
  108596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108599. * @param name defines the name of the mesh
  108600. * @param options defines the options used to create the mesh
  108601. * @param scene defines the hosting scene
  108602. * @returns the sphere mesh
  108603. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108604. */
  108605. static CreateSphere(name: string, options: {
  108606. segments?: number;
  108607. diameter?: number;
  108608. diameterX?: number;
  108609. diameterY?: number;
  108610. diameterZ?: number;
  108611. arc?: number;
  108612. slice?: number;
  108613. sideOrientation?: number;
  108614. frontUVs?: Vector4;
  108615. backUVs?: Vector4;
  108616. updatable?: boolean;
  108617. }, scene?: Nullable<Scene>): Mesh;
  108618. }
  108619. }
  108620. declare module BABYLON.Debug {
  108621. /**
  108622. * Used to show the physics impostor around the specific mesh
  108623. */
  108624. export class PhysicsViewer {
  108625. /** @hidden */
  108626. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108627. /** @hidden */
  108628. protected _meshes: Array<Nullable<AbstractMesh>>;
  108629. /** @hidden */
  108630. protected _scene: Nullable<Scene>;
  108631. /** @hidden */
  108632. protected _numMeshes: number;
  108633. /** @hidden */
  108634. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108635. private _renderFunction;
  108636. private _utilityLayer;
  108637. private _debugBoxMesh;
  108638. private _debugSphereMesh;
  108639. private _debugCylinderMesh;
  108640. private _debugMaterial;
  108641. private _debugMeshMeshes;
  108642. /**
  108643. * Creates a new PhysicsViewer
  108644. * @param scene defines the hosting scene
  108645. */
  108646. constructor(scene: Scene);
  108647. /** @hidden */
  108648. protected _updateDebugMeshes(): void;
  108649. /**
  108650. * Renders a specified physic impostor
  108651. * @param impostor defines the impostor to render
  108652. * @param targetMesh defines the mesh represented by the impostor
  108653. * @returns the new debug mesh used to render the impostor
  108654. */
  108655. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108656. /**
  108657. * Hides a specified physic impostor
  108658. * @param impostor defines the impostor to hide
  108659. */
  108660. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108661. private _getDebugMaterial;
  108662. private _getDebugBoxMesh;
  108663. private _getDebugSphereMesh;
  108664. private _getDebugCylinderMesh;
  108665. private _getDebugMeshMesh;
  108666. private _getDebugMesh;
  108667. /** Releases all resources */
  108668. dispose(): void;
  108669. }
  108670. }
  108671. declare module BABYLON {
  108672. /**
  108673. * Class containing static functions to help procedurally build meshes
  108674. */
  108675. export class LinesBuilder {
  108676. /**
  108677. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108678. * * 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
  108679. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108680. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108681. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108682. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108683. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108684. * * 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
  108685. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108688. * @param name defines the name of the new line system
  108689. * @param options defines the options used to create the line system
  108690. * @param scene defines the hosting scene
  108691. * @returns a new line system mesh
  108692. */
  108693. static CreateLineSystem(name: string, options: {
  108694. lines: Vector3[][];
  108695. updatable?: boolean;
  108696. instance?: Nullable<LinesMesh>;
  108697. colors?: Nullable<Color4[][]>;
  108698. useVertexAlpha?: boolean;
  108699. }, scene: Nullable<Scene>): LinesMesh;
  108700. /**
  108701. * Creates a line mesh
  108702. * 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
  108703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108704. * * The parameter `points` is an array successive Vector3
  108705. * * 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
  108706. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108707. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108708. * * When updating an instance, remember that only point positions can change, not the number of points
  108709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108711. * @param name defines the name of the new line system
  108712. * @param options defines the options used to create the line system
  108713. * @param scene defines the hosting scene
  108714. * @returns a new line mesh
  108715. */
  108716. static CreateLines(name: string, options: {
  108717. points: Vector3[];
  108718. updatable?: boolean;
  108719. instance?: Nullable<LinesMesh>;
  108720. colors?: Color4[];
  108721. useVertexAlpha?: boolean;
  108722. }, scene?: Nullable<Scene>): LinesMesh;
  108723. /**
  108724. * Creates a dashed line mesh
  108725. * * 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
  108726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108727. * * The parameter `points` is an array successive Vector3
  108728. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108729. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108730. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108731. * * 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
  108732. * * When updating an instance, remember that only point positions can change, not the number of points
  108733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108734. * @param name defines the name of the mesh
  108735. * @param options defines the options used to create the mesh
  108736. * @param scene defines the hosting scene
  108737. * @returns the dashed line mesh
  108738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108739. */
  108740. static CreateDashedLines(name: string, options: {
  108741. points: Vector3[];
  108742. dashSize?: number;
  108743. gapSize?: number;
  108744. dashNb?: number;
  108745. updatable?: boolean;
  108746. instance?: LinesMesh;
  108747. }, scene?: Nullable<Scene>): LinesMesh;
  108748. }
  108749. }
  108750. declare module BABYLON {
  108751. /**
  108752. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108753. * in order to better appreciate the issue one might have.
  108754. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108755. */
  108756. export class RayHelper {
  108757. /**
  108758. * Defines the ray we are currently tryin to visualize.
  108759. */
  108760. ray: Nullable<Ray>;
  108761. private _renderPoints;
  108762. private _renderLine;
  108763. private _renderFunction;
  108764. private _scene;
  108765. private _updateToMeshFunction;
  108766. private _attachedToMesh;
  108767. private _meshSpaceDirection;
  108768. private _meshSpaceOrigin;
  108769. /**
  108770. * Helper function to create a colored helper in a scene in one line.
  108771. * @param ray Defines the ray we are currently tryin to visualize
  108772. * @param scene Defines the scene the ray is used in
  108773. * @param color Defines the color we want to see the ray in
  108774. * @returns The newly created ray helper.
  108775. */
  108776. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108777. /**
  108778. * Instantiate a new ray helper.
  108779. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108780. * in order to better appreciate the issue one might have.
  108781. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108782. * @param ray Defines the ray we are currently tryin to visualize
  108783. */
  108784. constructor(ray: Ray);
  108785. /**
  108786. * Shows the ray we are willing to debug.
  108787. * @param scene Defines the scene the ray needs to be rendered in
  108788. * @param color Defines the color the ray needs to be rendered in
  108789. */
  108790. show(scene: Scene, color?: Color3): void;
  108791. /**
  108792. * Hides the ray we are debugging.
  108793. */
  108794. hide(): void;
  108795. private _render;
  108796. /**
  108797. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108798. * @param mesh Defines the mesh we want the helper attached to
  108799. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108800. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108801. * @param length Defines the length of the ray
  108802. */
  108803. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108804. /**
  108805. * Detach the ray helper from the mesh it has previously been attached to.
  108806. */
  108807. detachFromMesh(): void;
  108808. private _updateToMesh;
  108809. /**
  108810. * Dispose the helper and release its associated resources.
  108811. */
  108812. dispose(): void;
  108813. }
  108814. }
  108815. declare module BABYLON.Debug {
  108816. /**
  108817. * Class used to render a debug view of a given skeleton
  108818. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108819. */
  108820. export class SkeletonViewer {
  108821. /** defines the skeleton to render */
  108822. skeleton: Skeleton;
  108823. /** defines the mesh attached to the skeleton */
  108824. mesh: AbstractMesh;
  108825. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108826. autoUpdateBonesMatrices: boolean;
  108827. /** defines the rendering group id to use with the viewer */
  108828. renderingGroupId: number;
  108829. /** Gets or sets the color used to render the skeleton */
  108830. color: Color3;
  108831. private _scene;
  108832. private _debugLines;
  108833. private _debugMesh;
  108834. private _isEnabled;
  108835. private _renderFunction;
  108836. private _utilityLayer;
  108837. /**
  108838. * Returns the mesh used to render the bones
  108839. */
  108840. readonly debugMesh: Nullable<LinesMesh>;
  108841. /**
  108842. * Creates a new SkeletonViewer
  108843. * @param skeleton defines the skeleton to render
  108844. * @param mesh defines the mesh attached to the skeleton
  108845. * @param scene defines the hosting scene
  108846. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108847. * @param renderingGroupId defines the rendering group id to use with the viewer
  108848. */
  108849. constructor(
  108850. /** defines the skeleton to render */
  108851. skeleton: Skeleton,
  108852. /** defines the mesh attached to the skeleton */
  108853. mesh: AbstractMesh, scene: Scene,
  108854. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108855. autoUpdateBonesMatrices?: boolean,
  108856. /** defines the rendering group id to use with the viewer */
  108857. renderingGroupId?: number);
  108858. /** Gets or sets a boolean indicating if the viewer is enabled */
  108859. isEnabled: boolean;
  108860. private _getBonePosition;
  108861. private _getLinesForBonesWithLength;
  108862. private _getLinesForBonesNoLength;
  108863. /** Update the viewer to sync with current skeleton state */
  108864. update(): void;
  108865. /** Release associated resources */
  108866. dispose(): void;
  108867. }
  108868. }
  108869. declare module BABYLON {
  108870. /**
  108871. * Options to create the null engine
  108872. */
  108873. export class NullEngineOptions {
  108874. /**
  108875. * Render width (Default: 512)
  108876. */
  108877. renderWidth: number;
  108878. /**
  108879. * Render height (Default: 256)
  108880. */
  108881. renderHeight: number;
  108882. /**
  108883. * Texture size (Default: 512)
  108884. */
  108885. textureSize: number;
  108886. /**
  108887. * If delta time between frames should be constant
  108888. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108889. */
  108890. deterministicLockstep: boolean;
  108891. /**
  108892. * Maximum about of steps between frames (Default: 4)
  108893. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108894. */
  108895. lockstepMaxSteps: number;
  108896. }
  108897. /**
  108898. * The null engine class provides support for headless version of babylon.js.
  108899. * This can be used in server side scenario or for testing purposes
  108900. */
  108901. export class NullEngine extends Engine {
  108902. private _options;
  108903. /**
  108904. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108905. */
  108906. isDeterministicLockStep(): boolean;
  108907. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108908. getLockstepMaxSteps(): number;
  108909. /**
  108910. * Sets hardware scaling, used to save performance if needed
  108911. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108912. */
  108913. getHardwareScalingLevel(): number;
  108914. constructor(options?: NullEngineOptions);
  108915. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108916. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108917. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108918. getRenderWidth(useScreen?: boolean): number;
  108919. getRenderHeight(useScreen?: boolean): number;
  108920. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108921. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108922. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108923. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108924. bindSamplers(effect: Effect): void;
  108925. enableEffect(effect: Effect): void;
  108926. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108927. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108928. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108929. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108930. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108931. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108932. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108933. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108934. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108935. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108936. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108937. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108938. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108939. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108940. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108941. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108942. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108943. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108944. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108945. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108946. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108947. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108948. bindBuffers(vertexBuffers: {
  108949. [key: string]: VertexBuffer;
  108950. }, indexBuffer: DataBuffer, effect: Effect): void;
  108951. wipeCaches(bruteForce?: boolean): void;
  108952. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108953. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108954. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108955. /** @hidden */
  108956. _createTexture(): WebGLTexture;
  108957. /** @hidden */
  108958. _releaseTexture(texture: InternalTexture): void;
  108959. 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;
  108960. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108961. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108962. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108963. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108964. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108965. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108966. areAllEffectsReady(): boolean;
  108967. /**
  108968. * @hidden
  108969. * Get the current error code of the webGL context
  108970. * @returns the error code
  108971. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108972. */
  108973. getError(): number;
  108974. /** @hidden */
  108975. _getUnpackAlignement(): number;
  108976. /** @hidden */
  108977. _unpackFlipY(value: boolean): void;
  108978. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108979. /**
  108980. * Updates a dynamic vertex buffer.
  108981. * @param vertexBuffer the vertex buffer to update
  108982. * @param data the data used to update the vertex buffer
  108983. * @param byteOffset the byte offset of the data (optional)
  108984. * @param byteLength the byte length of the data (optional)
  108985. */
  108986. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108987. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108988. /** @hidden */
  108989. _bindTexture(channel: number, texture: InternalTexture): void;
  108990. protected _deleteBuffer(buffer: WebGLBuffer): void;
  108991. releaseEffects(): void;
  108992. displayLoadingUI(): void;
  108993. hideLoadingUI(): void;
  108994. /** @hidden */
  108995. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108996. /** @hidden */
  108997. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108998. /** @hidden */
  108999. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109000. /** @hidden */
  109001. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109002. }
  109003. }
  109004. declare module BABYLON {
  109005. /** @hidden */
  109006. export class _OcclusionDataStorage {
  109007. /** @hidden */
  109008. occlusionInternalRetryCounter: number;
  109009. /** @hidden */
  109010. isOcclusionQueryInProgress: boolean;
  109011. /** @hidden */
  109012. isOccluded: boolean;
  109013. /** @hidden */
  109014. occlusionRetryCount: number;
  109015. /** @hidden */
  109016. occlusionType: number;
  109017. /** @hidden */
  109018. occlusionQueryAlgorithmType: number;
  109019. }
  109020. interface Engine {
  109021. /**
  109022. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109023. * @return the new query
  109024. */
  109025. createQuery(): WebGLQuery;
  109026. /**
  109027. * Delete and release a webGL query
  109028. * @param query defines the query to delete
  109029. * @return the current engine
  109030. */
  109031. deleteQuery(query: WebGLQuery): Engine;
  109032. /**
  109033. * Check if a given query has resolved and got its value
  109034. * @param query defines the query to check
  109035. * @returns true if the query got its value
  109036. */
  109037. isQueryResultAvailable(query: WebGLQuery): boolean;
  109038. /**
  109039. * Gets the value of a given query
  109040. * @param query defines the query to check
  109041. * @returns the value of the query
  109042. */
  109043. getQueryResult(query: WebGLQuery): number;
  109044. /**
  109045. * Initiates an occlusion query
  109046. * @param algorithmType defines the algorithm to use
  109047. * @param query defines the query to use
  109048. * @returns the current engine
  109049. * @see http://doc.babylonjs.com/features/occlusionquery
  109050. */
  109051. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109052. /**
  109053. * Ends an occlusion query
  109054. * @see http://doc.babylonjs.com/features/occlusionquery
  109055. * @param algorithmType defines the algorithm to use
  109056. * @returns the current engine
  109057. */
  109058. endOcclusionQuery(algorithmType: number): Engine;
  109059. /**
  109060. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109061. * Please note that only one query can be issued at a time
  109062. * @returns a time token used to track the time span
  109063. */
  109064. startTimeQuery(): Nullable<_TimeToken>;
  109065. /**
  109066. * Ends a time query
  109067. * @param token defines the token used to measure the time span
  109068. * @returns the time spent (in ns)
  109069. */
  109070. endTimeQuery(token: _TimeToken): int;
  109071. /** @hidden */
  109072. _currentNonTimestampToken: Nullable<_TimeToken>;
  109073. /** @hidden */
  109074. _createTimeQuery(): WebGLQuery;
  109075. /** @hidden */
  109076. _deleteTimeQuery(query: WebGLQuery): void;
  109077. /** @hidden */
  109078. _getGlAlgorithmType(algorithmType: number): number;
  109079. /** @hidden */
  109080. _getTimeQueryResult(query: WebGLQuery): any;
  109081. /** @hidden */
  109082. _getTimeQueryAvailability(query: WebGLQuery): any;
  109083. }
  109084. interface AbstractMesh {
  109085. /**
  109086. * Backing filed
  109087. * @hidden
  109088. */
  109089. __occlusionDataStorage: _OcclusionDataStorage;
  109090. /**
  109091. * Access property
  109092. * @hidden
  109093. */
  109094. _occlusionDataStorage: _OcclusionDataStorage;
  109095. /**
  109096. * 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.
  109097. * The default value is -1 which means don't break the query and wait till the result
  109098. * @see http://doc.babylonjs.com/features/occlusionquery
  109099. */
  109100. occlusionRetryCount: number;
  109101. /**
  109102. * 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:
  109103. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109104. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109105. * * 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.
  109106. * @see http://doc.babylonjs.com/features/occlusionquery
  109107. */
  109108. occlusionType: number;
  109109. /**
  109110. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109111. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109112. * * 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.
  109113. * @see http://doc.babylonjs.com/features/occlusionquery
  109114. */
  109115. occlusionQueryAlgorithmType: number;
  109116. /**
  109117. * 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
  109118. * @see http://doc.babylonjs.com/features/occlusionquery
  109119. */
  109120. isOccluded: boolean;
  109121. /**
  109122. * Flag to check the progress status of the query
  109123. * @see http://doc.babylonjs.com/features/occlusionquery
  109124. */
  109125. isOcclusionQueryInProgress: boolean;
  109126. }
  109127. }
  109128. declare module BABYLON {
  109129. /** @hidden */
  109130. export var _forceTransformFeedbackToBundle: boolean;
  109131. interface Engine {
  109132. /**
  109133. * Creates a webGL transform feedback object
  109134. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109135. * @returns the webGL transform feedback object
  109136. */
  109137. createTransformFeedback(): WebGLTransformFeedback;
  109138. /**
  109139. * Delete a webGL transform feedback object
  109140. * @param value defines the webGL transform feedback object to delete
  109141. */
  109142. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109143. /**
  109144. * Bind a webGL transform feedback object to the webgl context
  109145. * @param value defines the webGL transform feedback object to bind
  109146. */
  109147. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109148. /**
  109149. * Begins a transform feedback operation
  109150. * @param usePoints defines if points or triangles must be used
  109151. */
  109152. beginTransformFeedback(usePoints: boolean): void;
  109153. /**
  109154. * Ends a transform feedback operation
  109155. */
  109156. endTransformFeedback(): void;
  109157. /**
  109158. * Specify the varyings to use with transform feedback
  109159. * @param program defines the associated webGL program
  109160. * @param value defines the list of strings representing the varying names
  109161. */
  109162. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109163. /**
  109164. * Bind a webGL buffer for a transform feedback operation
  109165. * @param value defines the webGL buffer to bind
  109166. */
  109167. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109168. }
  109169. }
  109170. declare module BABYLON {
  109171. /**
  109172. * Creation options of the multi render target texture.
  109173. */
  109174. export interface IMultiRenderTargetOptions {
  109175. /**
  109176. * Define if the texture needs to create mip maps after render.
  109177. */
  109178. generateMipMaps?: boolean;
  109179. /**
  109180. * Define the types of all the draw buffers we want to create
  109181. */
  109182. types?: number[];
  109183. /**
  109184. * Define the sampling modes of all the draw buffers we want to create
  109185. */
  109186. samplingModes?: number[];
  109187. /**
  109188. * Define if a depth buffer is required
  109189. */
  109190. generateDepthBuffer?: boolean;
  109191. /**
  109192. * Define if a stencil buffer is required
  109193. */
  109194. generateStencilBuffer?: boolean;
  109195. /**
  109196. * Define if a depth texture is required instead of a depth buffer
  109197. */
  109198. generateDepthTexture?: boolean;
  109199. /**
  109200. * Define the number of desired draw buffers
  109201. */
  109202. textureCount?: number;
  109203. /**
  109204. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109205. */
  109206. doNotChangeAspectRatio?: boolean;
  109207. /**
  109208. * Define the default type of the buffers we are creating
  109209. */
  109210. defaultType?: number;
  109211. }
  109212. /**
  109213. * A multi render target, like a render target provides the ability to render to a texture.
  109214. * Unlike the render target, it can render to several draw buffers in one draw.
  109215. * This is specially interesting in deferred rendering or for any effects requiring more than
  109216. * just one color from a single pass.
  109217. */
  109218. export class MultiRenderTarget extends RenderTargetTexture {
  109219. private _internalTextures;
  109220. private _textures;
  109221. private _multiRenderTargetOptions;
  109222. /**
  109223. * Get if draw buffers are currently supported by the used hardware and browser.
  109224. */
  109225. readonly isSupported: boolean;
  109226. /**
  109227. * Get the list of textures generated by the multi render target.
  109228. */
  109229. readonly textures: Texture[];
  109230. /**
  109231. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109232. */
  109233. readonly depthTexture: Texture;
  109234. /**
  109235. * Set the wrapping mode on U of all the textures we are rendering to.
  109236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109237. */
  109238. wrapU: number;
  109239. /**
  109240. * Set the wrapping mode on V of all the textures we are rendering to.
  109241. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109242. */
  109243. wrapV: number;
  109244. /**
  109245. * Instantiate a new multi render target texture.
  109246. * A multi render target, like a render target provides the ability to render to a texture.
  109247. * Unlike the render target, it can render to several draw buffers in one draw.
  109248. * This is specially interesting in deferred rendering or for any effects requiring more than
  109249. * just one color from a single pass.
  109250. * @param name Define the name of the texture
  109251. * @param size Define the size of the buffers to render to
  109252. * @param count Define the number of target we are rendering into
  109253. * @param scene Define the scene the texture belongs to
  109254. * @param options Define the options used to create the multi render target
  109255. */
  109256. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109257. /** @hidden */
  109258. _rebuild(): void;
  109259. private _createInternalTextures;
  109260. private _createTextures;
  109261. /**
  109262. * Define the number of samples used if MSAA is enabled.
  109263. */
  109264. samples: number;
  109265. /**
  109266. * Resize all the textures in the multi render target.
  109267. * Be carrefull as it will recreate all the data in the new texture.
  109268. * @param size Define the new size
  109269. */
  109270. resize(size: any): void;
  109271. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109272. /**
  109273. * Dispose the render targets and their associated resources
  109274. */
  109275. dispose(): void;
  109276. /**
  109277. * Release all the underlying texture used as draw buffers.
  109278. */
  109279. releaseInternalTextures(): void;
  109280. }
  109281. }
  109282. declare module BABYLON {
  109283. interface Engine {
  109284. /**
  109285. * Unbind a list of render target textures from the webGL context
  109286. * This is used only when drawBuffer extension or webGL2 are active
  109287. * @param textures defines the render target textures to unbind
  109288. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109289. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109290. */
  109291. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109292. /**
  109293. * Create a multi render target texture
  109294. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109295. * @param size defines the size of the texture
  109296. * @param options defines the creation options
  109297. * @returns the cube texture as an InternalTexture
  109298. */
  109299. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109300. /**
  109301. * Update the sample count for a given multiple render target texture
  109302. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109303. * @param textures defines the textures to update
  109304. * @param samples defines the sample count to set
  109305. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109306. */
  109307. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109308. }
  109309. }
  109310. declare module BABYLON {
  109311. /** @hidden */
  109312. export var rgbdEncodePixelShader: {
  109313. name: string;
  109314. shader: string;
  109315. };
  109316. }
  109317. declare module BABYLON {
  109318. /** @hidden */
  109319. export var rgbdDecodePixelShader: {
  109320. name: string;
  109321. shader: string;
  109322. };
  109323. }
  109324. declare module BABYLON {
  109325. /**
  109326. * Raw texture data and descriptor sufficient for WebGL texture upload
  109327. */
  109328. export interface EnvironmentTextureInfo {
  109329. /**
  109330. * Version of the environment map
  109331. */
  109332. version: number;
  109333. /**
  109334. * Width of image
  109335. */
  109336. width: number;
  109337. /**
  109338. * Irradiance information stored in the file.
  109339. */
  109340. irradiance: any;
  109341. /**
  109342. * Specular information stored in the file.
  109343. */
  109344. specular: any;
  109345. }
  109346. /**
  109347. * Defines One Image in the file. It requires only the position in the file
  109348. * as well as the length.
  109349. */
  109350. interface BufferImageData {
  109351. /**
  109352. * Length of the image data.
  109353. */
  109354. length: number;
  109355. /**
  109356. * Position of the data from the null terminator delimiting the end of the JSON.
  109357. */
  109358. position: number;
  109359. }
  109360. /**
  109361. * Defines the specular data enclosed in the file.
  109362. * This corresponds to the version 1 of the data.
  109363. */
  109364. export interface EnvironmentTextureSpecularInfoV1 {
  109365. /**
  109366. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109367. */
  109368. specularDataPosition?: number;
  109369. /**
  109370. * This contains all the images data needed to reconstruct the cubemap.
  109371. */
  109372. mipmaps: Array<BufferImageData>;
  109373. /**
  109374. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109375. */
  109376. lodGenerationScale: number;
  109377. }
  109378. /**
  109379. * Sets of helpers addressing the serialization and deserialization of environment texture
  109380. * stored in a BabylonJS env file.
  109381. * Those files are usually stored as .env files.
  109382. */
  109383. export class EnvironmentTextureTools {
  109384. /**
  109385. * Magic number identifying the env file.
  109386. */
  109387. private static _MagicBytes;
  109388. /**
  109389. * Gets the environment info from an env file.
  109390. * @param data The array buffer containing the .env bytes.
  109391. * @returns the environment file info (the json header) if successfully parsed.
  109392. */
  109393. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109394. /**
  109395. * Creates an environment texture from a loaded cube texture.
  109396. * @param texture defines the cube texture to convert in env file
  109397. * @return a promise containing the environment data if succesfull.
  109398. */
  109399. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109400. /**
  109401. * Creates a JSON representation of the spherical data.
  109402. * @param texture defines the texture containing the polynomials
  109403. * @return the JSON representation of the spherical info
  109404. */
  109405. private static _CreateEnvTextureIrradiance;
  109406. /**
  109407. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109408. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109409. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109410. * @return the views described by info providing access to the underlying buffer
  109411. */
  109412. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109413. /**
  109414. * Uploads the texture info contained in the env file to the GPU.
  109415. * @param texture defines the internal texture to upload to
  109416. * @param arrayBuffer defines the buffer cotaining the data to load
  109417. * @param info defines the texture info retrieved through the GetEnvInfo method
  109418. * @returns a promise
  109419. */
  109420. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109421. /**
  109422. * Uploads the levels of image data to the GPU.
  109423. * @param texture defines the internal texture to upload to
  109424. * @param imageData defines the array buffer views of image data [mipmap][face]
  109425. * @returns a promise
  109426. */
  109427. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109428. /**
  109429. * Uploads spherical polynomials information to the texture.
  109430. * @param texture defines the texture we are trying to upload the information to
  109431. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109432. */
  109433. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109434. /** @hidden */
  109435. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109436. }
  109437. }
  109438. declare module BABYLON {
  109439. /**
  109440. * Contains position and normal vectors for a vertex
  109441. */
  109442. export class PositionNormalVertex {
  109443. /** the position of the vertex (defaut: 0,0,0) */
  109444. position: Vector3;
  109445. /** the normal of the vertex (defaut: 0,1,0) */
  109446. normal: Vector3;
  109447. /**
  109448. * Creates a PositionNormalVertex
  109449. * @param position the position of the vertex (defaut: 0,0,0)
  109450. * @param normal the normal of the vertex (defaut: 0,1,0)
  109451. */
  109452. constructor(
  109453. /** the position of the vertex (defaut: 0,0,0) */
  109454. position?: Vector3,
  109455. /** the normal of the vertex (defaut: 0,1,0) */
  109456. normal?: Vector3);
  109457. /**
  109458. * Clones the PositionNormalVertex
  109459. * @returns the cloned PositionNormalVertex
  109460. */
  109461. clone(): PositionNormalVertex;
  109462. }
  109463. /**
  109464. * Contains position, normal and uv vectors for a vertex
  109465. */
  109466. export class PositionNormalTextureVertex {
  109467. /** the position of the vertex (defaut: 0,0,0) */
  109468. position: Vector3;
  109469. /** the normal of the vertex (defaut: 0,1,0) */
  109470. normal: Vector3;
  109471. /** the uv of the vertex (default: 0,0) */
  109472. uv: Vector2;
  109473. /**
  109474. * Creates a PositionNormalTextureVertex
  109475. * @param position the position of the vertex (defaut: 0,0,0)
  109476. * @param normal the normal of the vertex (defaut: 0,1,0)
  109477. * @param uv the uv of the vertex (default: 0,0)
  109478. */
  109479. constructor(
  109480. /** the position of the vertex (defaut: 0,0,0) */
  109481. position?: Vector3,
  109482. /** the normal of the vertex (defaut: 0,1,0) */
  109483. normal?: Vector3,
  109484. /** the uv of the vertex (default: 0,0) */
  109485. uv?: Vector2);
  109486. /**
  109487. * Clones the PositionNormalTextureVertex
  109488. * @returns the cloned PositionNormalTextureVertex
  109489. */
  109490. clone(): PositionNormalTextureVertex;
  109491. }
  109492. }
  109493. declare module BABYLON {
  109494. /** @hidden */
  109495. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109496. private _genericAttributeLocation;
  109497. private _varyingLocationCount;
  109498. private _varyingLocationMap;
  109499. private _replacements;
  109500. private _textureCount;
  109501. private _uniforms;
  109502. lineProcessor(line: string): string;
  109503. attributeProcessor(attribute: string): string;
  109504. varyingProcessor(varying: string, isFragment: boolean): string;
  109505. uniformProcessor(uniform: string): string;
  109506. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109507. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109508. }
  109509. }
  109510. declare module BABYLON {
  109511. /**
  109512. * Container for accessors for natively-stored mesh data buffers.
  109513. */
  109514. class NativeDataBuffer extends DataBuffer {
  109515. /**
  109516. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109517. */
  109518. nativeIndexBuffer?: any;
  109519. /**
  109520. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109521. */
  109522. nativeVertexBuffer?: any;
  109523. }
  109524. /** @hidden */
  109525. export class NativeEngine extends Engine {
  109526. private readonly _native;
  109527. getHardwareScalingLevel(): number;
  109528. constructor();
  109529. /**
  109530. * Can be used to override the current requestAnimationFrame requester.
  109531. * @hidden
  109532. */
  109533. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109534. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109535. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109536. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109537. recordVertexArrayObject(vertexBuffers: {
  109538. [key: string]: VertexBuffer;
  109539. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109540. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109541. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109542. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109543. /**
  109544. * Draw a list of indexed primitives
  109545. * @param fillMode defines the primitive to use
  109546. * @param indexStart defines the starting index
  109547. * @param indexCount defines the number of index to draw
  109548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109549. */
  109550. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109551. /**
  109552. * Draw a list of unindexed primitives
  109553. * @param fillMode defines the primitive to use
  109554. * @param verticesStart defines the index of first vertex to draw
  109555. * @param verticesCount defines the count of vertices to draw
  109556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109557. */
  109558. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109559. createPipelineContext(): IPipelineContext;
  109560. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109561. /** @hidden */
  109562. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109563. /** @hidden */
  109564. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109565. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109566. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109567. protected _setProgram(program: WebGLProgram): void;
  109568. _releaseEffect(effect: Effect): void;
  109569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109570. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109571. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109572. bindSamplers(effect: Effect): void;
  109573. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109574. getRenderWidth(useScreen?: boolean): number;
  109575. getRenderHeight(useScreen?: boolean): number;
  109576. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109577. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109578. /**
  109579. * Set the z offset to apply to current rendering
  109580. * @param value defines the offset to apply
  109581. */
  109582. setZOffset(value: number): void;
  109583. /**
  109584. * Gets the current value of the zOffset
  109585. * @returns the current zOffset state
  109586. */
  109587. getZOffset(): number;
  109588. /**
  109589. * Enable or disable depth buffering
  109590. * @param enable defines the state to set
  109591. */
  109592. setDepthBuffer(enable: boolean): void;
  109593. /**
  109594. * Gets a boolean indicating if depth writing is enabled
  109595. * @returns the current depth writing state
  109596. */
  109597. getDepthWrite(): boolean;
  109598. /**
  109599. * Enable or disable depth writing
  109600. * @param enable defines the state to set
  109601. */
  109602. setDepthWrite(enable: boolean): void;
  109603. /**
  109604. * Enable or disable color writing
  109605. * @param enable defines the state to set
  109606. */
  109607. setColorWrite(enable: boolean): void;
  109608. /**
  109609. * Gets a boolean indicating if color writing is enabled
  109610. * @returns the current color writing state
  109611. */
  109612. getColorWrite(): boolean;
  109613. /**
  109614. * Sets alpha constants used by some alpha blending modes
  109615. * @param r defines the red component
  109616. * @param g defines the green component
  109617. * @param b defines the blue component
  109618. * @param a defines the alpha component
  109619. */
  109620. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109621. /**
  109622. * Sets the current alpha mode
  109623. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109626. */
  109627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109628. /**
  109629. * Gets the current alpha mode
  109630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109631. * @returns the current alpha mode
  109632. */
  109633. getAlphaMode(): number;
  109634. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109635. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109636. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109637. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109638. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109639. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109640. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109641. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109642. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109643. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109644. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109645. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109646. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109647. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109648. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109649. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109650. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109651. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109652. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109653. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109654. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109655. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109656. wipeCaches(bruteForce?: boolean): void;
  109657. _createTexture(): WebGLTexture;
  109658. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109659. /**
  109660. * Usually called from BABYLON.Texture.ts.
  109661. * Passed information to create a WebGLTexture
  109662. * @param urlArg defines a value which contains one of the following:
  109663. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109664. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109665. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109666. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109667. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  109668. * @param scene needed for loading to the correct scene
  109669. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  109670. * @param onLoad optional callback to be called upon successful completion
  109671. * @param onError optional callback to be called upon failure
  109672. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  109673. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  109674. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  109675. * @param forcedExtension defines the extension to use to pick the right loader
  109676. * @returns a InternalTexture for assignment back into BABYLON.Texture
  109677. */
  109678. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  109679. /**
  109680. * Creates a cube texture
  109681. * @param rootUrl defines the url where the files to load is located
  109682. * @param scene defines the current scene
  109683. * @param files defines the list of files to load (1 per face)
  109684. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  109685. * @param onLoad defines an optional callback raised when the texture is loaded
  109686. * @param onError defines an optional callback raised if there is an issue to load the texture
  109687. * @param format defines the format of the data
  109688. * @param forcedExtension defines the extension to use to pick the right loader
  109689. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  109690. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109691. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109692. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  109693. * @returns the cube texture as an InternalTexture
  109694. */
  109695. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  109696. private _getSamplingFilter;
  109697. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  109702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  109703. /**
  109704. * Updates a dynamic vertex buffer.
  109705. * @param vertexBuffer the vertex buffer to update
  109706. * @param data the data used to update the vertex buffer
  109707. * @param byteOffset the byte offset of the data (optional)
  109708. * @param byteLength the byte length of the data (optional)
  109709. */
  109710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  109711. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  109712. private _updateAnisotropicLevel;
  109713. private _getAddressMode;
  109714. /** @hidden */
  109715. _bindTexture(channel: number, texture: InternalTexture): void;
  109716. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  109717. releaseEffects(): void;
  109718. /** @hidden */
  109719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109720. /** @hidden */
  109721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109722. /** @hidden */
  109723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109724. /** @hidden */
  109725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109726. }
  109727. }
  109728. declare module BABYLON {
  109729. /**
  109730. * Gather the list of clipboard event types as constants.
  109731. */
  109732. export class ClipboardEventTypes {
  109733. /**
  109734. * The clipboard event is fired when a copy command is active (pressed).
  109735. */
  109736. static readonly COPY: number;
  109737. /**
  109738. * The clipboard event is fired when a cut command is active (pressed).
  109739. */
  109740. static readonly CUT: number;
  109741. /**
  109742. * The clipboard event is fired when a paste command is active (pressed).
  109743. */
  109744. static readonly PASTE: number;
  109745. }
  109746. /**
  109747. * This class is used to store clipboard related info for the onClipboardObservable event.
  109748. */
  109749. export class ClipboardInfo {
  109750. /**
  109751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109752. */
  109753. type: number;
  109754. /**
  109755. * Defines the related dom event
  109756. */
  109757. event: ClipboardEvent;
  109758. /**
  109759. *Creates an instance of ClipboardInfo.
  109760. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  109761. * @param event Defines the related dom event
  109762. */
  109763. constructor(
  109764. /**
  109765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109766. */
  109767. type: number,
  109768. /**
  109769. * Defines the related dom event
  109770. */
  109771. event: ClipboardEvent);
  109772. /**
  109773. * Get the clipboard event's type from the keycode.
  109774. * @param keyCode Defines the keyCode for the current keyboard event.
  109775. * @return {number}
  109776. */
  109777. static GetTypeFromCharacter(keyCode: number): number;
  109778. }
  109779. }
  109780. declare module BABYLON {
  109781. /**
  109782. * Google Daydream controller
  109783. */
  109784. export class DaydreamController extends WebVRController {
  109785. /**
  109786. * Base Url for the controller model.
  109787. */
  109788. static MODEL_BASE_URL: string;
  109789. /**
  109790. * File name for the controller model.
  109791. */
  109792. static MODEL_FILENAME: string;
  109793. /**
  109794. * Gamepad Id prefix used to identify Daydream Controller.
  109795. */
  109796. static readonly GAMEPAD_ID_PREFIX: string;
  109797. /**
  109798. * Creates a new DaydreamController from a gamepad
  109799. * @param vrGamepad the gamepad that the controller should be created from
  109800. */
  109801. constructor(vrGamepad: any);
  109802. /**
  109803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109804. * @param scene scene in which to add meshes
  109805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109806. */
  109807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109808. /**
  109809. * Called once for each button that changed state since the last frame
  109810. * @param buttonIdx Which button index changed
  109811. * @param state New state of the button
  109812. * @param changes Which properties on the state changed since last frame
  109813. */
  109814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109815. }
  109816. }
  109817. declare module BABYLON {
  109818. /**
  109819. * Gear VR Controller
  109820. */
  109821. export class GearVRController extends WebVRController {
  109822. /**
  109823. * Base Url for the controller model.
  109824. */
  109825. static MODEL_BASE_URL: string;
  109826. /**
  109827. * File name for the controller model.
  109828. */
  109829. static MODEL_FILENAME: string;
  109830. /**
  109831. * Gamepad Id prefix used to identify this controller.
  109832. */
  109833. static readonly GAMEPAD_ID_PREFIX: string;
  109834. private readonly _buttonIndexToObservableNameMap;
  109835. /**
  109836. * Creates a new GearVRController from a gamepad
  109837. * @param vrGamepad the gamepad that the controller should be created from
  109838. */
  109839. constructor(vrGamepad: any);
  109840. /**
  109841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109842. * @param scene scene in which to add meshes
  109843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109844. */
  109845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109846. /**
  109847. * Called once for each button that changed state since the last frame
  109848. * @param buttonIdx Which button index changed
  109849. * @param state New state of the button
  109850. * @param changes Which properties on the state changed since last frame
  109851. */
  109852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109853. }
  109854. }
  109855. declare module BABYLON {
  109856. /**
  109857. * Class containing static functions to help procedurally build meshes
  109858. */
  109859. export class PolyhedronBuilder {
  109860. /**
  109861. * Creates a polyhedron mesh
  109862. * * 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
  109863. * * The parameter `size` (positive float, default 1) sets the polygon size
  109864. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109865. * * 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`
  109866. * * 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
  109867. * * 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)`)
  109868. * * 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
  109869. * * 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
  109870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109873. * @param name defines the name of the mesh
  109874. * @param options defines the options used to create the mesh
  109875. * @param scene defines the hosting scene
  109876. * @returns the polyhedron mesh
  109877. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109878. */
  109879. static CreatePolyhedron(name: string, options: {
  109880. type?: number;
  109881. size?: number;
  109882. sizeX?: number;
  109883. sizeY?: number;
  109884. sizeZ?: number;
  109885. custom?: any;
  109886. faceUV?: Vector4[];
  109887. faceColors?: Color4[];
  109888. flat?: boolean;
  109889. updatable?: boolean;
  109890. sideOrientation?: number;
  109891. frontUVs?: Vector4;
  109892. backUVs?: Vector4;
  109893. }, scene?: Nullable<Scene>): Mesh;
  109894. }
  109895. }
  109896. declare module BABYLON {
  109897. /**
  109898. * Gizmo that enables scaling a mesh along 3 axis
  109899. */
  109900. export class ScaleGizmo extends Gizmo {
  109901. /**
  109902. * Internal gizmo used for interactions on the x axis
  109903. */
  109904. xGizmo: AxisScaleGizmo;
  109905. /**
  109906. * Internal gizmo used for interactions on the y axis
  109907. */
  109908. yGizmo: AxisScaleGizmo;
  109909. /**
  109910. * Internal gizmo used for interactions on the z axis
  109911. */
  109912. zGizmo: AxisScaleGizmo;
  109913. /**
  109914. * Internal gizmo used to scale all axis equally
  109915. */
  109916. uniformScaleGizmo: AxisScaleGizmo;
  109917. private _meshAttached;
  109918. private _updateGizmoRotationToMatchAttachedMesh;
  109919. private _snapDistance;
  109920. private _scaleRatio;
  109921. private _uniformScalingMesh;
  109922. private _octahedron;
  109923. /** Fires an event when any of it's sub gizmos are dragged */
  109924. onDragStartObservable: Observable<unknown>;
  109925. /** Fires an event when any of it's sub gizmos are released from dragging */
  109926. onDragEndObservable: Observable<unknown>;
  109927. attachedMesh: Nullable<AbstractMesh>;
  109928. /**
  109929. * Creates a ScaleGizmo
  109930. * @param gizmoLayer The utility layer the gizmo will be added to
  109931. */
  109932. constructor(gizmoLayer?: UtilityLayerRenderer);
  109933. updateGizmoRotationToMatchAttachedMesh: boolean;
  109934. /**
  109935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109936. */
  109937. snapDistance: number;
  109938. /**
  109939. * Ratio for the scale of the gizmo (Default: 1)
  109940. */
  109941. scaleRatio: number;
  109942. /**
  109943. * Disposes of the gizmo
  109944. */
  109945. dispose(): void;
  109946. }
  109947. }
  109948. declare module BABYLON {
  109949. /**
  109950. * Single axis scale gizmo
  109951. */
  109952. export class AxisScaleGizmo extends Gizmo {
  109953. /**
  109954. * Drag behavior responsible for the gizmos dragging interactions
  109955. */
  109956. dragBehavior: PointerDragBehavior;
  109957. private _pointerObserver;
  109958. /**
  109959. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109960. */
  109961. snapDistance: number;
  109962. /**
  109963. * Event that fires each time the gizmo snaps to a new location.
  109964. * * snapDistance is the the change in distance
  109965. */
  109966. onSnapObservable: Observable<{
  109967. snapDistance: number;
  109968. }>;
  109969. /**
  109970. * If the scaling operation should be done on all axis (default: false)
  109971. */
  109972. uniformScaling: boolean;
  109973. private _isEnabled;
  109974. private _parent;
  109975. private _arrow;
  109976. private _coloredMaterial;
  109977. private _hoverMaterial;
  109978. /**
  109979. * Creates an AxisScaleGizmo
  109980. * @param gizmoLayer The utility layer the gizmo will be added to
  109981. * @param dragAxis The axis which the gizmo will be able to scale on
  109982. * @param color The color of the gizmo
  109983. */
  109984. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  109985. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109986. /**
  109987. * If the gizmo is enabled
  109988. */
  109989. isEnabled: boolean;
  109990. /**
  109991. * Disposes of the gizmo
  109992. */
  109993. dispose(): void;
  109994. /**
  109995. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109996. * @param mesh The mesh to replace the default mesh of the gizmo
  109997. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  109998. */
  109999. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110000. }
  110001. }
  110002. declare module BABYLON {
  110003. /**
  110004. * Bounding box gizmo
  110005. */
  110006. export class BoundingBoxGizmo extends Gizmo {
  110007. private _lineBoundingBox;
  110008. private _rotateSpheresParent;
  110009. private _scaleBoxesParent;
  110010. private _boundingDimensions;
  110011. private _renderObserver;
  110012. private _pointerObserver;
  110013. private _scaleDragSpeed;
  110014. private _tmpQuaternion;
  110015. private _tmpVector;
  110016. private _tmpRotationMatrix;
  110017. /**
  110018. * 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)
  110019. */
  110020. ignoreChildren: boolean;
  110021. /**
  110022. * 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)
  110023. */
  110024. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110025. /**
  110026. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110027. */
  110028. rotationSphereSize: number;
  110029. /**
  110030. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110031. */
  110032. scaleBoxSize: number;
  110033. /**
  110034. * 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)
  110035. */
  110036. fixedDragMeshScreenSize: boolean;
  110037. /**
  110038. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110039. */
  110040. fixedDragMeshScreenSizeDistanceFactor: number;
  110041. /**
  110042. * Fired when a rotation sphere or scale box is dragged
  110043. */
  110044. onDragStartObservable: Observable<{}>;
  110045. /**
  110046. * Fired when a scale box is dragged
  110047. */
  110048. onScaleBoxDragObservable: Observable<{}>;
  110049. /**
  110050. * Fired when a scale box drag is ended
  110051. */
  110052. onScaleBoxDragEndObservable: Observable<{}>;
  110053. /**
  110054. * Fired when a rotation sphere is dragged
  110055. */
  110056. onRotationSphereDragObservable: Observable<{}>;
  110057. /**
  110058. * Fired when a rotation sphere drag is ended
  110059. */
  110060. onRotationSphereDragEndObservable: Observable<{}>;
  110061. /**
  110062. * 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)
  110063. */
  110064. scalePivot: Nullable<Vector3>;
  110065. /**
  110066. * Mesh used as a pivot to rotate the attached mesh
  110067. */
  110068. private _anchorMesh;
  110069. private _existingMeshScale;
  110070. private _dragMesh;
  110071. private pointerDragBehavior;
  110072. private coloredMaterial;
  110073. private hoverColoredMaterial;
  110074. /**
  110075. * Sets the color of the bounding box gizmo
  110076. * @param color the color to set
  110077. */
  110078. setColor(color: Color3): void;
  110079. /**
  110080. * Creates an BoundingBoxGizmo
  110081. * @param gizmoLayer The utility layer the gizmo will be added to
  110082. * @param color The color of the gizmo
  110083. */
  110084. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110085. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110086. private _selectNode;
  110087. /**
  110088. * Updates the bounding box information for the Gizmo
  110089. */
  110090. updateBoundingBox(): void;
  110091. private _updateRotationSpheres;
  110092. private _updateScaleBoxes;
  110093. /**
  110094. * Enables rotation on the specified axis and disables rotation on the others
  110095. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110096. */
  110097. setEnabledRotationAxis(axis: string): void;
  110098. /**
  110099. * Enables/disables scaling
  110100. * @param enable if scaling should be enabled
  110101. */
  110102. setEnabledScaling(enable: boolean): void;
  110103. private _updateDummy;
  110104. /**
  110105. * Enables a pointer drag behavior on the bounding box of the gizmo
  110106. */
  110107. enableDragBehavior(): void;
  110108. /**
  110109. * Disposes of the gizmo
  110110. */
  110111. dispose(): void;
  110112. /**
  110113. * 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)
  110114. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110115. * @returns the bounding box mesh with the passed in mesh as a child
  110116. */
  110117. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110118. /**
  110119. * CustomMeshes are not supported by this gizmo
  110120. * @param mesh The mesh to replace the default mesh of the gizmo
  110121. */
  110122. setCustomMesh(mesh: Mesh): void;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. /**
  110127. * Single plane rotation gizmo
  110128. */
  110129. export class PlaneRotationGizmo extends Gizmo {
  110130. /**
  110131. * Drag behavior responsible for the gizmos dragging interactions
  110132. */
  110133. dragBehavior: PointerDragBehavior;
  110134. private _pointerObserver;
  110135. /**
  110136. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110137. */
  110138. snapDistance: number;
  110139. /**
  110140. * Event that fires each time the gizmo snaps to a new location.
  110141. * * snapDistance is the the change in distance
  110142. */
  110143. onSnapObservable: Observable<{
  110144. snapDistance: number;
  110145. }>;
  110146. private _isEnabled;
  110147. private _parent;
  110148. /**
  110149. * Creates a PlaneRotationGizmo
  110150. * @param gizmoLayer The utility layer the gizmo will be added to
  110151. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110152. * @param color The color of the gizmo
  110153. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110154. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110155. */
  110156. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110157. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110158. /**
  110159. * If the gizmo is enabled
  110160. */
  110161. isEnabled: boolean;
  110162. /**
  110163. * Disposes of the gizmo
  110164. */
  110165. dispose(): void;
  110166. }
  110167. }
  110168. declare module BABYLON {
  110169. /**
  110170. * Gizmo that enables rotating a mesh along 3 axis
  110171. */
  110172. export class RotationGizmo extends Gizmo {
  110173. /**
  110174. * Internal gizmo used for interactions on the x axis
  110175. */
  110176. xGizmo: PlaneRotationGizmo;
  110177. /**
  110178. * Internal gizmo used for interactions on the y axis
  110179. */
  110180. yGizmo: PlaneRotationGizmo;
  110181. /**
  110182. * Internal gizmo used for interactions on the z axis
  110183. */
  110184. zGizmo: PlaneRotationGizmo;
  110185. /** Fires an event when any of it's sub gizmos are dragged */
  110186. onDragStartObservable: Observable<unknown>;
  110187. /** Fires an event when any of it's sub gizmos are released from dragging */
  110188. onDragEndObservable: Observable<unknown>;
  110189. private _meshAttached;
  110190. attachedMesh: Nullable<AbstractMesh>;
  110191. /**
  110192. * Creates a RotationGizmo
  110193. * @param gizmoLayer The utility layer the gizmo will be added to
  110194. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110195. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110196. */
  110197. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110198. updateGizmoRotationToMatchAttachedMesh: boolean;
  110199. /**
  110200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110201. */
  110202. snapDistance: number;
  110203. /**
  110204. * Ratio for the scale of the gizmo (Default: 1)
  110205. */
  110206. scaleRatio: number;
  110207. /**
  110208. * Disposes of the gizmo
  110209. */
  110210. dispose(): void;
  110211. /**
  110212. * CustomMeshes are not supported by this gizmo
  110213. * @param mesh The mesh to replace the default mesh of the gizmo
  110214. */
  110215. setCustomMesh(mesh: Mesh): void;
  110216. }
  110217. }
  110218. declare module BABYLON {
  110219. /**
  110220. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110221. */
  110222. export class GizmoManager implements IDisposable {
  110223. private scene;
  110224. /**
  110225. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110226. */
  110227. gizmos: {
  110228. positionGizmo: Nullable<PositionGizmo>;
  110229. rotationGizmo: Nullable<RotationGizmo>;
  110230. scaleGizmo: Nullable<ScaleGizmo>;
  110231. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110232. };
  110233. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110234. clearGizmoOnEmptyPointerEvent: boolean;
  110235. /** Fires an event when the manager is attached to a mesh */
  110236. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110237. private _gizmosEnabled;
  110238. private _pointerObserver;
  110239. private _attachedMesh;
  110240. private _boundingBoxColor;
  110241. private _defaultUtilityLayer;
  110242. private _defaultKeepDepthUtilityLayer;
  110243. /**
  110244. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110245. */
  110246. boundingBoxDragBehavior: SixDofDragBehavior;
  110247. /**
  110248. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110249. */
  110250. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110251. /**
  110252. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110253. */
  110254. usePointerToAttachGizmos: boolean;
  110255. /**
  110256. * Utility layer that the bounding box gizmo belongs to
  110257. */
  110258. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110259. /**
  110260. * Utility layer that all gizmos besides bounding box belong to
  110261. */
  110262. readonly utilityLayer: UtilityLayerRenderer;
  110263. /**
  110264. * Instatiates a gizmo manager
  110265. * @param scene the scene to overlay the gizmos on top of
  110266. */
  110267. constructor(scene: Scene);
  110268. /**
  110269. * Attaches a set of gizmos to the specified mesh
  110270. * @param mesh The mesh the gizmo's should be attached to
  110271. */
  110272. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110273. /**
  110274. * If the position gizmo is enabled
  110275. */
  110276. positionGizmoEnabled: boolean;
  110277. /**
  110278. * If the rotation gizmo is enabled
  110279. */
  110280. rotationGizmoEnabled: boolean;
  110281. /**
  110282. * If the scale gizmo is enabled
  110283. */
  110284. scaleGizmoEnabled: boolean;
  110285. /**
  110286. * If the boundingBox gizmo is enabled
  110287. */
  110288. boundingBoxGizmoEnabled: boolean;
  110289. /**
  110290. * Disposes of the gizmo manager
  110291. */
  110292. dispose(): void;
  110293. }
  110294. }
  110295. declare module BABYLON {
  110296. /**
  110297. * A directional light is defined by a direction (what a surprise!).
  110298. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110299. * 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.
  110300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110301. */
  110302. export class DirectionalLight extends ShadowLight {
  110303. private _shadowFrustumSize;
  110304. /**
  110305. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110306. */
  110307. /**
  110308. * Specifies a fix frustum size for the shadow generation.
  110309. */
  110310. shadowFrustumSize: number;
  110311. private _shadowOrthoScale;
  110312. /**
  110313. * Gets the shadow projection scale against the optimal computed one.
  110314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110316. */
  110317. /**
  110318. * Sets the shadow projection scale against the optimal computed one.
  110319. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110320. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110321. */
  110322. shadowOrthoScale: number;
  110323. /**
  110324. * Automatically compute the projection matrix to best fit (including all the casters)
  110325. * on each frame.
  110326. */
  110327. autoUpdateExtends: boolean;
  110328. private _orthoLeft;
  110329. private _orthoRight;
  110330. private _orthoTop;
  110331. private _orthoBottom;
  110332. /**
  110333. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110334. * The directional light is emitted from everywhere in the given direction.
  110335. * It can cast shadows.
  110336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110337. * @param name The friendly name of the light
  110338. * @param direction The direction of the light
  110339. * @param scene The scene the light belongs to
  110340. */
  110341. constructor(name: string, direction: Vector3, scene: Scene);
  110342. /**
  110343. * Returns the string "DirectionalLight".
  110344. * @return The class name
  110345. */
  110346. getClassName(): string;
  110347. /**
  110348. * Returns the integer 1.
  110349. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110350. */
  110351. getTypeID(): number;
  110352. /**
  110353. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110354. * Returns the DirectionalLight Shadow projection matrix.
  110355. */
  110356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110357. /**
  110358. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110359. * Returns the DirectionalLight Shadow projection matrix.
  110360. */
  110361. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110362. /**
  110363. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110364. * Returns the DirectionalLight Shadow projection matrix.
  110365. */
  110366. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110367. protected _buildUniformLayout(): void;
  110368. /**
  110369. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110370. * @param effect The effect to update
  110371. * @param lightIndex The index of the light in the effect to update
  110372. * @returns The directional light
  110373. */
  110374. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110376. /**
  110377. * Gets the minZ used for shadow according to both the scene and the light.
  110378. *
  110379. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110380. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110381. * @param activeCamera The camera we are returning the min for
  110382. * @returns the depth min z
  110383. */
  110384. getDepthMinZ(activeCamera: Camera): number;
  110385. /**
  110386. * Gets the maxZ used for shadow according to both the scene and the light.
  110387. *
  110388. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110389. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110390. * @param activeCamera The camera we are returning the max for
  110391. * @returns the depth max z
  110392. */
  110393. getDepthMaxZ(activeCamera: Camera): number;
  110394. /**
  110395. * Prepares the list of defines specific to the light type.
  110396. * @param defines the list of defines
  110397. * @param lightIndex defines the index of the light for the effect
  110398. */
  110399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110400. }
  110401. }
  110402. declare module BABYLON {
  110403. /**
  110404. * Class containing static functions to help procedurally build meshes
  110405. */
  110406. export class HemisphereBuilder {
  110407. /**
  110408. * Creates a hemisphere mesh
  110409. * @param name defines the name of the mesh
  110410. * @param options defines the options used to create the mesh
  110411. * @param scene defines the hosting scene
  110412. * @returns the hemisphere mesh
  110413. */
  110414. static CreateHemisphere(name: string, options: {
  110415. segments?: number;
  110416. diameter?: number;
  110417. sideOrientation?: number;
  110418. }, scene: any): Mesh;
  110419. }
  110420. }
  110421. declare module BABYLON {
  110422. /**
  110423. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110424. * These values define a cone of light starting from the position, emitting toward the direction.
  110425. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110426. * and the exponent defines the speed of the decay of the light with distance (reach).
  110427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110428. */
  110429. export class SpotLight extends ShadowLight {
  110430. private _angle;
  110431. private _innerAngle;
  110432. private _cosHalfAngle;
  110433. private _lightAngleScale;
  110434. private _lightAngleOffset;
  110435. /**
  110436. * Gets the cone angle of the spot light in Radians.
  110437. */
  110438. /**
  110439. * Sets the cone angle of the spot light in Radians.
  110440. */
  110441. angle: number;
  110442. /**
  110443. * Only used in gltf falloff mode, this defines the angle where
  110444. * the directional falloff will start before cutting at angle which could be seen
  110445. * as outer angle.
  110446. */
  110447. /**
  110448. * Only used in gltf falloff mode, this defines the angle where
  110449. * the directional falloff will start before cutting at angle which could be seen
  110450. * as outer angle.
  110451. */
  110452. innerAngle: number;
  110453. private _shadowAngleScale;
  110454. /**
  110455. * Allows scaling the angle of the light for shadow generation only.
  110456. */
  110457. /**
  110458. * Allows scaling the angle of the light for shadow generation only.
  110459. */
  110460. shadowAngleScale: number;
  110461. /**
  110462. * The light decay speed with the distance from the emission spot.
  110463. */
  110464. exponent: number;
  110465. private _projectionTextureMatrix;
  110466. /**
  110467. * Allows reading the projecton texture
  110468. */
  110469. readonly projectionTextureMatrix: Matrix;
  110470. protected _projectionTextureLightNear: number;
  110471. /**
  110472. * Gets the near clip of the Spotlight for texture projection.
  110473. */
  110474. /**
  110475. * Sets the near clip of the Spotlight for texture projection.
  110476. */
  110477. projectionTextureLightNear: number;
  110478. protected _projectionTextureLightFar: number;
  110479. /**
  110480. * Gets the far clip of the Spotlight for texture projection.
  110481. */
  110482. /**
  110483. * Sets the far clip of the Spotlight for texture projection.
  110484. */
  110485. projectionTextureLightFar: number;
  110486. protected _projectionTextureUpDirection: Vector3;
  110487. /**
  110488. * Gets the Up vector of the Spotlight for texture projection.
  110489. */
  110490. /**
  110491. * Sets the Up vector of the Spotlight for texture projection.
  110492. */
  110493. projectionTextureUpDirection: Vector3;
  110494. private _projectionTexture;
  110495. /**
  110496. * Gets the projection texture of the light.
  110497. */
  110498. /**
  110499. * Sets the projection texture of the light.
  110500. */
  110501. projectionTexture: Nullable<BaseTexture>;
  110502. private _projectionTextureViewLightDirty;
  110503. private _projectionTextureProjectionLightDirty;
  110504. private _projectionTextureDirty;
  110505. private _projectionTextureViewTargetVector;
  110506. private _projectionTextureViewLightMatrix;
  110507. private _projectionTextureProjectionLightMatrix;
  110508. private _projectionTextureScalingMatrix;
  110509. /**
  110510. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110511. * It can cast shadows.
  110512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110513. * @param name The light friendly name
  110514. * @param position The position of the spot light in the scene
  110515. * @param direction The direction of the light in the scene
  110516. * @param angle The cone angle of the light in Radians
  110517. * @param exponent The light decay speed with the distance from the emission spot
  110518. * @param scene The scene the lights belongs to
  110519. */
  110520. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110521. /**
  110522. * Returns the string "SpotLight".
  110523. * @returns the class name
  110524. */
  110525. getClassName(): string;
  110526. /**
  110527. * Returns the integer 2.
  110528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110529. */
  110530. getTypeID(): number;
  110531. /**
  110532. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110533. */
  110534. protected _setDirection(value: Vector3): void;
  110535. /**
  110536. * Overrides the position setter to recompute the projection texture view light Matrix.
  110537. */
  110538. protected _setPosition(value: Vector3): void;
  110539. /**
  110540. * 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.
  110541. * Returns the SpotLight.
  110542. */
  110543. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110544. protected _computeProjectionTextureViewLightMatrix(): void;
  110545. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110546. /**
  110547. * Main function for light texture projection matrix computing.
  110548. */
  110549. protected _computeProjectionTextureMatrix(): void;
  110550. protected _buildUniformLayout(): void;
  110551. private _computeAngleValues;
  110552. /**
  110553. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110554. * @param effect The effect to update
  110555. * @param lightIndex The index of the light in the effect to update
  110556. * @returns The spot light
  110557. */
  110558. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110559. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110560. /**
  110561. * Disposes the light and the associated resources.
  110562. */
  110563. dispose(): void;
  110564. /**
  110565. * Prepares the list of defines specific to the light type.
  110566. * @param defines the list of defines
  110567. * @param lightIndex defines the index of the light for the effect
  110568. */
  110569. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110570. }
  110571. }
  110572. declare module BABYLON {
  110573. /**
  110574. * Gizmo that enables viewing a light
  110575. */
  110576. export class LightGizmo extends Gizmo {
  110577. private _lightMesh;
  110578. private _material;
  110579. private cachedPosition;
  110580. private cachedForward;
  110581. /**
  110582. * Creates a LightGizmo
  110583. * @param gizmoLayer The utility layer the gizmo will be added to
  110584. */
  110585. constructor(gizmoLayer?: UtilityLayerRenderer);
  110586. private _light;
  110587. /**
  110588. * The light that the gizmo is attached to
  110589. */
  110590. light: Nullable<Light>;
  110591. /**
  110592. * Gets the material used to render the light gizmo
  110593. */
  110594. readonly material: StandardMaterial;
  110595. /**
  110596. * @hidden
  110597. * Updates the gizmo to match the attached mesh's position/rotation
  110598. */
  110599. protected _update(): void;
  110600. private static _Scale;
  110601. /**
  110602. * Creates the lines for a light mesh
  110603. */
  110604. private static _createLightLines;
  110605. /**
  110606. * Disposes of the light gizmo
  110607. */
  110608. dispose(): void;
  110609. private static _CreateHemisphericLightMesh;
  110610. private static _CreatePointLightMesh;
  110611. private static _CreateSpotLightMesh;
  110612. private static _CreateDirectionalLightMesh;
  110613. }
  110614. }
  110615. declare module BABYLON {
  110616. /** @hidden */
  110617. export var backgroundFragmentDeclaration: {
  110618. name: string;
  110619. shader: string;
  110620. };
  110621. }
  110622. declare module BABYLON {
  110623. /** @hidden */
  110624. export var backgroundUboDeclaration: {
  110625. name: string;
  110626. shader: string;
  110627. };
  110628. }
  110629. declare module BABYLON {
  110630. /** @hidden */
  110631. export var backgroundPixelShader: {
  110632. name: string;
  110633. shader: string;
  110634. };
  110635. }
  110636. declare module BABYLON {
  110637. /** @hidden */
  110638. export var backgroundVertexDeclaration: {
  110639. name: string;
  110640. shader: string;
  110641. };
  110642. }
  110643. declare module BABYLON {
  110644. /** @hidden */
  110645. export var backgroundVertexShader: {
  110646. name: string;
  110647. shader: string;
  110648. };
  110649. }
  110650. declare module BABYLON {
  110651. /**
  110652. * Background material used to create an efficient environement around your scene.
  110653. */
  110654. export class BackgroundMaterial extends PushMaterial {
  110655. /**
  110656. * Standard reflectance value at parallel view angle.
  110657. */
  110658. static StandardReflectance0: number;
  110659. /**
  110660. * Standard reflectance value at grazing angle.
  110661. */
  110662. static StandardReflectance90: number;
  110663. protected _primaryColor: Color3;
  110664. /**
  110665. * Key light Color (multiply against the environement texture)
  110666. */
  110667. primaryColor: Color3;
  110668. protected __perceptualColor: Nullable<Color3>;
  110669. /**
  110670. * Experimental Internal Use Only.
  110671. *
  110672. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  110673. * This acts as a helper to set the primary color to a more "human friendly" value.
  110674. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  110675. * output color as close as possible from the chosen value.
  110676. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  110677. * part of lighting setup.)
  110678. */
  110679. _perceptualColor: Nullable<Color3>;
  110680. protected _primaryColorShadowLevel: float;
  110681. /**
  110682. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  110683. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  110684. */
  110685. primaryColorShadowLevel: float;
  110686. protected _primaryColorHighlightLevel: float;
  110687. /**
  110688. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  110689. * The primary color is used at the level chosen to define what the white area would look.
  110690. */
  110691. primaryColorHighlightLevel: float;
  110692. protected _reflectionTexture: Nullable<BaseTexture>;
  110693. /**
  110694. * Reflection Texture used in the material.
  110695. * Should be author in a specific way for the best result (refer to the documentation).
  110696. */
  110697. reflectionTexture: Nullable<BaseTexture>;
  110698. protected _reflectionBlur: float;
  110699. /**
  110700. * Reflection Texture level of blur.
  110701. *
  110702. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  110703. * texture twice.
  110704. */
  110705. reflectionBlur: float;
  110706. protected _diffuseTexture: Nullable<BaseTexture>;
  110707. /**
  110708. * Diffuse Texture used in the material.
  110709. * Should be author in a specific way for the best result (refer to the documentation).
  110710. */
  110711. diffuseTexture: Nullable<BaseTexture>;
  110712. protected _shadowLights: Nullable<IShadowLight[]>;
  110713. /**
  110714. * Specify the list of lights casting shadow on the material.
  110715. * All scene shadow lights will be included if null.
  110716. */
  110717. shadowLights: Nullable<IShadowLight[]>;
  110718. protected _shadowLevel: float;
  110719. /**
  110720. * Helps adjusting the shadow to a softer level if required.
  110721. * 0 means black shadows and 1 means no shadows.
  110722. */
  110723. shadowLevel: float;
  110724. protected _sceneCenter: Vector3;
  110725. /**
  110726. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  110727. * It is usually zero but might be interesting to modify according to your setup.
  110728. */
  110729. sceneCenter: Vector3;
  110730. protected _opacityFresnel: boolean;
  110731. /**
  110732. * This helps specifying that the material is falling off to the sky box at grazing angle.
  110733. * This helps ensuring a nice transition when the camera goes under the ground.
  110734. */
  110735. opacityFresnel: boolean;
  110736. protected _reflectionFresnel: boolean;
  110737. /**
  110738. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  110739. * This helps adding a mirror texture on the ground.
  110740. */
  110741. reflectionFresnel: boolean;
  110742. protected _reflectionFalloffDistance: number;
  110743. /**
  110744. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  110745. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  110746. */
  110747. reflectionFalloffDistance: number;
  110748. protected _reflectionAmount: number;
  110749. /**
  110750. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  110751. */
  110752. reflectionAmount: number;
  110753. protected _reflectionReflectance0: number;
  110754. /**
  110755. * This specifies the weight of the reflection at grazing angle.
  110756. */
  110757. reflectionReflectance0: number;
  110758. protected _reflectionReflectance90: number;
  110759. /**
  110760. * This specifies the weight of the reflection at a perpendicular point of view.
  110761. */
  110762. reflectionReflectance90: number;
  110763. /**
  110764. * Sets the reflection reflectance fresnel values according to the default standard
  110765. * empirically know to work well :-)
  110766. */
  110767. reflectionStandardFresnelWeight: number;
  110768. protected _useRGBColor: boolean;
  110769. /**
  110770. * Helps to directly use the maps channels instead of their level.
  110771. */
  110772. useRGBColor: boolean;
  110773. protected _enableNoise: boolean;
  110774. /**
  110775. * This helps reducing the banding effect that could occur on the background.
  110776. */
  110777. enableNoise: boolean;
  110778. /**
  110779. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110780. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  110781. * Recommended to be keep at 1.0 except for special cases.
  110782. */
  110783. fovMultiplier: number;
  110784. private _fovMultiplier;
  110785. /**
  110786. * Enable the FOV adjustment feature controlled by fovMultiplier.
  110787. */
  110788. useEquirectangularFOV: boolean;
  110789. private _maxSimultaneousLights;
  110790. /**
  110791. * Number of Simultaneous lights allowed on the material.
  110792. */
  110793. maxSimultaneousLights: int;
  110794. /**
  110795. * Default configuration related to image processing available in the Background Material.
  110796. */
  110797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110798. /**
  110799. * Keep track of the image processing observer to allow dispose and replace.
  110800. */
  110801. private _imageProcessingObserver;
  110802. /**
  110803. * Attaches a new image processing configuration to the PBR Material.
  110804. * @param configuration (if null the scene configuration will be use)
  110805. */
  110806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110807. /**
  110808. * Gets the image processing configuration used either in this material.
  110809. */
  110810. /**
  110811. * Sets the Default image processing configuration used either in the this material.
  110812. *
  110813. * If sets to null, the scene one is in use.
  110814. */
  110815. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  110816. /**
  110817. * Gets wether the color curves effect is enabled.
  110818. */
  110819. /**
  110820. * Sets wether the color curves effect is enabled.
  110821. */
  110822. cameraColorCurvesEnabled: boolean;
  110823. /**
  110824. * Gets wether the color grading effect is enabled.
  110825. */
  110826. /**
  110827. * Gets wether the color grading effect is enabled.
  110828. */
  110829. cameraColorGradingEnabled: boolean;
  110830. /**
  110831. * Gets wether tonemapping is enabled or not.
  110832. */
  110833. /**
  110834. * Sets wether tonemapping is enabled or not
  110835. */
  110836. cameraToneMappingEnabled: boolean;
  110837. /**
  110838. * The camera exposure used on this material.
  110839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110840. * This corresponds to a photographic exposure.
  110841. */
  110842. /**
  110843. * The camera exposure used on this material.
  110844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110845. * This corresponds to a photographic exposure.
  110846. */
  110847. cameraExposure: float;
  110848. /**
  110849. * Gets The camera contrast used on this material.
  110850. */
  110851. /**
  110852. * Sets The camera contrast used on this material.
  110853. */
  110854. cameraContrast: float;
  110855. /**
  110856. * Gets the Color Grading 2D Lookup Texture.
  110857. */
  110858. /**
  110859. * Sets the Color Grading 2D Lookup Texture.
  110860. */
  110861. cameraColorGradingTexture: Nullable<BaseTexture>;
  110862. /**
  110863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110865. * 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;
  110866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110867. */
  110868. /**
  110869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110871. * 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;
  110872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110873. */
  110874. cameraColorCurves: Nullable<ColorCurves>;
  110875. /**
  110876. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  110877. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  110878. */
  110879. switchToBGR: boolean;
  110880. private _renderTargets;
  110881. private _reflectionControls;
  110882. private _white;
  110883. private _primaryShadowColor;
  110884. private _primaryHighlightColor;
  110885. /**
  110886. * Instantiates a Background Material in the given scene
  110887. * @param name The friendly name of the material
  110888. * @param scene The scene to add the material to
  110889. */
  110890. constructor(name: string, scene: Scene);
  110891. /**
  110892. * Gets a boolean indicating that current material needs to register RTT
  110893. */
  110894. readonly hasRenderTargetTextures: boolean;
  110895. /**
  110896. * The entire material has been created in order to prevent overdraw.
  110897. * @returns false
  110898. */
  110899. needAlphaTesting(): boolean;
  110900. /**
  110901. * The entire material has been created in order to prevent overdraw.
  110902. * @returns true if blending is enable
  110903. */
  110904. needAlphaBlending(): boolean;
  110905. /**
  110906. * Checks wether the material is ready to be rendered for a given mesh.
  110907. * @param mesh The mesh to render
  110908. * @param subMesh The submesh to check against
  110909. * @param useInstances Specify wether or not the material is used with instances
  110910. * @returns true if all the dependencies are ready (Textures, Effects...)
  110911. */
  110912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110913. /**
  110914. * Compute the primary color according to the chosen perceptual color.
  110915. */
  110916. private _computePrimaryColorFromPerceptualColor;
  110917. /**
  110918. * Compute the highlights and shadow colors according to their chosen levels.
  110919. */
  110920. private _computePrimaryColors;
  110921. /**
  110922. * Build the uniform buffer used in the material.
  110923. */
  110924. buildUniformLayout(): void;
  110925. /**
  110926. * Unbind the material.
  110927. */
  110928. unbind(): void;
  110929. /**
  110930. * Bind only the world matrix to the material.
  110931. * @param world The world matrix to bind.
  110932. */
  110933. bindOnlyWorldMatrix(world: Matrix): void;
  110934. /**
  110935. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  110936. * @param world The world matrix to bind.
  110937. * @param subMesh The submesh to bind for.
  110938. */
  110939. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110940. /**
  110941. * Checks to see if a texture is used in the material.
  110942. * @param texture - Base texture to use.
  110943. * @returns - Boolean specifying if a texture is used in the material.
  110944. */
  110945. hasTexture(texture: BaseTexture): boolean;
  110946. /**
  110947. * Dispose the material.
  110948. * @param forceDisposeEffect Force disposal of the associated effect.
  110949. * @param forceDisposeTextures Force disposal of the associated textures.
  110950. */
  110951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110952. /**
  110953. * Clones the material.
  110954. * @param name The cloned name.
  110955. * @returns The cloned material.
  110956. */
  110957. clone(name: string): BackgroundMaterial;
  110958. /**
  110959. * Serializes the current material to its JSON representation.
  110960. * @returns The JSON representation.
  110961. */
  110962. serialize(): any;
  110963. /**
  110964. * Gets the class name of the material
  110965. * @returns "BackgroundMaterial"
  110966. */
  110967. getClassName(): string;
  110968. /**
  110969. * Parse a JSON input to create back a background material.
  110970. * @param source The JSON data to parse
  110971. * @param scene The scene to create the parsed material in
  110972. * @param rootUrl The root url of the assets the material depends upon
  110973. * @returns the instantiated BackgroundMaterial.
  110974. */
  110975. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  110976. }
  110977. }
  110978. declare module BABYLON {
  110979. /**
  110980. * Represents the different options available during the creation of
  110981. * a Environment helper.
  110982. *
  110983. * This can control the default ground, skybox and image processing setup of your scene.
  110984. */
  110985. export interface IEnvironmentHelperOptions {
  110986. /**
  110987. * Specifies wether or not to create a ground.
  110988. * True by default.
  110989. */
  110990. createGround: boolean;
  110991. /**
  110992. * Specifies the ground size.
  110993. * 15 by default.
  110994. */
  110995. groundSize: number;
  110996. /**
  110997. * The texture used on the ground for the main color.
  110998. * Comes from the BabylonJS CDN by default.
  110999. *
  111000. * Remarks: Can be either a texture or a url.
  111001. */
  111002. groundTexture: string | BaseTexture;
  111003. /**
  111004. * The color mixed in the ground texture by default.
  111005. * BabylonJS clearColor by default.
  111006. */
  111007. groundColor: Color3;
  111008. /**
  111009. * Specifies the ground opacity.
  111010. * 1 by default.
  111011. */
  111012. groundOpacity: number;
  111013. /**
  111014. * Enables the ground to receive shadows.
  111015. * True by default.
  111016. */
  111017. enableGroundShadow: boolean;
  111018. /**
  111019. * Helps preventing the shadow to be fully black on the ground.
  111020. * 0.5 by default.
  111021. */
  111022. groundShadowLevel: number;
  111023. /**
  111024. * Creates a mirror texture attach to the ground.
  111025. * false by default.
  111026. */
  111027. enableGroundMirror: boolean;
  111028. /**
  111029. * Specifies the ground mirror size ratio.
  111030. * 0.3 by default as the default kernel is 64.
  111031. */
  111032. groundMirrorSizeRatio: number;
  111033. /**
  111034. * Specifies the ground mirror blur kernel size.
  111035. * 64 by default.
  111036. */
  111037. groundMirrorBlurKernel: number;
  111038. /**
  111039. * Specifies the ground mirror visibility amount.
  111040. * 1 by default
  111041. */
  111042. groundMirrorAmount: number;
  111043. /**
  111044. * Specifies the ground mirror reflectance weight.
  111045. * This uses the standard weight of the background material to setup the fresnel effect
  111046. * of the mirror.
  111047. * 1 by default.
  111048. */
  111049. groundMirrorFresnelWeight: number;
  111050. /**
  111051. * Specifies the ground mirror Falloff distance.
  111052. * This can helps reducing the size of the reflection.
  111053. * 0 by Default.
  111054. */
  111055. groundMirrorFallOffDistance: number;
  111056. /**
  111057. * Specifies the ground mirror texture type.
  111058. * Unsigned Int by Default.
  111059. */
  111060. groundMirrorTextureType: number;
  111061. /**
  111062. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111063. * the shown objects.
  111064. */
  111065. groundYBias: number;
  111066. /**
  111067. * Specifies wether or not to create a skybox.
  111068. * True by default.
  111069. */
  111070. createSkybox: boolean;
  111071. /**
  111072. * Specifies the skybox size.
  111073. * 20 by default.
  111074. */
  111075. skyboxSize: number;
  111076. /**
  111077. * The texture used on the skybox for the main color.
  111078. * Comes from the BabylonJS CDN by default.
  111079. *
  111080. * Remarks: Can be either a texture or a url.
  111081. */
  111082. skyboxTexture: string | BaseTexture;
  111083. /**
  111084. * The color mixed in the skybox texture by default.
  111085. * BabylonJS clearColor by default.
  111086. */
  111087. skyboxColor: Color3;
  111088. /**
  111089. * The background rotation around the Y axis of the scene.
  111090. * This helps aligning the key lights of your scene with the background.
  111091. * 0 by default.
  111092. */
  111093. backgroundYRotation: number;
  111094. /**
  111095. * Compute automatically the size of the elements to best fit with the scene.
  111096. */
  111097. sizeAuto: boolean;
  111098. /**
  111099. * Default position of the rootMesh if autoSize is not true.
  111100. */
  111101. rootPosition: Vector3;
  111102. /**
  111103. * Sets up the image processing in the scene.
  111104. * true by default.
  111105. */
  111106. setupImageProcessing: boolean;
  111107. /**
  111108. * The texture used as your environment texture in the scene.
  111109. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111110. *
  111111. * Remarks: Can be either a texture or a url.
  111112. */
  111113. environmentTexture: string | BaseTexture;
  111114. /**
  111115. * The value of the exposure to apply to the scene.
  111116. * 0.6 by default if setupImageProcessing is true.
  111117. */
  111118. cameraExposure: number;
  111119. /**
  111120. * The value of the contrast to apply to the scene.
  111121. * 1.6 by default if setupImageProcessing is true.
  111122. */
  111123. cameraContrast: number;
  111124. /**
  111125. * Specifies wether or not tonemapping should be enabled in the scene.
  111126. * true by default if setupImageProcessing is true.
  111127. */
  111128. toneMappingEnabled: boolean;
  111129. }
  111130. /**
  111131. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111132. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111133. * It also helps with the default setup of your imageProcessing configuration.
  111134. */
  111135. export class EnvironmentHelper {
  111136. /**
  111137. * Default ground texture URL.
  111138. */
  111139. private static _groundTextureCDNUrl;
  111140. /**
  111141. * Default skybox texture URL.
  111142. */
  111143. private static _skyboxTextureCDNUrl;
  111144. /**
  111145. * Default environment texture URL.
  111146. */
  111147. private static _environmentTextureCDNUrl;
  111148. /**
  111149. * Creates the default options for the helper.
  111150. */
  111151. private static _getDefaultOptions;
  111152. private _rootMesh;
  111153. /**
  111154. * Gets the root mesh created by the helper.
  111155. */
  111156. readonly rootMesh: Mesh;
  111157. private _skybox;
  111158. /**
  111159. * Gets the skybox created by the helper.
  111160. */
  111161. readonly skybox: Nullable<Mesh>;
  111162. private _skyboxTexture;
  111163. /**
  111164. * Gets the skybox texture created by the helper.
  111165. */
  111166. readonly skyboxTexture: Nullable<BaseTexture>;
  111167. private _skyboxMaterial;
  111168. /**
  111169. * Gets the skybox material created by the helper.
  111170. */
  111171. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111172. private _ground;
  111173. /**
  111174. * Gets the ground mesh created by the helper.
  111175. */
  111176. readonly ground: Nullable<Mesh>;
  111177. private _groundTexture;
  111178. /**
  111179. * Gets the ground texture created by the helper.
  111180. */
  111181. readonly groundTexture: Nullable<BaseTexture>;
  111182. private _groundMirror;
  111183. /**
  111184. * Gets the ground mirror created by the helper.
  111185. */
  111186. readonly groundMirror: Nullable<MirrorTexture>;
  111187. /**
  111188. * Gets the ground mirror render list to helps pushing the meshes
  111189. * you wish in the ground reflection.
  111190. */
  111191. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111192. private _groundMaterial;
  111193. /**
  111194. * Gets the ground material created by the helper.
  111195. */
  111196. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111197. /**
  111198. * Stores the creation options.
  111199. */
  111200. private readonly _scene;
  111201. private _options;
  111202. /**
  111203. * This observable will be notified with any error during the creation of the environment,
  111204. * mainly texture creation errors.
  111205. */
  111206. onErrorObservable: Observable<{
  111207. message?: string;
  111208. exception?: any;
  111209. }>;
  111210. /**
  111211. * constructor
  111212. * @param options Defines the options we want to customize the helper
  111213. * @param scene The scene to add the material to
  111214. */
  111215. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111216. /**
  111217. * Updates the background according to the new options
  111218. * @param options
  111219. */
  111220. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111221. /**
  111222. * Sets the primary color of all the available elements.
  111223. * @param color the main color to affect to the ground and the background
  111224. */
  111225. setMainColor(color: Color3): void;
  111226. /**
  111227. * Setup the image processing according to the specified options.
  111228. */
  111229. private _setupImageProcessing;
  111230. /**
  111231. * Setup the environment texture according to the specified options.
  111232. */
  111233. private _setupEnvironmentTexture;
  111234. /**
  111235. * Setup the background according to the specified options.
  111236. */
  111237. private _setupBackground;
  111238. /**
  111239. * Get the scene sizes according to the setup.
  111240. */
  111241. private _getSceneSize;
  111242. /**
  111243. * Setup the ground according to the specified options.
  111244. */
  111245. private _setupGround;
  111246. /**
  111247. * Setup the ground material according to the specified options.
  111248. */
  111249. private _setupGroundMaterial;
  111250. /**
  111251. * Setup the ground diffuse texture according to the specified options.
  111252. */
  111253. private _setupGroundDiffuseTexture;
  111254. /**
  111255. * Setup the ground mirror texture according to the specified options.
  111256. */
  111257. private _setupGroundMirrorTexture;
  111258. /**
  111259. * Setup the ground to receive the mirror texture.
  111260. */
  111261. private _setupMirrorInGroundMaterial;
  111262. /**
  111263. * Setup the skybox according to the specified options.
  111264. */
  111265. private _setupSkybox;
  111266. /**
  111267. * Setup the skybox material according to the specified options.
  111268. */
  111269. private _setupSkyboxMaterial;
  111270. /**
  111271. * Setup the skybox reflection texture according to the specified options.
  111272. */
  111273. private _setupSkyboxReflectionTexture;
  111274. private _errorHandler;
  111275. /**
  111276. * Dispose all the elements created by the Helper.
  111277. */
  111278. dispose(): void;
  111279. }
  111280. }
  111281. declare module BABYLON {
  111282. /**
  111283. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111284. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111285. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111286. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111287. */
  111288. export class PhotoDome extends TransformNode {
  111289. /**
  111290. * Define the image as a Monoscopic panoramic 360 image.
  111291. */
  111292. static readonly MODE_MONOSCOPIC: number;
  111293. /**
  111294. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111295. */
  111296. static readonly MODE_TOPBOTTOM: number;
  111297. /**
  111298. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111299. */
  111300. static readonly MODE_SIDEBYSIDE: number;
  111301. private _useDirectMapping;
  111302. /**
  111303. * The texture being displayed on the sphere
  111304. */
  111305. protected _photoTexture: Texture;
  111306. /**
  111307. * Gets or sets the texture being displayed on the sphere
  111308. */
  111309. photoTexture: Texture;
  111310. /**
  111311. * Observable raised when an error occured while loading the 360 image
  111312. */
  111313. onLoadErrorObservable: Observable<string>;
  111314. /**
  111315. * The skybox material
  111316. */
  111317. protected _material: BackgroundMaterial;
  111318. /**
  111319. * The surface used for the skybox
  111320. */
  111321. protected _mesh: Mesh;
  111322. /**
  111323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111324. * Also see the options.resolution property.
  111325. */
  111326. fovMultiplier: number;
  111327. private _imageMode;
  111328. /**
  111329. * Gets or set the current video mode for the video. It can be:
  111330. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111331. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111332. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111333. */
  111334. imageMode: number;
  111335. /**
  111336. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111337. * @param name Element's name, child elements will append suffixes for their own names.
  111338. * @param urlsOfPhoto defines the url of the photo to display
  111339. * @param options defines an object containing optional or exposed sub element properties
  111340. * @param onError defines a callback called when an error occured while loading the texture
  111341. */
  111342. constructor(name: string, urlOfPhoto: string, options: {
  111343. resolution?: number;
  111344. size?: number;
  111345. useDirectMapping?: boolean;
  111346. faceForward?: boolean;
  111347. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111348. private _onBeforeCameraRenderObserver;
  111349. private _changeImageMode;
  111350. /**
  111351. * Releases resources associated with this node.
  111352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111354. */
  111355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111356. }
  111357. }
  111358. declare module BABYLON {
  111359. /**
  111360. * Class used to host texture specific utilities
  111361. */
  111362. export class BRDFTextureTools {
  111363. /**
  111364. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  111365. * @param texture the texture to expand.
  111366. */
  111367. private static _ExpandDefaultBRDFTexture;
  111368. /**
  111369. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111370. * @param scene defines the hosting scene
  111371. * @returns the environment BRDF texture
  111372. */
  111373. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111374. private static _environmentBRDFBase64Texture;
  111375. }
  111376. }
  111377. declare module BABYLON {
  111378. /**
  111379. * @hidden
  111380. */
  111381. export interface IMaterialClearCoatDefines {
  111382. CLEARCOAT: boolean;
  111383. CLEARCOAT_DEFAULTIOR: boolean;
  111384. CLEARCOAT_TEXTURE: boolean;
  111385. CLEARCOAT_TEXTUREDIRECTUV: number;
  111386. CLEARCOAT_BUMP: boolean;
  111387. CLEARCOAT_BUMPDIRECTUV: number;
  111388. CLEARCOAT_TINT: boolean;
  111389. CLEARCOAT_TINT_TEXTURE: boolean;
  111390. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111391. /** @hidden */
  111392. _areTexturesDirty: boolean;
  111393. }
  111394. /**
  111395. * Define the code related to the clear coat parameters of the pbr material.
  111396. */
  111397. export class PBRClearCoatConfiguration {
  111398. /**
  111399. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111400. * The default fits with a polyurethane material.
  111401. */
  111402. private static readonly _DefaultIndexOfRefraction;
  111403. private _isEnabled;
  111404. /**
  111405. * Defines if the clear coat is enabled in the material.
  111406. */
  111407. isEnabled: boolean;
  111408. /**
  111409. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111410. */
  111411. intensity: number;
  111412. /**
  111413. * Defines the clear coat layer roughness.
  111414. */
  111415. roughness: number;
  111416. private _indexOfRefraction;
  111417. /**
  111418. * Defines the index of refraction of the clear coat.
  111419. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111420. * The default fits with a polyurethane material.
  111421. * Changing the default value is more performance intensive.
  111422. */
  111423. indexOfRefraction: number;
  111424. private _texture;
  111425. /**
  111426. * Stores the clear coat values in a texture.
  111427. */
  111428. texture: Nullable<BaseTexture>;
  111429. private _bumpTexture;
  111430. /**
  111431. * Define the clear coat specific bump texture.
  111432. */
  111433. bumpTexture: Nullable<BaseTexture>;
  111434. private _isTintEnabled;
  111435. /**
  111436. * Defines if the clear coat tint is enabled in the material.
  111437. */
  111438. isTintEnabled: boolean;
  111439. /**
  111440. * Defines the clear coat tint of the material.
  111441. * This is only use if tint is enabled
  111442. */
  111443. tintColor: Color3;
  111444. /**
  111445. * Defines the distance at which the tint color should be found in the
  111446. * clear coat media.
  111447. * This is only use if tint is enabled
  111448. */
  111449. tintColorAtDistance: number;
  111450. /**
  111451. * Defines the clear coat layer thickness.
  111452. * This is only use if tint is enabled
  111453. */
  111454. tintThickness: number;
  111455. private _tintTexture;
  111456. /**
  111457. * Stores the clear tint values in a texture.
  111458. * rgb is tint
  111459. * a is a thickness factor
  111460. */
  111461. tintTexture: Nullable<BaseTexture>;
  111462. /** @hidden */
  111463. private _internalMarkAllSubMeshesAsTexturesDirty;
  111464. /** @hidden */
  111465. _markAllSubMeshesAsTexturesDirty(): void;
  111466. /**
  111467. * Instantiate a new istance of clear coat configuration.
  111468. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111469. */
  111470. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111471. /**
  111472. * Gets wehter the submesh is ready to be used or not.
  111473. * @param defines the list of "defines" to update.
  111474. * @param scene defines the scene the material belongs to.
  111475. * @param engine defines the engine the material belongs to.
  111476. * @param disableBumpMap defines wether the material disables bump or not.
  111477. * @returns - boolean indicating that the submesh is ready or not.
  111478. */
  111479. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111480. /**
  111481. * Checks to see if a texture is used in the material.
  111482. * @param defines the list of "defines" to update.
  111483. * @param scene defines the scene to the material belongs to.
  111484. */
  111485. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111486. /**
  111487. * Binds the material data.
  111488. * @param uniformBuffer defines the Uniform buffer to fill in.
  111489. * @param scene defines the scene the material belongs to.
  111490. * @param engine defines the engine the material belongs to.
  111491. * @param disableBumpMap defines wether the material disables bump or not.
  111492. * @param isFrozen defines wether the material is frozen or not.
  111493. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111494. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111495. */
  111496. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111497. /**
  111498. * Checks to see if a texture is used in the material.
  111499. * @param texture - Base texture to use.
  111500. * @returns - Boolean specifying if a texture is used in the material.
  111501. */
  111502. hasTexture(texture: BaseTexture): boolean;
  111503. /**
  111504. * Returns an array of the actively used textures.
  111505. * @param activeTextures Array of BaseTextures
  111506. */
  111507. getActiveTextures(activeTextures: BaseTexture[]): void;
  111508. /**
  111509. * Returns the animatable textures.
  111510. * @param animatables Array of animatable textures.
  111511. */
  111512. getAnimatables(animatables: IAnimatable[]): void;
  111513. /**
  111514. * Disposes the resources of the material.
  111515. * @param forceDisposeTextures - Forces the disposal of all textures.
  111516. */
  111517. dispose(forceDisposeTextures?: boolean): void;
  111518. /**
  111519. * Get the current class name of the texture useful for serialization or dynamic coding.
  111520. * @returns "PBRClearCoatConfiguration"
  111521. */
  111522. getClassName(): string;
  111523. /**
  111524. * Add fallbacks to the effect fallbacks list.
  111525. * @param defines defines the Base texture to use.
  111526. * @param fallbacks defines the current fallback list.
  111527. * @param currentRank defines the current fallback rank.
  111528. * @returns the new fallback rank.
  111529. */
  111530. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111531. /**
  111532. * Add the required uniforms to the current list.
  111533. * @param uniforms defines the current uniform list.
  111534. */
  111535. static AddUniforms(uniforms: string[]): void;
  111536. /**
  111537. * Add the required samplers to the current list.
  111538. * @param samplers defines the current sampler list.
  111539. */
  111540. static AddSamplers(samplers: string[]): void;
  111541. /**
  111542. * Add the required uniforms to the current buffer.
  111543. * @param uniformBuffer defines the current uniform buffer.
  111544. */
  111545. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111546. /**
  111547. * Makes a duplicate of the current configuration into another one.
  111548. * @param clearCoatConfiguration define the config where to copy the info
  111549. */
  111550. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111551. /**
  111552. * Serializes this clear coat configuration.
  111553. * @returns - An object with the serialized config.
  111554. */
  111555. serialize(): any;
  111556. /**
  111557. * Parses a anisotropy Configuration from a serialized object.
  111558. * @param source - Serialized object.
  111559. * @param scene Defines the scene we are parsing for
  111560. * @param rootUrl Defines the rootUrl to load from
  111561. */
  111562. parse(source: any, scene: Scene, rootUrl: string): void;
  111563. }
  111564. }
  111565. declare module BABYLON {
  111566. /**
  111567. * @hidden
  111568. */
  111569. export interface IMaterialAnisotropicDefines {
  111570. ANISOTROPIC: boolean;
  111571. ANISOTROPIC_TEXTURE: boolean;
  111572. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111573. MAINUV1: boolean;
  111574. _areTexturesDirty: boolean;
  111575. _needUVs: boolean;
  111576. }
  111577. /**
  111578. * Define the code related to the anisotropic parameters of the pbr material.
  111579. */
  111580. export class PBRAnisotropicConfiguration {
  111581. private _isEnabled;
  111582. /**
  111583. * Defines if the anisotropy is enabled in the material.
  111584. */
  111585. isEnabled: boolean;
  111586. /**
  111587. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111588. */
  111589. intensity: number;
  111590. /**
  111591. * Defines if the effect is along the tangents, bitangents or in between.
  111592. * By default, the effect is "strectching" the highlights along the tangents.
  111593. */
  111594. direction: Vector2;
  111595. private _texture;
  111596. /**
  111597. * Stores the anisotropy values in a texture.
  111598. * rg is direction (like normal from -1 to 1)
  111599. * b is a intensity
  111600. */
  111601. texture: Nullable<BaseTexture>;
  111602. /** @hidden */
  111603. private _internalMarkAllSubMeshesAsTexturesDirty;
  111604. /** @hidden */
  111605. _markAllSubMeshesAsTexturesDirty(): void;
  111606. /**
  111607. * Instantiate a new istance of anisotropy configuration.
  111608. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111609. */
  111610. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111611. /**
  111612. * Specifies that the submesh is ready to be used.
  111613. * @param defines the list of "defines" to update.
  111614. * @param scene defines the scene the material belongs to.
  111615. * @returns - boolean indicating that the submesh is ready or not.
  111616. */
  111617. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111618. /**
  111619. * Checks to see if a texture is used in the material.
  111620. * @param defines the list of "defines" to update.
  111621. * @param mesh the mesh we are preparing the defines for.
  111622. * @param scene defines the scene the material belongs to.
  111623. */
  111624. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111625. /**
  111626. * Binds the material data.
  111627. * @param uniformBuffer defines the Uniform buffer to fill in.
  111628. * @param scene defines the scene the material belongs to.
  111629. * @param isFrozen defines wether the material is frozen or not.
  111630. */
  111631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111632. /**
  111633. * Checks to see if a texture is used in the material.
  111634. * @param texture - Base texture to use.
  111635. * @returns - Boolean specifying if a texture is used in the material.
  111636. */
  111637. hasTexture(texture: BaseTexture): boolean;
  111638. /**
  111639. * Returns an array of the actively used textures.
  111640. * @param activeTextures Array of BaseTextures
  111641. */
  111642. getActiveTextures(activeTextures: BaseTexture[]): void;
  111643. /**
  111644. * Returns the animatable textures.
  111645. * @param animatables Array of animatable textures.
  111646. */
  111647. getAnimatables(animatables: IAnimatable[]): void;
  111648. /**
  111649. * Disposes the resources of the material.
  111650. * @param forceDisposeTextures - Forces the disposal of all textures.
  111651. */
  111652. dispose(forceDisposeTextures?: boolean): void;
  111653. /**
  111654. * Get the current class name of the texture useful for serialization or dynamic coding.
  111655. * @returns "PBRAnisotropicConfiguration"
  111656. */
  111657. getClassName(): string;
  111658. /**
  111659. * Add fallbacks to the effect fallbacks list.
  111660. * @param defines defines the Base texture to use.
  111661. * @param fallbacks defines the current fallback list.
  111662. * @param currentRank defines the current fallback rank.
  111663. * @returns the new fallback rank.
  111664. */
  111665. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111666. /**
  111667. * Add the required uniforms to the current list.
  111668. * @param uniforms defines the current uniform list.
  111669. */
  111670. static AddUniforms(uniforms: string[]): void;
  111671. /**
  111672. * Add the required uniforms to the current buffer.
  111673. * @param uniformBuffer defines the current uniform buffer.
  111674. */
  111675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111676. /**
  111677. * Add the required samplers to the current list.
  111678. * @param samplers defines the current sampler list.
  111679. */
  111680. static AddSamplers(samplers: string[]): void;
  111681. /**
  111682. * Makes a duplicate of the current configuration into another one.
  111683. * @param anisotropicConfiguration define the config where to copy the info
  111684. */
  111685. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  111686. /**
  111687. * Serializes this anisotropy configuration.
  111688. * @returns - An object with the serialized config.
  111689. */
  111690. serialize(): any;
  111691. /**
  111692. * Parses a anisotropy Configuration from a serialized object.
  111693. * @param source - Serialized object.
  111694. * @param scene Defines the scene we are parsing for
  111695. * @param rootUrl Defines the rootUrl to load from
  111696. */
  111697. parse(source: any, scene: Scene, rootUrl: string): void;
  111698. }
  111699. }
  111700. declare module BABYLON {
  111701. /**
  111702. * @hidden
  111703. */
  111704. export interface IMaterialBRDFDefines {
  111705. BRDF_V_HEIGHT_CORRELATED: boolean;
  111706. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111707. SPHERICAL_HARMONICS: boolean;
  111708. /** @hidden */
  111709. _areMiscDirty: boolean;
  111710. }
  111711. /**
  111712. * Define the code related to the BRDF parameters of the pbr material.
  111713. */
  111714. export class PBRBRDFConfiguration {
  111715. /**
  111716. * Default value used for the energy conservation.
  111717. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111718. */
  111719. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  111720. /**
  111721. * Default value used for the Smith Visibility Height Correlated mode.
  111722. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111723. */
  111724. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  111725. /**
  111726. * Default value used for the IBL diffuse part.
  111727. * This can help switching back to the polynomials mode globally which is a tiny bit
  111728. * less GPU intensive at the drawback of a lower quality.
  111729. */
  111730. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  111731. private _useEnergyConservation;
  111732. /**
  111733. * Defines if the material uses energy conservation.
  111734. */
  111735. useEnergyConservation: boolean;
  111736. private _useSmithVisibilityHeightCorrelated;
  111737. /**
  111738. * LEGACY Mode set to false
  111739. * Defines if the material uses height smith correlated visibility term.
  111740. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  111741. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  111742. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  111743. * Not relying on height correlated will also disable energy conservation.
  111744. */
  111745. useSmithVisibilityHeightCorrelated: boolean;
  111746. private _useSphericalHarmonics;
  111747. /**
  111748. * LEGACY Mode set to false
  111749. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  111750. * diffuse part of the IBL.
  111751. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  111752. * to the ground truth.
  111753. */
  111754. useSphericalHarmonics: boolean;
  111755. /** @hidden */
  111756. private _internalMarkAllSubMeshesAsMiscDirty;
  111757. /** @hidden */
  111758. _markAllSubMeshesAsMiscDirty(): void;
  111759. /**
  111760. * Instantiate a new istance of clear coat configuration.
  111761. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  111762. */
  111763. constructor(markAllSubMeshesAsMiscDirty: () => void);
  111764. /**
  111765. * Checks to see if a texture is used in the material.
  111766. * @param defines the list of "defines" to update.
  111767. */
  111768. prepareDefines(defines: IMaterialBRDFDefines): void;
  111769. /**
  111770. * Get the current class name of the texture useful for serialization or dynamic coding.
  111771. * @returns "PBRClearCoatConfiguration"
  111772. */
  111773. getClassName(): string;
  111774. /**
  111775. * Makes a duplicate of the current configuration into another one.
  111776. * @param brdfConfiguration define the config where to copy the info
  111777. */
  111778. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  111779. /**
  111780. * Serializes this BRDF configuration.
  111781. * @returns - An object with the serialized config.
  111782. */
  111783. serialize(): any;
  111784. /**
  111785. * Parses a anisotropy Configuration from a serialized object.
  111786. * @param source - Serialized object.
  111787. * @param scene Defines the scene we are parsing for
  111788. * @param rootUrl Defines the rootUrl to load from
  111789. */
  111790. parse(source: any, scene: Scene, rootUrl: string): void;
  111791. }
  111792. }
  111793. declare module BABYLON {
  111794. /**
  111795. * @hidden
  111796. */
  111797. export interface IMaterialSheenDefines {
  111798. SHEEN: boolean;
  111799. SHEEN_TEXTURE: boolean;
  111800. SHEEN_TEXTUREDIRECTUV: number;
  111801. SHEEN_LINKWITHALBEDO: boolean;
  111802. /** @hidden */
  111803. _areTexturesDirty: boolean;
  111804. }
  111805. /**
  111806. * Define the code related to the Sheen parameters of the pbr material.
  111807. */
  111808. export class PBRSheenConfiguration {
  111809. private _isEnabled;
  111810. /**
  111811. * Defines if the material uses sheen.
  111812. */
  111813. isEnabled: boolean;
  111814. private _linkSheenWithAlbedo;
  111815. /**
  111816. * Defines if the sheen is linked to the sheen color.
  111817. */
  111818. linkSheenWithAlbedo: boolean;
  111819. /**
  111820. * Defines the sheen intensity.
  111821. */
  111822. intensity: number;
  111823. /**
  111824. * Defines the sheen color.
  111825. */
  111826. color: Color3;
  111827. private _texture;
  111828. /**
  111829. * Stores the sheen tint values in a texture.
  111830. * rgb is tint
  111831. * a is a intensity
  111832. */
  111833. texture: Nullable<BaseTexture>;
  111834. /** @hidden */
  111835. private _internalMarkAllSubMeshesAsTexturesDirty;
  111836. /** @hidden */
  111837. _markAllSubMeshesAsTexturesDirty(): void;
  111838. /**
  111839. * Instantiate a new istance of clear coat configuration.
  111840. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111841. */
  111842. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111843. /**
  111844. * Specifies that the submesh is ready to be used.
  111845. * @param defines the list of "defines" to update.
  111846. * @param scene defines the scene the material belongs to.
  111847. * @returns - boolean indicating that the submesh is ready or not.
  111848. */
  111849. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  111850. /**
  111851. * Checks to see if a texture is used in the material.
  111852. * @param defines the list of "defines" to update.
  111853. * @param scene defines the scene the material belongs to.
  111854. */
  111855. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  111856. /**
  111857. * Binds the material data.
  111858. * @param uniformBuffer defines the Uniform buffer to fill in.
  111859. * @param scene defines the scene the material belongs to.
  111860. * @param isFrozen defines wether the material is frozen or not.
  111861. */
  111862. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111863. /**
  111864. * Checks to see if a texture is used in the material.
  111865. * @param texture - Base texture to use.
  111866. * @returns - Boolean specifying if a texture is used in the material.
  111867. */
  111868. hasTexture(texture: BaseTexture): boolean;
  111869. /**
  111870. * Returns an array of the actively used textures.
  111871. * @param activeTextures Array of BaseTextures
  111872. */
  111873. getActiveTextures(activeTextures: BaseTexture[]): void;
  111874. /**
  111875. * Returns the animatable textures.
  111876. * @param animatables Array of animatable textures.
  111877. */
  111878. getAnimatables(animatables: IAnimatable[]): void;
  111879. /**
  111880. * Disposes the resources of the material.
  111881. * @param forceDisposeTextures - Forces the disposal of all textures.
  111882. */
  111883. dispose(forceDisposeTextures?: boolean): void;
  111884. /**
  111885. * Get the current class name of the texture useful for serialization or dynamic coding.
  111886. * @returns "PBRSheenConfiguration"
  111887. */
  111888. getClassName(): string;
  111889. /**
  111890. * Add fallbacks to the effect fallbacks list.
  111891. * @param defines defines the Base texture to use.
  111892. * @param fallbacks defines the current fallback list.
  111893. * @param currentRank defines the current fallback rank.
  111894. * @returns the new fallback rank.
  111895. */
  111896. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111897. /**
  111898. * Add the required uniforms to the current list.
  111899. * @param uniforms defines the current uniform list.
  111900. */
  111901. static AddUniforms(uniforms: string[]): void;
  111902. /**
  111903. * Add the required uniforms to the current buffer.
  111904. * @param uniformBuffer defines the current uniform buffer.
  111905. */
  111906. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111907. /**
  111908. * Add the required samplers to the current list.
  111909. * @param samplers defines the current sampler list.
  111910. */
  111911. static AddSamplers(samplers: string[]): void;
  111912. /**
  111913. * Makes a duplicate of the current configuration into another one.
  111914. * @param sheenConfiguration define the config where to copy the info
  111915. */
  111916. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  111917. /**
  111918. * Serializes this BRDF configuration.
  111919. * @returns - An object with the serialized config.
  111920. */
  111921. serialize(): any;
  111922. /**
  111923. * Parses a anisotropy Configuration from a serialized object.
  111924. * @param source - Serialized object.
  111925. * @param scene Defines the scene we are parsing for
  111926. * @param rootUrl Defines the rootUrl to load from
  111927. */
  111928. parse(source: any, scene: Scene, rootUrl: string): void;
  111929. }
  111930. }
  111931. declare module BABYLON {
  111932. /**
  111933. * @hidden
  111934. */
  111935. export interface IMaterialSubSurfaceDefines {
  111936. SUBSURFACE: boolean;
  111937. SS_REFRACTION: boolean;
  111938. SS_TRANSLUCENCY: boolean;
  111939. SS_SCATERRING: boolean;
  111940. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111941. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111942. SS_REFRACTIONMAP_3D: boolean;
  111943. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111944. SS_LODINREFRACTIONALPHA: boolean;
  111945. SS_GAMMAREFRACTION: boolean;
  111946. SS_RGBDREFRACTION: boolean;
  111947. SS_LINEARSPECULARREFRACTION: boolean;
  111948. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111949. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111950. /** @hidden */
  111951. _areTexturesDirty: boolean;
  111952. }
  111953. /**
  111954. * Define the code related to the sub surface parameters of the pbr material.
  111955. */
  111956. export class PBRSubSurfaceConfiguration {
  111957. private _isRefractionEnabled;
  111958. /**
  111959. * Defines if the refraction is enabled in the material.
  111960. */
  111961. isRefractionEnabled: boolean;
  111962. private _isTranslucencyEnabled;
  111963. /**
  111964. * Defines if the translucency is enabled in the material.
  111965. */
  111966. isTranslucencyEnabled: boolean;
  111967. private _isScatteringEnabled;
  111968. /**
  111969. * Defines the refraction intensity of the material.
  111970. * The refraction when enabled replaces the Diffuse part of the material.
  111971. * The intensity helps transitionning between diffuse and refraction.
  111972. */
  111973. refractionIntensity: number;
  111974. /**
  111975. * Defines the translucency intensity of the material.
  111976. * When translucency has been enabled, this defines how much of the "translucency"
  111977. * is addded to the diffuse part of the material.
  111978. */
  111979. translucencyIntensity: number;
  111980. /**
  111981. * Defines the scattering intensity of the material.
  111982. * When scattering has been enabled, this defines how much of the "scattered light"
  111983. * is addded to the diffuse part of the material.
  111984. */
  111985. scatteringIntensity: number;
  111986. private _thicknessTexture;
  111987. /**
  111988. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  111989. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  111990. * 0 would mean minimumThickness
  111991. * 1 would mean maximumThickness
  111992. * The other channels might be use as a mask to vary the different effects intensity.
  111993. */
  111994. thicknessTexture: Nullable<BaseTexture>;
  111995. private _refractionTexture;
  111996. /**
  111997. * Defines the texture to use for refraction.
  111998. */
  111999. refractionTexture: Nullable<BaseTexture>;
  112000. private _indexOfRefraction;
  112001. /**
  112002. * Defines the index of refraction used in the material.
  112003. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112004. */
  112005. indexOfRefraction: number;
  112006. private _invertRefractionY;
  112007. /**
  112008. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112009. */
  112010. invertRefractionY: boolean;
  112011. private _linkRefractionWithTransparency;
  112012. /**
  112013. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112014. * Materials half opaque for instance using refraction could benefit from this control.
  112015. */
  112016. linkRefractionWithTransparency: boolean;
  112017. /**
  112018. * Defines the minimum thickness stored in the thickness map.
  112019. * If no thickness map is defined, this value will be used to simulate thickness.
  112020. */
  112021. minimumThickness: number;
  112022. /**
  112023. * Defines the maximum thickness stored in the thickness map.
  112024. */
  112025. maximumThickness: number;
  112026. /**
  112027. * Defines the volume tint of the material.
  112028. * This is used for both translucency and scattering.
  112029. */
  112030. tintColor: Color3;
  112031. /**
  112032. * Defines the distance at which the tint color should be found in the media.
  112033. * This is used for refraction only.
  112034. */
  112035. tintColorAtDistance: number;
  112036. /**
  112037. * Defines how far each channel transmit through the media.
  112038. * It is defined as a color to simplify it selection.
  112039. */
  112040. diffusionDistance: Color3;
  112041. private _useMaskFromThicknessTexture;
  112042. /**
  112043. * Stores the intensity of the different subsurface effects in the thickness texture.
  112044. * * the green channel is the translucency intensity.
  112045. * * the blue channel is the scattering intensity.
  112046. * * the alpha channel is the refraction intensity.
  112047. */
  112048. useMaskFromThicknessTexture: boolean;
  112049. /** @hidden */
  112050. private _internalMarkAllSubMeshesAsTexturesDirty;
  112051. /** @hidden */
  112052. _markAllSubMeshesAsTexturesDirty(): void;
  112053. /**
  112054. * Instantiate a new istance of sub surface configuration.
  112055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112056. */
  112057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112058. /**
  112059. * Gets wehter the submesh is ready to be used or not.
  112060. * @param defines the list of "defines" to update.
  112061. * @param scene defines the scene the material belongs to.
  112062. * @returns - boolean indicating that the submesh is ready or not.
  112063. */
  112064. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112065. /**
  112066. * Checks to see if a texture is used in the material.
  112067. * @param defines the list of "defines" to update.
  112068. * @param scene defines the scene to the material belongs to.
  112069. */
  112070. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112071. /**
  112072. * Binds the material data.
  112073. * @param uniformBuffer defines the Uniform buffer to fill in.
  112074. * @param scene defines the scene the material belongs to.
  112075. * @param engine defines the engine the material belongs to.
  112076. * @param isFrozen defines wether the material is frozen or not.
  112077. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112078. */
  112079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112080. /**
  112081. * Unbinds the material from the mesh.
  112082. * @param activeEffect defines the effect that should be unbound from.
  112083. * @returns true if unbound, otherwise false
  112084. */
  112085. unbind(activeEffect: Effect): boolean;
  112086. /**
  112087. * Returns the texture used for refraction or null if none is used.
  112088. * @param scene defines the scene the material belongs to.
  112089. * @returns - Refraction texture if present. If no refraction texture and refraction
  112090. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112091. */
  112092. private _getRefractionTexture;
  112093. /**
  112094. * Returns true if alpha blending should be disabled.
  112095. */
  112096. readonly disableAlphaBlending: boolean;
  112097. /**
  112098. * Fills the list of render target textures.
  112099. * @param renderTargets the list of render targets to update
  112100. */
  112101. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112102. /**
  112103. * Checks to see if a texture is used in the material.
  112104. * @param texture - Base texture to use.
  112105. * @returns - Boolean specifying if a texture is used in the material.
  112106. */
  112107. hasTexture(texture: BaseTexture): boolean;
  112108. /**
  112109. * Gets a boolean indicating that current material needs to register RTT
  112110. * @returns true if this uses a render target otherwise false.
  112111. */
  112112. hasRenderTargetTextures(): boolean;
  112113. /**
  112114. * Returns an array of the actively used textures.
  112115. * @param activeTextures Array of BaseTextures
  112116. */
  112117. getActiveTextures(activeTextures: BaseTexture[]): void;
  112118. /**
  112119. * Returns the animatable textures.
  112120. * @param animatables Array of animatable textures.
  112121. */
  112122. getAnimatables(animatables: IAnimatable[]): void;
  112123. /**
  112124. * Disposes the resources of the material.
  112125. * @param forceDisposeTextures - Forces the disposal of all textures.
  112126. */
  112127. dispose(forceDisposeTextures?: boolean): void;
  112128. /**
  112129. * Get the current class name of the texture useful for serialization or dynamic coding.
  112130. * @returns "PBRSubSurfaceConfiguration"
  112131. */
  112132. getClassName(): string;
  112133. /**
  112134. * Add fallbacks to the effect fallbacks list.
  112135. * @param defines defines the Base texture to use.
  112136. * @param fallbacks defines the current fallback list.
  112137. * @param currentRank defines the current fallback rank.
  112138. * @returns the new fallback rank.
  112139. */
  112140. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112141. /**
  112142. * Add the required uniforms to the current list.
  112143. * @param uniforms defines the current uniform list.
  112144. */
  112145. static AddUniforms(uniforms: string[]): void;
  112146. /**
  112147. * Add the required samplers to the current list.
  112148. * @param samplers defines the current sampler list.
  112149. */
  112150. static AddSamplers(samplers: string[]): void;
  112151. /**
  112152. * Add the required uniforms to the current buffer.
  112153. * @param uniformBuffer defines the current uniform buffer.
  112154. */
  112155. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112156. /**
  112157. * Makes a duplicate of the current configuration into another one.
  112158. * @param configuration define the config where to copy the info
  112159. */
  112160. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112161. /**
  112162. * Serializes this Sub Surface configuration.
  112163. * @returns - An object with the serialized config.
  112164. */
  112165. serialize(): any;
  112166. /**
  112167. * Parses a anisotropy Configuration from a serialized object.
  112168. * @param source - Serialized object.
  112169. * @param scene Defines the scene we are parsing for
  112170. * @param rootUrl Defines the rootUrl to load from
  112171. */
  112172. parse(source: any, scene: Scene, rootUrl: string): void;
  112173. }
  112174. }
  112175. declare module BABYLON {
  112176. /** @hidden */
  112177. export var pbrFragmentDeclaration: {
  112178. name: string;
  112179. shader: string;
  112180. };
  112181. }
  112182. declare module BABYLON {
  112183. /** @hidden */
  112184. export var pbrUboDeclaration: {
  112185. name: string;
  112186. shader: string;
  112187. };
  112188. }
  112189. declare module BABYLON {
  112190. /** @hidden */
  112191. export var pbrFragmentExtraDeclaration: {
  112192. name: string;
  112193. shader: string;
  112194. };
  112195. }
  112196. declare module BABYLON {
  112197. /** @hidden */
  112198. export var pbrFragmentSamplersDeclaration: {
  112199. name: string;
  112200. shader: string;
  112201. };
  112202. }
  112203. declare module BABYLON {
  112204. /** @hidden */
  112205. export var pbrHelperFunctions: {
  112206. name: string;
  112207. shader: string;
  112208. };
  112209. }
  112210. declare module BABYLON {
  112211. /** @hidden */
  112212. export var harmonicsFunctions: {
  112213. name: string;
  112214. shader: string;
  112215. };
  112216. }
  112217. declare module BABYLON {
  112218. /** @hidden */
  112219. export var pbrDirectLightingSetupFunctions: {
  112220. name: string;
  112221. shader: string;
  112222. };
  112223. }
  112224. declare module BABYLON {
  112225. /** @hidden */
  112226. export var pbrDirectLightingFalloffFunctions: {
  112227. name: string;
  112228. shader: string;
  112229. };
  112230. }
  112231. declare module BABYLON {
  112232. /** @hidden */
  112233. export var pbrBRDFFunctions: {
  112234. name: string;
  112235. shader: string;
  112236. };
  112237. }
  112238. declare module BABYLON {
  112239. /** @hidden */
  112240. export var pbrDirectLightingFunctions: {
  112241. name: string;
  112242. shader: string;
  112243. };
  112244. }
  112245. declare module BABYLON {
  112246. /** @hidden */
  112247. export var pbrIBLFunctions: {
  112248. name: string;
  112249. shader: string;
  112250. };
  112251. }
  112252. declare module BABYLON {
  112253. /** @hidden */
  112254. export var pbrDebug: {
  112255. name: string;
  112256. shader: string;
  112257. };
  112258. }
  112259. declare module BABYLON {
  112260. /** @hidden */
  112261. export var pbrPixelShader: {
  112262. name: string;
  112263. shader: string;
  112264. };
  112265. }
  112266. declare module BABYLON {
  112267. /** @hidden */
  112268. export var pbrVertexDeclaration: {
  112269. name: string;
  112270. shader: string;
  112271. };
  112272. }
  112273. declare module BABYLON {
  112274. /** @hidden */
  112275. export var pbrVertexShader: {
  112276. name: string;
  112277. shader: string;
  112278. };
  112279. }
  112280. declare module BABYLON {
  112281. /**
  112282. * Manages the defines for the PBR Material.
  112283. * @hidden
  112284. */
  112285. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112286. PBR: boolean;
  112287. MAINUV1: boolean;
  112288. MAINUV2: boolean;
  112289. UV1: boolean;
  112290. UV2: boolean;
  112291. ALBEDO: boolean;
  112292. ALBEDODIRECTUV: number;
  112293. VERTEXCOLOR: boolean;
  112294. AMBIENT: boolean;
  112295. AMBIENTDIRECTUV: number;
  112296. AMBIENTINGRAYSCALE: boolean;
  112297. OPACITY: boolean;
  112298. VERTEXALPHA: boolean;
  112299. OPACITYDIRECTUV: number;
  112300. OPACITYRGB: boolean;
  112301. ALPHATEST: boolean;
  112302. DEPTHPREPASS: boolean;
  112303. ALPHABLEND: boolean;
  112304. ALPHAFROMALBEDO: boolean;
  112305. ALPHATESTVALUE: string;
  112306. SPECULAROVERALPHA: boolean;
  112307. RADIANCEOVERALPHA: boolean;
  112308. ALPHAFRESNEL: boolean;
  112309. LINEARALPHAFRESNEL: boolean;
  112310. PREMULTIPLYALPHA: boolean;
  112311. EMISSIVE: boolean;
  112312. EMISSIVEDIRECTUV: number;
  112313. REFLECTIVITY: boolean;
  112314. REFLECTIVITYDIRECTUV: number;
  112315. SPECULARTERM: boolean;
  112316. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112317. MICROSURFACEAUTOMATIC: boolean;
  112318. LODBASEDMICROSFURACE: boolean;
  112319. MICROSURFACEMAP: boolean;
  112320. MICROSURFACEMAPDIRECTUV: number;
  112321. METALLICWORKFLOW: boolean;
  112322. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112323. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112324. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112325. AOSTOREINMETALMAPRED: boolean;
  112326. ENVIRONMENTBRDF: boolean;
  112327. ENVIRONMENTBRDF_RGBD: boolean;
  112328. NORMAL: boolean;
  112329. TANGENT: boolean;
  112330. BUMP: boolean;
  112331. BUMPDIRECTUV: number;
  112332. OBJECTSPACE_NORMALMAP: boolean;
  112333. PARALLAX: boolean;
  112334. PARALLAXOCCLUSION: boolean;
  112335. NORMALXYSCALE: boolean;
  112336. LIGHTMAP: boolean;
  112337. LIGHTMAPDIRECTUV: number;
  112338. USELIGHTMAPASSHADOWMAP: boolean;
  112339. GAMMALIGHTMAP: boolean;
  112340. REFLECTION: boolean;
  112341. REFLECTIONMAP_3D: boolean;
  112342. REFLECTIONMAP_SPHERICAL: boolean;
  112343. REFLECTIONMAP_PLANAR: boolean;
  112344. REFLECTIONMAP_CUBIC: boolean;
  112345. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112346. REFLECTIONMAP_PROJECTION: boolean;
  112347. REFLECTIONMAP_SKYBOX: boolean;
  112348. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112349. REFLECTIONMAP_EXPLICIT: boolean;
  112350. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112351. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112352. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112353. INVERTCUBICMAP: boolean;
  112354. USESPHERICALFROMREFLECTIONMAP: boolean;
  112355. USEIRRADIANCEMAP: boolean;
  112356. SPHERICAL_HARMONICS: boolean;
  112357. USESPHERICALINVERTEX: boolean;
  112358. REFLECTIONMAP_OPPOSITEZ: boolean;
  112359. LODINREFLECTIONALPHA: boolean;
  112360. GAMMAREFLECTION: boolean;
  112361. RGBDREFLECTION: boolean;
  112362. LINEARSPECULARREFLECTION: boolean;
  112363. RADIANCEOCCLUSION: boolean;
  112364. HORIZONOCCLUSION: boolean;
  112365. INSTANCES: boolean;
  112366. NUM_BONE_INFLUENCERS: number;
  112367. BonesPerMesh: number;
  112368. BONETEXTURE: boolean;
  112369. NONUNIFORMSCALING: boolean;
  112370. MORPHTARGETS: boolean;
  112371. MORPHTARGETS_NORMAL: boolean;
  112372. MORPHTARGETS_TANGENT: boolean;
  112373. MORPHTARGETS_UV: boolean;
  112374. NUM_MORPH_INFLUENCERS: number;
  112375. IMAGEPROCESSING: boolean;
  112376. VIGNETTE: boolean;
  112377. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112378. VIGNETTEBLENDMODEOPAQUE: boolean;
  112379. TONEMAPPING: boolean;
  112380. TONEMAPPING_ACES: boolean;
  112381. CONTRAST: boolean;
  112382. COLORCURVES: boolean;
  112383. COLORGRADING: boolean;
  112384. COLORGRADING3D: boolean;
  112385. SAMPLER3DGREENDEPTH: boolean;
  112386. SAMPLER3DBGRMAP: boolean;
  112387. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112388. EXPOSURE: boolean;
  112389. MULTIVIEW: boolean;
  112390. USEPHYSICALLIGHTFALLOFF: boolean;
  112391. USEGLTFLIGHTFALLOFF: boolean;
  112392. TWOSIDEDLIGHTING: boolean;
  112393. SHADOWFLOAT: boolean;
  112394. CLIPPLANE: boolean;
  112395. CLIPPLANE2: boolean;
  112396. CLIPPLANE3: boolean;
  112397. CLIPPLANE4: boolean;
  112398. POINTSIZE: boolean;
  112399. FOG: boolean;
  112400. LOGARITHMICDEPTH: boolean;
  112401. FORCENORMALFORWARD: boolean;
  112402. SPECULARAA: boolean;
  112403. CLEARCOAT: boolean;
  112404. CLEARCOAT_DEFAULTIOR: boolean;
  112405. CLEARCOAT_TEXTURE: boolean;
  112406. CLEARCOAT_TEXTUREDIRECTUV: number;
  112407. CLEARCOAT_BUMP: boolean;
  112408. CLEARCOAT_BUMPDIRECTUV: number;
  112409. CLEARCOAT_TINT: boolean;
  112410. CLEARCOAT_TINT_TEXTURE: boolean;
  112411. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112412. ANISOTROPIC: boolean;
  112413. ANISOTROPIC_TEXTURE: boolean;
  112414. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112415. BRDF_V_HEIGHT_CORRELATED: boolean;
  112416. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112417. SHEEN: boolean;
  112418. SHEEN_TEXTURE: boolean;
  112419. SHEEN_TEXTUREDIRECTUV: number;
  112420. SHEEN_LINKWITHALBEDO: boolean;
  112421. SUBSURFACE: boolean;
  112422. SS_REFRACTION: boolean;
  112423. SS_TRANSLUCENCY: boolean;
  112424. SS_SCATERRING: boolean;
  112425. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112426. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112427. SS_REFRACTIONMAP_3D: boolean;
  112428. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112429. SS_LODINREFRACTIONALPHA: boolean;
  112430. SS_GAMMAREFRACTION: boolean;
  112431. SS_RGBDREFRACTION: boolean;
  112432. SS_LINEARSPECULARREFRACTION: boolean;
  112433. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112434. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112435. UNLIT: boolean;
  112436. DEBUGMODE: number;
  112437. /**
  112438. * Initializes the PBR Material defines.
  112439. */
  112440. constructor();
  112441. /**
  112442. * Resets the PBR Material defines.
  112443. */
  112444. reset(): void;
  112445. }
  112446. /**
  112447. * The Physically based material base class of BJS.
  112448. *
  112449. * This offers the main features of a standard PBR material.
  112450. * For more information, please refer to the documentation :
  112451. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112452. */
  112453. export abstract class PBRBaseMaterial extends PushMaterial {
  112454. /**
  112455. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112456. */
  112457. static readonly PBRMATERIAL_OPAQUE: number;
  112458. /**
  112459. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112460. */
  112461. static readonly PBRMATERIAL_ALPHATEST: number;
  112462. /**
  112463. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112464. */
  112465. static readonly PBRMATERIAL_ALPHABLEND: number;
  112466. /**
  112467. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112468. * They are also discarded below the alpha cutoff threshold to improve performances.
  112469. */
  112470. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112471. /**
  112472. * Defines the default value of how much AO map is occluding the analytical lights
  112473. * (point spot...).
  112474. */
  112475. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112476. /**
  112477. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112478. */
  112479. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112480. /**
  112481. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112482. * to enhance interoperability with other engines.
  112483. */
  112484. static readonly LIGHTFALLOFF_GLTF: number;
  112485. /**
  112486. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112487. * to enhance interoperability with other materials.
  112488. */
  112489. static readonly LIGHTFALLOFF_STANDARD: number;
  112490. /**
  112491. * Intensity of the direct lights e.g. the four lights available in your scene.
  112492. * This impacts both the direct diffuse and specular highlights.
  112493. */
  112494. protected _directIntensity: number;
  112495. /**
  112496. * Intensity of the emissive part of the material.
  112497. * This helps controlling the emissive effect without modifying the emissive color.
  112498. */
  112499. protected _emissiveIntensity: number;
  112500. /**
  112501. * Intensity of the environment e.g. how much the environment will light the object
  112502. * either through harmonics for rough material or through the refelction for shiny ones.
  112503. */
  112504. protected _environmentIntensity: number;
  112505. /**
  112506. * This is a special control allowing the reduction of the specular highlights coming from the
  112507. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112508. */
  112509. protected _specularIntensity: number;
  112510. /**
  112511. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112512. */
  112513. private _lightingInfos;
  112514. /**
  112515. * Debug Control allowing disabling the bump map on this material.
  112516. */
  112517. protected _disableBumpMap: boolean;
  112518. /**
  112519. * AKA Diffuse Texture in standard nomenclature.
  112520. */
  112521. protected _albedoTexture: Nullable<BaseTexture>;
  112522. /**
  112523. * AKA Occlusion Texture in other nomenclature.
  112524. */
  112525. protected _ambientTexture: Nullable<BaseTexture>;
  112526. /**
  112527. * AKA Occlusion Texture Intensity in other nomenclature.
  112528. */
  112529. protected _ambientTextureStrength: number;
  112530. /**
  112531. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112532. * 1 means it completely occludes it
  112533. * 0 mean it has no impact
  112534. */
  112535. protected _ambientTextureImpactOnAnalyticalLights: number;
  112536. /**
  112537. * Stores the alpha values in a texture.
  112538. */
  112539. protected _opacityTexture: Nullable<BaseTexture>;
  112540. /**
  112541. * Stores the reflection values in a texture.
  112542. */
  112543. protected _reflectionTexture: Nullable<BaseTexture>;
  112544. /**
  112545. * Stores the emissive values in a texture.
  112546. */
  112547. protected _emissiveTexture: Nullable<BaseTexture>;
  112548. /**
  112549. * AKA Specular texture in other nomenclature.
  112550. */
  112551. protected _reflectivityTexture: Nullable<BaseTexture>;
  112552. /**
  112553. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112554. */
  112555. protected _metallicTexture: Nullable<BaseTexture>;
  112556. /**
  112557. * Specifies the metallic scalar of the metallic/roughness workflow.
  112558. * Can also be used to scale the metalness values of the metallic texture.
  112559. */
  112560. protected _metallic: Nullable<number>;
  112561. /**
  112562. * Specifies the roughness scalar of the metallic/roughness workflow.
  112563. * Can also be used to scale the roughness values of the metallic texture.
  112564. */
  112565. protected _roughness: Nullable<number>;
  112566. /**
  112567. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112568. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112569. */
  112570. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112571. /**
  112572. * Stores surface normal data used to displace a mesh in a texture.
  112573. */
  112574. protected _bumpTexture: Nullable<BaseTexture>;
  112575. /**
  112576. * Stores the pre-calculated light information of a mesh in a texture.
  112577. */
  112578. protected _lightmapTexture: Nullable<BaseTexture>;
  112579. /**
  112580. * The color of a material in ambient lighting.
  112581. */
  112582. protected _ambientColor: Color3;
  112583. /**
  112584. * AKA Diffuse Color in other nomenclature.
  112585. */
  112586. protected _albedoColor: Color3;
  112587. /**
  112588. * AKA Specular Color in other nomenclature.
  112589. */
  112590. protected _reflectivityColor: Color3;
  112591. /**
  112592. * The color applied when light is reflected from a material.
  112593. */
  112594. protected _reflectionColor: Color3;
  112595. /**
  112596. * The color applied when light is emitted from a material.
  112597. */
  112598. protected _emissiveColor: Color3;
  112599. /**
  112600. * AKA Glossiness in other nomenclature.
  112601. */
  112602. protected _microSurface: number;
  112603. /**
  112604. * Specifies that the material will use the light map as a show map.
  112605. */
  112606. protected _useLightmapAsShadowmap: boolean;
  112607. /**
  112608. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112609. * makes the reflect vector face the model (under horizon).
  112610. */
  112611. protected _useHorizonOcclusion: boolean;
  112612. /**
  112613. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112614. * too much the area relying on ambient texture to define their ambient occlusion.
  112615. */
  112616. protected _useRadianceOcclusion: boolean;
  112617. /**
  112618. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112619. */
  112620. protected _useAlphaFromAlbedoTexture: boolean;
  112621. /**
  112622. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112623. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112624. */
  112625. protected _useSpecularOverAlpha: boolean;
  112626. /**
  112627. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112628. */
  112629. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112630. /**
  112631. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112632. */
  112633. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112634. /**
  112635. * Specifies if the metallic texture contains the roughness information in its green channel.
  112636. */
  112637. protected _useRoughnessFromMetallicTextureGreen: boolean;
  112638. /**
  112639. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112640. */
  112641. protected _useMetallnessFromMetallicTextureBlue: boolean;
  112642. /**
  112643. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112644. */
  112645. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  112646. /**
  112647. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112648. */
  112649. protected _useAmbientInGrayScale: boolean;
  112650. /**
  112651. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112652. * The material will try to infer what glossiness each pixel should be.
  112653. */
  112654. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  112655. /**
  112656. * Defines the falloff type used in this material.
  112657. * It by default is Physical.
  112658. */
  112659. protected _lightFalloff: number;
  112660. /**
  112661. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112662. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112663. */
  112664. protected _useRadianceOverAlpha: boolean;
  112665. /**
  112666. * Allows using an object space normal map (instead of tangent space).
  112667. */
  112668. protected _useObjectSpaceNormalMap: boolean;
  112669. /**
  112670. * Allows using the bump map in parallax mode.
  112671. */
  112672. protected _useParallax: boolean;
  112673. /**
  112674. * Allows using the bump map in parallax occlusion mode.
  112675. */
  112676. protected _useParallaxOcclusion: boolean;
  112677. /**
  112678. * Controls the scale bias of the parallax mode.
  112679. */
  112680. protected _parallaxScaleBias: number;
  112681. /**
  112682. * If sets to true, disables all the lights affecting the material.
  112683. */
  112684. protected _disableLighting: boolean;
  112685. /**
  112686. * Number of Simultaneous lights allowed on the material.
  112687. */
  112688. protected _maxSimultaneousLights: number;
  112689. /**
  112690. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112691. */
  112692. protected _invertNormalMapX: boolean;
  112693. /**
  112694. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112695. */
  112696. protected _invertNormalMapY: boolean;
  112697. /**
  112698. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112699. */
  112700. protected _twoSidedLighting: boolean;
  112701. /**
  112702. * Defines the alpha limits in alpha test mode.
  112703. */
  112704. protected _alphaCutOff: number;
  112705. /**
  112706. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112707. */
  112708. protected _forceAlphaTest: boolean;
  112709. /**
  112710. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112711. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112712. */
  112713. protected _useAlphaFresnel: boolean;
  112714. /**
  112715. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112716. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112717. */
  112718. protected _useLinearAlphaFresnel: boolean;
  112719. /**
  112720. * The transparency mode of the material.
  112721. */
  112722. protected _transparencyMode: Nullable<number>;
  112723. /**
  112724. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  112725. * from cos thetav and roughness:
  112726. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  112727. */
  112728. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  112729. /**
  112730. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112731. */
  112732. protected _forceIrradianceInFragment: boolean;
  112733. /**
  112734. * Force normal to face away from face.
  112735. */
  112736. protected _forceNormalForward: boolean;
  112737. /**
  112738. * Enables specular anti aliasing in the PBR shader.
  112739. * It will both interacts on the Geometry for analytical and IBL lighting.
  112740. * It also prefilter the roughness map based on the bump values.
  112741. */
  112742. protected _enableSpecularAntiAliasing: boolean;
  112743. /**
  112744. * Default configuration related to image processing available in the PBR Material.
  112745. */
  112746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112747. /**
  112748. * Keep track of the image processing observer to allow dispose and replace.
  112749. */
  112750. private _imageProcessingObserver;
  112751. /**
  112752. * Attaches a new image processing configuration to the PBR Material.
  112753. * @param configuration
  112754. */
  112755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112756. /**
  112757. * Stores the available render targets.
  112758. */
  112759. private _renderTargets;
  112760. /**
  112761. * Sets the global ambient color for the material used in lighting calculations.
  112762. */
  112763. private _globalAmbientColor;
  112764. /**
  112765. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  112766. */
  112767. private _useLogarithmicDepth;
  112768. /**
  112769. * If set to true, no lighting calculations will be applied.
  112770. */
  112771. private _unlit;
  112772. private _debugMode;
  112773. /**
  112774. * @hidden
  112775. * This is reserved for the inspector.
  112776. * Defines the material debug mode.
  112777. * It helps seeing only some components of the material while troubleshooting.
  112778. */
  112779. debugMode: number;
  112780. /**
  112781. * @hidden
  112782. * This is reserved for the inspector.
  112783. * Specify from where on screen the debug mode should start.
  112784. * The value goes from -1 (full screen) to 1 (not visible)
  112785. * It helps with side by side comparison against the final render
  112786. * This defaults to -1
  112787. */
  112788. private debugLimit;
  112789. /**
  112790. * @hidden
  112791. * This is reserved for the inspector.
  112792. * As the default viewing range might not be enough (if the ambient is really small for instance)
  112793. * You can use the factor to better multiply the final value.
  112794. */
  112795. private debugFactor;
  112796. /**
  112797. * Defines the clear coat layer parameters for the material.
  112798. */
  112799. readonly clearCoat: PBRClearCoatConfiguration;
  112800. /**
  112801. * Defines the anisotropic parameters for the material.
  112802. */
  112803. readonly anisotropy: PBRAnisotropicConfiguration;
  112804. /**
  112805. * Defines the BRDF parameters for the material.
  112806. */
  112807. readonly brdf: PBRBRDFConfiguration;
  112808. /**
  112809. * Defines the Sheen parameters for the material.
  112810. */
  112811. readonly sheen: PBRSheenConfiguration;
  112812. /**
  112813. * Defines the SubSurface parameters for the material.
  112814. */
  112815. readonly subSurface: PBRSubSurfaceConfiguration;
  112816. /**
  112817. * Custom callback helping to override the default shader used in the material.
  112818. */
  112819. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  112820. protected _rebuildInParallel: boolean;
  112821. /**
  112822. * Instantiates a new PBRMaterial instance.
  112823. *
  112824. * @param name The material name
  112825. * @param scene The scene the material will be use in.
  112826. */
  112827. constructor(name: string, scene: Scene);
  112828. /**
  112829. * Gets a boolean indicating that current material needs to register RTT
  112830. */
  112831. readonly hasRenderTargetTextures: boolean;
  112832. /**
  112833. * Gets the name of the material class.
  112834. */
  112835. getClassName(): string;
  112836. /**
  112837. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112838. */
  112839. /**
  112840. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112841. */
  112842. useLogarithmicDepth: boolean;
  112843. /**
  112844. * Gets the current transparency mode.
  112845. */
  112846. /**
  112847. * Sets the transparency mode of the material.
  112848. *
  112849. * | Value | Type | Description |
  112850. * | ----- | ----------------------------------- | ----------- |
  112851. * | 0 | OPAQUE | |
  112852. * | 1 | ALPHATEST | |
  112853. * | 2 | ALPHABLEND | |
  112854. * | 3 | ALPHATESTANDBLEND | |
  112855. *
  112856. */
  112857. transparencyMode: Nullable<number>;
  112858. /**
  112859. * Returns true if alpha blending should be disabled.
  112860. */
  112861. private readonly _disableAlphaBlending;
  112862. /**
  112863. * Specifies whether or not this material should be rendered in alpha blend mode.
  112864. */
  112865. needAlphaBlending(): boolean;
  112866. /**
  112867. * Specifies if the mesh will require alpha blending.
  112868. * @param mesh - BJS mesh.
  112869. */
  112870. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  112871. /**
  112872. * Specifies whether or not this material should be rendered in alpha test mode.
  112873. */
  112874. needAlphaTesting(): boolean;
  112875. /**
  112876. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  112877. */
  112878. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  112879. /**
  112880. * Gets the texture used for the alpha test.
  112881. */
  112882. getAlphaTestTexture(): Nullable<BaseTexture>;
  112883. /**
  112884. * Specifies that the submesh is ready to be used.
  112885. * @param mesh - BJS mesh.
  112886. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  112887. * @param useInstances - Specifies that instances should be used.
  112888. * @returns - boolean indicating that the submesh is ready or not.
  112889. */
  112890. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112891. /**
  112892. * Specifies if the material uses metallic roughness workflow.
  112893. * @returns boolean specifiying if the material uses metallic roughness workflow.
  112894. */
  112895. isMetallicWorkflow(): boolean;
  112896. private _prepareEffect;
  112897. private _prepareDefines;
  112898. /**
  112899. * Force shader compilation
  112900. */
  112901. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  112902. clipPlane: boolean;
  112903. }>): void;
  112904. /**
  112905. * Initializes the uniform buffer layout for the shader.
  112906. */
  112907. buildUniformLayout(): void;
  112908. /**
  112909. * Unbinds the material from the mesh
  112910. */
  112911. unbind(): void;
  112912. /**
  112913. * Binds the submesh data.
  112914. * @param world - The world matrix.
  112915. * @param mesh - The BJS mesh.
  112916. * @param subMesh - A submesh of the BJS mesh.
  112917. */
  112918. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112919. /**
  112920. * Returns the animatable textures.
  112921. * @returns - Array of animatable textures.
  112922. */
  112923. getAnimatables(): IAnimatable[];
  112924. /**
  112925. * Returns the texture used for reflections.
  112926. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  112927. */
  112928. private _getReflectionTexture;
  112929. /**
  112930. * Returns an array of the actively used textures.
  112931. * @returns - Array of BaseTextures
  112932. */
  112933. getActiveTextures(): BaseTexture[];
  112934. /**
  112935. * Checks to see if a texture is used in the material.
  112936. * @param texture - Base texture to use.
  112937. * @returns - Boolean specifying if a texture is used in the material.
  112938. */
  112939. hasTexture(texture: BaseTexture): boolean;
  112940. /**
  112941. * Disposes the resources of the material.
  112942. * @param forceDisposeEffect - Forces the disposal of effects.
  112943. * @param forceDisposeTextures - Forces the disposal of all textures.
  112944. */
  112945. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112946. }
  112947. }
  112948. declare module BABYLON {
  112949. /**
  112950. * The Physically based material of BJS.
  112951. *
  112952. * This offers the main features of a standard PBR material.
  112953. * For more information, please refer to the documentation :
  112954. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112955. */
  112956. export class PBRMaterial extends PBRBaseMaterial {
  112957. /**
  112958. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112959. */
  112960. static readonly PBRMATERIAL_OPAQUE: number;
  112961. /**
  112962. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112963. */
  112964. static readonly PBRMATERIAL_ALPHATEST: number;
  112965. /**
  112966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112967. */
  112968. static readonly PBRMATERIAL_ALPHABLEND: number;
  112969. /**
  112970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112971. * They are also discarded below the alpha cutoff threshold to improve performances.
  112972. */
  112973. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112974. /**
  112975. * Defines the default value of how much AO map is occluding the analytical lights
  112976. * (point spot...).
  112977. */
  112978. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112979. /**
  112980. * Intensity of the direct lights e.g. the four lights available in your scene.
  112981. * This impacts both the direct diffuse and specular highlights.
  112982. */
  112983. directIntensity: number;
  112984. /**
  112985. * Intensity of the emissive part of the material.
  112986. * This helps controlling the emissive effect without modifying the emissive color.
  112987. */
  112988. emissiveIntensity: number;
  112989. /**
  112990. * Intensity of the environment e.g. how much the environment will light the object
  112991. * either through harmonics for rough material or through the refelction for shiny ones.
  112992. */
  112993. environmentIntensity: number;
  112994. /**
  112995. * This is a special control allowing the reduction of the specular highlights coming from the
  112996. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112997. */
  112998. specularIntensity: number;
  112999. /**
  113000. * Debug Control allowing disabling the bump map on this material.
  113001. */
  113002. disableBumpMap: boolean;
  113003. /**
  113004. * AKA Diffuse Texture in standard nomenclature.
  113005. */
  113006. albedoTexture: BaseTexture;
  113007. /**
  113008. * AKA Occlusion Texture in other nomenclature.
  113009. */
  113010. ambientTexture: BaseTexture;
  113011. /**
  113012. * AKA Occlusion Texture Intensity in other nomenclature.
  113013. */
  113014. ambientTextureStrength: number;
  113015. /**
  113016. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113017. * 1 means it completely occludes it
  113018. * 0 mean it has no impact
  113019. */
  113020. ambientTextureImpactOnAnalyticalLights: number;
  113021. /**
  113022. * Stores the alpha values in a texture.
  113023. */
  113024. opacityTexture: BaseTexture;
  113025. /**
  113026. * Stores the reflection values in a texture.
  113027. */
  113028. reflectionTexture: Nullable<BaseTexture>;
  113029. /**
  113030. * Stores the emissive values in a texture.
  113031. */
  113032. emissiveTexture: BaseTexture;
  113033. /**
  113034. * AKA Specular texture in other nomenclature.
  113035. */
  113036. reflectivityTexture: BaseTexture;
  113037. /**
  113038. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113039. */
  113040. metallicTexture: BaseTexture;
  113041. /**
  113042. * Specifies the metallic scalar of the metallic/roughness workflow.
  113043. * Can also be used to scale the metalness values of the metallic texture.
  113044. */
  113045. metallic: Nullable<number>;
  113046. /**
  113047. * Specifies the roughness scalar of the metallic/roughness workflow.
  113048. * Can also be used to scale the roughness values of the metallic texture.
  113049. */
  113050. roughness: Nullable<number>;
  113051. /**
  113052. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113054. */
  113055. microSurfaceTexture: BaseTexture;
  113056. /**
  113057. * Stores surface normal data used to displace a mesh in a texture.
  113058. */
  113059. bumpTexture: BaseTexture;
  113060. /**
  113061. * Stores the pre-calculated light information of a mesh in a texture.
  113062. */
  113063. lightmapTexture: BaseTexture;
  113064. /**
  113065. * Stores the refracted light information in a texture.
  113066. */
  113067. refractionTexture: Nullable<BaseTexture>;
  113068. /**
  113069. * The color of a material in ambient lighting.
  113070. */
  113071. ambientColor: Color3;
  113072. /**
  113073. * AKA Diffuse Color in other nomenclature.
  113074. */
  113075. albedoColor: Color3;
  113076. /**
  113077. * AKA Specular Color in other nomenclature.
  113078. */
  113079. reflectivityColor: Color3;
  113080. /**
  113081. * The color reflected from the material.
  113082. */
  113083. reflectionColor: Color3;
  113084. /**
  113085. * The color emitted from the material.
  113086. */
  113087. emissiveColor: Color3;
  113088. /**
  113089. * AKA Glossiness in other nomenclature.
  113090. */
  113091. microSurface: number;
  113092. /**
  113093. * source material index of refraction (IOR)' / 'destination material IOR.
  113094. */
  113095. indexOfRefraction: number;
  113096. /**
  113097. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113098. */
  113099. invertRefractionY: boolean;
  113100. /**
  113101. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113102. * Materials half opaque for instance using refraction could benefit from this control.
  113103. */
  113104. linkRefractionWithTransparency: boolean;
  113105. /**
  113106. * If true, the light map contains occlusion information instead of lighting info.
  113107. */
  113108. useLightmapAsShadowmap: boolean;
  113109. /**
  113110. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113111. */
  113112. useAlphaFromAlbedoTexture: boolean;
  113113. /**
  113114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113115. */
  113116. forceAlphaTest: boolean;
  113117. /**
  113118. * Defines the alpha limits in alpha test mode.
  113119. */
  113120. alphaCutOff: number;
  113121. /**
  113122. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113123. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113124. */
  113125. useSpecularOverAlpha: boolean;
  113126. /**
  113127. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113128. */
  113129. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113130. /**
  113131. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113132. */
  113133. useRoughnessFromMetallicTextureAlpha: boolean;
  113134. /**
  113135. * Specifies if the metallic texture contains the roughness information in its green channel.
  113136. */
  113137. useRoughnessFromMetallicTextureGreen: boolean;
  113138. /**
  113139. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113140. */
  113141. useMetallnessFromMetallicTextureBlue: boolean;
  113142. /**
  113143. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113144. */
  113145. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113146. /**
  113147. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113148. */
  113149. useAmbientInGrayScale: boolean;
  113150. /**
  113151. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113152. * The material will try to infer what glossiness each pixel should be.
  113153. */
  113154. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113155. /**
  113156. * BJS is using an harcoded light falloff based on a manually sets up range.
  113157. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113158. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113159. */
  113160. /**
  113161. * BJS is using an harcoded light falloff based on a manually sets up range.
  113162. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113163. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113164. */
  113165. usePhysicalLightFalloff: boolean;
  113166. /**
  113167. * In order to support the falloff compatibility with gltf, a special mode has been added
  113168. * to reproduce the gltf light falloff.
  113169. */
  113170. /**
  113171. * In order to support the falloff compatibility with gltf, a special mode has been added
  113172. * to reproduce the gltf light falloff.
  113173. */
  113174. useGLTFLightFalloff: boolean;
  113175. /**
  113176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113178. */
  113179. useRadianceOverAlpha: boolean;
  113180. /**
  113181. * Allows using an object space normal map (instead of tangent space).
  113182. */
  113183. useObjectSpaceNormalMap: boolean;
  113184. /**
  113185. * Allows using the bump map in parallax mode.
  113186. */
  113187. useParallax: boolean;
  113188. /**
  113189. * Allows using the bump map in parallax occlusion mode.
  113190. */
  113191. useParallaxOcclusion: boolean;
  113192. /**
  113193. * Controls the scale bias of the parallax mode.
  113194. */
  113195. parallaxScaleBias: number;
  113196. /**
  113197. * If sets to true, disables all the lights affecting the material.
  113198. */
  113199. disableLighting: boolean;
  113200. /**
  113201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113202. */
  113203. forceIrradianceInFragment: boolean;
  113204. /**
  113205. * Number of Simultaneous lights allowed on the material.
  113206. */
  113207. maxSimultaneousLights: number;
  113208. /**
  113209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113210. */
  113211. invertNormalMapX: boolean;
  113212. /**
  113213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113214. */
  113215. invertNormalMapY: boolean;
  113216. /**
  113217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113218. */
  113219. twoSidedLighting: boolean;
  113220. /**
  113221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113222. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113223. */
  113224. useAlphaFresnel: boolean;
  113225. /**
  113226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113227. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113228. */
  113229. useLinearAlphaFresnel: boolean;
  113230. /**
  113231. * Let user defines the brdf lookup texture used for IBL.
  113232. * A default 8bit version is embedded but you could point at :
  113233. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113234. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113235. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113236. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113237. */
  113238. environmentBRDFTexture: Nullable<BaseTexture>;
  113239. /**
  113240. * Force normal to face away from face.
  113241. */
  113242. forceNormalForward: boolean;
  113243. /**
  113244. * Enables specular anti aliasing in the PBR shader.
  113245. * It will both interacts on the Geometry for analytical and IBL lighting.
  113246. * It also prefilter the roughness map based on the bump values.
  113247. */
  113248. enableSpecularAntiAliasing: boolean;
  113249. /**
  113250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113251. * makes the reflect vector face the model (under horizon).
  113252. */
  113253. useHorizonOcclusion: boolean;
  113254. /**
  113255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113256. * too much the area relying on ambient texture to define their ambient occlusion.
  113257. */
  113258. useRadianceOcclusion: boolean;
  113259. /**
  113260. * If set to true, no lighting calculations will be applied.
  113261. */
  113262. unlit: boolean;
  113263. /**
  113264. * Gets the image processing configuration used either in this material.
  113265. */
  113266. /**
  113267. * Sets the Default image processing configuration used either in the this material.
  113268. *
  113269. * If sets to null, the scene one is in use.
  113270. */
  113271. imageProcessingConfiguration: ImageProcessingConfiguration;
  113272. /**
  113273. * Gets wether the color curves effect is enabled.
  113274. */
  113275. /**
  113276. * Sets wether the color curves effect is enabled.
  113277. */
  113278. cameraColorCurvesEnabled: boolean;
  113279. /**
  113280. * Gets wether the color grading effect is enabled.
  113281. */
  113282. /**
  113283. * Gets wether the color grading effect is enabled.
  113284. */
  113285. cameraColorGradingEnabled: boolean;
  113286. /**
  113287. * Gets wether tonemapping is enabled or not.
  113288. */
  113289. /**
  113290. * Sets wether tonemapping is enabled or not
  113291. */
  113292. cameraToneMappingEnabled: boolean;
  113293. /**
  113294. * The camera exposure used on this material.
  113295. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113296. * This corresponds to a photographic exposure.
  113297. */
  113298. /**
  113299. * The camera exposure used on this material.
  113300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113301. * This corresponds to a photographic exposure.
  113302. */
  113303. cameraExposure: number;
  113304. /**
  113305. * Gets The camera contrast used on this material.
  113306. */
  113307. /**
  113308. * Sets The camera contrast used on this material.
  113309. */
  113310. cameraContrast: number;
  113311. /**
  113312. * Gets the Color Grading 2D Lookup Texture.
  113313. */
  113314. /**
  113315. * Sets the Color Grading 2D Lookup Texture.
  113316. */
  113317. cameraColorGradingTexture: Nullable<BaseTexture>;
  113318. /**
  113319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113321. * 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;
  113322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113323. */
  113324. /**
  113325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113327. * 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;
  113328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113329. */
  113330. cameraColorCurves: Nullable<ColorCurves>;
  113331. /**
  113332. * Instantiates a new PBRMaterial instance.
  113333. *
  113334. * @param name The material name
  113335. * @param scene The scene the material will be use in.
  113336. */
  113337. constructor(name: string, scene: Scene);
  113338. /**
  113339. * Returns the name of this material class.
  113340. */
  113341. getClassName(): string;
  113342. /**
  113343. * Makes a duplicate of the current material.
  113344. * @param name - name to use for the new material.
  113345. */
  113346. clone(name: string): PBRMaterial;
  113347. /**
  113348. * Serializes this PBR Material.
  113349. * @returns - An object with the serialized material.
  113350. */
  113351. serialize(): any;
  113352. /**
  113353. * Parses a PBR Material from a serialized object.
  113354. * @param source - Serialized object.
  113355. * @param scene - BJS scene instance.
  113356. * @param rootUrl - url for the scene object
  113357. * @returns - PBRMaterial
  113358. */
  113359. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113360. }
  113361. }
  113362. declare module BABYLON {
  113363. /**
  113364. * Direct draw surface info
  113365. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113366. */
  113367. export interface DDSInfo {
  113368. /**
  113369. * Width of the texture
  113370. */
  113371. width: number;
  113372. /**
  113373. * Width of the texture
  113374. */
  113375. height: number;
  113376. /**
  113377. * Number of Mipmaps for the texture
  113378. * @see https://en.wikipedia.org/wiki/Mipmap
  113379. */
  113380. mipmapCount: number;
  113381. /**
  113382. * If the textures format is a known fourCC format
  113383. * @see https://www.fourcc.org/
  113384. */
  113385. isFourCC: boolean;
  113386. /**
  113387. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113388. */
  113389. isRGB: boolean;
  113390. /**
  113391. * If the texture is a lumincance format
  113392. */
  113393. isLuminance: boolean;
  113394. /**
  113395. * If this is a cube texture
  113396. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113397. */
  113398. isCube: boolean;
  113399. /**
  113400. * If the texture is a compressed format eg. FOURCC_DXT1
  113401. */
  113402. isCompressed: boolean;
  113403. /**
  113404. * The dxgiFormat of the texture
  113405. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113406. */
  113407. dxgiFormat: number;
  113408. /**
  113409. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113410. */
  113411. textureType: number;
  113412. /**
  113413. * Sphericle polynomial created for the dds texture
  113414. */
  113415. sphericalPolynomial?: SphericalPolynomial;
  113416. }
  113417. /**
  113418. * Class used to provide DDS decompression tools
  113419. */
  113420. export class DDSTools {
  113421. /**
  113422. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113423. */
  113424. static StoreLODInAlphaChannel: boolean;
  113425. /**
  113426. * Gets DDS information from an array buffer
  113427. * @param arrayBuffer defines the array buffer to read data from
  113428. * @returns the DDS information
  113429. */
  113430. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113431. private static _FloatView;
  113432. private static _Int32View;
  113433. private static _ToHalfFloat;
  113434. private static _FromHalfFloat;
  113435. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113436. private static _GetHalfFloatRGBAArrayBuffer;
  113437. private static _GetFloatRGBAArrayBuffer;
  113438. private static _GetFloatAsUIntRGBAArrayBuffer;
  113439. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113440. private static _GetRGBAArrayBuffer;
  113441. private static _ExtractLongWordOrder;
  113442. private static _GetRGBArrayBuffer;
  113443. private static _GetLuminanceArrayBuffer;
  113444. /**
  113445. * Uploads DDS Levels to a Babylon Texture
  113446. * @hidden
  113447. */
  113448. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113449. }
  113450. interface Engine {
  113451. /**
  113452. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113453. * @param rootUrl defines the url where the file to load is located
  113454. * @param scene defines the current scene
  113455. * @param lodScale defines scale to apply to the mip map selection
  113456. * @param lodOffset defines offset to apply to the mip map selection
  113457. * @param onLoad defines an optional callback raised when the texture is loaded
  113458. * @param onError defines an optional callback raised if there is an issue to load the texture
  113459. * @param format defines the format of the data
  113460. * @param forcedExtension defines the extension to use to pick the right loader
  113461. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113462. * @returns the cube texture as an InternalTexture
  113463. */
  113464. 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;
  113465. }
  113466. }
  113467. declare module BABYLON {
  113468. /**
  113469. * Implementation of the DDS Texture Loader.
  113470. * @hidden
  113471. */
  113472. export class _DDSTextureLoader implements IInternalTextureLoader {
  113473. /**
  113474. * Defines wether the loader supports cascade loading the different faces.
  113475. */
  113476. readonly supportCascades: boolean;
  113477. /**
  113478. * This returns if the loader support the current file information.
  113479. * @param extension defines the file extension of the file being loaded
  113480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113481. * @param fallback defines the fallback internal texture if any
  113482. * @param isBase64 defines whether the texture is encoded as a base64
  113483. * @param isBuffer defines whether the texture data are stored as a buffer
  113484. * @returns true if the loader can load the specified file
  113485. */
  113486. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113487. /**
  113488. * Transform the url before loading if required.
  113489. * @param rootUrl the url of the texture
  113490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113491. * @returns the transformed texture
  113492. */
  113493. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113494. /**
  113495. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113496. * @param rootUrl the url of the texture
  113497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113498. * @returns the fallback texture
  113499. */
  113500. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113501. /**
  113502. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113503. * @param data contains the texture data
  113504. * @param texture defines the BabylonJS internal texture
  113505. * @param createPolynomials will be true if polynomials have been requested
  113506. * @param onLoad defines the callback to trigger once the texture is ready
  113507. * @param onError defines the callback to trigger in case of error
  113508. */
  113509. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113510. /**
  113511. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113512. * @param data contains the texture data
  113513. * @param texture defines the BabylonJS internal texture
  113514. * @param callback defines the method to call once ready to upload
  113515. */
  113516. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113517. }
  113518. }
  113519. declare module BABYLON {
  113520. /**
  113521. * Implementation of the ENV Texture Loader.
  113522. * @hidden
  113523. */
  113524. export class _ENVTextureLoader implements IInternalTextureLoader {
  113525. /**
  113526. * Defines wether the loader supports cascade loading the different faces.
  113527. */
  113528. readonly supportCascades: boolean;
  113529. /**
  113530. * This returns if the loader support the current file information.
  113531. * @param extension defines the file extension of the file being loaded
  113532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113533. * @param fallback defines the fallback internal texture if any
  113534. * @param isBase64 defines whether the texture is encoded as a base64
  113535. * @param isBuffer defines whether the texture data are stored as a buffer
  113536. * @returns true if the loader can load the specified file
  113537. */
  113538. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113539. /**
  113540. * Transform the url before loading if required.
  113541. * @param rootUrl the url of the texture
  113542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113543. * @returns the transformed texture
  113544. */
  113545. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113546. /**
  113547. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113548. * @param rootUrl the url of the texture
  113549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113550. * @returns the fallback texture
  113551. */
  113552. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113553. /**
  113554. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113555. * @param data contains the texture data
  113556. * @param texture defines the BabylonJS internal texture
  113557. * @param createPolynomials will be true if polynomials have been requested
  113558. * @param onLoad defines the callback to trigger once the texture is ready
  113559. * @param onError defines the callback to trigger in case of error
  113560. */
  113561. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113562. /**
  113563. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113564. * @param data contains the texture data
  113565. * @param texture defines the BabylonJS internal texture
  113566. * @param callback defines the method to call once ready to upload
  113567. */
  113568. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113569. }
  113570. }
  113571. declare module BABYLON {
  113572. /**
  113573. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113574. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113575. */
  113576. export class KhronosTextureContainer {
  113577. /** contents of the KTX container file */
  113578. arrayBuffer: any;
  113579. private static HEADER_LEN;
  113580. private static COMPRESSED_2D;
  113581. private static COMPRESSED_3D;
  113582. private static TEX_2D;
  113583. private static TEX_3D;
  113584. /**
  113585. * Gets the openGL type
  113586. */
  113587. glType: number;
  113588. /**
  113589. * Gets the openGL type size
  113590. */
  113591. glTypeSize: number;
  113592. /**
  113593. * Gets the openGL format
  113594. */
  113595. glFormat: number;
  113596. /**
  113597. * Gets the openGL internal format
  113598. */
  113599. glInternalFormat: number;
  113600. /**
  113601. * Gets the base internal format
  113602. */
  113603. glBaseInternalFormat: number;
  113604. /**
  113605. * Gets image width in pixel
  113606. */
  113607. pixelWidth: number;
  113608. /**
  113609. * Gets image height in pixel
  113610. */
  113611. pixelHeight: number;
  113612. /**
  113613. * Gets image depth in pixels
  113614. */
  113615. pixelDepth: number;
  113616. /**
  113617. * Gets the number of array elements
  113618. */
  113619. numberOfArrayElements: number;
  113620. /**
  113621. * Gets the number of faces
  113622. */
  113623. numberOfFaces: number;
  113624. /**
  113625. * Gets the number of mipmap levels
  113626. */
  113627. numberOfMipmapLevels: number;
  113628. /**
  113629. * Gets the bytes of key value data
  113630. */
  113631. bytesOfKeyValueData: number;
  113632. /**
  113633. * Gets the load type
  113634. */
  113635. loadType: number;
  113636. /**
  113637. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  113638. */
  113639. isInvalid: boolean;
  113640. /**
  113641. * Creates a new KhronosTextureContainer
  113642. * @param arrayBuffer contents of the KTX container file
  113643. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  113644. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  113645. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  113646. */
  113647. constructor(
  113648. /** contents of the KTX container file */
  113649. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  113650. /**
  113651. * Uploads KTX content to a Babylon Texture.
  113652. * It is assumed that the texture has already been created & is currently bound
  113653. * @hidden
  113654. */
  113655. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  113656. private _upload2DCompressedLevels;
  113657. }
  113658. }
  113659. declare module BABYLON {
  113660. /**
  113661. * Implementation of the KTX Texture Loader.
  113662. * @hidden
  113663. */
  113664. export class _KTXTextureLoader implements IInternalTextureLoader {
  113665. /**
  113666. * Defines wether the loader supports cascade loading the different faces.
  113667. */
  113668. readonly supportCascades: boolean;
  113669. /**
  113670. * This returns if the loader support the current file information.
  113671. * @param extension defines the file extension of the file being loaded
  113672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113673. * @param fallback defines the fallback internal texture if any
  113674. * @param isBase64 defines whether the texture is encoded as a base64
  113675. * @param isBuffer defines whether the texture data are stored as a buffer
  113676. * @returns true if the loader can load the specified file
  113677. */
  113678. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113679. /**
  113680. * Transform the url before loading if required.
  113681. * @param rootUrl the url of the texture
  113682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113683. * @returns the transformed texture
  113684. */
  113685. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113686. /**
  113687. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113688. * @param rootUrl the url of the texture
  113689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113690. * @returns the fallback texture
  113691. */
  113692. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113693. /**
  113694. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113695. * @param data contains the texture data
  113696. * @param texture defines the BabylonJS internal texture
  113697. * @param createPolynomials will be true if polynomials have been requested
  113698. * @param onLoad defines the callback to trigger once the texture is ready
  113699. * @param onError defines the callback to trigger in case of error
  113700. */
  113701. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113702. /**
  113703. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113704. * @param data contains the texture data
  113705. * @param texture defines the BabylonJS internal texture
  113706. * @param callback defines the method to call once ready to upload
  113707. */
  113708. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  113709. }
  113710. }
  113711. declare module BABYLON {
  113712. /**
  113713. * Options for the default xr helper
  113714. */
  113715. export class WebXRDefaultExperienceOptions {
  113716. /**
  113717. * Floor meshes that should be used for teleporting
  113718. */
  113719. floorMeshes: Array<AbstractMesh>;
  113720. }
  113721. /**
  113722. * Default experience which provides a similar setup to the previous webVRExperience
  113723. */
  113724. export class WebXRDefaultExperience {
  113725. /**
  113726. * Base experience
  113727. */
  113728. baseExperience: WebXRExperienceHelper;
  113729. /**
  113730. * Input experience extension
  113731. */
  113732. input: WebXRInput;
  113733. /**
  113734. * Loads the controller models
  113735. */
  113736. controllerModelLoader: WebXRControllerModelLoader;
  113737. /**
  113738. * Enables laser pointer and selection
  113739. */
  113740. pointerSelection: WebXRControllerPointerSelection;
  113741. /**
  113742. * Enables teleportation
  113743. */
  113744. teleportation: WebXRControllerTeleportation;
  113745. /**
  113746. * Enables ui for enetering/exiting xr
  113747. */
  113748. enterExitUI: WebXREnterExitUI;
  113749. /**
  113750. * Default output canvas xr should render to
  113751. */
  113752. outputCanvas: WebXRManagedOutputCanvas;
  113753. /**
  113754. * Creates the default xr experience
  113755. * @param scene scene
  113756. * @param options options for basic configuration
  113757. * @returns resulting WebXRDefaultExperience
  113758. */
  113759. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113760. private constructor();
  113761. /**
  113762. * DIsposes of the experience helper
  113763. */
  113764. dispose(): void;
  113765. }
  113766. }
  113767. declare module BABYLON {
  113768. /** @hidden */
  113769. export var _forceSceneHelpersToBundle: boolean;
  113770. interface Scene {
  113771. /**
  113772. * Creates a default light for the scene.
  113773. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  113774. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  113775. */
  113776. createDefaultLight(replace?: boolean): void;
  113777. /**
  113778. * Creates a default camera for the scene.
  113779. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  113780. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113781. * @param replace has default false, when true replaces the active camera in the scene
  113782. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  113783. */
  113784. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113785. /**
  113786. * Creates a default camera and a default light.
  113787. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  113788. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113789. * @param replace has the default false, when true replaces the active camera/light in the scene
  113790. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  113791. */
  113792. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113793. /**
  113794. * Creates a new sky box
  113795. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  113796. * @param environmentTexture defines the texture to use as environment texture
  113797. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  113798. * @param scale defines the overall scale of the skybox
  113799. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  113800. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  113801. * @returns a new mesh holding the sky box
  113802. */
  113803. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  113804. /**
  113805. * Creates a new environment
  113806. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  113807. * @param options defines the options you can use to configure the environment
  113808. * @returns the new EnvironmentHelper
  113809. */
  113810. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  113811. /**
  113812. * Creates a new VREXperienceHelper
  113813. * @see http://doc.babylonjs.com/how_to/webvr_helper
  113814. * @param webVROptions defines the options used to create the new VREXperienceHelper
  113815. * @returns a new VREXperienceHelper
  113816. */
  113817. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  113818. /**
  113819. * Creates a new WebXRDefaultExperience
  113820. * @see http://doc.babylonjs.com/how_to/webxr
  113821. * @param options experience options
  113822. * @returns a promise for a new WebXRDefaultExperience
  113823. */
  113824. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113825. }
  113826. }
  113827. declare module BABYLON {
  113828. /**
  113829. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  113830. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  113831. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  113832. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113833. */
  113834. export class VideoDome extends TransformNode {
  113835. /**
  113836. * Define the video source as a Monoscopic panoramic 360 video.
  113837. */
  113838. static readonly MODE_MONOSCOPIC: number;
  113839. /**
  113840. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113841. */
  113842. static readonly MODE_TOPBOTTOM: number;
  113843. /**
  113844. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113845. */
  113846. static readonly MODE_SIDEBYSIDE: number;
  113847. private _halfDome;
  113848. private _useDirectMapping;
  113849. /**
  113850. * The video texture being displayed on the sphere
  113851. */
  113852. protected _videoTexture: VideoTexture;
  113853. /**
  113854. * Gets the video texture being displayed on the sphere
  113855. */
  113856. readonly videoTexture: VideoTexture;
  113857. /**
  113858. * The skybox material
  113859. */
  113860. protected _material: BackgroundMaterial;
  113861. /**
  113862. * The surface used for the skybox
  113863. */
  113864. protected _mesh: Mesh;
  113865. /**
  113866. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  113867. */
  113868. private _halfDomeMask;
  113869. /**
  113870. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113871. * Also see the options.resolution property.
  113872. */
  113873. fovMultiplier: number;
  113874. private _videoMode;
  113875. /**
  113876. * Gets or set the current video mode for the video. It can be:
  113877. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113878. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113879. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113880. */
  113881. videoMode: number;
  113882. /**
  113883. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113884. *
  113885. */
  113886. /**
  113887. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113888. */
  113889. halfDome: boolean;
  113890. /**
  113891. * Oberserver used in Stereoscopic VR Mode.
  113892. */
  113893. private _onBeforeCameraRenderObserver;
  113894. /**
  113895. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113896. * @param name Element's name, child elements will append suffixes for their own names.
  113897. * @param urlsOrVideo defines the url(s) or the video element to use
  113898. * @param options An object containing optional or exposed sub element properties
  113899. */
  113900. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113901. resolution?: number;
  113902. clickToPlay?: boolean;
  113903. autoPlay?: boolean;
  113904. loop?: boolean;
  113905. size?: number;
  113906. poster?: string;
  113907. faceForward?: boolean;
  113908. useDirectMapping?: boolean;
  113909. halfDomeMode?: boolean;
  113910. }, scene: Scene);
  113911. private _changeVideoMode;
  113912. /**
  113913. * Releases resources associated with this node.
  113914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113916. */
  113917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113918. }
  113919. }
  113920. declare module BABYLON {
  113921. /**
  113922. * This class can be used to get instrumentation data from a Babylon engine
  113923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113924. */
  113925. export class EngineInstrumentation implements IDisposable {
  113926. /**
  113927. * Define the instrumented engine.
  113928. */
  113929. engine: Engine;
  113930. private _captureGPUFrameTime;
  113931. private _gpuFrameTimeToken;
  113932. private _gpuFrameTime;
  113933. private _captureShaderCompilationTime;
  113934. private _shaderCompilationTime;
  113935. private _onBeginFrameObserver;
  113936. private _onEndFrameObserver;
  113937. private _onBeforeShaderCompilationObserver;
  113938. private _onAfterShaderCompilationObserver;
  113939. /**
  113940. * Gets the perf counter used for GPU frame time
  113941. */
  113942. readonly gpuFrameTimeCounter: PerfCounter;
  113943. /**
  113944. * Gets the GPU frame time capture status
  113945. */
  113946. /**
  113947. * Enable or disable the GPU frame time capture
  113948. */
  113949. captureGPUFrameTime: boolean;
  113950. /**
  113951. * Gets the perf counter used for shader compilation time
  113952. */
  113953. readonly shaderCompilationTimeCounter: PerfCounter;
  113954. /**
  113955. * Gets the shader compilation time capture status
  113956. */
  113957. /**
  113958. * Enable or disable the shader compilation time capture
  113959. */
  113960. captureShaderCompilationTime: boolean;
  113961. /**
  113962. * Instantiates a new engine instrumentation.
  113963. * This class can be used to get instrumentation data from a Babylon engine
  113964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113965. * @param engine Defines the engine to instrument
  113966. */
  113967. constructor(
  113968. /**
  113969. * Define the instrumented engine.
  113970. */
  113971. engine: Engine);
  113972. /**
  113973. * Dispose and release associated resources.
  113974. */
  113975. dispose(): void;
  113976. }
  113977. }
  113978. declare module BABYLON {
  113979. /**
  113980. * This class can be used to get instrumentation data from a Babylon engine
  113981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113982. */
  113983. export class SceneInstrumentation implements IDisposable {
  113984. /**
  113985. * Defines the scene to instrument
  113986. */
  113987. scene: Scene;
  113988. private _captureActiveMeshesEvaluationTime;
  113989. private _activeMeshesEvaluationTime;
  113990. private _captureRenderTargetsRenderTime;
  113991. private _renderTargetsRenderTime;
  113992. private _captureFrameTime;
  113993. private _frameTime;
  113994. private _captureRenderTime;
  113995. private _renderTime;
  113996. private _captureInterFrameTime;
  113997. private _interFrameTime;
  113998. private _captureParticlesRenderTime;
  113999. private _particlesRenderTime;
  114000. private _captureSpritesRenderTime;
  114001. private _spritesRenderTime;
  114002. private _capturePhysicsTime;
  114003. private _physicsTime;
  114004. private _captureAnimationsTime;
  114005. private _animationsTime;
  114006. private _captureCameraRenderTime;
  114007. private _cameraRenderTime;
  114008. private _onBeforeActiveMeshesEvaluationObserver;
  114009. private _onAfterActiveMeshesEvaluationObserver;
  114010. private _onBeforeRenderTargetsRenderObserver;
  114011. private _onAfterRenderTargetsRenderObserver;
  114012. private _onAfterRenderObserver;
  114013. private _onBeforeDrawPhaseObserver;
  114014. private _onAfterDrawPhaseObserver;
  114015. private _onBeforeAnimationsObserver;
  114016. private _onBeforeParticlesRenderingObserver;
  114017. private _onAfterParticlesRenderingObserver;
  114018. private _onBeforeSpritesRenderingObserver;
  114019. private _onAfterSpritesRenderingObserver;
  114020. private _onBeforePhysicsObserver;
  114021. private _onAfterPhysicsObserver;
  114022. private _onAfterAnimationsObserver;
  114023. private _onBeforeCameraRenderObserver;
  114024. private _onAfterCameraRenderObserver;
  114025. /**
  114026. * Gets the perf counter used for active meshes evaluation time
  114027. */
  114028. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114029. /**
  114030. * Gets the active meshes evaluation time capture status
  114031. */
  114032. /**
  114033. * Enable or disable the active meshes evaluation time capture
  114034. */
  114035. captureActiveMeshesEvaluationTime: boolean;
  114036. /**
  114037. * Gets the perf counter used for render targets render time
  114038. */
  114039. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114040. /**
  114041. * Gets the render targets render time capture status
  114042. */
  114043. /**
  114044. * Enable or disable the render targets render time capture
  114045. */
  114046. captureRenderTargetsRenderTime: boolean;
  114047. /**
  114048. * Gets the perf counter used for particles render time
  114049. */
  114050. readonly particlesRenderTimeCounter: PerfCounter;
  114051. /**
  114052. * Gets the particles render time capture status
  114053. */
  114054. /**
  114055. * Enable or disable the particles render time capture
  114056. */
  114057. captureParticlesRenderTime: boolean;
  114058. /**
  114059. * Gets the perf counter used for sprites render time
  114060. */
  114061. readonly spritesRenderTimeCounter: PerfCounter;
  114062. /**
  114063. * Gets the sprites render time capture status
  114064. */
  114065. /**
  114066. * Enable or disable the sprites render time capture
  114067. */
  114068. captureSpritesRenderTime: boolean;
  114069. /**
  114070. * Gets the perf counter used for physics time
  114071. */
  114072. readonly physicsTimeCounter: PerfCounter;
  114073. /**
  114074. * Gets the physics time capture status
  114075. */
  114076. /**
  114077. * Enable or disable the physics time capture
  114078. */
  114079. capturePhysicsTime: boolean;
  114080. /**
  114081. * Gets the perf counter used for animations time
  114082. */
  114083. readonly animationsTimeCounter: PerfCounter;
  114084. /**
  114085. * Gets the animations time capture status
  114086. */
  114087. /**
  114088. * Enable or disable the animations time capture
  114089. */
  114090. captureAnimationsTime: boolean;
  114091. /**
  114092. * Gets the perf counter used for frame time capture
  114093. */
  114094. readonly frameTimeCounter: PerfCounter;
  114095. /**
  114096. * Gets the frame time capture status
  114097. */
  114098. /**
  114099. * Enable or disable the frame time capture
  114100. */
  114101. captureFrameTime: boolean;
  114102. /**
  114103. * Gets the perf counter used for inter-frames time capture
  114104. */
  114105. readonly interFrameTimeCounter: PerfCounter;
  114106. /**
  114107. * Gets the inter-frames time capture status
  114108. */
  114109. /**
  114110. * Enable or disable the inter-frames time capture
  114111. */
  114112. captureInterFrameTime: boolean;
  114113. /**
  114114. * Gets the perf counter used for render time capture
  114115. */
  114116. readonly renderTimeCounter: PerfCounter;
  114117. /**
  114118. * Gets the render time capture status
  114119. */
  114120. /**
  114121. * Enable or disable the render time capture
  114122. */
  114123. captureRenderTime: boolean;
  114124. /**
  114125. * Gets the perf counter used for camera render time capture
  114126. */
  114127. readonly cameraRenderTimeCounter: PerfCounter;
  114128. /**
  114129. * Gets the camera render time capture status
  114130. */
  114131. /**
  114132. * Enable or disable the camera render time capture
  114133. */
  114134. captureCameraRenderTime: boolean;
  114135. /**
  114136. * Gets the perf counter used for draw calls
  114137. */
  114138. readonly drawCallsCounter: PerfCounter;
  114139. /**
  114140. * Instantiates a new scene instrumentation.
  114141. * This class can be used to get instrumentation data from a Babylon engine
  114142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114143. * @param scene Defines the scene to instrument
  114144. */
  114145. constructor(
  114146. /**
  114147. * Defines the scene to instrument
  114148. */
  114149. scene: Scene);
  114150. /**
  114151. * Dispose and release associated resources.
  114152. */
  114153. dispose(): void;
  114154. }
  114155. }
  114156. declare module BABYLON {
  114157. /** @hidden */
  114158. export var glowMapGenerationPixelShader: {
  114159. name: string;
  114160. shader: string;
  114161. };
  114162. }
  114163. declare module BABYLON {
  114164. /** @hidden */
  114165. export var glowMapGenerationVertexShader: {
  114166. name: string;
  114167. shader: string;
  114168. };
  114169. }
  114170. declare module BABYLON {
  114171. /**
  114172. * Effect layer options. This helps customizing the behaviour
  114173. * of the effect layer.
  114174. */
  114175. export interface IEffectLayerOptions {
  114176. /**
  114177. * Multiplication factor apply to the canvas size to compute the render target size
  114178. * used to generated the objects (the smaller the faster).
  114179. */
  114180. mainTextureRatio: number;
  114181. /**
  114182. * Enforces a fixed size texture to ensure effect stability across devices.
  114183. */
  114184. mainTextureFixedSize?: number;
  114185. /**
  114186. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114187. */
  114188. alphaBlendingMode: number;
  114189. /**
  114190. * The camera attached to the layer.
  114191. */
  114192. camera: Nullable<Camera>;
  114193. /**
  114194. * The rendering group to draw the layer in.
  114195. */
  114196. renderingGroupId: number;
  114197. }
  114198. /**
  114199. * The effect layer Helps adding post process effect blended with the main pass.
  114200. *
  114201. * This can be for instance use to generate glow or higlight effects on the scene.
  114202. *
  114203. * The effect layer class can not be used directly and is intented to inherited from to be
  114204. * customized per effects.
  114205. */
  114206. export abstract class EffectLayer {
  114207. private _vertexBuffers;
  114208. private _indexBuffer;
  114209. private _cachedDefines;
  114210. private _effectLayerMapGenerationEffect;
  114211. private _effectLayerOptions;
  114212. private _mergeEffect;
  114213. protected _scene: Scene;
  114214. protected _engine: Engine;
  114215. protected _maxSize: number;
  114216. protected _mainTextureDesiredSize: ISize;
  114217. protected _mainTexture: RenderTargetTexture;
  114218. protected _shouldRender: boolean;
  114219. protected _postProcesses: PostProcess[];
  114220. protected _textures: BaseTexture[];
  114221. protected _emissiveTextureAndColor: {
  114222. texture: Nullable<BaseTexture>;
  114223. color: Color4;
  114224. };
  114225. /**
  114226. * The name of the layer
  114227. */
  114228. name: string;
  114229. /**
  114230. * The clear color of the texture used to generate the glow map.
  114231. */
  114232. neutralColor: Color4;
  114233. /**
  114234. * Specifies wether the highlight layer is enabled or not.
  114235. */
  114236. isEnabled: boolean;
  114237. /**
  114238. * Gets the camera attached to the layer.
  114239. */
  114240. readonly camera: Nullable<Camera>;
  114241. /**
  114242. * Gets the rendering group id the layer should render in.
  114243. */
  114244. renderingGroupId: number;
  114245. /**
  114246. * An event triggered when the effect layer has been disposed.
  114247. */
  114248. onDisposeObservable: Observable<EffectLayer>;
  114249. /**
  114250. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114251. */
  114252. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114253. /**
  114254. * An event triggered when the generated texture is being merged in the scene.
  114255. */
  114256. onBeforeComposeObservable: Observable<EffectLayer>;
  114257. /**
  114258. * An event triggered when the generated texture has been merged in the scene.
  114259. */
  114260. onAfterComposeObservable: Observable<EffectLayer>;
  114261. /**
  114262. * An event triggered when the efffect layer changes its size.
  114263. */
  114264. onSizeChangedObservable: Observable<EffectLayer>;
  114265. /** @hidden */
  114266. static _SceneComponentInitialization: (scene: Scene) => void;
  114267. /**
  114268. * Instantiates a new effect Layer and references it in the scene.
  114269. * @param name The name of the layer
  114270. * @param scene The scene to use the layer in
  114271. */
  114272. constructor(
  114273. /** The Friendly of the effect in the scene */
  114274. name: string, scene: Scene);
  114275. /**
  114276. * Get the effect name of the layer.
  114277. * @return The effect name
  114278. */
  114279. abstract getEffectName(): string;
  114280. /**
  114281. * Checks for the readiness of the element composing the layer.
  114282. * @param subMesh the mesh to check for
  114283. * @param useInstances specify wether or not to use instances to render the mesh
  114284. * @return true if ready otherwise, false
  114285. */
  114286. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114287. /**
  114288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114289. * @returns true if the effect requires stencil during the main canvas render pass.
  114290. */
  114291. abstract needStencil(): boolean;
  114292. /**
  114293. * Create the merge effect. This is the shader use to blit the information back
  114294. * to the main canvas at the end of the scene rendering.
  114295. * @returns The effect containing the shader used to merge the effect on the main canvas
  114296. */
  114297. protected abstract _createMergeEffect(): Effect;
  114298. /**
  114299. * Creates the render target textures and post processes used in the effect layer.
  114300. */
  114301. protected abstract _createTextureAndPostProcesses(): void;
  114302. /**
  114303. * Implementation specific of rendering the generating effect on the main canvas.
  114304. * @param effect The effect used to render through
  114305. */
  114306. protected abstract _internalRender(effect: Effect): void;
  114307. /**
  114308. * Sets the required values for both the emissive texture and and the main color.
  114309. */
  114310. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114311. /**
  114312. * Free any resources and references associated to a mesh.
  114313. * Internal use
  114314. * @param mesh The mesh to free.
  114315. */
  114316. abstract _disposeMesh(mesh: Mesh): void;
  114317. /**
  114318. * Serializes this layer (Glow or Highlight for example)
  114319. * @returns a serialized layer object
  114320. */
  114321. abstract serialize?(): any;
  114322. /**
  114323. * Initializes the effect layer with the required options.
  114324. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114325. */
  114326. protected _init(options: Partial<IEffectLayerOptions>): void;
  114327. /**
  114328. * Generates the index buffer of the full screen quad blending to the main canvas.
  114329. */
  114330. private _generateIndexBuffer;
  114331. /**
  114332. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114333. */
  114334. private _generateVertexBuffer;
  114335. /**
  114336. * Sets the main texture desired size which is the closest power of two
  114337. * of the engine canvas size.
  114338. */
  114339. private _setMainTextureSize;
  114340. /**
  114341. * Creates the main texture for the effect layer.
  114342. */
  114343. protected _createMainTexture(): void;
  114344. /**
  114345. * Adds specific effects defines.
  114346. * @param defines The defines to add specifics to.
  114347. */
  114348. protected _addCustomEffectDefines(defines: string[]): void;
  114349. /**
  114350. * Checks for the readiness of the element composing the layer.
  114351. * @param subMesh the mesh to check for
  114352. * @param useInstances specify wether or not to use instances to render the mesh
  114353. * @param emissiveTexture the associated emissive texture used to generate the glow
  114354. * @return true if ready otherwise, false
  114355. */
  114356. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114357. /**
  114358. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114359. */
  114360. render(): void;
  114361. /**
  114362. * Determine if a given mesh will be used in the current effect.
  114363. * @param mesh mesh to test
  114364. * @returns true if the mesh will be used
  114365. */
  114366. hasMesh(mesh: AbstractMesh): boolean;
  114367. /**
  114368. * Returns true if the layer contains information to display, otherwise false.
  114369. * @returns true if the glow layer should be rendered
  114370. */
  114371. shouldRender(): boolean;
  114372. /**
  114373. * Returns true if the mesh should render, otherwise false.
  114374. * @param mesh The mesh to render
  114375. * @returns true if it should render otherwise false
  114376. */
  114377. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114378. /**
  114379. * Returns true if the mesh can be rendered, otherwise false.
  114380. * @param mesh The mesh to render
  114381. * @param material The material used on the mesh
  114382. * @returns true if it can be rendered otherwise false
  114383. */
  114384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114385. /**
  114386. * Returns true if the mesh should render, otherwise false.
  114387. * @param mesh The mesh to render
  114388. * @returns true if it should render otherwise false
  114389. */
  114390. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114391. /**
  114392. * Renders the submesh passed in parameter to the generation map.
  114393. */
  114394. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114395. /**
  114396. * Rebuild the required buffers.
  114397. * @hidden Internal use only.
  114398. */
  114399. _rebuild(): void;
  114400. /**
  114401. * Dispose only the render target textures and post process.
  114402. */
  114403. private _disposeTextureAndPostProcesses;
  114404. /**
  114405. * Dispose the highlight layer and free resources.
  114406. */
  114407. dispose(): void;
  114408. /**
  114409. * Gets the class name of the effect layer
  114410. * @returns the string with the class name of the effect layer
  114411. */
  114412. getClassName(): string;
  114413. /**
  114414. * Creates an effect layer from parsed effect layer data
  114415. * @param parsedEffectLayer defines effect layer data
  114416. * @param scene defines the current scene
  114417. * @param rootUrl defines the root URL containing the effect layer information
  114418. * @returns a parsed effect Layer
  114419. */
  114420. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114421. }
  114422. }
  114423. declare module BABYLON {
  114424. interface AbstractScene {
  114425. /**
  114426. * The list of effect layers (highlights/glow) added to the scene
  114427. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114428. * @see http://doc.babylonjs.com/how_to/glow_layer
  114429. */
  114430. effectLayers: Array<EffectLayer>;
  114431. /**
  114432. * Removes the given effect layer from this scene.
  114433. * @param toRemove defines the effect layer to remove
  114434. * @returns the index of the removed effect layer
  114435. */
  114436. removeEffectLayer(toRemove: EffectLayer): number;
  114437. /**
  114438. * Adds the given effect layer to this scene
  114439. * @param newEffectLayer defines the effect layer to add
  114440. */
  114441. addEffectLayer(newEffectLayer: EffectLayer): void;
  114442. }
  114443. /**
  114444. * Defines the layer scene component responsible to manage any effect layers
  114445. * in a given scene.
  114446. */
  114447. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114448. /**
  114449. * The component name helpfull to identify the component in the list of scene components.
  114450. */
  114451. readonly name: string;
  114452. /**
  114453. * The scene the component belongs to.
  114454. */
  114455. scene: Scene;
  114456. private _engine;
  114457. private _renderEffects;
  114458. private _needStencil;
  114459. private _previousStencilState;
  114460. /**
  114461. * Creates a new instance of the component for the given scene
  114462. * @param scene Defines the scene to register the component in
  114463. */
  114464. constructor(scene: Scene);
  114465. /**
  114466. * Registers the component in a given scene
  114467. */
  114468. register(): void;
  114469. /**
  114470. * Rebuilds the elements related to this component in case of
  114471. * context lost for instance.
  114472. */
  114473. rebuild(): void;
  114474. /**
  114475. * Serializes the component data to the specified json object
  114476. * @param serializationObject The object to serialize to
  114477. */
  114478. serialize(serializationObject: any): void;
  114479. /**
  114480. * Adds all the elements from the container to the scene
  114481. * @param container the container holding the elements
  114482. */
  114483. addFromContainer(container: AbstractScene): void;
  114484. /**
  114485. * Removes all the elements in the container from the scene
  114486. * @param container contains the elements to remove
  114487. * @param dispose if the removed element should be disposed (default: false)
  114488. */
  114489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114490. /**
  114491. * Disposes the component and the associated ressources.
  114492. */
  114493. dispose(): void;
  114494. private _isReadyForMesh;
  114495. private _renderMainTexture;
  114496. private _setStencil;
  114497. private _setStencilBack;
  114498. private _draw;
  114499. private _drawCamera;
  114500. private _drawRenderingGroup;
  114501. }
  114502. }
  114503. declare module BABYLON {
  114504. /** @hidden */
  114505. export var glowMapMergePixelShader: {
  114506. name: string;
  114507. shader: string;
  114508. };
  114509. }
  114510. declare module BABYLON {
  114511. /** @hidden */
  114512. export var glowMapMergeVertexShader: {
  114513. name: string;
  114514. shader: string;
  114515. };
  114516. }
  114517. declare module BABYLON {
  114518. interface AbstractScene {
  114519. /**
  114520. * Return a the first highlight layer of the scene with a given name.
  114521. * @param name The name of the highlight layer to look for.
  114522. * @return The highlight layer if found otherwise null.
  114523. */
  114524. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114525. }
  114526. /**
  114527. * Glow layer options. This helps customizing the behaviour
  114528. * of the glow layer.
  114529. */
  114530. export interface IGlowLayerOptions {
  114531. /**
  114532. * Multiplication factor apply to the canvas size to compute the render target size
  114533. * used to generated the glowing objects (the smaller the faster).
  114534. */
  114535. mainTextureRatio: number;
  114536. /**
  114537. * Enforces a fixed size texture to ensure resize independant blur.
  114538. */
  114539. mainTextureFixedSize?: number;
  114540. /**
  114541. * How big is the kernel of the blur texture.
  114542. */
  114543. blurKernelSize: number;
  114544. /**
  114545. * The camera attached to the layer.
  114546. */
  114547. camera: Nullable<Camera>;
  114548. /**
  114549. * Enable MSAA by chosing the number of samples.
  114550. */
  114551. mainTextureSamples?: number;
  114552. /**
  114553. * The rendering group to draw the layer in.
  114554. */
  114555. renderingGroupId: number;
  114556. }
  114557. /**
  114558. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114559. *
  114560. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114561. * glowy meshes to your scene.
  114562. *
  114563. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114564. */
  114565. export class GlowLayer extends EffectLayer {
  114566. /**
  114567. * Effect Name of the layer.
  114568. */
  114569. static readonly EffectName: string;
  114570. /**
  114571. * The default blur kernel size used for the glow.
  114572. */
  114573. static DefaultBlurKernelSize: number;
  114574. /**
  114575. * The default texture size ratio used for the glow.
  114576. */
  114577. static DefaultTextureRatio: number;
  114578. /**
  114579. * Sets the kernel size of the blur.
  114580. */
  114581. /**
  114582. * Gets the kernel size of the blur.
  114583. */
  114584. blurKernelSize: number;
  114585. /**
  114586. * Sets the glow intensity.
  114587. */
  114588. /**
  114589. * Gets the glow intensity.
  114590. */
  114591. intensity: number;
  114592. private _options;
  114593. private _intensity;
  114594. private _horizontalBlurPostprocess1;
  114595. private _verticalBlurPostprocess1;
  114596. private _horizontalBlurPostprocess2;
  114597. private _verticalBlurPostprocess2;
  114598. private _blurTexture1;
  114599. private _blurTexture2;
  114600. private _postProcesses1;
  114601. private _postProcesses2;
  114602. private _includedOnlyMeshes;
  114603. private _excludedMeshes;
  114604. /**
  114605. * Callback used to let the user override the color selection on a per mesh basis
  114606. */
  114607. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114608. /**
  114609. * Callback used to let the user override the texture selection on a per mesh basis
  114610. */
  114611. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114612. /**
  114613. * Instantiates a new glow Layer and references it to the scene.
  114614. * @param name The name of the layer
  114615. * @param scene The scene to use the layer in
  114616. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114617. */
  114618. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114619. /**
  114620. * Get the effect name of the layer.
  114621. * @return The effect name
  114622. */
  114623. getEffectName(): string;
  114624. /**
  114625. * Create the merge effect. This is the shader use to blit the information back
  114626. * to the main canvas at the end of the scene rendering.
  114627. */
  114628. protected _createMergeEffect(): Effect;
  114629. /**
  114630. * Creates the render target textures and post processes used in the glow layer.
  114631. */
  114632. protected _createTextureAndPostProcesses(): void;
  114633. /**
  114634. * Checks for the readiness of the element composing the layer.
  114635. * @param subMesh the mesh to check for
  114636. * @param useInstances specify wether or not to use instances to render the mesh
  114637. * @param emissiveTexture the associated emissive texture used to generate the glow
  114638. * @return true if ready otherwise, false
  114639. */
  114640. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114641. /**
  114642. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114643. */
  114644. needStencil(): boolean;
  114645. /**
  114646. * Returns true if the mesh can be rendered, otherwise false.
  114647. * @param mesh The mesh to render
  114648. * @param material The material used on the mesh
  114649. * @returns true if it can be rendered otherwise false
  114650. */
  114651. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114652. /**
  114653. * Implementation specific of rendering the generating effect on the main canvas.
  114654. * @param effect The effect used to render through
  114655. */
  114656. protected _internalRender(effect: Effect): void;
  114657. /**
  114658. * Sets the required values for both the emissive texture and and the main color.
  114659. */
  114660. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114661. /**
  114662. * Returns true if the mesh should render, otherwise false.
  114663. * @param mesh The mesh to render
  114664. * @returns true if it should render otherwise false
  114665. */
  114666. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114667. /**
  114668. * Adds specific effects defines.
  114669. * @param defines The defines to add specifics to.
  114670. */
  114671. protected _addCustomEffectDefines(defines: string[]): void;
  114672. /**
  114673. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  114674. * @param mesh The mesh to exclude from the glow layer
  114675. */
  114676. addExcludedMesh(mesh: Mesh): void;
  114677. /**
  114678. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  114679. * @param mesh The mesh to remove
  114680. */
  114681. removeExcludedMesh(mesh: Mesh): void;
  114682. /**
  114683. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  114684. * @param mesh The mesh to include in the glow layer
  114685. */
  114686. addIncludedOnlyMesh(mesh: Mesh): void;
  114687. /**
  114688. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  114689. * @param mesh The mesh to remove
  114690. */
  114691. removeIncludedOnlyMesh(mesh: Mesh): void;
  114692. /**
  114693. * Determine if a given mesh will be used in the glow layer
  114694. * @param mesh The mesh to test
  114695. * @returns true if the mesh will be highlighted by the current glow layer
  114696. */
  114697. hasMesh(mesh: AbstractMesh): boolean;
  114698. /**
  114699. * Free any resources and references associated to a mesh.
  114700. * Internal use
  114701. * @param mesh The mesh to free.
  114702. * @hidden
  114703. */
  114704. _disposeMesh(mesh: Mesh): void;
  114705. /**
  114706. * Gets the class name of the effect layer
  114707. * @returns the string with the class name of the effect layer
  114708. */
  114709. getClassName(): string;
  114710. /**
  114711. * Serializes this glow layer
  114712. * @returns a serialized glow layer object
  114713. */
  114714. serialize(): any;
  114715. /**
  114716. * Creates a Glow Layer from parsed glow layer data
  114717. * @param parsedGlowLayer defines glow layer data
  114718. * @param scene defines the current scene
  114719. * @param rootUrl defines the root URL containing the glow layer information
  114720. * @returns a parsed Glow Layer
  114721. */
  114722. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  114723. }
  114724. }
  114725. declare module BABYLON {
  114726. /** @hidden */
  114727. export var glowBlurPostProcessPixelShader: {
  114728. name: string;
  114729. shader: string;
  114730. };
  114731. }
  114732. declare module BABYLON {
  114733. interface AbstractScene {
  114734. /**
  114735. * Return a the first highlight layer of the scene with a given name.
  114736. * @param name The name of the highlight layer to look for.
  114737. * @return The highlight layer if found otherwise null.
  114738. */
  114739. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  114740. }
  114741. /**
  114742. * Highlight layer options. This helps customizing the behaviour
  114743. * of the highlight layer.
  114744. */
  114745. export interface IHighlightLayerOptions {
  114746. /**
  114747. * Multiplication factor apply to the canvas size to compute the render target size
  114748. * used to generated the glowing objects (the smaller the faster).
  114749. */
  114750. mainTextureRatio: number;
  114751. /**
  114752. * Enforces a fixed size texture to ensure resize independant blur.
  114753. */
  114754. mainTextureFixedSize?: number;
  114755. /**
  114756. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  114757. * of the picture to blur (the smaller the faster).
  114758. */
  114759. blurTextureSizeRatio: number;
  114760. /**
  114761. * How big in texel of the blur texture is the vertical blur.
  114762. */
  114763. blurVerticalSize: number;
  114764. /**
  114765. * How big in texel of the blur texture is the horizontal blur.
  114766. */
  114767. blurHorizontalSize: number;
  114768. /**
  114769. * Alpha blending mode used to apply the blur. Default is combine.
  114770. */
  114771. alphaBlendingMode: number;
  114772. /**
  114773. * The camera attached to the layer.
  114774. */
  114775. camera: Nullable<Camera>;
  114776. /**
  114777. * Should we display highlight as a solid stroke?
  114778. */
  114779. isStroke?: boolean;
  114780. /**
  114781. * The rendering group to draw the layer in.
  114782. */
  114783. renderingGroupId: number;
  114784. }
  114785. /**
  114786. * The highlight layer Helps adding a glow effect around a mesh.
  114787. *
  114788. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114789. * glowy meshes to your scene.
  114790. *
  114791. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  114792. */
  114793. export class HighlightLayer extends EffectLayer {
  114794. name: string;
  114795. /**
  114796. * Effect Name of the highlight layer.
  114797. */
  114798. static readonly EffectName: string;
  114799. /**
  114800. * The neutral color used during the preparation of the glow effect.
  114801. * This is black by default as the blend operation is a blend operation.
  114802. */
  114803. static NeutralColor: Color4;
  114804. /**
  114805. * Stencil value used for glowing meshes.
  114806. */
  114807. static GlowingMeshStencilReference: number;
  114808. /**
  114809. * Stencil value used for the other meshes in the scene.
  114810. */
  114811. static NormalMeshStencilReference: number;
  114812. /**
  114813. * Specifies whether or not the inner glow is ACTIVE in the layer.
  114814. */
  114815. innerGlow: boolean;
  114816. /**
  114817. * Specifies whether or not the outer glow is ACTIVE in the layer.
  114818. */
  114819. outerGlow: boolean;
  114820. /**
  114821. * Specifies the horizontal size of the blur.
  114822. */
  114823. /**
  114824. * Gets the horizontal size of the blur.
  114825. */
  114826. blurHorizontalSize: number;
  114827. /**
  114828. * Specifies the vertical size of the blur.
  114829. */
  114830. /**
  114831. * Gets the vertical size of the blur.
  114832. */
  114833. blurVerticalSize: number;
  114834. /**
  114835. * An event triggered when the highlight layer is being blurred.
  114836. */
  114837. onBeforeBlurObservable: Observable<HighlightLayer>;
  114838. /**
  114839. * An event triggered when the highlight layer has been blurred.
  114840. */
  114841. onAfterBlurObservable: Observable<HighlightLayer>;
  114842. private _instanceGlowingMeshStencilReference;
  114843. private _options;
  114844. private _downSamplePostprocess;
  114845. private _horizontalBlurPostprocess;
  114846. private _verticalBlurPostprocess;
  114847. private _blurTexture;
  114848. private _meshes;
  114849. private _excludedMeshes;
  114850. /**
  114851. * Instantiates a new highlight Layer and references it to the scene..
  114852. * @param name The name of the layer
  114853. * @param scene The scene to use the layer in
  114854. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  114855. */
  114856. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  114857. /**
  114858. * Get the effect name of the layer.
  114859. * @return The effect name
  114860. */
  114861. getEffectName(): string;
  114862. /**
  114863. * Create the merge effect. This is the shader use to blit the information back
  114864. * to the main canvas at the end of the scene rendering.
  114865. */
  114866. protected _createMergeEffect(): Effect;
  114867. /**
  114868. * Creates the render target textures and post processes used in the highlight layer.
  114869. */
  114870. protected _createTextureAndPostProcesses(): void;
  114871. /**
  114872. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114873. */
  114874. needStencil(): boolean;
  114875. /**
  114876. * Checks for the readiness of the element composing the layer.
  114877. * @param subMesh the mesh to check for
  114878. * @param useInstances specify wether or not to use instances to render the mesh
  114879. * @param emissiveTexture the associated emissive texture used to generate the glow
  114880. * @return true if ready otherwise, false
  114881. */
  114882. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114883. /**
  114884. * Implementation specific of rendering the generating effect on the main canvas.
  114885. * @param effect The effect used to render through
  114886. */
  114887. protected _internalRender(effect: Effect): void;
  114888. /**
  114889. * Returns true if the layer contains information to display, otherwise false.
  114890. */
  114891. shouldRender(): boolean;
  114892. /**
  114893. * Returns true if the mesh should render, otherwise false.
  114894. * @param mesh The mesh to render
  114895. * @returns true if it should render otherwise false
  114896. */
  114897. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114898. /**
  114899. * Sets the required values for both the emissive texture and and the main color.
  114900. */
  114901. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114902. /**
  114903. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114904. * @param mesh The mesh to exclude from the highlight layer
  114905. */
  114906. addExcludedMesh(mesh: Mesh): void;
  114907. /**
  114908. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114909. * @param mesh The mesh to highlight
  114910. */
  114911. removeExcludedMesh(mesh: Mesh): void;
  114912. /**
  114913. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114914. * @param mesh mesh to test
  114915. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114916. */
  114917. hasMesh(mesh: AbstractMesh): boolean;
  114918. /**
  114919. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114920. * @param mesh The mesh to highlight
  114921. * @param color The color of the highlight
  114922. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114923. */
  114924. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114925. /**
  114926. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114927. * @param mesh The mesh to highlight
  114928. */
  114929. removeMesh(mesh: Mesh): void;
  114930. /**
  114931. * Force the stencil to the normal expected value for none glowing parts
  114932. */
  114933. private _defaultStencilReference;
  114934. /**
  114935. * Free any resources and references associated to a mesh.
  114936. * Internal use
  114937. * @param mesh The mesh to free.
  114938. * @hidden
  114939. */
  114940. _disposeMesh(mesh: Mesh): void;
  114941. /**
  114942. * Dispose the highlight layer and free resources.
  114943. */
  114944. dispose(): void;
  114945. /**
  114946. * Gets the class name of the effect layer
  114947. * @returns the string with the class name of the effect layer
  114948. */
  114949. getClassName(): string;
  114950. /**
  114951. * Serializes this Highlight layer
  114952. * @returns a serialized Highlight layer object
  114953. */
  114954. serialize(): any;
  114955. /**
  114956. * Creates a Highlight layer from parsed Highlight layer data
  114957. * @param parsedHightlightLayer defines the Highlight layer data
  114958. * @param scene defines the current scene
  114959. * @param rootUrl defines the root URL containing the Highlight layer information
  114960. * @returns a parsed Highlight layer
  114961. */
  114962. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114963. }
  114964. }
  114965. declare module BABYLON {
  114966. interface AbstractScene {
  114967. /**
  114968. * The list of layers (background and foreground) of the scene
  114969. */
  114970. layers: Array<Layer>;
  114971. }
  114972. /**
  114973. * Defines the layer scene component responsible to manage any layers
  114974. * in a given scene.
  114975. */
  114976. export class LayerSceneComponent implements ISceneComponent {
  114977. /**
  114978. * The component name helpfull to identify the component in the list of scene components.
  114979. */
  114980. readonly name: string;
  114981. /**
  114982. * The scene the component belongs to.
  114983. */
  114984. scene: Scene;
  114985. private _engine;
  114986. /**
  114987. * Creates a new instance of the component for the given scene
  114988. * @param scene Defines the scene to register the component in
  114989. */
  114990. constructor(scene: Scene);
  114991. /**
  114992. * Registers the component in a given scene
  114993. */
  114994. register(): void;
  114995. /**
  114996. * Rebuilds the elements related to this component in case of
  114997. * context lost for instance.
  114998. */
  114999. rebuild(): void;
  115000. /**
  115001. * Disposes the component and the associated ressources.
  115002. */
  115003. dispose(): void;
  115004. private _draw;
  115005. private _drawCameraPredicate;
  115006. private _drawCameraBackground;
  115007. private _drawCameraForeground;
  115008. private _drawRenderTargetPredicate;
  115009. private _drawRenderTargetBackground;
  115010. private _drawRenderTargetForeground;
  115011. /**
  115012. * Adds all the elements from the container to the scene
  115013. * @param container the container holding the elements
  115014. */
  115015. addFromContainer(container: AbstractScene): void;
  115016. /**
  115017. * Removes all the elements in the container from the scene
  115018. * @param container contains the elements to remove
  115019. * @param dispose if the removed element should be disposed (default: false)
  115020. */
  115021. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115022. }
  115023. }
  115024. declare module BABYLON {
  115025. /** @hidden */
  115026. export var layerPixelShader: {
  115027. name: string;
  115028. shader: string;
  115029. };
  115030. }
  115031. declare module BABYLON {
  115032. /** @hidden */
  115033. export var layerVertexShader: {
  115034. name: string;
  115035. shader: string;
  115036. };
  115037. }
  115038. declare module BABYLON {
  115039. /**
  115040. * This represents a full screen 2d layer.
  115041. * This can be useful to display a picture in the background of your scene for instance.
  115042. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115043. */
  115044. export class Layer {
  115045. /**
  115046. * Define the name of the layer.
  115047. */
  115048. name: string;
  115049. /**
  115050. * Define the texture the layer should display.
  115051. */
  115052. texture: Nullable<Texture>;
  115053. /**
  115054. * Is the layer in background or foreground.
  115055. */
  115056. isBackground: boolean;
  115057. /**
  115058. * Define the color of the layer (instead of texture).
  115059. */
  115060. color: Color4;
  115061. /**
  115062. * Define the scale of the layer in order to zoom in out of the texture.
  115063. */
  115064. scale: Vector2;
  115065. /**
  115066. * Define an offset for the layer in order to shift the texture.
  115067. */
  115068. offset: Vector2;
  115069. /**
  115070. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115071. */
  115072. alphaBlendingMode: number;
  115073. /**
  115074. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115075. * Alpha test will not mix with the background color in case of transparency.
  115076. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115077. */
  115078. alphaTest: boolean;
  115079. /**
  115080. * Define a mask to restrict the layer to only some of the scene cameras.
  115081. */
  115082. layerMask: number;
  115083. /**
  115084. * Define the list of render target the layer is visible into.
  115085. */
  115086. renderTargetTextures: RenderTargetTexture[];
  115087. /**
  115088. * Define if the layer is only used in renderTarget or if it also
  115089. * renders in the main frame buffer of the canvas.
  115090. */
  115091. renderOnlyInRenderTargetTextures: boolean;
  115092. private _scene;
  115093. private _vertexBuffers;
  115094. private _indexBuffer;
  115095. private _effect;
  115096. private _alphaTestEffect;
  115097. /**
  115098. * An event triggered when the layer is disposed.
  115099. */
  115100. onDisposeObservable: Observable<Layer>;
  115101. private _onDisposeObserver;
  115102. /**
  115103. * Back compatibility with callback before the onDisposeObservable existed.
  115104. * The set callback will be triggered when the layer has been disposed.
  115105. */
  115106. onDispose: () => void;
  115107. /**
  115108. * An event triggered before rendering the scene
  115109. */
  115110. onBeforeRenderObservable: Observable<Layer>;
  115111. private _onBeforeRenderObserver;
  115112. /**
  115113. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115114. * The set callback will be triggered just before rendering the layer.
  115115. */
  115116. onBeforeRender: () => void;
  115117. /**
  115118. * An event triggered after rendering the scene
  115119. */
  115120. onAfterRenderObservable: Observable<Layer>;
  115121. private _onAfterRenderObserver;
  115122. /**
  115123. * Back compatibility with callback before the onAfterRenderObservable existed.
  115124. * The set callback will be triggered just after rendering the layer.
  115125. */
  115126. onAfterRender: () => void;
  115127. /**
  115128. * Instantiates a new layer.
  115129. * This represents a full screen 2d layer.
  115130. * This can be useful to display a picture in the background of your scene for instance.
  115131. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115132. * @param name Define the name of the layer in the scene
  115133. * @param imgUrl Define the url of the texture to display in the layer
  115134. * @param scene Define the scene the layer belongs to
  115135. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115136. * @param color Defines a color for the layer
  115137. */
  115138. constructor(
  115139. /**
  115140. * Define the name of the layer.
  115141. */
  115142. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115143. private _createIndexBuffer;
  115144. /** @hidden */
  115145. _rebuild(): void;
  115146. /**
  115147. * Renders the layer in the scene.
  115148. */
  115149. render(): void;
  115150. /**
  115151. * Disposes and releases the associated ressources.
  115152. */
  115153. dispose(): void;
  115154. }
  115155. }
  115156. declare module BABYLON {
  115157. /** @hidden */
  115158. export var lensFlarePixelShader: {
  115159. name: string;
  115160. shader: string;
  115161. };
  115162. }
  115163. declare module BABYLON {
  115164. /** @hidden */
  115165. export var lensFlareVertexShader: {
  115166. name: string;
  115167. shader: string;
  115168. };
  115169. }
  115170. declare module BABYLON {
  115171. /**
  115172. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115173. * It is usually composed of several `lensFlare`.
  115174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115175. */
  115176. export class LensFlareSystem {
  115177. /**
  115178. * Define the name of the lens flare system
  115179. */
  115180. name: string;
  115181. /**
  115182. * List of lens flares used in this system.
  115183. */
  115184. lensFlares: LensFlare[];
  115185. /**
  115186. * Define a limit from the border the lens flare can be visible.
  115187. */
  115188. borderLimit: number;
  115189. /**
  115190. * Define a viewport border we do not want to see the lens flare in.
  115191. */
  115192. viewportBorder: number;
  115193. /**
  115194. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115195. */
  115196. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115197. /**
  115198. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115199. */
  115200. layerMask: number;
  115201. /**
  115202. * Define the id of the lens flare system in the scene.
  115203. * (equal to name by default)
  115204. */
  115205. id: string;
  115206. private _scene;
  115207. private _emitter;
  115208. private _vertexBuffers;
  115209. private _indexBuffer;
  115210. private _effect;
  115211. private _positionX;
  115212. private _positionY;
  115213. private _isEnabled;
  115214. /** @hidden */
  115215. static _SceneComponentInitialization: (scene: Scene) => void;
  115216. /**
  115217. * Instantiates a lens flare system.
  115218. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115219. * It is usually composed of several `lensFlare`.
  115220. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115221. * @param name Define the name of the lens flare system in the scene
  115222. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115223. * @param scene Define the scene the lens flare system belongs to
  115224. */
  115225. constructor(
  115226. /**
  115227. * Define the name of the lens flare system
  115228. */
  115229. name: string, emitter: any, scene: Scene);
  115230. /**
  115231. * Define if the lens flare system is enabled.
  115232. */
  115233. isEnabled: boolean;
  115234. /**
  115235. * Get the scene the effects belongs to.
  115236. * @returns the scene holding the lens flare system
  115237. */
  115238. getScene(): Scene;
  115239. /**
  115240. * Get the emitter of the lens flare system.
  115241. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115242. * @returns the emitter of the lens flare system
  115243. */
  115244. getEmitter(): any;
  115245. /**
  115246. * Set the emitter of the lens flare system.
  115247. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115248. * @param newEmitter Define the new emitter of the system
  115249. */
  115250. setEmitter(newEmitter: any): void;
  115251. /**
  115252. * Get the lens flare system emitter position.
  115253. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115254. * @returns the position
  115255. */
  115256. getEmitterPosition(): Vector3;
  115257. /**
  115258. * @hidden
  115259. */
  115260. computeEffectivePosition(globalViewport: Viewport): boolean;
  115261. /** @hidden */
  115262. _isVisible(): boolean;
  115263. /**
  115264. * @hidden
  115265. */
  115266. render(): boolean;
  115267. /**
  115268. * Dispose and release the lens flare with its associated resources.
  115269. */
  115270. dispose(): void;
  115271. /**
  115272. * Parse a lens flare system from a JSON repressentation
  115273. * @param parsedLensFlareSystem Define the JSON to parse
  115274. * @param scene Define the scene the parsed system should be instantiated in
  115275. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115276. * @returns the parsed system
  115277. */
  115278. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115279. /**
  115280. * Serialize the current Lens Flare System into a JSON representation.
  115281. * @returns the serialized JSON
  115282. */
  115283. serialize(): any;
  115284. }
  115285. }
  115286. declare module BABYLON {
  115287. /**
  115288. * This represents one of the lens effect in a `lensFlareSystem`.
  115289. * It controls one of the indiviual texture used in the effect.
  115290. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115291. */
  115292. export class LensFlare {
  115293. /**
  115294. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115295. */
  115296. size: number;
  115297. /**
  115298. * 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.
  115299. */
  115300. position: number;
  115301. /**
  115302. * Define the lens color.
  115303. */
  115304. color: Color3;
  115305. /**
  115306. * Define the lens texture.
  115307. */
  115308. texture: Nullable<Texture>;
  115309. /**
  115310. * Define the alpha mode to render this particular lens.
  115311. */
  115312. alphaMode: number;
  115313. private _system;
  115314. /**
  115315. * Creates a new Lens Flare.
  115316. * This represents one of the lens effect in a `lensFlareSystem`.
  115317. * It controls one of the indiviual texture used in the effect.
  115318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115319. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115320. * @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.
  115321. * @param color Define the lens color
  115322. * @param imgUrl Define the lens texture url
  115323. * @param system Define the `lensFlareSystem` this flare is part of
  115324. * @returns The newly created Lens Flare
  115325. */
  115326. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115327. /**
  115328. * Instantiates a new Lens Flare.
  115329. * This represents one of the lens effect in a `lensFlareSystem`.
  115330. * It controls one of the indiviual texture used in the effect.
  115331. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115332. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115333. * @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.
  115334. * @param color Define the lens color
  115335. * @param imgUrl Define the lens texture url
  115336. * @param system Define the `lensFlareSystem` this flare is part of
  115337. */
  115338. constructor(
  115339. /**
  115340. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115341. */
  115342. size: number,
  115343. /**
  115344. * 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.
  115345. */
  115346. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115347. /**
  115348. * Dispose and release the lens flare with its associated resources.
  115349. */
  115350. dispose(): void;
  115351. }
  115352. }
  115353. declare module BABYLON {
  115354. interface AbstractScene {
  115355. /**
  115356. * The list of lens flare system added to the scene
  115357. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115358. */
  115359. lensFlareSystems: Array<LensFlareSystem>;
  115360. /**
  115361. * Removes the given lens flare system from this scene.
  115362. * @param toRemove The lens flare system to remove
  115363. * @returns The index of the removed lens flare system
  115364. */
  115365. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115366. /**
  115367. * Adds the given lens flare system to this scene
  115368. * @param newLensFlareSystem The lens flare system to add
  115369. */
  115370. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115371. /**
  115372. * Gets a lens flare system using its name
  115373. * @param name defines the name to look for
  115374. * @returns the lens flare system or null if not found
  115375. */
  115376. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115377. /**
  115378. * Gets a lens flare system using its id
  115379. * @param id defines the id to look for
  115380. * @returns the lens flare system or null if not found
  115381. */
  115382. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115383. }
  115384. /**
  115385. * Defines the lens flare scene component responsible to manage any lens flares
  115386. * in a given scene.
  115387. */
  115388. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115389. /**
  115390. * The component name helpfull to identify the component in the list of scene components.
  115391. */
  115392. readonly name: string;
  115393. /**
  115394. * The scene the component belongs to.
  115395. */
  115396. scene: Scene;
  115397. /**
  115398. * Creates a new instance of the component for the given scene
  115399. * @param scene Defines the scene to register the component in
  115400. */
  115401. constructor(scene: Scene);
  115402. /**
  115403. * Registers the component in a given scene
  115404. */
  115405. register(): void;
  115406. /**
  115407. * Rebuilds the elements related to this component in case of
  115408. * context lost for instance.
  115409. */
  115410. rebuild(): void;
  115411. /**
  115412. * Adds all the elements from the container to the scene
  115413. * @param container the container holding the elements
  115414. */
  115415. addFromContainer(container: AbstractScene): void;
  115416. /**
  115417. * Removes all the elements in the container from the scene
  115418. * @param container contains the elements to remove
  115419. * @param dispose if the removed element should be disposed (default: false)
  115420. */
  115421. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115422. /**
  115423. * Serializes the component data to the specified json object
  115424. * @param serializationObject The object to serialize to
  115425. */
  115426. serialize(serializationObject: any): void;
  115427. /**
  115428. * Disposes the component and the associated ressources.
  115429. */
  115430. dispose(): void;
  115431. private _draw;
  115432. }
  115433. }
  115434. declare module BABYLON {
  115435. /**
  115436. * Defines the shadow generator component responsible to manage any shadow generators
  115437. * in a given scene.
  115438. */
  115439. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115440. /**
  115441. * The component name helpfull to identify the component in the list of scene components.
  115442. */
  115443. readonly name: string;
  115444. /**
  115445. * The scene the component belongs to.
  115446. */
  115447. scene: Scene;
  115448. /**
  115449. * Creates a new instance of the component for the given scene
  115450. * @param scene Defines the scene to register the component in
  115451. */
  115452. constructor(scene: Scene);
  115453. /**
  115454. * Registers the component in a given scene
  115455. */
  115456. register(): void;
  115457. /**
  115458. * Rebuilds the elements related to this component in case of
  115459. * context lost for instance.
  115460. */
  115461. rebuild(): void;
  115462. /**
  115463. * Serializes the component data to the specified json object
  115464. * @param serializationObject The object to serialize to
  115465. */
  115466. serialize(serializationObject: any): void;
  115467. /**
  115468. * Adds all the elements from the container to the scene
  115469. * @param container the container holding the elements
  115470. */
  115471. addFromContainer(container: AbstractScene): void;
  115472. /**
  115473. * Removes all the elements in the container from the scene
  115474. * @param container contains the elements to remove
  115475. * @param dispose if the removed element should be disposed (default: false)
  115476. */
  115477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115478. /**
  115479. * Rebuilds the elements related to this component in case of
  115480. * context lost for instance.
  115481. */
  115482. dispose(): void;
  115483. private _gatherRenderTargets;
  115484. }
  115485. }
  115486. declare module BABYLON {
  115487. /**
  115488. * A point light is a light defined by an unique point in world space.
  115489. * The light is emitted in every direction from this point.
  115490. * A good example of a point light is a standard light bulb.
  115491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115492. */
  115493. export class PointLight extends ShadowLight {
  115494. private _shadowAngle;
  115495. /**
  115496. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115497. * This specifies what angle the shadow will use to be created.
  115498. *
  115499. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115500. */
  115501. /**
  115502. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115503. * This specifies what angle the shadow will use to be created.
  115504. *
  115505. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115506. */
  115507. shadowAngle: number;
  115508. /**
  115509. * Gets the direction if it has been set.
  115510. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115511. */
  115512. /**
  115513. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115514. */
  115515. direction: Vector3;
  115516. /**
  115517. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115518. * A PointLight emits the light in every direction.
  115519. * It can cast shadows.
  115520. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115521. * ```javascript
  115522. * var pointLight = new PointLight("pl", camera.position, scene);
  115523. * ```
  115524. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115525. * @param name The light friendly name
  115526. * @param position The position of the point light in the scene
  115527. * @param scene The scene the lights belongs to
  115528. */
  115529. constructor(name: string, position: Vector3, scene: Scene);
  115530. /**
  115531. * Returns the string "PointLight"
  115532. * @returns the class name
  115533. */
  115534. getClassName(): string;
  115535. /**
  115536. * Returns the integer 0.
  115537. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115538. */
  115539. getTypeID(): number;
  115540. /**
  115541. * Specifies wether or not the shadowmap should be a cube texture.
  115542. * @returns true if the shadowmap needs to be a cube texture.
  115543. */
  115544. needCube(): boolean;
  115545. /**
  115546. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115547. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115548. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115549. */
  115550. getShadowDirection(faceIndex?: number): Vector3;
  115551. /**
  115552. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115553. * - fov = PI / 2
  115554. * - aspect ratio : 1.0
  115555. * - z-near and far equal to the active camera minZ and maxZ.
  115556. * Returns the PointLight.
  115557. */
  115558. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115559. protected _buildUniformLayout(): void;
  115560. /**
  115561. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115562. * @param effect The effect to update
  115563. * @param lightIndex The index of the light in the effect to update
  115564. * @returns The point light
  115565. */
  115566. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115567. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115568. /**
  115569. * Prepares the list of defines specific to the light type.
  115570. * @param defines the list of defines
  115571. * @param lightIndex defines the index of the light for the effect
  115572. */
  115573. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115574. }
  115575. }
  115576. declare module BABYLON {
  115577. /**
  115578. * Header information of HDR texture files.
  115579. */
  115580. export interface HDRInfo {
  115581. /**
  115582. * The height of the texture in pixels.
  115583. */
  115584. height: number;
  115585. /**
  115586. * The width of the texture in pixels.
  115587. */
  115588. width: number;
  115589. /**
  115590. * The index of the beginning of the data in the binary file.
  115591. */
  115592. dataPosition: number;
  115593. }
  115594. /**
  115595. * This groups tools to convert HDR texture to native colors array.
  115596. */
  115597. export class HDRTools {
  115598. private static Ldexp;
  115599. private static Rgbe2float;
  115600. private static readStringLine;
  115601. /**
  115602. * Reads header information from an RGBE texture stored in a native array.
  115603. * More information on this format are available here:
  115604. * https://en.wikipedia.org/wiki/RGBE_image_format
  115605. *
  115606. * @param uint8array The binary file stored in native array.
  115607. * @return The header information.
  115608. */
  115609. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115610. /**
  115611. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115612. * This RGBE texture needs to store the information as a panorama.
  115613. *
  115614. * More information on this format are available here:
  115615. * https://en.wikipedia.org/wiki/RGBE_image_format
  115616. *
  115617. * @param buffer The binary file stored in an array buffer.
  115618. * @param size The expected size of the extracted cubemap.
  115619. * @return The Cube Map information.
  115620. */
  115621. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115622. /**
  115623. * Returns the pixels data extracted from an RGBE texture.
  115624. * This pixels will be stored left to right up to down in the R G B order in one array.
  115625. *
  115626. * More information on this format are available here:
  115627. * https://en.wikipedia.org/wiki/RGBE_image_format
  115628. *
  115629. * @param uint8array The binary file stored in an array buffer.
  115630. * @param hdrInfo The header information of the file.
  115631. * @return The pixels data in RGB right to left up to down order.
  115632. */
  115633. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115634. private static RGBE_ReadPixels_RLE;
  115635. }
  115636. }
  115637. declare module BABYLON {
  115638. /**
  115639. * This represents a texture coming from an HDR input.
  115640. *
  115641. * The only supported format is currently panorama picture stored in RGBE format.
  115642. * Example of such files can be found on HDRLib: http://hdrlib.com/
  115643. */
  115644. export class HDRCubeTexture extends BaseTexture {
  115645. private static _facesMapping;
  115646. private _generateHarmonics;
  115647. private _noMipmap;
  115648. private _textureMatrix;
  115649. private _size;
  115650. private _onLoad;
  115651. private _onError;
  115652. /**
  115653. * The texture URL.
  115654. */
  115655. url: string;
  115656. /**
  115657. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  115658. */
  115659. coordinatesMode: number;
  115660. protected _isBlocking: boolean;
  115661. /**
  115662. * Sets wether or not the texture is blocking during loading.
  115663. */
  115664. /**
  115665. * Gets wether or not the texture is blocking during loading.
  115666. */
  115667. isBlocking: boolean;
  115668. protected _rotationY: number;
  115669. /**
  115670. * Sets texture matrix rotation angle around Y axis in radians.
  115671. */
  115672. /**
  115673. * Gets texture matrix rotation angle around Y axis radians.
  115674. */
  115675. rotationY: number;
  115676. /**
  115677. * Gets or sets the center of the bounding box associated with the cube texture
  115678. * It must define where the camera used to render the texture was set
  115679. */
  115680. boundingBoxPosition: Vector3;
  115681. private _boundingBoxSize;
  115682. /**
  115683. * Gets or sets the size of the bounding box associated with the cube texture
  115684. * When defined, the cubemap will switch to local mode
  115685. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  115686. * @example https://www.babylonjs-playground.com/#RNASML
  115687. */
  115688. boundingBoxSize: Vector3;
  115689. /**
  115690. * Instantiates an HDRTexture from the following parameters.
  115691. *
  115692. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  115693. * @param scene The scene the texture will be used in
  115694. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115695. * @param noMipmap Forces to not generate the mipmap if true
  115696. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  115697. * @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)
  115698. * @param reserved Reserved flag for internal use.
  115699. */
  115700. 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>);
  115701. /**
  115702. * Get the current class name of the texture useful for serialization or dynamic coding.
  115703. * @returns "HDRCubeTexture"
  115704. */
  115705. getClassName(): string;
  115706. /**
  115707. * Occurs when the file is raw .hdr file.
  115708. */
  115709. private loadTexture;
  115710. clone(): HDRCubeTexture;
  115711. delayLoad(): void;
  115712. /**
  115713. * Get the texture reflection matrix used to rotate/transform the reflection.
  115714. * @returns the reflection matrix
  115715. */
  115716. getReflectionTextureMatrix(): Matrix;
  115717. /**
  115718. * Set the texture reflection matrix used to rotate/transform the reflection.
  115719. * @param value Define the reflection matrix to set
  115720. */
  115721. setReflectionTextureMatrix(value: Matrix): void;
  115722. /**
  115723. * Parses a JSON representation of an HDR Texture in order to create the texture
  115724. * @param parsedTexture Define the JSON representation
  115725. * @param scene Define the scene the texture should be created in
  115726. * @param rootUrl Define the root url in case we need to load relative dependencies
  115727. * @returns the newly created texture after parsing
  115728. */
  115729. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  115730. serialize(): any;
  115731. }
  115732. }
  115733. declare module BABYLON {
  115734. /**
  115735. * Class used to control physics engine
  115736. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115737. */
  115738. export class PhysicsEngine implements IPhysicsEngine {
  115739. private _physicsPlugin;
  115740. /**
  115741. * Global value used to control the smallest number supported by the simulation
  115742. */
  115743. static Epsilon: number;
  115744. private _impostors;
  115745. private _joints;
  115746. /**
  115747. * Gets the gravity vector used by the simulation
  115748. */
  115749. gravity: Vector3;
  115750. /**
  115751. * Factory used to create the default physics plugin.
  115752. * @returns The default physics plugin
  115753. */
  115754. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  115755. /**
  115756. * Creates a new Physics Engine
  115757. * @param gravity defines the gravity vector used by the simulation
  115758. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  115759. */
  115760. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  115761. /**
  115762. * Sets the gravity vector used by the simulation
  115763. * @param gravity defines the gravity vector to use
  115764. */
  115765. setGravity(gravity: Vector3): void;
  115766. /**
  115767. * Set the time step of the physics engine.
  115768. * Default is 1/60.
  115769. * To slow it down, enter 1/600 for example.
  115770. * To speed it up, 1/30
  115771. * @param newTimeStep defines the new timestep to apply to this world.
  115772. */
  115773. setTimeStep(newTimeStep?: number): void;
  115774. /**
  115775. * Get the time step of the physics engine.
  115776. * @returns the current time step
  115777. */
  115778. getTimeStep(): number;
  115779. /**
  115780. * Release all resources
  115781. */
  115782. dispose(): void;
  115783. /**
  115784. * Gets the name of the current physics plugin
  115785. * @returns the name of the plugin
  115786. */
  115787. getPhysicsPluginName(): string;
  115788. /**
  115789. * Adding a new impostor for the impostor tracking.
  115790. * This will be done by the impostor itself.
  115791. * @param impostor the impostor to add
  115792. */
  115793. addImpostor(impostor: PhysicsImpostor): void;
  115794. /**
  115795. * Remove an impostor from the engine.
  115796. * This impostor and its mesh will not longer be updated by the physics engine.
  115797. * @param impostor the impostor to remove
  115798. */
  115799. removeImpostor(impostor: PhysicsImpostor): void;
  115800. /**
  115801. * Add a joint to the physics engine
  115802. * @param mainImpostor defines the main impostor to which the joint is added.
  115803. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115804. * @param joint defines the joint that will connect both impostors.
  115805. */
  115806. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115807. /**
  115808. * Removes a joint from the simulation
  115809. * @param mainImpostor defines the impostor used with the joint
  115810. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115811. * @param joint defines the joint to remove
  115812. */
  115813. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115814. /**
  115815. * Called by the scene. No need to call it.
  115816. * @param delta defines the timespam between frames
  115817. */
  115818. _step(delta: number): void;
  115819. /**
  115820. * Gets the current plugin used to run the simulation
  115821. * @returns current plugin
  115822. */
  115823. getPhysicsPlugin(): IPhysicsEnginePlugin;
  115824. /**
  115825. * Gets the list of physic impostors
  115826. * @returns an array of PhysicsImpostor
  115827. */
  115828. getImpostors(): Array<PhysicsImpostor>;
  115829. /**
  115830. * Gets the impostor for a physics enabled object
  115831. * @param object defines the object impersonated by the impostor
  115832. * @returns the PhysicsImpostor or null if not found
  115833. */
  115834. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  115835. /**
  115836. * Gets the impostor for a physics body object
  115837. * @param body defines physics body used by the impostor
  115838. * @returns the PhysicsImpostor or null if not found
  115839. */
  115840. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  115841. /**
  115842. * Does a raycast in the physics world
  115843. * @param from when should the ray start?
  115844. * @param to when should the ray end?
  115845. * @returns PhysicsRaycastResult
  115846. */
  115847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115848. }
  115849. }
  115850. declare module BABYLON {
  115851. /** @hidden */
  115852. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  115853. private _useDeltaForWorldStep;
  115854. world: any;
  115855. name: string;
  115856. private _physicsMaterials;
  115857. private _fixedTimeStep;
  115858. private _cannonRaycastResult;
  115859. private _raycastResult;
  115860. private _physicsBodysToRemoveAfterStep;
  115861. BJSCANNON: any;
  115862. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  115863. setGravity(gravity: Vector3): void;
  115864. setTimeStep(timeStep: number): void;
  115865. getTimeStep(): number;
  115866. executeStep(delta: number): void;
  115867. private _removeMarkedPhysicsBodiesFromWorld;
  115868. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115869. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115870. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115871. private _processChildMeshes;
  115872. removePhysicsBody(impostor: PhysicsImpostor): void;
  115873. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115874. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115875. private _addMaterial;
  115876. private _checkWithEpsilon;
  115877. private _createShape;
  115878. private _createHeightmap;
  115879. private _minus90X;
  115880. private _plus90X;
  115881. private _tmpPosition;
  115882. private _tmpDeltaPosition;
  115883. private _tmpUnityRotation;
  115884. private _updatePhysicsBodyTransformation;
  115885. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115886. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115887. isSupported(): boolean;
  115888. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115889. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115890. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115891. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115893. getBodyMass(impostor: PhysicsImpostor): number;
  115894. getBodyFriction(impostor: PhysicsImpostor): number;
  115895. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115896. getBodyRestitution(impostor: PhysicsImpostor): number;
  115897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115898. sleepBody(impostor: PhysicsImpostor): void;
  115899. wakeUpBody(impostor: PhysicsImpostor): void;
  115900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115901. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115903. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115904. getRadius(impostor: PhysicsImpostor): number;
  115905. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115906. dispose(): void;
  115907. private _extendNamespace;
  115908. /**
  115909. * Does a raycast in the physics world
  115910. * @param from when should the ray start?
  115911. * @param to when should the ray end?
  115912. * @returns PhysicsRaycastResult
  115913. */
  115914. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115915. }
  115916. }
  115917. declare module BABYLON {
  115918. /** @hidden */
  115919. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115920. world: any;
  115921. name: string;
  115922. BJSOIMO: any;
  115923. private _raycastResult;
  115924. constructor(iterations?: number, oimoInjection?: any);
  115925. setGravity(gravity: Vector3): void;
  115926. setTimeStep(timeStep: number): void;
  115927. getTimeStep(): number;
  115928. private _tmpImpostorsArray;
  115929. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115930. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115931. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115932. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115933. private _tmpPositionVector;
  115934. removePhysicsBody(impostor: PhysicsImpostor): void;
  115935. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115936. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115937. isSupported(): boolean;
  115938. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115939. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115940. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115941. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115942. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115943. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115944. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115945. getBodyMass(impostor: PhysicsImpostor): number;
  115946. getBodyFriction(impostor: PhysicsImpostor): number;
  115947. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115948. getBodyRestitution(impostor: PhysicsImpostor): number;
  115949. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115950. sleepBody(impostor: PhysicsImpostor): void;
  115951. wakeUpBody(impostor: PhysicsImpostor): void;
  115952. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115953. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115954. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115955. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115956. getRadius(impostor: PhysicsImpostor): number;
  115957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115958. dispose(): void;
  115959. /**
  115960. * Does a raycast in the physics world
  115961. * @param from when should the ray start?
  115962. * @param to when should the ray end?
  115963. * @returns PhysicsRaycastResult
  115964. */
  115965. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115966. }
  115967. }
  115968. declare module BABYLON {
  115969. /**
  115970. * Class containing static functions to help procedurally build meshes
  115971. */
  115972. export class RibbonBuilder {
  115973. /**
  115974. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115975. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115976. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115977. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115978. * * 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
  115979. * * 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
  115980. * * 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
  115981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115984. * * 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
  115985. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115986. * * 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
  115987. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115989. * @param name defines the name of the mesh
  115990. * @param options defines the options used to create the mesh
  115991. * @param scene defines the hosting scene
  115992. * @returns the ribbon mesh
  115993. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115995. */
  115996. static CreateRibbon(name: string, options: {
  115997. pathArray: Vector3[][];
  115998. closeArray?: boolean;
  115999. closePath?: boolean;
  116000. offset?: number;
  116001. updatable?: boolean;
  116002. sideOrientation?: number;
  116003. frontUVs?: Vector4;
  116004. backUVs?: Vector4;
  116005. instance?: Mesh;
  116006. invertUV?: boolean;
  116007. uvs?: Vector2[];
  116008. colors?: Color4[];
  116009. }, scene?: Nullable<Scene>): Mesh;
  116010. }
  116011. }
  116012. declare module BABYLON {
  116013. /**
  116014. * Class containing static functions to help procedurally build meshes
  116015. */
  116016. export class ShapeBuilder {
  116017. /**
  116018. * 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.
  116019. * * 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.
  116020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116021. * * 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.
  116022. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116023. * * 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
  116024. * * 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
  116025. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116030. * @param name defines the name of the mesh
  116031. * @param options defines the options used to create the mesh
  116032. * @param scene defines the hosting scene
  116033. * @returns the extruded shape mesh
  116034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116035. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116036. */
  116037. static ExtrudeShape(name: string, options: {
  116038. shape: Vector3[];
  116039. path: Vector3[];
  116040. scale?: number;
  116041. rotation?: number;
  116042. cap?: number;
  116043. updatable?: boolean;
  116044. sideOrientation?: number;
  116045. frontUVs?: Vector4;
  116046. backUVs?: Vector4;
  116047. instance?: Mesh;
  116048. invertUV?: boolean;
  116049. }, scene?: Nullable<Scene>): Mesh;
  116050. /**
  116051. * Creates an custom extruded shape mesh.
  116052. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116053. * * 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.
  116054. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116055. * * 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
  116056. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116057. * * 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
  116058. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116059. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116060. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116061. * * 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
  116062. * * 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
  116063. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116068. * @param name defines the name of the mesh
  116069. * @param options defines the options used to create the mesh
  116070. * @param scene defines the hosting scene
  116071. * @returns the custom extruded shape mesh
  116072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116075. */
  116076. static ExtrudeShapeCustom(name: string, options: {
  116077. shape: Vector3[];
  116078. path: Vector3[];
  116079. scaleFunction?: any;
  116080. rotationFunction?: any;
  116081. ribbonCloseArray?: boolean;
  116082. ribbonClosePath?: boolean;
  116083. cap?: number;
  116084. updatable?: boolean;
  116085. sideOrientation?: number;
  116086. frontUVs?: Vector4;
  116087. backUVs?: Vector4;
  116088. instance?: Mesh;
  116089. invertUV?: boolean;
  116090. }, scene?: Nullable<Scene>): Mesh;
  116091. private static _ExtrudeShapeGeneric;
  116092. }
  116093. }
  116094. declare module BABYLON {
  116095. /**
  116096. * AmmoJS Physics plugin
  116097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116098. * @see https://github.com/kripken/ammo.js/
  116099. */
  116100. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116101. private _useDeltaForWorldStep;
  116102. /**
  116103. * Reference to the Ammo library
  116104. */
  116105. bjsAMMO: any;
  116106. /**
  116107. * Created ammoJS world which physics bodies are added to
  116108. */
  116109. world: any;
  116110. /**
  116111. * Name of the plugin
  116112. */
  116113. name: string;
  116114. private _timeStep;
  116115. private _fixedTimeStep;
  116116. private _maxSteps;
  116117. private _tmpQuaternion;
  116118. private _tmpAmmoTransform;
  116119. private _tmpAmmoQuaternion;
  116120. private _tmpAmmoConcreteContactResultCallback;
  116121. private _collisionConfiguration;
  116122. private _dispatcher;
  116123. private _overlappingPairCache;
  116124. private _solver;
  116125. private _softBodySolver;
  116126. private _tmpAmmoVectorA;
  116127. private _tmpAmmoVectorB;
  116128. private _tmpAmmoVectorC;
  116129. private _tmpAmmoVectorD;
  116130. private _tmpContactCallbackResult;
  116131. private _tmpAmmoVectorRCA;
  116132. private _tmpAmmoVectorRCB;
  116133. private _raycastResult;
  116134. private static readonly DISABLE_COLLISION_FLAG;
  116135. private static readonly KINEMATIC_FLAG;
  116136. private static readonly DISABLE_DEACTIVATION_FLAG;
  116137. /**
  116138. * Initializes the ammoJS plugin
  116139. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116140. * @param ammoInjection can be used to inject your own ammo reference
  116141. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116142. */
  116143. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116144. /**
  116145. * Sets the gravity of the physics world (m/(s^2))
  116146. * @param gravity Gravity to set
  116147. */
  116148. setGravity(gravity: Vector3): void;
  116149. /**
  116150. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116151. * @param timeStep timestep to use in seconds
  116152. */
  116153. setTimeStep(timeStep: number): void;
  116154. /**
  116155. * 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)
  116156. * @param fixedTimeStep fixedTimeStep to use in seconds
  116157. */
  116158. setFixedTimeStep(fixedTimeStep: number): void;
  116159. /**
  116160. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116161. * @param maxSteps the maximum number of steps by the physics engine per frame
  116162. */
  116163. setMaxSteps(maxSteps: number): void;
  116164. /**
  116165. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116166. * @returns the current timestep in seconds
  116167. */
  116168. getTimeStep(): number;
  116169. private _isImpostorInContact;
  116170. private _isImpostorPairInContact;
  116171. private _stepSimulation;
  116172. /**
  116173. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116174. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116175. * After the step the babylon meshes are set to the position of the physics imposters
  116176. * @param delta amount of time to step forward
  116177. * @param impostors array of imposters to update before/after the step
  116178. */
  116179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116180. /**
  116181. * Update babylon mesh to match physics world object
  116182. * @param impostor imposter to match
  116183. */
  116184. private _afterSoftStep;
  116185. /**
  116186. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116187. * @param impostor imposter to match
  116188. */
  116189. private _ropeStep;
  116190. /**
  116191. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116192. * @param impostor imposter to match
  116193. */
  116194. private _softbodyOrClothStep;
  116195. private _tmpVector;
  116196. private _tmpMatrix;
  116197. /**
  116198. * Applies an impulse on the imposter
  116199. * @param impostor imposter to apply impulse to
  116200. * @param force amount of force to be applied to the imposter
  116201. * @param contactPoint the location to apply the impulse on the imposter
  116202. */
  116203. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116204. /**
  116205. * Applies a force on the imposter
  116206. * @param impostor imposter to apply force
  116207. * @param force amount of force to be applied to the imposter
  116208. * @param contactPoint the location to apply the force on the imposter
  116209. */
  116210. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116211. /**
  116212. * Creates a physics body using the plugin
  116213. * @param impostor the imposter to create the physics body on
  116214. */
  116215. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116216. /**
  116217. * Removes the physics body from the imposter and disposes of the body's memory
  116218. * @param impostor imposter to remove the physics body from
  116219. */
  116220. removePhysicsBody(impostor: PhysicsImpostor): void;
  116221. /**
  116222. * Generates a joint
  116223. * @param impostorJoint the imposter joint to create the joint with
  116224. */
  116225. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116226. /**
  116227. * Removes a joint
  116228. * @param impostorJoint the imposter joint to remove the joint from
  116229. */
  116230. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116231. private _addMeshVerts;
  116232. /**
  116233. * Initialise the soft body vertices to match its object's (mesh) vertices
  116234. * Softbody vertices (nodes) are in world space and to match this
  116235. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116236. * @param impostor to create the softbody for
  116237. */
  116238. private _softVertexData;
  116239. /**
  116240. * Create an impostor's soft body
  116241. * @param impostor to create the softbody for
  116242. */
  116243. private _createSoftbody;
  116244. /**
  116245. * Create cloth for an impostor
  116246. * @param impostor to create the softbody for
  116247. */
  116248. private _createCloth;
  116249. /**
  116250. * Create rope for an impostor
  116251. * @param impostor to create the softbody for
  116252. */
  116253. private _createRope;
  116254. private _addHullVerts;
  116255. private _createShape;
  116256. /**
  116257. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116258. * @param impostor imposter containing the physics body and babylon object
  116259. */
  116260. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116261. /**
  116262. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116263. * @param impostor imposter containing the physics body and babylon object
  116264. * @param newPosition new position
  116265. * @param newRotation new rotation
  116266. */
  116267. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116268. /**
  116269. * If this plugin is supported
  116270. * @returns true if its supported
  116271. */
  116272. isSupported(): boolean;
  116273. /**
  116274. * Sets the linear velocity of the physics body
  116275. * @param impostor imposter to set the velocity on
  116276. * @param velocity velocity to set
  116277. */
  116278. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116279. /**
  116280. * Sets the angular velocity of the physics body
  116281. * @param impostor imposter to set the velocity on
  116282. * @param velocity velocity to set
  116283. */
  116284. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116285. /**
  116286. * gets the linear velocity
  116287. * @param impostor imposter to get linear velocity from
  116288. * @returns linear velocity
  116289. */
  116290. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116291. /**
  116292. * gets the angular velocity
  116293. * @param impostor imposter to get angular velocity from
  116294. * @returns angular velocity
  116295. */
  116296. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116297. /**
  116298. * Sets the mass of physics body
  116299. * @param impostor imposter to set the mass on
  116300. * @param mass mass to set
  116301. */
  116302. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116303. /**
  116304. * Gets the mass of the physics body
  116305. * @param impostor imposter to get the mass from
  116306. * @returns mass
  116307. */
  116308. getBodyMass(impostor: PhysicsImpostor): number;
  116309. /**
  116310. * Gets friction of the impostor
  116311. * @param impostor impostor to get friction from
  116312. * @returns friction value
  116313. */
  116314. getBodyFriction(impostor: PhysicsImpostor): number;
  116315. /**
  116316. * Sets friction of the impostor
  116317. * @param impostor impostor to set friction on
  116318. * @param friction friction value
  116319. */
  116320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116321. /**
  116322. * Gets restitution of the impostor
  116323. * @param impostor impostor to get restitution from
  116324. * @returns restitution value
  116325. */
  116326. getBodyRestitution(impostor: PhysicsImpostor): number;
  116327. /**
  116328. * Sets resitution of the impostor
  116329. * @param impostor impostor to set resitution on
  116330. * @param restitution resitution value
  116331. */
  116332. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116333. /**
  116334. * Gets pressure inside the impostor
  116335. * @param impostor impostor to get pressure from
  116336. * @returns pressure value
  116337. */
  116338. getBodyPressure(impostor: PhysicsImpostor): number;
  116339. /**
  116340. * Sets pressure inside a soft body impostor
  116341. * Cloth and rope must remain 0 pressure
  116342. * @param impostor impostor to set pressure on
  116343. * @param pressure pressure value
  116344. */
  116345. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116346. /**
  116347. * Gets stiffness of the impostor
  116348. * @param impostor impostor to get stiffness from
  116349. * @returns pressure value
  116350. */
  116351. getBodyStiffness(impostor: PhysicsImpostor): number;
  116352. /**
  116353. * Sets stiffness of the impostor
  116354. * @param impostor impostor to set stiffness on
  116355. * @param stiffness stiffness value from 0 to 1
  116356. */
  116357. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116358. /**
  116359. * Gets velocityIterations of the impostor
  116360. * @param impostor impostor to get velocity iterations from
  116361. * @returns velocityIterations value
  116362. */
  116363. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116364. /**
  116365. * Sets velocityIterations of the impostor
  116366. * @param impostor impostor to set velocity iterations on
  116367. * @param velocityIterations velocityIterations value
  116368. */
  116369. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116370. /**
  116371. * Gets positionIterations of the impostor
  116372. * @param impostor impostor to get position iterations from
  116373. * @returns positionIterations value
  116374. */
  116375. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116376. /**
  116377. * Sets positionIterations of the impostor
  116378. * @param impostor impostor to set position on
  116379. * @param positionIterations positionIterations value
  116380. */
  116381. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116382. /**
  116383. * Append an anchor to a cloth object
  116384. * @param impostor is the cloth impostor to add anchor to
  116385. * @param otherImpostor is the rigid impostor to anchor to
  116386. * @param width ratio across width from 0 to 1
  116387. * @param height ratio up height from 0 to 1
  116388. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116389. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116390. */
  116391. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116392. /**
  116393. * Append an hook to a rope object
  116394. * @param impostor is the rope impostor to add hook to
  116395. * @param otherImpostor is the rigid impostor to hook to
  116396. * @param length ratio along the rope from 0 to 1
  116397. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116398. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116399. */
  116400. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116401. /**
  116402. * Sleeps the physics body and stops it from being active
  116403. * @param impostor impostor to sleep
  116404. */
  116405. sleepBody(impostor: PhysicsImpostor): void;
  116406. /**
  116407. * Activates the physics body
  116408. * @param impostor impostor to activate
  116409. */
  116410. wakeUpBody(impostor: PhysicsImpostor): void;
  116411. /**
  116412. * Updates the distance parameters of the joint
  116413. * @param joint joint to update
  116414. * @param maxDistance maximum distance of the joint
  116415. * @param minDistance minimum distance of the joint
  116416. */
  116417. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116418. /**
  116419. * Sets a motor on the joint
  116420. * @param joint joint to set motor on
  116421. * @param speed speed of the motor
  116422. * @param maxForce maximum force of the motor
  116423. * @param motorIndex index of the motor
  116424. */
  116425. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116426. /**
  116427. * Sets the motors limit
  116428. * @param joint joint to set limit on
  116429. * @param upperLimit upper limit
  116430. * @param lowerLimit lower limit
  116431. */
  116432. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116433. /**
  116434. * Syncs the position and rotation of a mesh with the impostor
  116435. * @param mesh mesh to sync
  116436. * @param impostor impostor to update the mesh with
  116437. */
  116438. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116439. /**
  116440. * Gets the radius of the impostor
  116441. * @param impostor impostor to get radius from
  116442. * @returns the radius
  116443. */
  116444. getRadius(impostor: PhysicsImpostor): number;
  116445. /**
  116446. * Gets the box size of the impostor
  116447. * @param impostor impostor to get box size from
  116448. * @param result the resulting box size
  116449. */
  116450. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116451. /**
  116452. * Disposes of the impostor
  116453. */
  116454. dispose(): void;
  116455. /**
  116456. * Does a raycast in the physics world
  116457. * @param from when should the ray start?
  116458. * @param to when should the ray end?
  116459. * @returns PhysicsRaycastResult
  116460. */
  116461. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116462. }
  116463. }
  116464. declare module BABYLON {
  116465. interface AbstractScene {
  116466. /**
  116467. * The list of reflection probes added to the scene
  116468. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116469. */
  116470. reflectionProbes: Array<ReflectionProbe>;
  116471. /**
  116472. * Removes the given reflection probe from this scene.
  116473. * @param toRemove The reflection probe to remove
  116474. * @returns The index of the removed reflection probe
  116475. */
  116476. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116477. /**
  116478. * Adds the given reflection probe to this scene.
  116479. * @param newReflectionProbe The reflection probe to add
  116480. */
  116481. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116482. }
  116483. /**
  116484. * Class used to generate realtime reflection / refraction cube textures
  116485. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116486. */
  116487. export class ReflectionProbe {
  116488. /** defines the name of the probe */
  116489. name: string;
  116490. private _scene;
  116491. private _renderTargetTexture;
  116492. private _projectionMatrix;
  116493. private _viewMatrix;
  116494. private _target;
  116495. private _add;
  116496. private _attachedMesh;
  116497. private _invertYAxis;
  116498. /** Gets or sets probe position (center of the cube map) */
  116499. position: Vector3;
  116500. /**
  116501. * Creates a new reflection probe
  116502. * @param name defines the name of the probe
  116503. * @param size defines the texture resolution (for each face)
  116504. * @param scene defines the hosting scene
  116505. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116506. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116507. */
  116508. constructor(
  116509. /** defines the name of the probe */
  116510. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116511. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116512. samples: number;
  116513. /** Gets or sets the refresh rate to use (on every frame by default) */
  116514. refreshRate: number;
  116515. /**
  116516. * Gets the hosting scene
  116517. * @returns a Scene
  116518. */
  116519. getScene(): Scene;
  116520. /** Gets the internal CubeTexture used to render to */
  116521. readonly cubeTexture: RenderTargetTexture;
  116522. /** Gets the list of meshes to render */
  116523. readonly renderList: Nullable<AbstractMesh[]>;
  116524. /**
  116525. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116526. * @param mesh defines the mesh to attach to
  116527. */
  116528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116529. /**
  116530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116531. * @param renderingGroupId The rendering group id corresponding to its index
  116532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116533. */
  116534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116535. /**
  116536. * Clean all associated resources
  116537. */
  116538. dispose(): void;
  116539. /**
  116540. * Converts the reflection probe information to a readable string for debug purpose.
  116541. * @param fullDetails Supports for multiple levels of logging within scene loading
  116542. * @returns the human readable reflection probe info
  116543. */
  116544. toString(fullDetails?: boolean): string;
  116545. /**
  116546. * Get the class name of the relfection probe.
  116547. * @returns "ReflectionProbe"
  116548. */
  116549. getClassName(): string;
  116550. /**
  116551. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116552. * @returns The JSON representation of the texture
  116553. */
  116554. serialize(): any;
  116555. /**
  116556. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116557. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116558. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116560. * @returns The parsed reflection probe if successful
  116561. */
  116562. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116563. }
  116564. }
  116565. declare module BABYLON {
  116566. /** @hidden */
  116567. export var _BabylonLoaderRegistered: boolean;
  116568. }
  116569. declare module BABYLON {
  116570. /**
  116571. * The Physically based simple base material of BJS.
  116572. *
  116573. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116574. * It is used as the base class for both the specGloss and metalRough conventions.
  116575. */
  116576. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116577. /**
  116578. * Number of Simultaneous lights allowed on the material.
  116579. */
  116580. maxSimultaneousLights: number;
  116581. /**
  116582. * If sets to true, disables all the lights affecting the material.
  116583. */
  116584. disableLighting: boolean;
  116585. /**
  116586. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116587. */
  116588. environmentTexture: BaseTexture;
  116589. /**
  116590. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116591. */
  116592. invertNormalMapX: boolean;
  116593. /**
  116594. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116595. */
  116596. invertNormalMapY: boolean;
  116597. /**
  116598. * Normal map used in the model.
  116599. */
  116600. normalTexture: BaseTexture;
  116601. /**
  116602. * Emissivie color used to self-illuminate the model.
  116603. */
  116604. emissiveColor: Color3;
  116605. /**
  116606. * Emissivie texture used to self-illuminate the model.
  116607. */
  116608. emissiveTexture: BaseTexture;
  116609. /**
  116610. * Occlusion Channel Strenght.
  116611. */
  116612. occlusionStrength: number;
  116613. /**
  116614. * Occlusion Texture of the material (adding extra occlusion effects).
  116615. */
  116616. occlusionTexture: BaseTexture;
  116617. /**
  116618. * Defines the alpha limits in alpha test mode.
  116619. */
  116620. alphaCutOff: number;
  116621. /**
  116622. * Gets the current double sided mode.
  116623. */
  116624. /**
  116625. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116626. */
  116627. doubleSided: boolean;
  116628. /**
  116629. * Stores the pre-calculated light information of a mesh in a texture.
  116630. */
  116631. lightmapTexture: BaseTexture;
  116632. /**
  116633. * If true, the light map contains occlusion information instead of lighting info.
  116634. */
  116635. useLightmapAsShadowmap: boolean;
  116636. /**
  116637. * Instantiates a new PBRMaterial instance.
  116638. *
  116639. * @param name The material name
  116640. * @param scene The scene the material will be use in.
  116641. */
  116642. constructor(name: string, scene: Scene);
  116643. getClassName(): string;
  116644. }
  116645. }
  116646. declare module BABYLON {
  116647. /**
  116648. * The PBR material of BJS following the metal roughness convention.
  116649. *
  116650. * This fits to the PBR convention in the GLTF definition:
  116651. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  116652. */
  116653. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  116654. /**
  116655. * The base color has two different interpretations depending on the value of metalness.
  116656. * When the material is a metal, the base color is the specific measured reflectance value
  116657. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  116658. * of the material.
  116659. */
  116660. baseColor: Color3;
  116661. /**
  116662. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  116663. * well as opacity information in the alpha channel.
  116664. */
  116665. baseTexture: BaseTexture;
  116666. /**
  116667. * Specifies the metallic scalar value of the material.
  116668. * Can also be used to scale the metalness values of the metallic texture.
  116669. */
  116670. metallic: number;
  116671. /**
  116672. * Specifies the roughness scalar value of the material.
  116673. * Can also be used to scale the roughness values of the metallic texture.
  116674. */
  116675. roughness: number;
  116676. /**
  116677. * Texture containing both the metallic value in the B channel and the
  116678. * roughness value in the G channel to keep better precision.
  116679. */
  116680. metallicRoughnessTexture: BaseTexture;
  116681. /**
  116682. * Instantiates a new PBRMetalRoughnessMaterial instance.
  116683. *
  116684. * @param name The material name
  116685. * @param scene The scene the material will be use in.
  116686. */
  116687. constructor(name: string, scene: Scene);
  116688. /**
  116689. * Return the currrent class name of the material.
  116690. */
  116691. getClassName(): string;
  116692. /**
  116693. * Makes a duplicate of the current material.
  116694. * @param name - name to use for the new material.
  116695. */
  116696. clone(name: string): PBRMetallicRoughnessMaterial;
  116697. /**
  116698. * Serialize the material to a parsable JSON object.
  116699. */
  116700. serialize(): any;
  116701. /**
  116702. * Parses a JSON object correponding to the serialize function.
  116703. */
  116704. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  116705. }
  116706. }
  116707. declare module BABYLON {
  116708. /**
  116709. * The PBR material of BJS following the specular glossiness convention.
  116710. *
  116711. * This fits to the PBR convention in the GLTF definition:
  116712. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  116713. */
  116714. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  116715. /**
  116716. * Specifies the diffuse color of the material.
  116717. */
  116718. diffuseColor: Color3;
  116719. /**
  116720. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  116721. * channel.
  116722. */
  116723. diffuseTexture: BaseTexture;
  116724. /**
  116725. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  116726. */
  116727. specularColor: Color3;
  116728. /**
  116729. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  116730. */
  116731. glossiness: number;
  116732. /**
  116733. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  116734. */
  116735. specularGlossinessTexture: BaseTexture;
  116736. /**
  116737. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  116738. *
  116739. * @param name The material name
  116740. * @param scene The scene the material will be use in.
  116741. */
  116742. constructor(name: string, scene: Scene);
  116743. /**
  116744. * Return the currrent class name of the material.
  116745. */
  116746. getClassName(): string;
  116747. /**
  116748. * Makes a duplicate of the current material.
  116749. * @param name - name to use for the new material.
  116750. */
  116751. clone(name: string): PBRSpecularGlossinessMaterial;
  116752. /**
  116753. * Serialize the material to a parsable JSON object.
  116754. */
  116755. serialize(): any;
  116756. /**
  116757. * Parses a JSON object correponding to the serialize function.
  116758. */
  116759. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  116760. }
  116761. }
  116762. declare module BABYLON {
  116763. /**
  116764. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  116765. * It can help converting any input color in a desired output one. This can then be used to create effects
  116766. * from sepia, black and white to sixties or futuristic rendering...
  116767. *
  116768. * The only supported format is currently 3dl.
  116769. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  116770. */
  116771. export class ColorGradingTexture extends BaseTexture {
  116772. /**
  116773. * The current texture matrix. (will always be identity in color grading texture)
  116774. */
  116775. private _textureMatrix;
  116776. /**
  116777. * The texture URL.
  116778. */
  116779. url: string;
  116780. /**
  116781. * Empty line regex stored for GC.
  116782. */
  116783. private static _noneEmptyLineRegex;
  116784. private _engine;
  116785. /**
  116786. * Instantiates a ColorGradingTexture from the following parameters.
  116787. *
  116788. * @param url The location of the color gradind data (currently only supporting 3dl)
  116789. * @param scene The scene the texture will be used in
  116790. */
  116791. constructor(url: string, scene: Scene);
  116792. /**
  116793. * Returns the texture matrix used in most of the material.
  116794. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  116795. */
  116796. getTextureMatrix(): Matrix;
  116797. /**
  116798. * Occurs when the file being loaded is a .3dl LUT file.
  116799. */
  116800. private load3dlTexture;
  116801. /**
  116802. * Starts the loading process of the texture.
  116803. */
  116804. private loadTexture;
  116805. /**
  116806. * Clones the color gradind texture.
  116807. */
  116808. clone(): ColorGradingTexture;
  116809. /**
  116810. * Called during delayed load for textures.
  116811. */
  116812. delayLoad(): void;
  116813. /**
  116814. * Parses a color grading texture serialized by Babylon.
  116815. * @param parsedTexture The texture information being parsedTexture
  116816. * @param scene The scene to load the texture in
  116817. * @param rootUrl The root url of the data assets to load
  116818. * @return A color gradind texture
  116819. */
  116820. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  116821. /**
  116822. * Serializes the LUT texture to json format.
  116823. */
  116824. serialize(): any;
  116825. }
  116826. }
  116827. declare module BABYLON {
  116828. /**
  116829. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  116830. */
  116831. export class EquiRectangularCubeTexture extends BaseTexture {
  116832. /** The six faces of the cube. */
  116833. private static _FacesMapping;
  116834. private _noMipmap;
  116835. private _onLoad;
  116836. private _onError;
  116837. /** The size of the cubemap. */
  116838. private _size;
  116839. /** The buffer of the image. */
  116840. private _buffer;
  116841. /** The width of the input image. */
  116842. private _width;
  116843. /** The height of the input image. */
  116844. private _height;
  116845. /** The URL to the image. */
  116846. url: string;
  116847. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  116848. coordinatesMode: number;
  116849. /**
  116850. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  116851. * @param url The location of the image
  116852. * @param scene The scene the texture will be used in
  116853. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116854. * @param noMipmap Forces to not generate the mipmap if true
  116855. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  116856. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  116857. * @param onLoad — defines a callback called when texture is loaded
  116858. * @param onError — defines a callback called if there is an error
  116859. */
  116860. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  116861. /**
  116862. * Load the image data, by putting the image on a canvas and extracting its buffer.
  116863. */
  116864. private loadImage;
  116865. /**
  116866. * Convert the image buffer into a cubemap and create a CubeTexture.
  116867. */
  116868. private loadTexture;
  116869. /**
  116870. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  116871. * @param buffer The ArrayBuffer that should be converted.
  116872. * @returns The buffer as Float32Array.
  116873. */
  116874. private getFloat32ArrayFromArrayBuffer;
  116875. /**
  116876. * Get the current class name of the texture useful for serialization or dynamic coding.
  116877. * @returns "EquiRectangularCubeTexture"
  116878. */
  116879. getClassName(): string;
  116880. /**
  116881. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116882. * @returns A clone of the current EquiRectangularCubeTexture.
  116883. */
  116884. clone(): EquiRectangularCubeTexture;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. /**
  116889. * Based on jsTGALoader - Javascript loader for TGA file
  116890. * By Vincent Thibault
  116891. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116892. */
  116893. export class TGATools {
  116894. private static _TYPE_INDEXED;
  116895. private static _TYPE_RGB;
  116896. private static _TYPE_GREY;
  116897. private static _TYPE_RLE_INDEXED;
  116898. private static _TYPE_RLE_RGB;
  116899. private static _TYPE_RLE_GREY;
  116900. private static _ORIGIN_MASK;
  116901. private static _ORIGIN_SHIFT;
  116902. private static _ORIGIN_BL;
  116903. private static _ORIGIN_BR;
  116904. private static _ORIGIN_UL;
  116905. private static _ORIGIN_UR;
  116906. /**
  116907. * Gets the header of a TGA file
  116908. * @param data defines the TGA data
  116909. * @returns the header
  116910. */
  116911. static GetTGAHeader(data: Uint8Array): any;
  116912. /**
  116913. * Uploads TGA content to a Babylon Texture
  116914. * @hidden
  116915. */
  116916. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116917. /** @hidden */
  116918. 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;
  116919. /** @hidden */
  116920. 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;
  116921. /** @hidden */
  116922. 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;
  116923. /** @hidden */
  116924. 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;
  116925. /** @hidden */
  116926. 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;
  116927. /** @hidden */
  116928. 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;
  116929. }
  116930. }
  116931. declare module BABYLON {
  116932. /**
  116933. * Implementation of the TGA Texture Loader.
  116934. * @hidden
  116935. */
  116936. export class _TGATextureLoader implements IInternalTextureLoader {
  116937. /**
  116938. * Defines wether the loader supports cascade loading the different faces.
  116939. */
  116940. readonly supportCascades: boolean;
  116941. /**
  116942. * This returns if the loader support the current file information.
  116943. * @param extension defines the file extension of the file being loaded
  116944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116945. * @param fallback defines the fallback internal texture if any
  116946. * @param isBase64 defines whether the texture is encoded as a base64
  116947. * @param isBuffer defines whether the texture data are stored as a buffer
  116948. * @returns true if the loader can load the specified file
  116949. */
  116950. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116951. /**
  116952. * Transform the url before loading if required.
  116953. * @param rootUrl the url of the texture
  116954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116955. * @returns the transformed texture
  116956. */
  116957. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116958. /**
  116959. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116960. * @param rootUrl the url of the texture
  116961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116962. * @returns the fallback texture
  116963. */
  116964. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116965. /**
  116966. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116967. * @param data contains the texture data
  116968. * @param texture defines the BabylonJS internal texture
  116969. * @param createPolynomials will be true if polynomials have been requested
  116970. * @param onLoad defines the callback to trigger once the texture is ready
  116971. * @param onError defines the callback to trigger in case of error
  116972. */
  116973. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116974. /**
  116975. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116976. * @param data contains the texture data
  116977. * @param texture defines the BabylonJS internal texture
  116978. * @param callback defines the method to call once ready to upload
  116979. */
  116980. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116981. }
  116982. }
  116983. declare module BABYLON {
  116984. /**
  116985. * Info about the .basis files
  116986. */
  116987. class BasisFileInfo {
  116988. /**
  116989. * If the file has alpha
  116990. */
  116991. hasAlpha: boolean;
  116992. /**
  116993. * Info about each image of the basis file
  116994. */
  116995. images: Array<{
  116996. levels: Array<{
  116997. width: number;
  116998. height: number;
  116999. transcodedPixels: ArrayBufferView;
  117000. }>;
  117001. }>;
  117002. }
  117003. /**
  117004. * Result of transcoding a basis file
  117005. */
  117006. class TranscodeResult {
  117007. /**
  117008. * Info about the .basis file
  117009. */
  117010. fileInfo: BasisFileInfo;
  117011. /**
  117012. * Format to use when loading the file
  117013. */
  117014. format: number;
  117015. }
  117016. /**
  117017. * Configuration options for the Basis transcoder
  117018. */
  117019. export class BasisTranscodeConfiguration {
  117020. /**
  117021. * Supported compression formats used to determine the supported output format of the transcoder
  117022. */
  117023. supportedCompressionFormats?: {
  117024. /**
  117025. * etc1 compression format
  117026. */
  117027. etc1?: boolean;
  117028. /**
  117029. * s3tc compression format
  117030. */
  117031. s3tc?: boolean;
  117032. /**
  117033. * pvrtc compression format
  117034. */
  117035. pvrtc?: boolean;
  117036. /**
  117037. * etc2 compression format
  117038. */
  117039. etc2?: boolean;
  117040. };
  117041. /**
  117042. * If mipmap levels should be loaded for transcoded images (Default: true)
  117043. */
  117044. loadMipmapLevels?: boolean;
  117045. /**
  117046. * Index of a single image to load (Default: all images)
  117047. */
  117048. loadSingleImage?: number;
  117049. }
  117050. /**
  117051. * Used to load .Basis files
  117052. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117053. */
  117054. export class BasisTools {
  117055. private static _IgnoreSupportedFormats;
  117056. /**
  117057. * URL to use when loading the basis transcoder
  117058. */
  117059. static JSModuleURL: string;
  117060. /**
  117061. * URL to use when loading the wasm module for the transcoder
  117062. */
  117063. static WasmModuleURL: string;
  117064. /**
  117065. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117066. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117067. * @returns internal format corresponding to the Basis format
  117068. */
  117069. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117070. private static _WorkerPromise;
  117071. private static _Worker;
  117072. private static _actionId;
  117073. private static _CreateWorkerAsync;
  117074. /**
  117075. * Transcodes a loaded image file to compressed pixel data
  117076. * @param imageData image data to transcode
  117077. * @param config configuration options for the transcoding
  117078. * @returns a promise resulting in the transcoded image
  117079. */
  117080. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117081. /**
  117082. * Loads a texture from the transcode result
  117083. * @param texture texture load to
  117084. * @param transcodeResult the result of transcoding the basis file to load from
  117085. */
  117086. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117087. }
  117088. }
  117089. declare module BABYLON {
  117090. /**
  117091. * Loader for .basis file format
  117092. */
  117093. export class _BasisTextureLoader implements IInternalTextureLoader {
  117094. /**
  117095. * Defines whether the loader supports cascade loading the different faces.
  117096. */
  117097. readonly supportCascades: boolean;
  117098. /**
  117099. * This returns if the loader support the current file information.
  117100. * @param extension defines the file extension of the file being loaded
  117101. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117102. * @param fallback defines the fallback internal texture if any
  117103. * @param isBase64 defines whether the texture is encoded as a base64
  117104. * @param isBuffer defines whether the texture data are stored as a buffer
  117105. * @returns true if the loader can load the specified file
  117106. */
  117107. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117108. /**
  117109. * Transform the url before loading if required.
  117110. * @param rootUrl the url of the texture
  117111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117112. * @returns the transformed texture
  117113. */
  117114. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117115. /**
  117116. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117117. * @param rootUrl the url of the texture
  117118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117119. * @returns the fallback texture
  117120. */
  117121. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117122. /**
  117123. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117124. * @param data contains the texture data
  117125. * @param texture defines the BabylonJS internal texture
  117126. * @param createPolynomials will be true if polynomials have been requested
  117127. * @param onLoad defines the callback to trigger once the texture is ready
  117128. * @param onError defines the callback to trigger in case of error
  117129. */
  117130. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117131. /**
  117132. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117133. * @param data contains the texture data
  117134. * @param texture defines the BabylonJS internal texture
  117135. * @param callback defines the method to call once ready to upload
  117136. */
  117137. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117138. }
  117139. }
  117140. declare module BABYLON {
  117141. /**
  117142. * 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.
  117143. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117145. */
  117146. export class CustomProceduralTexture extends ProceduralTexture {
  117147. private _animate;
  117148. private _time;
  117149. private _config;
  117150. private _texturePath;
  117151. /**
  117152. * Instantiates a new Custom Procedural Texture.
  117153. * 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.
  117154. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117155. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117156. * @param name Define the name of the texture
  117157. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117158. * @param size Define the size of the texture to create
  117159. * @param scene Define the scene the texture belongs to
  117160. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117161. * @param generateMipMaps Define if the texture should creates mip maps or not
  117162. */
  117163. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117164. private _loadJson;
  117165. /**
  117166. * Is the texture ready to be used ? (rendered at least once)
  117167. * @returns true if ready, otherwise, false.
  117168. */
  117169. isReady(): boolean;
  117170. /**
  117171. * Render the texture to its associated render target.
  117172. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117173. */
  117174. render(useCameraPostProcess?: boolean): void;
  117175. /**
  117176. * Update the list of dependant textures samplers in the shader.
  117177. */
  117178. updateTextures(): void;
  117179. /**
  117180. * Update the uniform values of the procedural texture in the shader.
  117181. */
  117182. updateShaderUniforms(): void;
  117183. /**
  117184. * Define if the texture animates or not.
  117185. */
  117186. animate: boolean;
  117187. }
  117188. }
  117189. declare module BABYLON {
  117190. /** @hidden */
  117191. export var noisePixelShader: {
  117192. name: string;
  117193. shader: string;
  117194. };
  117195. }
  117196. declare module BABYLON {
  117197. /**
  117198. * Class used to generate noise procedural textures
  117199. */
  117200. export class NoiseProceduralTexture extends ProceduralTexture {
  117201. private _time;
  117202. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117203. brightness: number;
  117204. /** Defines the number of octaves to process */
  117205. octaves: number;
  117206. /** Defines the level of persistence (0.8 by default) */
  117207. persistence: number;
  117208. /** Gets or sets animation speed factor (default is 1) */
  117209. animationSpeedFactor: number;
  117210. /**
  117211. * Creates a new NoiseProceduralTexture
  117212. * @param name defines the name fo the texture
  117213. * @param size defines the size of the texture (default is 256)
  117214. * @param scene defines the hosting scene
  117215. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117216. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117217. */
  117218. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117219. private _updateShaderUniforms;
  117220. protected _getDefines(): string;
  117221. /** Generate the current state of the procedural texture */
  117222. render(useCameraPostProcess?: boolean): void;
  117223. /**
  117224. * Serializes this noise procedural texture
  117225. * @returns a serialized noise procedural texture object
  117226. */
  117227. serialize(): any;
  117228. /**
  117229. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117230. * @param parsedTexture defines parsed texture data
  117231. * @param scene defines the current scene
  117232. * @param rootUrl defines the root URL containing noise procedural texture information
  117233. * @returns a parsed NoiseProceduralTexture
  117234. */
  117235. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117236. }
  117237. }
  117238. declare module BABYLON {
  117239. /**
  117240. * Raw cube texture where the raw buffers are passed in
  117241. */
  117242. export class RawCubeTexture extends CubeTexture {
  117243. /**
  117244. * Creates a cube texture where the raw buffers are passed in.
  117245. * @param scene defines the scene the texture is attached to
  117246. * @param data defines the array of data to use to create each face
  117247. * @param size defines the size of the textures
  117248. * @param format defines the format of the data
  117249. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117250. * @param generateMipMaps defines if the engine should generate the mip levels
  117251. * @param invertY defines if data must be stored with Y axis inverted
  117252. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117253. * @param compression defines the compression used (null by default)
  117254. */
  117255. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117256. /**
  117257. * Updates the raw cube texture.
  117258. * @param data defines the data to store
  117259. * @param format defines the data format
  117260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117261. * @param invertY defines if data must be stored with Y axis inverted
  117262. * @param compression defines the compression used (null by default)
  117263. * @param level defines which level of the texture to update
  117264. */
  117265. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117266. /**
  117267. * Updates a raw cube texture with RGBD encoded data.
  117268. * @param data defines the array of data [mipmap][face] to use to create each face
  117269. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117270. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117271. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117272. * @returns a promsie that resolves when the operation is complete
  117273. */
  117274. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117275. /**
  117276. * Clones the raw cube texture.
  117277. * @return a new cube texture
  117278. */
  117279. clone(): CubeTexture;
  117280. /** @hidden */
  117281. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117282. }
  117283. }
  117284. declare module BABYLON {
  117285. /**
  117286. * Class used to store 3D textures containing user data
  117287. */
  117288. export class RawTexture3D extends Texture {
  117289. /** Gets or sets the texture format to use */
  117290. format: number;
  117291. private _engine;
  117292. /**
  117293. * Create a new RawTexture3D
  117294. * @param data defines the data of the texture
  117295. * @param width defines the width of the texture
  117296. * @param height defines the height of the texture
  117297. * @param depth defines the depth of the texture
  117298. * @param format defines the texture format to use
  117299. * @param scene defines the hosting scene
  117300. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117301. * @param invertY defines if texture must be stored with Y axis inverted
  117302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117303. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117304. */
  117305. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117306. /** Gets or sets the texture format to use */
  117307. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117308. /**
  117309. * Update the texture with new data
  117310. * @param data defines the data to store in the texture
  117311. */
  117312. update(data: ArrayBufferView): void;
  117313. }
  117314. }
  117315. declare module BABYLON {
  117316. /**
  117317. * Creates a refraction texture used by refraction channel of the standard material.
  117318. * It is like a mirror but to see through a material.
  117319. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117320. */
  117321. export class RefractionTexture extends RenderTargetTexture {
  117322. /**
  117323. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117324. * 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.
  117325. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117326. */
  117327. refractionPlane: Plane;
  117328. /**
  117329. * Define how deep under the surface we should see.
  117330. */
  117331. depth: number;
  117332. /**
  117333. * Creates a refraction texture used by refraction channel of the standard material.
  117334. * It is like a mirror but to see through a material.
  117335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117336. * @param name Define the texture name
  117337. * @param size Define the size of the underlying texture
  117338. * @param scene Define the scene the refraction belongs to
  117339. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117340. */
  117341. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117342. /**
  117343. * Clone the refraction texture.
  117344. * @returns the cloned texture
  117345. */
  117346. clone(): RefractionTexture;
  117347. /**
  117348. * Serialize the texture to a JSON representation you could use in Parse later on
  117349. * @returns the serialized JSON representation
  117350. */
  117351. serialize(): any;
  117352. }
  117353. }
  117354. declare module BABYLON {
  117355. /**
  117356. * Defines the options related to the creation of an HtmlElementTexture
  117357. */
  117358. export interface IHtmlElementTextureOptions {
  117359. /**
  117360. * Defines wether mip maps should be created or not.
  117361. */
  117362. generateMipMaps?: boolean;
  117363. /**
  117364. * Defines the sampling mode of the texture.
  117365. */
  117366. samplingMode?: number;
  117367. /**
  117368. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117369. */
  117370. engine: Nullable<Engine>;
  117371. /**
  117372. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117373. */
  117374. scene: Nullable<Scene>;
  117375. }
  117376. /**
  117377. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117378. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117379. * is automatically managed.
  117380. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117381. * in your application.
  117382. *
  117383. * As the update is not automatic, you need to call them manually.
  117384. */
  117385. export class HtmlElementTexture extends BaseTexture {
  117386. /**
  117387. * The texture URL.
  117388. */
  117389. element: HTMLVideoElement | HTMLCanvasElement;
  117390. private static readonly DefaultOptions;
  117391. private _textureMatrix;
  117392. private _engine;
  117393. private _isVideo;
  117394. private _generateMipMaps;
  117395. private _samplingMode;
  117396. /**
  117397. * Instantiates a HtmlElementTexture from the following parameters.
  117398. *
  117399. * @param name Defines the name of the texture
  117400. * @param element Defines the video or canvas the texture is filled with
  117401. * @param options Defines the other none mandatory texture creation options
  117402. */
  117403. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117404. private _createInternalTexture;
  117405. /**
  117406. * Returns the texture matrix used in most of the material.
  117407. */
  117408. getTextureMatrix(): Matrix;
  117409. /**
  117410. * Updates the content of the texture.
  117411. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117412. */
  117413. update(invertY?: Nullable<boolean>): void;
  117414. }
  117415. }
  117416. declare module BABYLON {
  117417. /**
  117418. * Enum used to define the target of a block
  117419. */
  117420. export enum NodeMaterialBlockTargets {
  117421. /** Vertex shader */
  117422. Vertex = 1,
  117423. /** Fragment shader */
  117424. Fragment = 2,
  117425. /** Neutral */
  117426. Neutral = 4,
  117427. /** Vertex and Fragment */
  117428. VertexAndFragment = 3
  117429. }
  117430. }
  117431. declare module BABYLON {
  117432. /**
  117433. * Defines the kind of connection point for node based material
  117434. */
  117435. export enum NodeMaterialBlockConnectionPointTypes {
  117436. /** Float */
  117437. Float = 1,
  117438. /** Int */
  117439. Int = 2,
  117440. /** Vector2 */
  117441. Vector2 = 4,
  117442. /** Vector3 */
  117443. Vector3 = 8,
  117444. /** Vector4 */
  117445. Vector4 = 16,
  117446. /** Color3 */
  117447. Color3 = 32,
  117448. /** Color4 */
  117449. Color4 = 64,
  117450. /** Matrix */
  117451. Matrix = 128,
  117452. /** Detect type based on connection */
  117453. AutoDetect = 1024,
  117454. /** Output type that will be defined by input type */
  117455. BasedOnInput = 2048
  117456. }
  117457. }
  117458. declare module BABYLON {
  117459. /**
  117460. * Root class for all node material optimizers
  117461. */
  117462. export class NodeMaterialOptimizer {
  117463. /**
  117464. * Function used to optimize a NodeMaterial graph
  117465. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117466. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117467. */
  117468. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117469. }
  117470. }
  117471. declare module BABYLON {
  117472. /**
  117473. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117474. */
  117475. export class TransformBlock extends NodeMaterialBlock {
  117476. /**
  117477. * Defines the value to use to complement W value to transform it to a Vector4
  117478. */
  117479. complementW: number;
  117480. /**
  117481. * Defines the value to use to complement z value to transform it to a Vector4
  117482. */
  117483. complementZ: number;
  117484. /**
  117485. * Creates a new TransformBlock
  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 vector input
  117496. */
  117497. readonly vector: NodeMaterialConnectionPoint;
  117498. /**
  117499. * Gets the output component
  117500. */
  117501. readonly output: NodeMaterialConnectionPoint;
  117502. /**
  117503. * Gets the matrix transform input
  117504. */
  117505. readonly transform: NodeMaterialConnectionPoint;
  117506. protected _buildBlock(state: NodeMaterialBuildState): this;
  117507. serialize(): any;
  117508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117509. protected _dumpPropertiesCode(): string;
  117510. }
  117511. }
  117512. declare module BABYLON {
  117513. /**
  117514. * Block used to output the vertex position
  117515. */
  117516. export class VertexOutputBlock extends NodeMaterialBlock {
  117517. /**
  117518. * Creates a new VertexOutputBlock
  117519. * @param name defines the block name
  117520. */
  117521. constructor(name: string);
  117522. /**
  117523. * Gets the current class name
  117524. * @returns the class name
  117525. */
  117526. getClassName(): string;
  117527. /**
  117528. * Gets the vector input component
  117529. */
  117530. readonly vector: NodeMaterialConnectionPoint;
  117531. protected _buildBlock(state: NodeMaterialBuildState): this;
  117532. }
  117533. }
  117534. declare module BABYLON {
  117535. /**
  117536. * Block used to output the final color
  117537. */
  117538. export class FragmentOutputBlock extends NodeMaterialBlock {
  117539. /**
  117540. * Create a new FragmentOutputBlock
  117541. * @param name defines the block name
  117542. */
  117543. constructor(name: string);
  117544. /**
  117545. * Gets the current class name
  117546. * @returns the class name
  117547. */
  117548. getClassName(): string;
  117549. /**
  117550. * Gets the rgba input component
  117551. */
  117552. readonly rgba: NodeMaterialConnectionPoint;
  117553. /**
  117554. * Gets the rgb input component
  117555. */
  117556. readonly rgb: NodeMaterialConnectionPoint;
  117557. /**
  117558. * Gets the a input component
  117559. */
  117560. readonly a: NodeMaterialConnectionPoint;
  117561. protected _buildBlock(state: NodeMaterialBuildState): this;
  117562. }
  117563. }
  117564. declare module BABYLON {
  117565. /**
  117566. * Enum used to define well known values e.g. values automatically provided by the system
  117567. */
  117568. export enum NodeMaterialWellKnownValues {
  117569. /** World */
  117570. World = 1,
  117571. /** View */
  117572. View = 2,
  117573. /** Projection */
  117574. Projection = 3,
  117575. /** ViewProjection */
  117576. ViewProjection = 4,
  117577. /** WorldView */
  117578. WorldView = 5,
  117579. /** WorldViewProjection */
  117580. WorldViewProjection = 6,
  117581. /** CameraPosition */
  117582. CameraPosition = 7,
  117583. /** Fog Color */
  117584. FogColor = 8
  117585. }
  117586. }
  117587. declare module BABYLON {
  117588. /**
  117589. * Block used to read a reflection texture from a sampler
  117590. */
  117591. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117592. private _define3DName;
  117593. private _defineCubicName;
  117594. private _defineExplicitName;
  117595. private _defineProjectionName;
  117596. private _defineLocalCubicName;
  117597. private _defineSphericalName;
  117598. private _definePlanarName;
  117599. private _defineEquirectangularName;
  117600. private _defineMirroredEquirectangularFixedName;
  117601. private _defineEquirectangularFixedName;
  117602. private _defineSkyboxName;
  117603. private _cubeSamplerName;
  117604. private _2DSamplerName;
  117605. private _positionUVWName;
  117606. private _directionWName;
  117607. private _reflectionCoordsName;
  117608. private _reflection2DCoordsName;
  117609. private _reflectionColorName;
  117610. private _reflectionMatrixName;
  117611. /**
  117612. * Gets or sets the texture associated with the node
  117613. */
  117614. texture: Nullable<BaseTexture>;
  117615. /**
  117616. * Create a new TextureBlock
  117617. * @param name defines the block name
  117618. */
  117619. constructor(name: string);
  117620. /**
  117621. * Gets the current class name
  117622. * @returns the class name
  117623. */
  117624. getClassName(): string;
  117625. /**
  117626. * Gets the world position input component
  117627. */
  117628. readonly position: NodeMaterialConnectionPoint;
  117629. /**
  117630. * Gets the world position input component
  117631. */
  117632. readonly worldPosition: NodeMaterialConnectionPoint;
  117633. /**
  117634. * Gets the world normal input component
  117635. */
  117636. readonly worldNormal: NodeMaterialConnectionPoint;
  117637. /**
  117638. * Gets the world input component
  117639. */
  117640. readonly world: NodeMaterialConnectionPoint;
  117641. /**
  117642. * Gets the camera (or eye) position component
  117643. */
  117644. readonly cameraPosition: NodeMaterialConnectionPoint;
  117645. /**
  117646. * Gets the view input component
  117647. */
  117648. readonly view: NodeMaterialConnectionPoint;
  117649. /**
  117650. * Gets the rgb output component
  117651. */
  117652. readonly rgb: NodeMaterialConnectionPoint;
  117653. /**
  117654. * Gets the r output component
  117655. */
  117656. readonly r: NodeMaterialConnectionPoint;
  117657. /**
  117658. * Gets the g output component
  117659. */
  117660. readonly g: NodeMaterialConnectionPoint;
  117661. /**
  117662. * Gets the b output component
  117663. */
  117664. readonly b: NodeMaterialConnectionPoint;
  117665. autoConfigure(material: NodeMaterial): void;
  117666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117667. isReady(): boolean;
  117668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117669. private _injectVertexCode;
  117670. private _writeOutput;
  117671. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117672. serialize(): any;
  117673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117674. }
  117675. }
  117676. declare module BABYLON {
  117677. /**
  117678. * Interface used to configure the node material editor
  117679. */
  117680. export interface INodeMaterialEditorOptions {
  117681. /** Define the URl to load node editor script */
  117682. editorURL?: string;
  117683. }
  117684. /** @hidden */
  117685. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  117686. /** BONES */
  117687. NUM_BONE_INFLUENCERS: number;
  117688. BonesPerMesh: number;
  117689. BONETEXTURE: boolean;
  117690. /** MORPH TARGETS */
  117691. MORPHTARGETS: boolean;
  117692. MORPHTARGETS_NORMAL: boolean;
  117693. MORPHTARGETS_TANGENT: boolean;
  117694. MORPHTARGETS_UV: boolean;
  117695. NUM_MORPH_INFLUENCERS: number;
  117696. /** IMAGE PROCESSING */
  117697. IMAGEPROCESSING: boolean;
  117698. VIGNETTE: boolean;
  117699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117700. VIGNETTEBLENDMODEOPAQUE: boolean;
  117701. TONEMAPPING: boolean;
  117702. TONEMAPPING_ACES: boolean;
  117703. CONTRAST: boolean;
  117704. EXPOSURE: boolean;
  117705. COLORCURVES: boolean;
  117706. COLORGRADING: boolean;
  117707. COLORGRADING3D: boolean;
  117708. SAMPLER3DGREENDEPTH: boolean;
  117709. SAMPLER3DBGRMAP: boolean;
  117710. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117711. constructor();
  117712. setValue(name: string, value: boolean): void;
  117713. }
  117714. /**
  117715. * Class used to configure NodeMaterial
  117716. */
  117717. export interface INodeMaterialOptions {
  117718. /**
  117719. * Defines if blocks should emit comments
  117720. */
  117721. emitComments: boolean;
  117722. }
  117723. /**
  117724. * Class used to create a node based material built by assembling shader blocks
  117725. */
  117726. export class NodeMaterial extends PushMaterial {
  117727. private static _BuildIdGenerator;
  117728. private _options;
  117729. private _vertexCompilationState;
  117730. private _fragmentCompilationState;
  117731. private _sharedData;
  117732. private _buildId;
  117733. private _buildWasSuccessful;
  117734. private _cachedWorldViewMatrix;
  117735. private _cachedWorldViewProjectionMatrix;
  117736. private _optimizers;
  117737. private _animationFrame;
  117738. /** Define the URl to load node editor script */
  117739. static EditorURL: string;
  117740. private BJSNODEMATERIALEDITOR;
  117741. /** Get the inspector from bundle or global */
  117742. private _getGlobalNodeMaterialEditor;
  117743. /**
  117744. * 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)
  117745. */
  117746. ignoreAlpha: boolean;
  117747. /**
  117748. * Defines the maximum number of lights that can be used in the material
  117749. */
  117750. maxSimultaneousLights: number;
  117751. /**
  117752. * Observable raised when the material is built
  117753. */
  117754. onBuildObservable: Observable<NodeMaterial>;
  117755. /**
  117756. * Gets or sets the root nodes of the material vertex shader
  117757. */
  117758. _vertexOutputNodes: NodeMaterialBlock[];
  117759. /**
  117760. * Gets or sets the root nodes of the material fragment (pixel) shader
  117761. */
  117762. _fragmentOutputNodes: NodeMaterialBlock[];
  117763. /** Gets or sets options to control the node material overall behavior */
  117764. options: INodeMaterialOptions;
  117765. /**
  117766. * Default configuration related to image processing available in the standard Material.
  117767. */
  117768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117769. /**
  117770. * Gets the image processing configuration used either in this material.
  117771. */
  117772. /**
  117773. * Sets the Default image processing configuration used either in the this material.
  117774. *
  117775. * If sets to null, the scene one is in use.
  117776. */
  117777. imageProcessingConfiguration: ImageProcessingConfiguration;
  117778. /**
  117779. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  117780. */
  117781. attachedBlocks: NodeMaterialBlock[];
  117782. /**
  117783. * Create a new node based material
  117784. * @param name defines the material name
  117785. * @param scene defines the hosting scene
  117786. * @param options defines creation option
  117787. */
  117788. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  117789. /**
  117790. * Gets the current class name of the material e.g. "NodeMaterial"
  117791. * @returns the class name
  117792. */
  117793. getClassName(): string;
  117794. /**
  117795. * Keep track of the image processing observer to allow dispose and replace.
  117796. */
  117797. private _imageProcessingObserver;
  117798. /**
  117799. * Attaches a new image processing configuration to the Standard Material.
  117800. * @param configuration
  117801. */
  117802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117803. /**
  117804. * Get a block by its name
  117805. * @param name defines the name of the block to retrieve
  117806. * @returns the required block or null if not found
  117807. */
  117808. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  117809. /**
  117810. * Get a block by its name
  117811. * @param predicate defines the predicate used to find the good candidate
  117812. * @returns the required block or null if not found
  117813. */
  117814. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  117815. /**
  117816. * Get an input block by its name
  117817. * @param predicate defines the predicate used to find the good candidate
  117818. * @returns the required input block or null if not found
  117819. */
  117820. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  117821. /**
  117822. * Gets the list of input blocks attached to this material
  117823. * @returns an array of InputBlocks
  117824. */
  117825. getInputBlocks(): InputBlock[];
  117826. /**
  117827. * Adds a new optimizer to the list of optimizers
  117828. * @param optimizer defines the optimizers to add
  117829. * @returns the current material
  117830. */
  117831. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117832. /**
  117833. * Remove an optimizer from the list of optimizers
  117834. * @param optimizer defines the optimizers to remove
  117835. * @returns the current material
  117836. */
  117837. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117838. /**
  117839. * Add a new block to the list of output nodes
  117840. * @param node defines the node to add
  117841. * @returns the current material
  117842. */
  117843. addOutputNode(node: NodeMaterialBlock): this;
  117844. /**
  117845. * Remove a block from the list of root nodes
  117846. * @param node defines the node to remove
  117847. * @returns the current material
  117848. */
  117849. removeOutputNode(node: NodeMaterialBlock): this;
  117850. private _addVertexOutputNode;
  117851. private _removeVertexOutputNode;
  117852. private _addFragmentOutputNode;
  117853. private _removeFragmentOutputNode;
  117854. /**
  117855. * Specifies if the material will require alpha blending
  117856. * @returns a boolean specifying if alpha blending is needed
  117857. */
  117858. needAlphaBlending(): boolean;
  117859. /**
  117860. * Specifies if this material should be rendered in alpha test mode
  117861. * @returns a boolean specifying if an alpha test is needed.
  117862. */
  117863. needAlphaTesting(): boolean;
  117864. private _initializeBlock;
  117865. private _resetDualBlocks;
  117866. /**
  117867. * Build the material and generates the inner effect
  117868. * @param verbose defines if the build should log activity
  117869. */
  117870. build(verbose?: boolean): void;
  117871. /**
  117872. * Runs an otpimization phase to try to improve the shader code
  117873. */
  117874. optimize(): void;
  117875. private _prepareDefinesForAttributes;
  117876. /**
  117877. * Get if the submesh is ready to be used and all its information available.
  117878. * Child classes can use it to update shaders
  117879. * @param mesh defines the mesh to check
  117880. * @param subMesh defines which submesh to check
  117881. * @param useInstances specifies that instances should be used
  117882. * @returns a boolean indicating that the submesh is ready or not
  117883. */
  117884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117885. /**
  117886. * Get a string representing the shaders built by the current node graph
  117887. */
  117888. readonly compiledShaders: string;
  117889. /**
  117890. * Binds the world matrix to the material
  117891. * @param world defines the world transformation matrix
  117892. */
  117893. bindOnlyWorldMatrix(world: Matrix): void;
  117894. /**
  117895. * Binds the submesh to this material by preparing the effect and shader to draw
  117896. * @param world defines the world transformation matrix
  117897. * @param mesh defines the mesh containing the submesh
  117898. * @param subMesh defines the submesh to bind the material to
  117899. */
  117900. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117901. /**
  117902. * Gets the active textures from the material
  117903. * @returns an array of textures
  117904. */
  117905. getActiveTextures(): BaseTexture[];
  117906. /**
  117907. * Gets the list of texture blocks
  117908. * @returns an array of texture blocks
  117909. */
  117910. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117911. /**
  117912. * Specifies if the material uses a texture
  117913. * @param texture defines the texture to check against the material
  117914. * @returns a boolean specifying if the material uses the texture
  117915. */
  117916. hasTexture(texture: BaseTexture): boolean;
  117917. /**
  117918. * Disposes the material
  117919. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117920. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117921. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117922. */
  117923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117924. /** Creates the node editor window. */
  117925. private _createNodeEditor;
  117926. /**
  117927. * Launch the node material editor
  117928. * @param config Define the configuration of the editor
  117929. * @return a promise fulfilled when the node editor is visible
  117930. */
  117931. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117932. /**
  117933. * Clear the current material
  117934. */
  117935. clear(): void;
  117936. /**
  117937. * Clear the current material and set it to a default state
  117938. */
  117939. setToDefault(): void;
  117940. /**
  117941. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117942. * @param url defines the url to load from
  117943. * @returns a promise that will fullfil when the material is fully loaded
  117944. */
  117945. loadAsync(url: string): Promise<unknown>;
  117946. private _gatherBlocks;
  117947. /**
  117948. * Generate a string containing the code declaration required to create an equivalent of this material
  117949. * @returns a string
  117950. */
  117951. generateCode(): string;
  117952. /**
  117953. * Serializes this material in a JSON representation
  117954. * @returns the serialized material object
  117955. */
  117956. serialize(): any;
  117957. private _restoreConnections;
  117958. /**
  117959. * Clear the current graph and load a new one from a serialization object
  117960. * @param source defines the JSON representation of the material
  117961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117962. */
  117963. loadFromSerialization(source: any, rootUrl?: string): void;
  117964. /**
  117965. * Creates a node material from parsed material data
  117966. * @param source defines the JSON representation of the material
  117967. * @param scene defines the hosting scene
  117968. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117969. * @returns a new node material
  117970. */
  117971. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117972. /**
  117973. * Creates a new node material set to default basic configuration
  117974. * @param name defines the name of the material
  117975. * @param scene defines the hosting scene
  117976. * @returns a new NodeMaterial
  117977. */
  117978. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117979. }
  117980. }
  117981. declare module BABYLON {
  117982. /**
  117983. * Block used to read a texture from a sampler
  117984. */
  117985. export class TextureBlock extends NodeMaterialBlock {
  117986. private _defineName;
  117987. private _samplerName;
  117988. private _transformedUVName;
  117989. private _textureTransformName;
  117990. private _textureInfoName;
  117991. private _mainUVName;
  117992. private _mainUVDefineName;
  117993. /**
  117994. * Gets or sets the texture associated with the node
  117995. */
  117996. texture: Nullable<BaseTexture>;
  117997. /**
  117998. * Create a new TextureBlock
  117999. * @param name defines the block name
  118000. */
  118001. constructor(name: string);
  118002. /**
  118003. * Gets the current class name
  118004. * @returns the class name
  118005. */
  118006. getClassName(): string;
  118007. /**
  118008. * Gets the uv input component
  118009. */
  118010. readonly uv: NodeMaterialConnectionPoint;
  118011. /**
  118012. * Gets the rgba output component
  118013. */
  118014. readonly rgba: NodeMaterialConnectionPoint;
  118015. /**
  118016. * Gets the rgb output component
  118017. */
  118018. readonly rgb: NodeMaterialConnectionPoint;
  118019. /**
  118020. * Gets the r output component
  118021. */
  118022. readonly r: NodeMaterialConnectionPoint;
  118023. /**
  118024. * Gets the g output component
  118025. */
  118026. readonly g: NodeMaterialConnectionPoint;
  118027. /**
  118028. * Gets the b output component
  118029. */
  118030. readonly b: NodeMaterialConnectionPoint;
  118031. /**
  118032. * Gets the a output component
  118033. */
  118034. readonly a: NodeMaterialConnectionPoint;
  118035. readonly target: NodeMaterialBlockTargets;
  118036. autoConfigure(material: NodeMaterial): void;
  118037. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118039. isReady(): boolean;
  118040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118041. private readonly _isMixed;
  118042. private _injectVertexCode;
  118043. private _writeOutput;
  118044. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118045. protected _dumpPropertiesCode(): string;
  118046. serialize(): any;
  118047. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118048. }
  118049. }
  118050. declare module BABYLON {
  118051. /**
  118052. * Class used to store shared data between 2 NodeMaterialBuildState
  118053. */
  118054. export class NodeMaterialBuildStateSharedData {
  118055. /**
  118056. * Gets the list of emitted varyings
  118057. */
  118058. temps: string[];
  118059. /**
  118060. * Gets the list of emitted varyings
  118061. */
  118062. varyings: string[];
  118063. /**
  118064. * Gets the varying declaration string
  118065. */
  118066. varyingDeclaration: string;
  118067. /**
  118068. * Input blocks
  118069. */
  118070. inputBlocks: InputBlock[];
  118071. /**
  118072. * Input blocks
  118073. */
  118074. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118075. /**
  118076. * Bindable blocks (Blocks that need to set data to the effect)
  118077. */
  118078. bindableBlocks: NodeMaterialBlock[];
  118079. /**
  118080. * List of blocks that can provide a compilation fallback
  118081. */
  118082. blocksWithFallbacks: NodeMaterialBlock[];
  118083. /**
  118084. * List of blocks that can provide a define update
  118085. */
  118086. blocksWithDefines: NodeMaterialBlock[];
  118087. /**
  118088. * List of blocks that can provide a repeatable content
  118089. */
  118090. repeatableContentBlocks: NodeMaterialBlock[];
  118091. /**
  118092. * List of blocks that can provide a dynamic list of uniforms
  118093. */
  118094. dynamicUniformBlocks: NodeMaterialBlock[];
  118095. /**
  118096. * List of blocks that can block the isReady function for the material
  118097. */
  118098. blockingBlocks: NodeMaterialBlock[];
  118099. /**
  118100. * Gets the list of animated inputs
  118101. */
  118102. animatedInputs: InputBlock[];
  118103. /**
  118104. * Build Id used to avoid multiple recompilations
  118105. */
  118106. buildId: number;
  118107. /** List of emitted variables */
  118108. variableNames: {
  118109. [key: string]: number;
  118110. };
  118111. /** List of emitted defines */
  118112. defineNames: {
  118113. [key: string]: number;
  118114. };
  118115. /** Should emit comments? */
  118116. emitComments: boolean;
  118117. /** Emit build activity */
  118118. verbose: boolean;
  118119. /**
  118120. * Gets the compilation hints emitted at compilation time
  118121. */
  118122. hints: {
  118123. needWorldViewMatrix: boolean;
  118124. needWorldViewProjectionMatrix: boolean;
  118125. needAlphaBlending: boolean;
  118126. needAlphaTesting: boolean;
  118127. };
  118128. /**
  118129. * List of compilation checks
  118130. */
  118131. checks: {
  118132. emitVertex: boolean;
  118133. emitFragment: boolean;
  118134. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118135. };
  118136. /** Creates a new shared data */
  118137. constructor();
  118138. /**
  118139. * Emits console errors and exceptions if there is a failing check
  118140. */
  118141. emitErrors(): void;
  118142. }
  118143. }
  118144. declare module BABYLON {
  118145. /**
  118146. * Class used to store node based material build state
  118147. */
  118148. export class NodeMaterialBuildState {
  118149. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118150. supportUniformBuffers: boolean;
  118151. /**
  118152. * Gets the list of emitted attributes
  118153. */
  118154. attributes: string[];
  118155. /**
  118156. * Gets the list of emitted uniforms
  118157. */
  118158. uniforms: string[];
  118159. /**
  118160. * Gets the list of emitted uniform buffers
  118161. */
  118162. uniformBuffers: string[];
  118163. /**
  118164. * Gets the list of emitted samplers
  118165. */
  118166. samplers: string[];
  118167. /**
  118168. * Gets the list of emitted functions
  118169. */
  118170. functions: {
  118171. [key: string]: string;
  118172. };
  118173. /**
  118174. * Gets the target of the compilation state
  118175. */
  118176. target: NodeMaterialBlockTargets;
  118177. /**
  118178. * Gets the list of emitted counters
  118179. */
  118180. counters: {
  118181. [key: string]: number;
  118182. };
  118183. /**
  118184. * Shared data between multiple NodeMaterialBuildState instances
  118185. */
  118186. sharedData: NodeMaterialBuildStateSharedData;
  118187. /** @hidden */
  118188. _vertexState: NodeMaterialBuildState;
  118189. /** @hidden */
  118190. _attributeDeclaration: string;
  118191. /** @hidden */
  118192. _uniformDeclaration: string;
  118193. /** @hidden */
  118194. _samplerDeclaration: string;
  118195. /** @hidden */
  118196. _varyingTransfer: string;
  118197. private _repeatableContentAnchorIndex;
  118198. /** @hidden */
  118199. _builtCompilationString: string;
  118200. /**
  118201. * Gets the emitted compilation strings
  118202. */
  118203. compilationString: string;
  118204. /**
  118205. * Finalize the compilation strings
  118206. * @param state defines the current compilation state
  118207. */
  118208. finalize(state: NodeMaterialBuildState): void;
  118209. /** @hidden */
  118210. readonly _repeatableContentAnchor: string;
  118211. /** @hidden */
  118212. _getFreeVariableName(prefix: string): string;
  118213. /** @hidden */
  118214. _getFreeDefineName(prefix: string): string;
  118215. /** @hidden */
  118216. _excludeVariableName(name: string): void;
  118217. /** @hidden */
  118218. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118219. /** @hidden */
  118220. _emitFunction(name: string, code: string, comments: string): void;
  118221. /** @hidden */
  118222. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118223. replaceStrings?: {
  118224. search: RegExp;
  118225. replace: string;
  118226. }[];
  118227. repeatKey?: string;
  118228. }): string;
  118229. /** @hidden */
  118230. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118231. repeatKey?: string;
  118232. removeAttributes?: boolean;
  118233. removeUniforms?: boolean;
  118234. removeVaryings?: boolean;
  118235. removeIfDef?: boolean;
  118236. replaceStrings?: {
  118237. search: RegExp;
  118238. replace: string;
  118239. }[];
  118240. }, storeKey?: string): void;
  118241. /** @hidden */
  118242. _registerTempVariable(name: string): boolean;
  118243. /** @hidden */
  118244. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118245. /** @hidden */
  118246. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118247. }
  118248. }
  118249. declare module BABYLON {
  118250. /**
  118251. * Defines a block that can be used inside a node based material
  118252. */
  118253. export class NodeMaterialBlock {
  118254. private _buildId;
  118255. private _buildTarget;
  118256. private _target;
  118257. private _isFinalMerger;
  118258. private _isInput;
  118259. /** @hidden */
  118260. _codeVariableName: string;
  118261. /** @hidden */
  118262. _inputs: NodeMaterialConnectionPoint[];
  118263. /** @hidden */
  118264. _outputs: NodeMaterialConnectionPoint[];
  118265. /** @hidden */
  118266. _preparationId: number;
  118267. /**
  118268. * Gets or sets the name of the block
  118269. */
  118270. name: string;
  118271. /**
  118272. * Gets or sets the unique id of the node
  118273. */
  118274. uniqueId: number;
  118275. /**
  118276. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118277. */
  118278. readonly isFinalMerger: boolean;
  118279. /**
  118280. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118281. */
  118282. readonly isInput: boolean;
  118283. /**
  118284. * Gets or sets the build Id
  118285. */
  118286. buildId: number;
  118287. /**
  118288. * Gets or sets the target of the block
  118289. */
  118290. target: NodeMaterialBlockTargets;
  118291. /**
  118292. * Gets the list of input points
  118293. */
  118294. readonly inputs: NodeMaterialConnectionPoint[];
  118295. /** Gets the list of output points */
  118296. readonly outputs: NodeMaterialConnectionPoint[];
  118297. /**
  118298. * Find an input by its name
  118299. * @param name defines the name of the input to look for
  118300. * @returns the input or null if not found
  118301. */
  118302. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118303. /**
  118304. * Find an output by its name
  118305. * @param name defines the name of the outputto look for
  118306. * @returns the output or null if not found
  118307. */
  118308. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118309. /**
  118310. * Creates a new NodeMaterialBlock
  118311. * @param name defines the block name
  118312. * @param target defines the target of that block (Vertex by default)
  118313. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118314. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118315. */
  118316. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118317. /**
  118318. * Initialize the block and prepare the context for build
  118319. * @param state defines the state that will be used for the build
  118320. */
  118321. initialize(state: NodeMaterialBuildState): void;
  118322. /**
  118323. * Bind data to effect. Will only be called for blocks with isBindable === true
  118324. * @param effect defines the effect to bind data to
  118325. * @param nodeMaterial defines the hosting NodeMaterial
  118326. * @param mesh defines the mesh that will be rendered
  118327. */
  118328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118329. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118330. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118331. protected _writeFloat(value: number): string;
  118332. /**
  118333. * Gets the current class name e.g. "NodeMaterialBlock"
  118334. * @returns the class name
  118335. */
  118336. getClassName(): string;
  118337. /**
  118338. * Register a new input. Must be called inside a block constructor
  118339. * @param name defines the connection point name
  118340. * @param type defines the connection point type
  118341. * @param isOptional defines a boolean indicating that this input can be omitted
  118342. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118343. * @returns the current block
  118344. */
  118345. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118346. /**
  118347. * Register a new output. Must be called inside a block constructor
  118348. * @param name defines the connection point name
  118349. * @param type defines the connection point type
  118350. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118351. * @returns the current block
  118352. */
  118353. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118354. /**
  118355. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118356. * @param forOutput defines an optional connection point to check compatibility with
  118357. * @returns the first available input or null
  118358. */
  118359. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118360. /**
  118361. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118362. * @param forBlock defines an optional block to check compatibility with
  118363. * @returns the first available input or null
  118364. */
  118365. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118366. /**
  118367. * Gets the sibling of the given output
  118368. * @param current defines the current output
  118369. * @returns the next output in the list or null
  118370. */
  118371. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118372. /**
  118373. * Connect current block with another block
  118374. * @param other defines the block to connect with
  118375. * @param options define the various options to help pick the right connections
  118376. * @returns the current block
  118377. */
  118378. connectTo(other: NodeMaterialBlock, options?: {
  118379. input?: string;
  118380. output?: string;
  118381. outputSwizzle?: string;
  118382. }): this | undefined;
  118383. protected _buildBlock(state: NodeMaterialBuildState): void;
  118384. /**
  118385. * Add uniforms, samplers and uniform buffers at compilation time
  118386. * @param state defines the state to update
  118387. * @param nodeMaterial defines the node material requesting the update
  118388. * @param defines defines the material defines to update
  118389. */
  118390. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118391. /**
  118392. * Add potential fallbacks if shader compilation fails
  118393. * @param mesh defines the mesh to be rendered
  118394. * @param fallbacks defines the current prioritized list of fallbacks
  118395. */
  118396. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118397. /**
  118398. * Update defines for shader compilation
  118399. * @param mesh defines the mesh to be rendered
  118400. * @param nodeMaterial defines the node material requesting the update
  118401. * @param defines defines the material defines to update
  118402. * @param useInstances specifies that instances should be used
  118403. */
  118404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118405. /**
  118406. * Initialize defines for shader compilation
  118407. * @param mesh defines the mesh to be rendered
  118408. * @param nodeMaterial defines the node material requesting the update
  118409. * @param defines defines the material defines to be prepared
  118410. * @param useInstances specifies that instances should be used
  118411. */
  118412. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118413. /**
  118414. * Lets the block try to connect some inputs automatically
  118415. * @param material defines the hosting NodeMaterial
  118416. */
  118417. autoConfigure(material: NodeMaterial): void;
  118418. /**
  118419. * Function called when a block is declared as repeatable content generator
  118420. * @param vertexShaderState defines the current compilation state for the vertex shader
  118421. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118422. * @param mesh defines the mesh to be rendered
  118423. * @param defines defines the material defines to update
  118424. */
  118425. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118426. /**
  118427. * Checks if the block is ready
  118428. * @param mesh defines the mesh to be rendered
  118429. * @param nodeMaterial defines the node material requesting the update
  118430. * @param defines defines the material defines to update
  118431. * @param useInstances specifies that instances should be used
  118432. * @returns true if the block is ready
  118433. */
  118434. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118435. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118436. private _processBuild;
  118437. /**
  118438. * Compile the current node and generate the shader code
  118439. * @param state defines the current compilation state (uniforms, samplers, current string)
  118440. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118441. * @returns true if already built
  118442. */
  118443. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118444. protected _inputRename(name: string): string;
  118445. protected _outputRename(name: string): string;
  118446. protected _dumpPropertiesCode(): string;
  118447. /** @hidden */
  118448. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118449. /**
  118450. * Clone the current block to a new identical block
  118451. * @param scene defines the hosting scene
  118452. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118453. * @returns a copy of the current block
  118454. */
  118455. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118456. /**
  118457. * Serializes this block in a JSON representation
  118458. * @returns the serialized block object
  118459. */
  118460. serialize(): any;
  118461. /** @hidden */
  118462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118463. }
  118464. }
  118465. declare module BABYLON {
  118466. /**
  118467. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118468. */
  118469. export enum NodeMaterialBlockConnectionPointMode {
  118470. /** Value is an uniform */
  118471. Uniform = 0,
  118472. /** Value is a mesh attribute */
  118473. Attribute = 1,
  118474. /** Value is a varying between vertex and fragment shaders */
  118475. Varying = 2,
  118476. /** Mode is undefined */
  118477. Undefined = 3
  118478. }
  118479. }
  118480. declare module BABYLON {
  118481. /**
  118482. * Enum defining the type of animations supported by InputBlock
  118483. */
  118484. export enum AnimatedInputBlockTypes {
  118485. /** No animation */
  118486. None = 0,
  118487. /** Time based animation. Will only work for floats */
  118488. Time = 1
  118489. }
  118490. }
  118491. declare module BABYLON {
  118492. /**
  118493. * Block used to expose an input value
  118494. */
  118495. export class InputBlock extends NodeMaterialBlock {
  118496. private _mode;
  118497. private _associatedVariableName;
  118498. private _storedValue;
  118499. private _valueCallback;
  118500. private _type;
  118501. private _animationType;
  118502. /** @hidden */
  118503. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  118504. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118505. visibleInInspector: boolean;
  118506. /**
  118507. * Gets or sets the connection point type (default is float)
  118508. */
  118509. readonly type: NodeMaterialBlockConnectionPointTypes;
  118510. /**
  118511. * Creates a new InputBlock
  118512. * @param name defines the block name
  118513. * @param target defines the target of that block (Vertex by default)
  118514. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118515. */
  118516. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118517. /**
  118518. * Gets the output component
  118519. */
  118520. readonly output: NodeMaterialConnectionPoint;
  118521. /**
  118522. * Set the source of this connection point to a vertex attribute
  118523. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118524. * @returns the current connection point
  118525. */
  118526. setAsAttribute(attributeName?: string): InputBlock;
  118527. /**
  118528. * Set the source of this connection point to a well known value
  118529. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  118530. * @returns the current connection point
  118531. */
  118532. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  118533. /**
  118534. * Gets or sets the value of that point.
  118535. * Please note that this value will be ignored if valueCallback is defined
  118536. */
  118537. value: any;
  118538. /**
  118539. * Gets or sets a callback used to get the value of that point.
  118540. * Please note that setting this value will force the connection point to ignore the value property
  118541. */
  118542. valueCallback: () => any;
  118543. /**
  118544. * Gets or sets the associated variable name in the shader
  118545. */
  118546. associatedVariableName: string;
  118547. /** Gets or sets the type of animation applied to the input */
  118548. animationType: AnimatedInputBlockTypes;
  118549. /**
  118550. * Gets a boolean indicating that this connection point not defined yet
  118551. */
  118552. readonly isUndefined: boolean;
  118553. /**
  118554. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118555. * In this case the connection point name must be the name of the uniform to use.
  118556. * Can only be set on inputs
  118557. */
  118558. isUniform: boolean;
  118559. /**
  118560. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118561. * In this case the connection point name must be the name of the attribute to use
  118562. * Can only be set on inputs
  118563. */
  118564. isAttribute: boolean;
  118565. /**
  118566. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118567. * Can only be set on exit points
  118568. */
  118569. isVarying: boolean;
  118570. /**
  118571. * Gets a boolean indicating that the current connection point is a well known value
  118572. */
  118573. readonly isWellKnownValue: boolean;
  118574. /**
  118575. * Gets or sets the current well known value or null if not defined as well know value
  118576. */
  118577. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  118578. /**
  118579. * Gets the current class name
  118580. * @returns the class name
  118581. */
  118582. getClassName(): string;
  118583. /**
  118584. * Animate the input if animationType !== None
  118585. * @param scene defines the rendering scene
  118586. */
  118587. animate(scene: Scene): void;
  118588. private _emitDefine;
  118589. /**
  118590. * Set the input block to its default value (based on its type)
  118591. */
  118592. setDefaultValue(): void;
  118593. protected _dumpPropertiesCode(): string;
  118594. private _emit;
  118595. /** @hidden */
  118596. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118597. /** @hidden */
  118598. _transmit(effect: Effect, scene: Scene): void;
  118599. protected _buildBlock(state: NodeMaterialBuildState): void;
  118600. serialize(): any;
  118601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118602. }
  118603. }
  118604. declare module BABYLON {
  118605. /**
  118606. * Defines a connection point for a block
  118607. */
  118608. export class NodeMaterialConnectionPoint {
  118609. /** @hidden */
  118610. _ownerBlock: NodeMaterialBlock;
  118611. /** @hidden */
  118612. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118613. private _endpoints;
  118614. private _associatedVariableName;
  118615. /** @hidden */
  118616. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118617. /** @hidden */
  118618. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118619. private _type;
  118620. /** @hidden */
  118621. _enforceAssociatedVariableName: boolean;
  118622. /**
  118623. * Gets or sets the additional types supported byt this connection point
  118624. */
  118625. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  118626. /**
  118627. * Gets or sets the associated variable name in the shader
  118628. */
  118629. associatedVariableName: string;
  118630. /**
  118631. * Gets or sets the connection point type (default is float)
  118632. */
  118633. type: NodeMaterialBlockConnectionPointTypes;
  118634. /**
  118635. * Gets or sets the connection point name
  118636. */
  118637. name: string;
  118638. /**
  118639. * Gets or sets a boolean indicating that this connection point can be omitted
  118640. */
  118641. isOptional: boolean;
  118642. /**
  118643. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  118644. */
  118645. define: string;
  118646. /** Gets or sets the target of that connection point */
  118647. target: NodeMaterialBlockTargets;
  118648. /**
  118649. * Gets a boolean indicating that the current point is connected
  118650. */
  118651. readonly isConnected: boolean;
  118652. /**
  118653. * Gets a boolean indicating that the current point is connected to an input block
  118654. */
  118655. readonly isConnectedToInputBlock: boolean;
  118656. /**
  118657. * Gets a the connected input block (if any)
  118658. */
  118659. readonly connectInputBlock: Nullable<InputBlock>;
  118660. /** Get the other side of the connection (if any) */
  118661. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118662. /** Get the block that owns this connection point */
  118663. readonly ownerBlock: NodeMaterialBlock;
  118664. /** Get the block connected on the other side of this connection (if any) */
  118665. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  118666. /** Get the block connected on the endpoints of this connection (if any) */
  118667. readonly connectedBlocks: Array<NodeMaterialBlock>;
  118668. /** Gets the list of connected endpoints */
  118669. readonly endpoints: NodeMaterialConnectionPoint[];
  118670. /** Gets a boolean indicating if that output point is connected to at least one input */
  118671. readonly hasEndpoints: boolean;
  118672. /**
  118673. * Creates a new connection point
  118674. * @param name defines the connection point name
  118675. * @param ownerBlock defines the block hosting this connection point
  118676. */
  118677. constructor(name: string, ownerBlock: NodeMaterialBlock);
  118678. /**
  118679. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  118680. * @returns the class name
  118681. */
  118682. getClassName(): string;
  118683. /**
  118684. * Gets an boolean indicating if the current point can be connected to another point
  118685. * @param connectionPoint defines the other connection point
  118686. * @returns true if the connection is possible
  118687. */
  118688. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  118689. /**
  118690. * Connect this point to another connection point
  118691. * @param connectionPoint defines the other connection point
  118692. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  118693. * @returns the current connection point
  118694. */
  118695. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  118696. /**
  118697. * Disconnect this point from one of his endpoint
  118698. * @param endpoint defines the other connection point
  118699. * @returns the current connection point
  118700. */
  118701. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  118702. /**
  118703. * Serializes this point in a JSON representation
  118704. * @returns the serialized point object
  118705. */
  118706. serialize(): any;
  118707. }
  118708. }
  118709. declare module BABYLON {
  118710. /**
  118711. * Block used to add support for vertex skinning (bones)
  118712. */
  118713. export class BonesBlock extends NodeMaterialBlock {
  118714. /**
  118715. * Creates a new BonesBlock
  118716. * @param name defines the block name
  118717. */
  118718. constructor(name: string);
  118719. /**
  118720. * Initialize the block and prepare the context for build
  118721. * @param state defines the state that will be used for the build
  118722. */
  118723. initialize(state: NodeMaterialBuildState): void;
  118724. /**
  118725. * Gets the current class name
  118726. * @returns the class name
  118727. */
  118728. getClassName(): string;
  118729. /**
  118730. * Gets the matrix indices input component
  118731. */
  118732. readonly matricesIndices: NodeMaterialConnectionPoint;
  118733. /**
  118734. * Gets the matrix weights input component
  118735. */
  118736. readonly matricesWeights: NodeMaterialConnectionPoint;
  118737. /**
  118738. * Gets the extra matrix indices input component
  118739. */
  118740. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  118741. /**
  118742. * Gets the extra matrix weights input component
  118743. */
  118744. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  118745. /**
  118746. * Gets the world input component
  118747. */
  118748. readonly world: NodeMaterialConnectionPoint;
  118749. /**
  118750. * Gets the output component
  118751. */
  118752. readonly output: NodeMaterialConnectionPoint;
  118753. autoConfigure(material: NodeMaterial): void;
  118754. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118757. protected _buildBlock(state: NodeMaterialBuildState): this;
  118758. }
  118759. }
  118760. declare module BABYLON {
  118761. /**
  118762. * Block used to add support for instances
  118763. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118764. */
  118765. export class InstancesBlock extends NodeMaterialBlock {
  118766. /**
  118767. * Creates a new InstancesBlock
  118768. * @param name defines the block name
  118769. */
  118770. constructor(name: string);
  118771. /**
  118772. * Gets the current class name
  118773. * @returns the class name
  118774. */
  118775. getClassName(): string;
  118776. /**
  118777. * Gets the first world row input component
  118778. */
  118779. readonly world0: NodeMaterialConnectionPoint;
  118780. /**
  118781. * Gets the second world row input component
  118782. */
  118783. readonly world1: NodeMaterialConnectionPoint;
  118784. /**
  118785. * Gets the third world row input component
  118786. */
  118787. readonly world2: NodeMaterialConnectionPoint;
  118788. /**
  118789. * Gets the forth world row input component
  118790. */
  118791. readonly world3: NodeMaterialConnectionPoint;
  118792. /**
  118793. * Gets the world input component
  118794. */
  118795. readonly world: NodeMaterialConnectionPoint;
  118796. /**
  118797. * Gets the output component
  118798. */
  118799. readonly output: NodeMaterialConnectionPoint;
  118800. autoConfigure(material: NodeMaterial): void;
  118801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118802. protected _buildBlock(state: NodeMaterialBuildState): this;
  118803. }
  118804. }
  118805. declare module BABYLON {
  118806. /**
  118807. * Block used to add morph targets support to vertex shader
  118808. */
  118809. export class MorphTargetsBlock extends NodeMaterialBlock {
  118810. private _repeatableContentAnchor;
  118811. private _repeatebleContentGenerated;
  118812. /**
  118813. * Create a new MorphTargetsBlock
  118814. * @param name defines the block name
  118815. */
  118816. constructor(name: string);
  118817. /**
  118818. * Gets the current class name
  118819. * @returns the class name
  118820. */
  118821. getClassName(): string;
  118822. /**
  118823. * Gets the position input component
  118824. */
  118825. readonly position: NodeMaterialConnectionPoint;
  118826. /**
  118827. * Gets the normal input component
  118828. */
  118829. readonly normal: NodeMaterialConnectionPoint;
  118830. /**
  118831. * Gets the tangent input component
  118832. */
  118833. readonly tangent: NodeMaterialConnectionPoint;
  118834. /**
  118835. * Gets the tangent input component
  118836. */
  118837. readonly uv: NodeMaterialConnectionPoint;
  118838. /**
  118839. * Gets the position output component
  118840. */
  118841. readonly positionOutput: NodeMaterialConnectionPoint;
  118842. /**
  118843. * Gets the normal output component
  118844. */
  118845. readonly normalOutput: NodeMaterialConnectionPoint;
  118846. /**
  118847. * Gets the tangent output component
  118848. */
  118849. readonly tangentOutput: NodeMaterialConnectionPoint;
  118850. /**
  118851. * Gets the tangent output component
  118852. */
  118853. readonly uvOutput: NodeMaterialConnectionPoint;
  118854. initialize(state: NodeMaterialBuildState): void;
  118855. autoConfigure(material: NodeMaterial): void;
  118856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118858. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118859. protected _buildBlock(state: NodeMaterialBuildState): this;
  118860. }
  118861. }
  118862. declare module BABYLON {
  118863. /**
  118864. * Block used to get data information from a light
  118865. */
  118866. export class LightInformationBlock extends NodeMaterialBlock {
  118867. private _lightDataDefineName;
  118868. private _lightColorDefineName;
  118869. /**
  118870. * Gets or sets the light associated with this block
  118871. */
  118872. light: Nullable<Light>;
  118873. /**
  118874. * Creates a new LightInformationBlock
  118875. * @param name defines the block name
  118876. */
  118877. constructor(name: string);
  118878. /**
  118879. * Gets the current class name
  118880. * @returns the class name
  118881. */
  118882. getClassName(): string;
  118883. /**
  118884. * Gets the world position input component
  118885. */
  118886. readonly worldPosition: NodeMaterialConnectionPoint;
  118887. /**
  118888. * Gets the direction output component
  118889. */
  118890. readonly direction: NodeMaterialConnectionPoint;
  118891. /**
  118892. * Gets the direction output component
  118893. */
  118894. readonly color: NodeMaterialConnectionPoint;
  118895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118896. protected _buildBlock(state: NodeMaterialBuildState): this;
  118897. serialize(): any;
  118898. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118899. }
  118900. }
  118901. declare module BABYLON {
  118902. /**
  118903. * Block used to add an alpha test in the fragment shader
  118904. */
  118905. export class AlphaTestBlock extends NodeMaterialBlock {
  118906. /**
  118907. * Gets or sets the alpha value where alpha testing happens
  118908. */
  118909. alphaCutOff: number;
  118910. /**
  118911. * Create a new AlphaTestBlock
  118912. * @param name defines the block name
  118913. */
  118914. constructor(name: string);
  118915. /**
  118916. * Gets the current class name
  118917. * @returns the class name
  118918. */
  118919. getClassName(): string;
  118920. /**
  118921. * Gets the color input component
  118922. */
  118923. readonly color: NodeMaterialConnectionPoint;
  118924. /**
  118925. * Gets the alpha input component
  118926. */
  118927. readonly alpha: NodeMaterialConnectionPoint;
  118928. protected _buildBlock(state: NodeMaterialBuildState): this;
  118929. protected _dumpPropertiesCode(): string;
  118930. serialize(): any;
  118931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118932. }
  118933. }
  118934. declare module BABYLON {
  118935. /**
  118936. * Block used to add image processing support to fragment shader
  118937. */
  118938. export class ImageProcessingBlock extends NodeMaterialBlock {
  118939. /**
  118940. * Create a new ImageProcessingBlock
  118941. * @param name defines the block name
  118942. */
  118943. constructor(name: string);
  118944. /**
  118945. * Gets the current class name
  118946. * @returns the class name
  118947. */
  118948. getClassName(): string;
  118949. /**
  118950. * Gets the color input component
  118951. */
  118952. readonly color: NodeMaterialConnectionPoint;
  118953. /**
  118954. * Gets the output component
  118955. */
  118956. readonly output: NodeMaterialConnectionPoint;
  118957. /**
  118958. * Initialize the block and prepare the context for build
  118959. * @param state defines the state that will be used for the build
  118960. */
  118961. initialize(state: NodeMaterialBuildState): void;
  118962. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118965. protected _buildBlock(state: NodeMaterialBuildState): this;
  118966. }
  118967. }
  118968. declare module BABYLON {
  118969. /**
  118970. * Block used to add support for scene fog
  118971. */
  118972. export class FogBlock extends NodeMaterialBlock {
  118973. private _fogDistanceName;
  118974. private _fogParameters;
  118975. /**
  118976. * Create a new FogBlock
  118977. * @param name defines the block name
  118978. */
  118979. constructor(name: string);
  118980. /**
  118981. * Gets the current class name
  118982. * @returns the class name
  118983. */
  118984. getClassName(): string;
  118985. /**
  118986. * Gets the world position input component
  118987. */
  118988. readonly worldPosition: NodeMaterialConnectionPoint;
  118989. /**
  118990. * Gets the view input component
  118991. */
  118992. readonly view: NodeMaterialConnectionPoint;
  118993. /**
  118994. * Gets the color input component
  118995. */
  118996. readonly input: NodeMaterialConnectionPoint;
  118997. /**
  118998. * Gets the fog color input component
  118999. */
  119000. readonly fogColor: NodeMaterialConnectionPoint;
  119001. /**
  119002. * Gets the output component
  119003. */
  119004. readonly output: NodeMaterialConnectionPoint;
  119005. autoConfigure(material: NodeMaterial): void;
  119006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119007. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119008. protected _buildBlock(state: NodeMaterialBuildState): this;
  119009. }
  119010. }
  119011. declare module BABYLON {
  119012. /**
  119013. * Block used to add light in the fragment shader
  119014. */
  119015. export class LightBlock extends NodeMaterialBlock {
  119016. private _lightId;
  119017. /**
  119018. * Gets or sets the light associated with this block
  119019. */
  119020. light: Nullable<Light>;
  119021. /**
  119022. * Create a new LightBlock
  119023. * @param name defines the block name
  119024. */
  119025. constructor(name: string);
  119026. /**
  119027. * Gets the current class name
  119028. * @returns the class name
  119029. */
  119030. getClassName(): string;
  119031. /**
  119032. * Gets the world position input component
  119033. */
  119034. readonly worldPosition: NodeMaterialConnectionPoint;
  119035. /**
  119036. * Gets the world normal input component
  119037. */
  119038. readonly worldNormal: NodeMaterialConnectionPoint;
  119039. /**
  119040. * Gets the camera (or eye) position component
  119041. */
  119042. readonly cameraPosition: NodeMaterialConnectionPoint;
  119043. /**
  119044. * Gets the diffuse output component
  119045. */
  119046. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119047. /**
  119048. * Gets the specular output component
  119049. */
  119050. readonly specularOutput: NodeMaterialConnectionPoint;
  119051. autoConfigure(material: NodeMaterial): void;
  119052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119053. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119055. private _injectVertexCode;
  119056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119057. serialize(): any;
  119058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119059. }
  119060. }
  119061. declare module BABYLON {
  119062. /**
  119063. * Block used to multiply 2 values
  119064. */
  119065. export class MultiplyBlock extends NodeMaterialBlock {
  119066. /**
  119067. * Creates a new MultiplyBlock
  119068. * @param name defines the block name
  119069. */
  119070. constructor(name: string);
  119071. /**
  119072. * Gets the current class name
  119073. * @returns the class name
  119074. */
  119075. getClassName(): string;
  119076. /**
  119077. * Gets the left operand input component
  119078. */
  119079. readonly left: NodeMaterialConnectionPoint;
  119080. /**
  119081. * Gets the right operand input component
  119082. */
  119083. readonly right: NodeMaterialConnectionPoint;
  119084. /**
  119085. * Gets the output component
  119086. */
  119087. readonly output: NodeMaterialConnectionPoint;
  119088. protected _buildBlock(state: NodeMaterialBuildState): this;
  119089. }
  119090. }
  119091. declare module BABYLON {
  119092. /**
  119093. * Block used to add 2 vectors
  119094. */
  119095. export class AddBlock extends NodeMaterialBlock {
  119096. /**
  119097. * Creates a new AddBlock
  119098. * @param name defines the block name
  119099. */
  119100. constructor(name: string);
  119101. /**
  119102. * Gets the current class name
  119103. * @returns the class name
  119104. */
  119105. getClassName(): string;
  119106. /**
  119107. * Gets the left operand input component
  119108. */
  119109. readonly left: NodeMaterialConnectionPoint;
  119110. /**
  119111. * Gets the right operand input component
  119112. */
  119113. readonly right: NodeMaterialConnectionPoint;
  119114. /**
  119115. * Gets the output component
  119116. */
  119117. readonly output: NodeMaterialConnectionPoint;
  119118. protected _buildBlock(state: NodeMaterialBuildState): this;
  119119. }
  119120. }
  119121. declare module BABYLON {
  119122. /**
  119123. * Block used to scale a vector by a float
  119124. */
  119125. export class ScaleBlock extends NodeMaterialBlock {
  119126. /**
  119127. * Creates a new ScaleBlock
  119128. * @param name defines the block name
  119129. */
  119130. constructor(name: string);
  119131. /**
  119132. * Gets the current class name
  119133. * @returns the class name
  119134. */
  119135. getClassName(): string;
  119136. /**
  119137. * Gets the input component
  119138. */
  119139. readonly input: NodeMaterialConnectionPoint;
  119140. /**
  119141. * Gets the factor input component
  119142. */
  119143. readonly factor: NodeMaterialConnectionPoint;
  119144. /**
  119145. * Gets the output component
  119146. */
  119147. readonly output: NodeMaterialConnectionPoint;
  119148. protected _buildBlock(state: NodeMaterialBuildState): this;
  119149. }
  119150. }
  119151. declare module BABYLON {
  119152. /**
  119153. * Block used to clamp a float
  119154. */
  119155. export class ClampBlock extends NodeMaterialBlock {
  119156. /** Gets or sets the minimum range */
  119157. minimum: number;
  119158. /** Gets or sets the maximum range */
  119159. maximum: number;
  119160. /**
  119161. * Creates a new ClampBlock
  119162. * @param name defines the block name
  119163. */
  119164. constructor(name: string);
  119165. /**
  119166. * Gets the current class name
  119167. * @returns the class name
  119168. */
  119169. getClassName(): string;
  119170. /**
  119171. * Gets the value input component
  119172. */
  119173. readonly value: NodeMaterialConnectionPoint;
  119174. /**
  119175. * Gets the output component
  119176. */
  119177. readonly output: NodeMaterialConnectionPoint;
  119178. protected _buildBlock(state: NodeMaterialBuildState): this;
  119179. protected _dumpPropertiesCode(): string;
  119180. serialize(): any;
  119181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119182. }
  119183. }
  119184. declare module BABYLON {
  119185. /**
  119186. * Block used to apply a cross product between 2 vectors
  119187. */
  119188. export class CrossBlock extends NodeMaterialBlock {
  119189. /**
  119190. * Creates a new CrossBlock
  119191. * @param name defines the block name
  119192. */
  119193. constructor(name: string);
  119194. /**
  119195. * Gets the current class name
  119196. * @returns the class name
  119197. */
  119198. getClassName(): string;
  119199. /**
  119200. * Gets the left operand input component
  119201. */
  119202. readonly left: NodeMaterialConnectionPoint;
  119203. /**
  119204. * Gets the right operand input component
  119205. */
  119206. readonly right: NodeMaterialConnectionPoint;
  119207. /**
  119208. * Gets the output component
  119209. */
  119210. readonly output: NodeMaterialConnectionPoint;
  119211. protected _buildBlock(state: NodeMaterialBuildState): this;
  119212. }
  119213. }
  119214. declare module BABYLON {
  119215. /**
  119216. * Block used to apply a dot product between 2 vectors
  119217. */
  119218. export class DotBlock extends NodeMaterialBlock {
  119219. /**
  119220. * Creates a new DotBlock
  119221. * @param name defines the block name
  119222. */
  119223. constructor(name: string);
  119224. /**
  119225. * Gets the current class name
  119226. * @returns the class name
  119227. */
  119228. getClassName(): string;
  119229. /**
  119230. * Gets the left operand input component
  119231. */
  119232. readonly left: NodeMaterialConnectionPoint;
  119233. /**
  119234. * Gets the right operand input component
  119235. */
  119236. readonly right: NodeMaterialConnectionPoint;
  119237. /**
  119238. * Gets the output component
  119239. */
  119240. readonly output: NodeMaterialConnectionPoint;
  119241. protected _buildBlock(state: NodeMaterialBuildState): this;
  119242. }
  119243. }
  119244. declare module BABYLON {
  119245. /**
  119246. * Block used to remap a float from a range to a new one
  119247. */
  119248. export class RemapBlock extends NodeMaterialBlock {
  119249. /**
  119250. * Gets or sets the source range
  119251. */
  119252. sourceRange: Vector2;
  119253. /**
  119254. * Gets or sets the target range
  119255. */
  119256. targetRange: Vector2;
  119257. /**
  119258. * Creates a new RemapBlock
  119259. * @param name defines the block name
  119260. */
  119261. constructor(name: string);
  119262. /**
  119263. * Gets the current class name
  119264. * @returns the class name
  119265. */
  119266. getClassName(): string;
  119267. /**
  119268. * Gets the input component
  119269. */
  119270. readonly input: NodeMaterialConnectionPoint;
  119271. /**
  119272. * Gets the output component
  119273. */
  119274. readonly output: NodeMaterialConnectionPoint;
  119275. protected _buildBlock(state: NodeMaterialBuildState): this;
  119276. protected _dumpPropertiesCode(): string;
  119277. serialize(): any;
  119278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119279. }
  119280. }
  119281. declare module BABYLON {
  119282. /**
  119283. * Block used to normalize a vector
  119284. */
  119285. export class NormalizeBlock extends NodeMaterialBlock {
  119286. /**
  119287. * Creates a new NormalizeBlock
  119288. * @param name defines the block name
  119289. */
  119290. constructor(name: string);
  119291. /**
  119292. * Gets the current class name
  119293. * @returns the class name
  119294. */
  119295. getClassName(): string;
  119296. /**
  119297. * Gets the input component
  119298. */
  119299. readonly input: NodeMaterialConnectionPoint;
  119300. /**
  119301. * Gets the output component
  119302. */
  119303. readonly output: NodeMaterialConnectionPoint;
  119304. protected _buildBlock(state: NodeMaterialBuildState): this;
  119305. }
  119306. }
  119307. declare module BABYLON {
  119308. /**
  119309. * Operations supported by the Trigonometry block
  119310. */
  119311. export enum TrigonometryBlockOperations {
  119312. /** Cos */
  119313. Cos = 0,
  119314. /** Sin */
  119315. Sin = 1,
  119316. /** Abs */
  119317. Abs = 2,
  119318. /** Exp */
  119319. Exp = 3,
  119320. /** Exp2 */
  119321. Exp2 = 4,
  119322. /** Round */
  119323. Round = 5,
  119324. /** Floor */
  119325. Floor = 6,
  119326. /** Ceiling */
  119327. Ceiling = 7
  119328. }
  119329. /**
  119330. * Block used to apply trigonometry operation to floats
  119331. */
  119332. export class TrigonometryBlock extends NodeMaterialBlock {
  119333. /**
  119334. * Gets or sets the operation applied by the block
  119335. */
  119336. operation: TrigonometryBlockOperations;
  119337. /**
  119338. * Creates a new TrigonometryBlock
  119339. * @param name defines the block name
  119340. */
  119341. constructor(name: string);
  119342. /**
  119343. * Gets the current class name
  119344. * @returns the class name
  119345. */
  119346. getClassName(): string;
  119347. /**
  119348. * Gets the input component
  119349. */
  119350. readonly input: NodeMaterialConnectionPoint;
  119351. /**
  119352. * Gets the output component
  119353. */
  119354. readonly output: NodeMaterialConnectionPoint;
  119355. protected _buildBlock(state: NodeMaterialBuildState): this;
  119356. serialize(): any;
  119357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119358. }
  119359. }
  119360. declare module BABYLON {
  119361. /**
  119362. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119363. */
  119364. export class ColorMergerBlock extends NodeMaterialBlock {
  119365. /**
  119366. * Create a new ColorMergerBlock
  119367. * @param name defines the block name
  119368. */
  119369. constructor(name: string);
  119370. /**
  119371. * Gets the current class name
  119372. * @returns the class name
  119373. */
  119374. getClassName(): string;
  119375. /**
  119376. * Gets the r component (input)
  119377. */
  119378. readonly r: NodeMaterialConnectionPoint;
  119379. /**
  119380. * Gets the g component (input)
  119381. */
  119382. readonly g: NodeMaterialConnectionPoint;
  119383. /**
  119384. * Gets the b component (input)
  119385. */
  119386. readonly b: NodeMaterialConnectionPoint;
  119387. /**
  119388. * Gets the a component (input)
  119389. */
  119390. readonly a: NodeMaterialConnectionPoint;
  119391. /**
  119392. * Gets the rgba component (output)
  119393. */
  119394. readonly rgba: NodeMaterialConnectionPoint;
  119395. /**
  119396. * Gets the rgb component (output)
  119397. */
  119398. readonly rgb: NodeMaterialConnectionPoint;
  119399. protected _buildBlock(state: NodeMaterialBuildState): this;
  119400. }
  119401. }
  119402. declare module BABYLON {
  119403. /**
  119404. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119405. */
  119406. export class VectorMergerBlock extends NodeMaterialBlock {
  119407. /**
  119408. * Create a new VectorMergerBlock
  119409. * @param name defines the block name
  119410. */
  119411. constructor(name: string);
  119412. /**
  119413. * Gets the current class name
  119414. * @returns the class name
  119415. */
  119416. getClassName(): string;
  119417. /**
  119418. * Gets the x component (input)
  119419. */
  119420. readonly x: NodeMaterialConnectionPoint;
  119421. /**
  119422. * Gets the y component (input)
  119423. */
  119424. readonly y: NodeMaterialConnectionPoint;
  119425. /**
  119426. * Gets the z component (input)
  119427. */
  119428. readonly z: NodeMaterialConnectionPoint;
  119429. /**
  119430. * Gets the w component (input)
  119431. */
  119432. readonly w: NodeMaterialConnectionPoint;
  119433. /**
  119434. * Gets the xyzw component (output)
  119435. */
  119436. readonly xyzw: NodeMaterialConnectionPoint;
  119437. /**
  119438. * Gets the xyz component (output)
  119439. */
  119440. readonly xyz: NodeMaterialConnectionPoint;
  119441. /**
  119442. * Gets the xy component (output)
  119443. */
  119444. readonly xy: NodeMaterialConnectionPoint;
  119445. protected _buildBlock(state: NodeMaterialBuildState): this;
  119446. }
  119447. }
  119448. declare module BABYLON {
  119449. /**
  119450. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119451. */
  119452. export class ColorSplitterBlock extends NodeMaterialBlock {
  119453. /**
  119454. * Create a new ColorSplitterBlock
  119455. * @param name defines the block name
  119456. */
  119457. constructor(name: string);
  119458. /**
  119459. * Gets the current class name
  119460. * @returns the class name
  119461. */
  119462. getClassName(): string;
  119463. /**
  119464. * Gets the rgba component (input)
  119465. */
  119466. readonly rgba: NodeMaterialConnectionPoint;
  119467. /**
  119468. * Gets the rgb component (input)
  119469. */
  119470. readonly rgbIn: NodeMaterialConnectionPoint;
  119471. /**
  119472. * Gets the rgb component (output)
  119473. */
  119474. readonly rgbOut: NodeMaterialConnectionPoint;
  119475. /**
  119476. * Gets the r component (output)
  119477. */
  119478. readonly r: NodeMaterialConnectionPoint;
  119479. /**
  119480. * Gets the g component (output)
  119481. */
  119482. readonly g: NodeMaterialConnectionPoint;
  119483. /**
  119484. * Gets the b component (output)
  119485. */
  119486. readonly b: NodeMaterialConnectionPoint;
  119487. /**
  119488. * Gets the a component (output)
  119489. */
  119490. readonly a: NodeMaterialConnectionPoint;
  119491. protected _inputRename(name: string): string;
  119492. protected _outputRename(name: string): string;
  119493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119494. }
  119495. }
  119496. declare module BABYLON {
  119497. /**
  119498. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119499. */
  119500. export class VectorSplitterBlock extends NodeMaterialBlock {
  119501. /**
  119502. * Create a new VectorSplitterBlock
  119503. * @param name defines the block name
  119504. */
  119505. constructor(name: string);
  119506. /**
  119507. * Gets the current class name
  119508. * @returns the class name
  119509. */
  119510. getClassName(): string;
  119511. /**
  119512. * Gets the xyzw component (input)
  119513. */
  119514. readonly xyzw: NodeMaterialConnectionPoint;
  119515. /**
  119516. * Gets the xyz component (input)
  119517. */
  119518. readonly xyzIn: NodeMaterialConnectionPoint;
  119519. /**
  119520. * Gets the xy component (input)
  119521. */
  119522. readonly xyIn: NodeMaterialConnectionPoint;
  119523. /**
  119524. * Gets the xyz component (output)
  119525. */
  119526. readonly xyzOut: NodeMaterialConnectionPoint;
  119527. /**
  119528. * Gets the xy component (output)
  119529. */
  119530. readonly xyOut: NodeMaterialConnectionPoint;
  119531. /**
  119532. * Gets the x component (output)
  119533. */
  119534. readonly x: NodeMaterialConnectionPoint;
  119535. /**
  119536. * Gets the y component (output)
  119537. */
  119538. readonly y: NodeMaterialConnectionPoint;
  119539. /**
  119540. * Gets the z component (output)
  119541. */
  119542. readonly z: NodeMaterialConnectionPoint;
  119543. /**
  119544. * Gets the w component (output)
  119545. */
  119546. readonly w: NodeMaterialConnectionPoint;
  119547. protected _inputRename(name: string): string;
  119548. protected _outputRename(name: string): string;
  119549. protected _buildBlock(state: NodeMaterialBuildState): this;
  119550. }
  119551. }
  119552. declare module BABYLON {
  119553. /**
  119554. * Block used to lerp 2 values
  119555. */
  119556. export class LerpBlock extends NodeMaterialBlock {
  119557. /**
  119558. * Creates a new LerpBlock
  119559. * @param name defines the block name
  119560. */
  119561. constructor(name: string);
  119562. /**
  119563. * Gets the current class name
  119564. * @returns the class name
  119565. */
  119566. getClassName(): string;
  119567. /**
  119568. * Gets the left operand input component
  119569. */
  119570. readonly left: NodeMaterialConnectionPoint;
  119571. /**
  119572. * Gets the right operand input component
  119573. */
  119574. readonly right: NodeMaterialConnectionPoint;
  119575. /**
  119576. * Gets the gradient operand input component
  119577. */
  119578. readonly gradient: NodeMaterialConnectionPoint;
  119579. /**
  119580. * Gets the output component
  119581. */
  119582. readonly output: NodeMaterialConnectionPoint;
  119583. protected _buildBlock(state: NodeMaterialBuildState): this;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /**
  119588. * Block used to divide 2 vectors
  119589. */
  119590. export class DivideBlock extends NodeMaterialBlock {
  119591. /**
  119592. * Creates a new DivideBlock
  119593. * @param name defines the block name
  119594. */
  119595. constructor(name: string);
  119596. /**
  119597. * Gets the current class name
  119598. * @returns the class name
  119599. */
  119600. getClassName(): string;
  119601. /**
  119602. * Gets the left operand input component
  119603. */
  119604. readonly left: NodeMaterialConnectionPoint;
  119605. /**
  119606. * Gets the right operand input component
  119607. */
  119608. readonly right: NodeMaterialConnectionPoint;
  119609. /**
  119610. * Gets the output component
  119611. */
  119612. readonly output: NodeMaterialConnectionPoint;
  119613. protected _buildBlock(state: NodeMaterialBuildState): this;
  119614. }
  119615. }
  119616. declare module BABYLON {
  119617. /**
  119618. * Block used to subtract 2 vectors
  119619. */
  119620. export class SubtractBlock extends NodeMaterialBlock {
  119621. /**
  119622. * Creates a new SubtractBlock
  119623. * @param name defines the block name
  119624. */
  119625. constructor(name: string);
  119626. /**
  119627. * Gets the current class name
  119628. * @returns the class name
  119629. */
  119630. getClassName(): string;
  119631. /**
  119632. * Gets the left operand input component
  119633. */
  119634. readonly left: NodeMaterialConnectionPoint;
  119635. /**
  119636. * Gets the right operand input component
  119637. */
  119638. readonly right: NodeMaterialConnectionPoint;
  119639. /**
  119640. * Gets the output component
  119641. */
  119642. readonly output: NodeMaterialConnectionPoint;
  119643. protected _buildBlock(state: NodeMaterialBuildState): this;
  119644. }
  119645. }
  119646. declare module BABYLON {
  119647. /**
  119648. * Block used to step a value
  119649. */
  119650. export class StepBlock extends NodeMaterialBlock {
  119651. /**
  119652. * Creates a new AddBlock
  119653. * @param name defines the block name
  119654. */
  119655. constructor(name: string);
  119656. /**
  119657. * Gets the current class name
  119658. * @returns the class name
  119659. */
  119660. getClassName(): string;
  119661. /**
  119662. * Gets the value operand input component
  119663. */
  119664. readonly value: NodeMaterialConnectionPoint;
  119665. /**
  119666. * Gets the edge operand input component
  119667. */
  119668. readonly edge: NodeMaterialConnectionPoint;
  119669. /**
  119670. * Gets the output component
  119671. */
  119672. readonly output: NodeMaterialConnectionPoint;
  119673. protected _buildBlock(state: NodeMaterialBuildState): this;
  119674. }
  119675. }
  119676. declare module BABYLON {
  119677. /**
  119678. * Block used to get the opposite of a value
  119679. */
  119680. export class OppositeBlock extends NodeMaterialBlock {
  119681. /**
  119682. * Creates a new OppositeBlock
  119683. * @param name defines the block name
  119684. */
  119685. constructor(name: string);
  119686. /**
  119687. * Gets the current class name
  119688. * @returns the class name
  119689. */
  119690. getClassName(): string;
  119691. /**
  119692. * Gets the input component
  119693. */
  119694. readonly input: NodeMaterialConnectionPoint;
  119695. /**
  119696. * Gets the output component
  119697. */
  119698. readonly output: NodeMaterialConnectionPoint;
  119699. protected _buildBlock(state: NodeMaterialBuildState): this;
  119700. }
  119701. }
  119702. declare module BABYLON {
  119703. /**
  119704. * Block used to get the view direction
  119705. */
  119706. export class ViewDirectionBlock extends NodeMaterialBlock {
  119707. /**
  119708. * Creates a new ViewDirectionBlock
  119709. * @param name defines the block name
  119710. */
  119711. constructor(name: string);
  119712. /**
  119713. * Gets the current class name
  119714. * @returns the class name
  119715. */
  119716. getClassName(): string;
  119717. /**
  119718. * Gets the world position component
  119719. */
  119720. readonly worldPosition: NodeMaterialConnectionPoint;
  119721. /**
  119722. * Gets the camera position component
  119723. */
  119724. readonly cameraPosition: NodeMaterialConnectionPoint;
  119725. /**
  119726. * Gets the output component
  119727. */
  119728. readonly output: NodeMaterialConnectionPoint;
  119729. autoConfigure(material: NodeMaterial): void;
  119730. protected _buildBlock(state: NodeMaterialBuildState): this;
  119731. }
  119732. }
  119733. declare module BABYLON {
  119734. /**
  119735. * Block used to compute fresnel value
  119736. */
  119737. export class FresnelBlock extends NodeMaterialBlock {
  119738. /**
  119739. * Create a new FresnelBlock
  119740. * @param name defines the block name
  119741. */
  119742. constructor(name: string);
  119743. /**
  119744. * Gets the current class name
  119745. * @returns the class name
  119746. */
  119747. getClassName(): string;
  119748. /**
  119749. * Gets the world normal input component
  119750. */
  119751. readonly worldNormal: NodeMaterialConnectionPoint;
  119752. /**
  119753. * Gets the view direction input component
  119754. */
  119755. readonly viewDirection: NodeMaterialConnectionPoint;
  119756. /**
  119757. * Gets the bias input component
  119758. */
  119759. readonly bias: NodeMaterialConnectionPoint;
  119760. /**
  119761. * Gets the camera (or eye) position component
  119762. */
  119763. readonly power: NodeMaterialConnectionPoint;
  119764. /**
  119765. * Gets the fresnel output component
  119766. */
  119767. readonly fresnel: NodeMaterialConnectionPoint;
  119768. autoConfigure(material: NodeMaterial): void;
  119769. protected _buildBlock(state: NodeMaterialBuildState): this;
  119770. }
  119771. }
  119772. declare module BABYLON {
  119773. /**
  119774. * Block used to get the max of 2 values
  119775. */
  119776. export class MaxBlock extends NodeMaterialBlock {
  119777. /**
  119778. * Creates a new MaxBlock
  119779. * @param name defines the block name
  119780. */
  119781. constructor(name: string);
  119782. /**
  119783. * Gets the current class name
  119784. * @returns the class name
  119785. */
  119786. getClassName(): string;
  119787. /**
  119788. * Gets the left operand input component
  119789. */
  119790. readonly left: NodeMaterialConnectionPoint;
  119791. /**
  119792. * Gets the right operand input component
  119793. */
  119794. readonly right: NodeMaterialConnectionPoint;
  119795. /**
  119796. * Gets the output component
  119797. */
  119798. readonly output: NodeMaterialConnectionPoint;
  119799. protected _buildBlock(state: NodeMaterialBuildState): this;
  119800. }
  119801. }
  119802. declare module BABYLON {
  119803. /**
  119804. * Block used to get the min of 2 values
  119805. */
  119806. export class MinBlock extends NodeMaterialBlock {
  119807. /**
  119808. * Creates a new MinBlock
  119809. * @param name defines the block name
  119810. */
  119811. constructor(name: string);
  119812. /**
  119813. * Gets the current class name
  119814. * @returns the class name
  119815. */
  119816. getClassName(): string;
  119817. /**
  119818. * Gets the left operand input component
  119819. */
  119820. readonly left: NodeMaterialConnectionPoint;
  119821. /**
  119822. * Gets the right operand input component
  119823. */
  119824. readonly right: NodeMaterialConnectionPoint;
  119825. /**
  119826. * Gets the output component
  119827. */
  119828. readonly output: NodeMaterialConnectionPoint;
  119829. protected _buildBlock(state: NodeMaterialBuildState): this;
  119830. }
  119831. }
  119832. declare module BABYLON {
  119833. /**
  119834. * Effect Render Options
  119835. */
  119836. export interface IEffectRendererOptions {
  119837. /**
  119838. * Defines the vertices positions.
  119839. */
  119840. positions?: number[];
  119841. /**
  119842. * Defines the indices.
  119843. */
  119844. indices?: number[];
  119845. }
  119846. /**
  119847. * Helper class to render one or more effects
  119848. */
  119849. export class EffectRenderer {
  119850. private engine;
  119851. private static _DefaultOptions;
  119852. private _vertexBuffers;
  119853. private _indexBuffer;
  119854. private _ringBufferIndex;
  119855. private _ringScreenBuffer;
  119856. private _fullscreenViewport;
  119857. private _getNextFrameBuffer;
  119858. /**
  119859. * Creates an effect renderer
  119860. * @param engine the engine to use for rendering
  119861. * @param options defines the options of the effect renderer
  119862. */
  119863. constructor(engine: Engine, options?: IEffectRendererOptions);
  119864. /**
  119865. * Sets the current viewport in normalized coordinates 0-1
  119866. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  119867. */
  119868. setViewport(viewport?: Viewport): void;
  119869. /**
  119870. * Sets the current effect wrapper to use during draw.
  119871. * The effect needs to be ready before calling this api.
  119872. * This also sets the default full screen position attribute.
  119873. * @param effectWrapper Defines the effect to draw with
  119874. */
  119875. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  119876. /**
  119877. * Draws a full screen quad.
  119878. */
  119879. draw(): void;
  119880. /**
  119881. * renders one or more effects to a specified texture
  119882. * @param effectWrappers list of effects to renderer
  119883. * @param outputTexture texture to draw to, if null it will render to the screen
  119884. */
  119885. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  119886. /**
  119887. * Disposes of the effect renderer
  119888. */
  119889. dispose(): void;
  119890. }
  119891. /**
  119892. * Options to create an EffectWrapper
  119893. */
  119894. interface EffectWrapperCreationOptions {
  119895. /**
  119896. * Engine to use to create the effect
  119897. */
  119898. engine: Engine;
  119899. /**
  119900. * Fragment shader for the effect
  119901. */
  119902. fragmentShader: string;
  119903. /**
  119904. * Vertex shader for the effect
  119905. */
  119906. vertexShader?: string;
  119907. /**
  119908. * Attributes to use in the shader
  119909. */
  119910. attributeNames?: Array<string>;
  119911. /**
  119912. * Uniforms to use in the shader
  119913. */
  119914. uniformNames?: Array<string>;
  119915. /**
  119916. * Texture sampler names to use in the shader
  119917. */
  119918. samplerNames?: Array<string>;
  119919. /**
  119920. * The friendly name of the effect displayed in Spector.
  119921. */
  119922. name?: string;
  119923. }
  119924. /**
  119925. * Wraps an effect to be used for rendering
  119926. */
  119927. export class EffectWrapper {
  119928. /**
  119929. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  119930. */
  119931. onApplyObservable: Observable<{}>;
  119932. /**
  119933. * The underlying effect
  119934. */
  119935. effect: Effect;
  119936. /**
  119937. * Creates an effect to be renderer
  119938. * @param creationOptions options to create the effect
  119939. */
  119940. constructor(creationOptions: EffectWrapperCreationOptions);
  119941. /**
  119942. * Disposes of the effect wrapper
  119943. */
  119944. dispose(): void;
  119945. }
  119946. }
  119947. declare module BABYLON {
  119948. /**
  119949. * Helper class to push actions to a pool of workers.
  119950. */
  119951. export class WorkerPool implements IDisposable {
  119952. private _workerInfos;
  119953. private _pendingActions;
  119954. /**
  119955. * Constructor
  119956. * @param workers Array of workers to use for actions
  119957. */
  119958. constructor(workers: Array<Worker>);
  119959. /**
  119960. * Terminates all workers and clears any pending actions.
  119961. */
  119962. dispose(): void;
  119963. /**
  119964. * Pushes an action to the worker pool. If all the workers are active, the action will be
  119965. * pended until a worker has completed its action.
  119966. * @param action The action to perform. Call onComplete when the action is complete.
  119967. */
  119968. push(action: (worker: Worker, onComplete: () => void) => void): void;
  119969. private _execute;
  119970. }
  119971. }
  119972. declare module BABYLON {
  119973. /**
  119974. * Configuration for Draco compression
  119975. */
  119976. export interface IDracoCompressionConfiguration {
  119977. /**
  119978. * Configuration for the decoder.
  119979. */
  119980. decoder: {
  119981. /**
  119982. * The url to the WebAssembly module.
  119983. */
  119984. wasmUrl?: string;
  119985. /**
  119986. * The url to the WebAssembly binary.
  119987. */
  119988. wasmBinaryUrl?: string;
  119989. /**
  119990. * The url to the fallback JavaScript module.
  119991. */
  119992. fallbackUrl?: string;
  119993. };
  119994. }
  119995. /**
  119996. * Draco compression (https://google.github.io/draco/)
  119997. *
  119998. * This class wraps the Draco module.
  119999. *
  120000. * **Encoder**
  120001. *
  120002. * The encoder is not currently implemented.
  120003. *
  120004. * **Decoder**
  120005. *
  120006. * 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.
  120007. *
  120008. * To update the configuration, use the following code:
  120009. * ```javascript
  120010. * DracoCompression.Configuration = {
  120011. * decoder: {
  120012. * wasmUrl: "<url to the WebAssembly library>",
  120013. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120014. * fallbackUrl: "<url to the fallback JavaScript library>",
  120015. * }
  120016. * };
  120017. * ```
  120018. *
  120019. * 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.
  120020. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120021. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120022. *
  120023. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120024. * ```javascript
  120025. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120026. * ```
  120027. *
  120028. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120029. */
  120030. export class DracoCompression implements IDisposable {
  120031. private _workerPoolPromise?;
  120032. private _decoderModulePromise?;
  120033. /**
  120034. * The configuration. Defaults to the following urls:
  120035. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120036. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120037. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120038. */
  120039. static Configuration: IDracoCompressionConfiguration;
  120040. /**
  120041. * Returns true if the decoder configuration is available.
  120042. */
  120043. static readonly DecoderAvailable: boolean;
  120044. /**
  120045. * Default number of workers to create when creating the draco compression object.
  120046. */
  120047. static DefaultNumWorkers: number;
  120048. private static GetDefaultNumWorkers;
  120049. private static _Default;
  120050. /**
  120051. * Default instance for the draco compression object.
  120052. */
  120053. static readonly Default: DracoCompression;
  120054. /**
  120055. * Constructor
  120056. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120057. */
  120058. constructor(numWorkers?: number);
  120059. /**
  120060. * Stop all async operations and release resources.
  120061. */
  120062. dispose(): void;
  120063. /**
  120064. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120065. * @returns a promise that resolves when ready
  120066. */
  120067. whenReadyAsync(): Promise<void>;
  120068. /**
  120069. * Decode Draco compressed mesh data to vertex data.
  120070. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120071. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120072. * @returns A promise that resolves with the decoded vertex data
  120073. */
  120074. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120075. [kind: string]: number;
  120076. }): Promise<VertexData>;
  120077. }
  120078. }
  120079. declare module BABYLON {
  120080. /**
  120081. * Class for building Constructive Solid Geometry
  120082. */
  120083. export class CSG {
  120084. private polygons;
  120085. /**
  120086. * The world matrix
  120087. */
  120088. matrix: Matrix;
  120089. /**
  120090. * Stores the position
  120091. */
  120092. position: Vector3;
  120093. /**
  120094. * Stores the rotation
  120095. */
  120096. rotation: Vector3;
  120097. /**
  120098. * Stores the rotation quaternion
  120099. */
  120100. rotationQuaternion: Nullable<Quaternion>;
  120101. /**
  120102. * Stores the scaling vector
  120103. */
  120104. scaling: Vector3;
  120105. /**
  120106. * Convert the Mesh to CSG
  120107. * @param mesh The Mesh to convert to CSG
  120108. * @returns A new CSG from the Mesh
  120109. */
  120110. static FromMesh(mesh: Mesh): CSG;
  120111. /**
  120112. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120113. * @param polygons Polygons used to construct a CSG solid
  120114. */
  120115. private static FromPolygons;
  120116. /**
  120117. * Clones, or makes a deep copy, of the CSG
  120118. * @returns A new CSG
  120119. */
  120120. clone(): CSG;
  120121. /**
  120122. * Unions this CSG with another CSG
  120123. * @param csg The CSG to union against this CSG
  120124. * @returns The unioned CSG
  120125. */
  120126. union(csg: CSG): CSG;
  120127. /**
  120128. * Unions this CSG with another CSG in place
  120129. * @param csg The CSG to union against this CSG
  120130. */
  120131. unionInPlace(csg: CSG): void;
  120132. /**
  120133. * Subtracts this CSG with another CSG
  120134. * @param csg The CSG to subtract against this CSG
  120135. * @returns A new CSG
  120136. */
  120137. subtract(csg: CSG): CSG;
  120138. /**
  120139. * Subtracts this CSG with another CSG in place
  120140. * @param csg The CSG to subtact against this CSG
  120141. */
  120142. subtractInPlace(csg: CSG): void;
  120143. /**
  120144. * Intersect this CSG with another CSG
  120145. * @param csg The CSG to intersect against this CSG
  120146. * @returns A new CSG
  120147. */
  120148. intersect(csg: CSG): CSG;
  120149. /**
  120150. * Intersects this CSG with another CSG in place
  120151. * @param csg The CSG to intersect against this CSG
  120152. */
  120153. intersectInPlace(csg: CSG): void;
  120154. /**
  120155. * Return a new CSG solid with solid and empty space switched. This solid is
  120156. * not modified.
  120157. * @returns A new CSG solid with solid and empty space switched
  120158. */
  120159. inverse(): CSG;
  120160. /**
  120161. * Inverses the CSG in place
  120162. */
  120163. inverseInPlace(): void;
  120164. /**
  120165. * This is used to keep meshes transformations so they can be restored
  120166. * when we build back a Babylon Mesh
  120167. * NB : All CSG operations are performed in world coordinates
  120168. * @param csg The CSG to copy the transform attributes from
  120169. * @returns This CSG
  120170. */
  120171. copyTransformAttributes(csg: CSG): CSG;
  120172. /**
  120173. * Build Raw mesh from CSG
  120174. * Coordinates here are in world space
  120175. * @param name The name of the mesh geometry
  120176. * @param scene The Scene
  120177. * @param keepSubMeshes Specifies if the submeshes should be kept
  120178. * @returns A new Mesh
  120179. */
  120180. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120181. /**
  120182. * Build Mesh from CSG taking material and transforms into account
  120183. * @param name The name of the Mesh
  120184. * @param material The material of the Mesh
  120185. * @param scene The Scene
  120186. * @param keepSubMeshes Specifies if submeshes should be kept
  120187. * @returns The new Mesh
  120188. */
  120189. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120190. }
  120191. }
  120192. declare module BABYLON {
  120193. /**
  120194. * Class used to create a trail following a mesh
  120195. */
  120196. export class TrailMesh extends Mesh {
  120197. private _generator;
  120198. private _autoStart;
  120199. private _running;
  120200. private _diameter;
  120201. private _length;
  120202. private _sectionPolygonPointsCount;
  120203. private _sectionVectors;
  120204. private _sectionNormalVectors;
  120205. private _beforeRenderObserver;
  120206. /**
  120207. * @constructor
  120208. * @param name The value used by scene.getMeshByName() to do a lookup.
  120209. * @param generator The mesh to generate a trail.
  120210. * @param scene The scene to add this mesh to.
  120211. * @param diameter Diameter of trailing mesh. Default is 1.
  120212. * @param length Length of trailing mesh. Default is 60.
  120213. * @param autoStart Automatically start trailing mesh. Default true.
  120214. */
  120215. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120216. /**
  120217. * "TrailMesh"
  120218. * @returns "TrailMesh"
  120219. */
  120220. getClassName(): string;
  120221. private _createMesh;
  120222. /**
  120223. * Start trailing mesh.
  120224. */
  120225. start(): void;
  120226. /**
  120227. * Stop trailing mesh.
  120228. */
  120229. stop(): void;
  120230. /**
  120231. * Update trailing mesh geometry.
  120232. */
  120233. update(): void;
  120234. /**
  120235. * Returns a new TrailMesh object.
  120236. * @param name is a string, the name given to the new mesh
  120237. * @param newGenerator use new generator object for cloned trail mesh
  120238. * @returns a new mesh
  120239. */
  120240. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120241. /**
  120242. * Serializes this trail mesh
  120243. * @param serializationObject object to write serialization to
  120244. */
  120245. serialize(serializationObject: any): void;
  120246. /**
  120247. * Parses a serialized trail mesh
  120248. * @param parsedMesh the serialized mesh
  120249. * @param scene the scene to create the trail mesh in
  120250. * @returns the created trail mesh
  120251. */
  120252. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120253. }
  120254. }
  120255. declare module BABYLON {
  120256. /**
  120257. * Class containing static functions to help procedurally build meshes
  120258. */
  120259. export class TiledBoxBuilder {
  120260. /**
  120261. * Creates a box mesh
  120262. * 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)
  120263. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120267. * @param name defines the name of the mesh
  120268. * @param options defines the options used to create the mesh
  120269. * @param scene defines the hosting scene
  120270. * @returns the box mesh
  120271. */
  120272. static CreateTiledBox(name: string, options: {
  120273. pattern?: number;
  120274. width?: number;
  120275. height?: number;
  120276. depth?: number;
  120277. tileSize?: number;
  120278. tileWidth?: number;
  120279. tileHeight?: number;
  120280. alignHorizontal?: number;
  120281. alignVertical?: number;
  120282. faceUV?: Vector4[];
  120283. faceColors?: Color4[];
  120284. sideOrientation?: number;
  120285. updatable?: boolean;
  120286. }, scene?: Nullable<Scene>): Mesh;
  120287. }
  120288. }
  120289. declare module BABYLON {
  120290. /**
  120291. * Class containing static functions to help procedurally build meshes
  120292. */
  120293. export class TorusKnotBuilder {
  120294. /**
  120295. * Creates a torus knot mesh
  120296. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120297. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120298. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120299. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120303. * @param name defines the name of the mesh
  120304. * @param options defines the options used to create the mesh
  120305. * @param scene defines the hosting scene
  120306. * @returns the torus knot mesh
  120307. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120308. */
  120309. static CreateTorusKnot(name: string, options: {
  120310. radius?: number;
  120311. tube?: number;
  120312. radialSegments?: number;
  120313. tubularSegments?: number;
  120314. p?: number;
  120315. q?: number;
  120316. updatable?: boolean;
  120317. sideOrientation?: number;
  120318. frontUVs?: Vector4;
  120319. backUVs?: Vector4;
  120320. }, scene: any): Mesh;
  120321. }
  120322. }
  120323. declare module BABYLON {
  120324. /**
  120325. * Polygon
  120326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120327. */
  120328. export class Polygon {
  120329. /**
  120330. * Creates a rectangle
  120331. * @param xmin bottom X coord
  120332. * @param ymin bottom Y coord
  120333. * @param xmax top X coord
  120334. * @param ymax top Y coord
  120335. * @returns points that make the resulting rectation
  120336. */
  120337. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120338. /**
  120339. * Creates a circle
  120340. * @param radius radius of circle
  120341. * @param cx scale in x
  120342. * @param cy scale in y
  120343. * @param numberOfSides number of sides that make up the circle
  120344. * @returns points that make the resulting circle
  120345. */
  120346. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120347. /**
  120348. * Creates a polygon from input string
  120349. * @param input Input polygon data
  120350. * @returns the parsed points
  120351. */
  120352. static Parse(input: string): Vector2[];
  120353. /**
  120354. * Starts building a polygon from x and y coordinates
  120355. * @param x x coordinate
  120356. * @param y y coordinate
  120357. * @returns the started path2
  120358. */
  120359. static StartingAt(x: number, y: number): Path2;
  120360. }
  120361. /**
  120362. * Builds a polygon
  120363. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120364. */
  120365. export class PolygonMeshBuilder {
  120366. private _points;
  120367. private _outlinepoints;
  120368. private _holes;
  120369. private _name;
  120370. private _scene;
  120371. private _epoints;
  120372. private _eholes;
  120373. private _addToepoint;
  120374. /**
  120375. * Babylon reference to the earcut plugin.
  120376. */
  120377. bjsEarcut: any;
  120378. /**
  120379. * Creates a PolygonMeshBuilder
  120380. * @param name name of the builder
  120381. * @param contours Path of the polygon
  120382. * @param scene scene to add to when creating the mesh
  120383. * @param earcutInjection can be used to inject your own earcut reference
  120384. */
  120385. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120386. /**
  120387. * Adds a whole within the polygon
  120388. * @param hole Array of points defining the hole
  120389. * @returns this
  120390. */
  120391. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120392. /**
  120393. * Creates the polygon
  120394. * @param updatable If the mesh should be updatable
  120395. * @param depth The depth of the mesh created
  120396. * @returns the created mesh
  120397. */
  120398. build(updatable?: boolean, depth?: number): Mesh;
  120399. /**
  120400. * Creates the polygon
  120401. * @param depth The depth of the mesh created
  120402. * @returns the created VertexData
  120403. */
  120404. buildVertexData(depth?: number): VertexData;
  120405. /**
  120406. * Adds a side to the polygon
  120407. * @param positions points that make the polygon
  120408. * @param normals normals of the polygon
  120409. * @param uvs uvs of the polygon
  120410. * @param indices indices of the polygon
  120411. * @param bounds bounds of the polygon
  120412. * @param points points of the polygon
  120413. * @param depth depth of the polygon
  120414. * @param flip flip of the polygon
  120415. */
  120416. private addSide;
  120417. }
  120418. }
  120419. declare module BABYLON {
  120420. /**
  120421. * Class containing static functions to help procedurally build meshes
  120422. */
  120423. export class PolygonBuilder {
  120424. /**
  120425. * Creates a polygon mesh
  120426. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120427. * * 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
  120428. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120431. * * Remember you can only change the shape positions, not their number when updating a polygon
  120432. * @param name defines the name of the mesh
  120433. * @param options defines the options used to create the mesh
  120434. * @param scene defines the hosting scene
  120435. * @param earcutInjection can be used to inject your own earcut reference
  120436. * @returns the polygon mesh
  120437. */
  120438. static CreatePolygon(name: string, options: {
  120439. shape: Vector3[];
  120440. holes?: Vector3[][];
  120441. depth?: number;
  120442. faceUV?: Vector4[];
  120443. faceColors?: Color4[];
  120444. updatable?: boolean;
  120445. sideOrientation?: number;
  120446. frontUVs?: Vector4;
  120447. backUVs?: Vector4;
  120448. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120449. /**
  120450. * Creates an extruded polygon mesh, with depth in the Y direction.
  120451. * * 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)
  120452. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120453. * @param name defines the name of the mesh
  120454. * @param options defines the options used to create the mesh
  120455. * @param scene defines the hosting scene
  120456. * @param earcutInjection can be used to inject your own earcut reference
  120457. * @returns the polygon mesh
  120458. */
  120459. static ExtrudePolygon(name: string, options: {
  120460. shape: Vector3[];
  120461. holes?: Vector3[][];
  120462. depth?: number;
  120463. faceUV?: Vector4[];
  120464. faceColors?: Color4[];
  120465. updatable?: boolean;
  120466. sideOrientation?: number;
  120467. frontUVs?: Vector4;
  120468. backUVs?: Vector4;
  120469. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. /**
  120474. * Class containing static functions to help procedurally build meshes
  120475. */
  120476. export class LatheBuilder {
  120477. /**
  120478. * Creates lathe mesh.
  120479. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120480. * * 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
  120481. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120482. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120483. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120484. * * 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
  120485. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120486. * * 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
  120487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120491. * @param name defines the name of the mesh
  120492. * @param options defines the options used to create the mesh
  120493. * @param scene defines the hosting scene
  120494. * @returns the lathe mesh
  120495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120496. */
  120497. static CreateLathe(name: string, options: {
  120498. shape: Vector3[];
  120499. radius?: number;
  120500. tessellation?: number;
  120501. clip?: number;
  120502. arc?: number;
  120503. closed?: boolean;
  120504. updatable?: boolean;
  120505. sideOrientation?: number;
  120506. frontUVs?: Vector4;
  120507. backUVs?: Vector4;
  120508. cap?: number;
  120509. invertUV?: boolean;
  120510. }, scene?: Nullable<Scene>): Mesh;
  120511. }
  120512. }
  120513. declare module BABYLON {
  120514. /**
  120515. * Class containing static functions to help procedurally build meshes
  120516. */
  120517. export class TiledPlaneBuilder {
  120518. /**
  120519. * Creates a tiled plane mesh
  120520. * * The parameter `pattern` will, depending on value, do nothing or
  120521. * * * flip (reflect about central vertical) alternate tiles across and up
  120522. * * * flip every tile on alternate rows
  120523. * * * rotate (180 degs) alternate tiles across and up
  120524. * * * rotate every tile on alternate rows
  120525. * * * flip and rotate alternate tiles across and up
  120526. * * * flip and rotate every tile on alternate rows
  120527. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  120528. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  120529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120531. * * 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)
  120532. * * 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)
  120533. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120534. * @param name defines the name of the mesh
  120535. * @param options defines the options used to create the mesh
  120536. * @param scene defines the hosting scene
  120537. * @returns the box mesh
  120538. */
  120539. static CreateTiledPlane(name: string, options: {
  120540. pattern?: number;
  120541. tileSize?: number;
  120542. tileWidth?: number;
  120543. tileHeight?: number;
  120544. size?: number;
  120545. width?: number;
  120546. height?: number;
  120547. alignHorizontal?: number;
  120548. alignVertical?: number;
  120549. sideOrientation?: number;
  120550. frontUVs?: Vector4;
  120551. backUVs?: Vector4;
  120552. updatable?: boolean;
  120553. }, scene?: Nullable<Scene>): Mesh;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /**
  120558. * Class containing static functions to help procedurally build meshes
  120559. */
  120560. export class TubeBuilder {
  120561. /**
  120562. * Creates a tube mesh.
  120563. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120564. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120565. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120566. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120567. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120568. * * 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)
  120569. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120570. * * 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
  120571. * * 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
  120572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120576. * @param name defines the name of the mesh
  120577. * @param options defines the options used to create the mesh
  120578. * @param scene defines the hosting scene
  120579. * @returns the tube mesh
  120580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120581. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120582. */
  120583. static CreateTube(name: string, options: {
  120584. path: Vector3[];
  120585. radius?: number;
  120586. tessellation?: number;
  120587. radiusFunction?: {
  120588. (i: number, distance: number): number;
  120589. };
  120590. cap?: number;
  120591. arc?: number;
  120592. updatable?: boolean;
  120593. sideOrientation?: number;
  120594. frontUVs?: Vector4;
  120595. backUVs?: Vector4;
  120596. instance?: Mesh;
  120597. invertUV?: boolean;
  120598. }, scene?: Nullable<Scene>): Mesh;
  120599. }
  120600. }
  120601. declare module BABYLON {
  120602. /**
  120603. * Class containing static functions to help procedurally build meshes
  120604. */
  120605. export class IcoSphereBuilder {
  120606. /**
  120607. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120608. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120609. * * 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`)
  120610. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120611. * * 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
  120612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120615. * @param name defines the name of the mesh
  120616. * @param options defines the options used to create the mesh
  120617. * @param scene defines the hosting scene
  120618. * @returns the icosahedron mesh
  120619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120620. */
  120621. static CreateIcoSphere(name: string, options: {
  120622. radius?: number;
  120623. radiusX?: number;
  120624. radiusY?: number;
  120625. radiusZ?: number;
  120626. flat?: boolean;
  120627. subdivisions?: number;
  120628. sideOrientation?: number;
  120629. frontUVs?: Vector4;
  120630. backUVs?: Vector4;
  120631. updatable?: boolean;
  120632. }, scene?: Nullable<Scene>): Mesh;
  120633. }
  120634. }
  120635. declare module BABYLON {
  120636. /**
  120637. * Class containing static functions to help procedurally build meshes
  120638. */
  120639. export class DecalBuilder {
  120640. /**
  120641. * Creates a decal mesh.
  120642. * 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
  120643. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120644. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120645. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120646. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120647. * @param name defines the name of the mesh
  120648. * @param sourceMesh defines the mesh where the decal must be applied
  120649. * @param options defines the options used to create the mesh
  120650. * @param scene defines the hosting scene
  120651. * @returns the decal mesh
  120652. * @see https://doc.babylonjs.com/how_to/decals
  120653. */
  120654. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120655. position?: Vector3;
  120656. normal?: Vector3;
  120657. size?: Vector3;
  120658. angle?: number;
  120659. }): Mesh;
  120660. }
  120661. }
  120662. declare module BABYLON {
  120663. /**
  120664. * Class containing static functions to help procedurally build meshes
  120665. */
  120666. export class MeshBuilder {
  120667. /**
  120668. * Creates a box mesh
  120669. * * The parameter `size` sets the size (float) of each box side (default 1)
  120670. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120671. * * 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)
  120672. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120676. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120677. * @param name defines the name of the mesh
  120678. * @param options defines the options used to create the mesh
  120679. * @param scene defines the hosting scene
  120680. * @returns the box mesh
  120681. */
  120682. static CreateBox(name: string, options: {
  120683. size?: number;
  120684. width?: number;
  120685. height?: number;
  120686. depth?: number;
  120687. faceUV?: Vector4[];
  120688. faceColors?: Color4[];
  120689. sideOrientation?: number;
  120690. frontUVs?: Vector4;
  120691. backUVs?: Vector4;
  120692. updatable?: boolean;
  120693. }, scene?: Nullable<Scene>): Mesh;
  120694. /**
  120695. * Creates a tiled box mesh
  120696. * * faceTiles sets the pattern, tile size and number of tiles for a face
  120697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120698. * @param name defines the name of the mesh
  120699. * @param options defines the options used to create the mesh
  120700. * @param scene defines the hosting scene
  120701. * @returns the tiled box mesh
  120702. */
  120703. static CreateTiledBox(name: string, options: {
  120704. pattern?: number;
  120705. size?: number;
  120706. width?: number;
  120707. height?: number;
  120708. depth: number;
  120709. tileSize?: number;
  120710. tileWidth?: number;
  120711. tileHeight?: number;
  120712. faceUV?: Vector4[];
  120713. faceColors?: Color4[];
  120714. alignHorizontal?: number;
  120715. alignVertical?: number;
  120716. sideOrientation?: number;
  120717. updatable?: boolean;
  120718. }, scene?: Nullable<Scene>): Mesh;
  120719. /**
  120720. * Creates a sphere mesh
  120721. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120722. * * 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`)
  120723. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120724. * * 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
  120725. * * 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)
  120726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120729. * @param name defines the name of the mesh
  120730. * @param options defines the options used to create the mesh
  120731. * @param scene defines the hosting scene
  120732. * @returns the sphere mesh
  120733. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120734. */
  120735. static CreateSphere(name: string, options: {
  120736. segments?: number;
  120737. diameter?: number;
  120738. diameterX?: number;
  120739. diameterY?: number;
  120740. diameterZ?: number;
  120741. arc?: number;
  120742. slice?: number;
  120743. sideOrientation?: number;
  120744. frontUVs?: Vector4;
  120745. backUVs?: Vector4;
  120746. updatable?: boolean;
  120747. }, scene?: Nullable<Scene>): Mesh;
  120748. /**
  120749. * Creates a plane polygonal mesh. By default, this is a disc
  120750. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  120751. * * 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
  120752. * * 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
  120753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120756. * @param name defines the name of the mesh
  120757. * @param options defines the options used to create the mesh
  120758. * @param scene defines the hosting scene
  120759. * @returns the plane polygonal mesh
  120760. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  120761. */
  120762. static CreateDisc(name: string, options: {
  120763. radius?: number;
  120764. tessellation?: number;
  120765. arc?: number;
  120766. updatable?: boolean;
  120767. sideOrientation?: number;
  120768. frontUVs?: Vector4;
  120769. backUVs?: Vector4;
  120770. }, scene?: Nullable<Scene>): Mesh;
  120771. /**
  120772. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120773. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120774. * * 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`)
  120775. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120776. * * 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
  120777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120780. * @param name defines the name of the mesh
  120781. * @param options defines the options used to create the mesh
  120782. * @param scene defines the hosting scene
  120783. * @returns the icosahedron mesh
  120784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120785. */
  120786. static CreateIcoSphere(name: string, options: {
  120787. radius?: number;
  120788. radiusX?: number;
  120789. radiusY?: number;
  120790. radiusZ?: number;
  120791. flat?: boolean;
  120792. subdivisions?: number;
  120793. sideOrientation?: number;
  120794. frontUVs?: Vector4;
  120795. backUVs?: Vector4;
  120796. updatable?: boolean;
  120797. }, scene?: Nullable<Scene>): Mesh;
  120798. /**
  120799. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120800. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120801. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120802. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120803. * * 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
  120804. * * 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
  120805. * * 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
  120806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120809. * * 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
  120810. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120811. * * 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
  120812. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120814. * @param name defines the name of the mesh
  120815. * @param options defines the options used to create the mesh
  120816. * @param scene defines the hosting scene
  120817. * @returns the ribbon mesh
  120818. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120820. */
  120821. static CreateRibbon(name: string, options: {
  120822. pathArray: Vector3[][];
  120823. closeArray?: boolean;
  120824. closePath?: boolean;
  120825. offset?: number;
  120826. updatable?: boolean;
  120827. sideOrientation?: number;
  120828. frontUVs?: Vector4;
  120829. backUVs?: Vector4;
  120830. instance?: Mesh;
  120831. invertUV?: boolean;
  120832. uvs?: Vector2[];
  120833. colors?: Color4[];
  120834. }, scene?: Nullable<Scene>): Mesh;
  120835. /**
  120836. * Creates a cylinder or a cone mesh
  120837. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  120838. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  120839. * * 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.
  120840. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  120841. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  120842. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  120843. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  120844. * * 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).
  120845. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  120846. * * 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).
  120847. * * 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
  120848. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  120849. * * 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
  120850. * * 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.
  120851. * * If `enclose` is false, a ring surface is one element.
  120852. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  120853. * * 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
  120854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120857. * @param name defines the name of the mesh
  120858. * @param options defines the options used to create the mesh
  120859. * @param scene defines the hosting scene
  120860. * @returns the cylinder mesh
  120861. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  120862. */
  120863. static CreateCylinder(name: string, options: {
  120864. height?: number;
  120865. diameterTop?: number;
  120866. diameterBottom?: number;
  120867. diameter?: number;
  120868. tessellation?: number;
  120869. subdivisions?: number;
  120870. arc?: number;
  120871. faceColors?: Color4[];
  120872. faceUV?: Vector4[];
  120873. updatable?: boolean;
  120874. hasRings?: boolean;
  120875. enclose?: boolean;
  120876. cap?: number;
  120877. sideOrientation?: number;
  120878. frontUVs?: Vector4;
  120879. backUVs?: Vector4;
  120880. }, scene?: Nullable<Scene>): Mesh;
  120881. /**
  120882. * Creates a torus mesh
  120883. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  120884. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  120885. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  120886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120889. * @param name defines the name of the mesh
  120890. * @param options defines the options used to create the mesh
  120891. * @param scene defines the hosting scene
  120892. * @returns the torus mesh
  120893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  120894. */
  120895. static CreateTorus(name: string, options: {
  120896. diameter?: number;
  120897. thickness?: number;
  120898. tessellation?: number;
  120899. updatable?: boolean;
  120900. sideOrientation?: number;
  120901. frontUVs?: Vector4;
  120902. backUVs?: Vector4;
  120903. }, scene?: Nullable<Scene>): Mesh;
  120904. /**
  120905. * Creates a torus knot mesh
  120906. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120907. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120908. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120909. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120913. * @param name defines the name of the mesh
  120914. * @param options defines the options used to create the mesh
  120915. * @param scene defines the hosting scene
  120916. * @returns the torus knot mesh
  120917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120918. */
  120919. static CreateTorusKnot(name: string, options: {
  120920. radius?: number;
  120921. tube?: number;
  120922. radialSegments?: number;
  120923. tubularSegments?: number;
  120924. p?: number;
  120925. q?: number;
  120926. updatable?: boolean;
  120927. sideOrientation?: number;
  120928. frontUVs?: Vector4;
  120929. backUVs?: Vector4;
  120930. }, scene?: Nullable<Scene>): Mesh;
  120931. /**
  120932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  120933. * * 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
  120934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  120935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  120936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  120937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  120938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120939. * * 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
  120940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  120941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  120943. * @param name defines the name of the new line system
  120944. * @param options defines the options used to create the line system
  120945. * @param scene defines the hosting scene
  120946. * @returns a new line system mesh
  120947. */
  120948. static CreateLineSystem(name: string, options: {
  120949. lines: Vector3[][];
  120950. updatable?: boolean;
  120951. instance?: Nullable<LinesMesh>;
  120952. colors?: Nullable<Color4[][]>;
  120953. useVertexAlpha?: boolean;
  120954. }, scene: Nullable<Scene>): LinesMesh;
  120955. /**
  120956. * Creates a line mesh
  120957. * 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
  120958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120959. * * The parameter `points` is an array successive Vector3
  120960. * * 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
  120961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  120962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  120963. * * When updating an instance, remember that only point positions can change, not the number of points
  120964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  120966. * @param name defines the name of the new line system
  120967. * @param options defines the options used to create the line system
  120968. * @param scene defines the hosting scene
  120969. * @returns a new line mesh
  120970. */
  120971. static CreateLines(name: string, options: {
  120972. points: Vector3[];
  120973. updatable?: boolean;
  120974. instance?: Nullable<LinesMesh>;
  120975. colors?: Color4[];
  120976. useVertexAlpha?: boolean;
  120977. }, scene?: Nullable<Scene>): LinesMesh;
  120978. /**
  120979. * Creates a dashed line mesh
  120980. * * 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
  120981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120982. * * The parameter `points` is an array successive Vector3
  120983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  120984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  120985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  120986. * * 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
  120987. * * When updating an instance, remember that only point positions can change, not the number of points
  120988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120989. * @param name defines the name of the mesh
  120990. * @param options defines the options used to create the mesh
  120991. * @param scene defines the hosting scene
  120992. * @returns the dashed line mesh
  120993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  120994. */
  120995. static CreateDashedLines(name: string, options: {
  120996. points: Vector3[];
  120997. dashSize?: number;
  120998. gapSize?: number;
  120999. dashNb?: number;
  121000. updatable?: boolean;
  121001. instance?: LinesMesh;
  121002. }, scene?: Nullable<Scene>): LinesMesh;
  121003. /**
  121004. * 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.
  121005. * * 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.
  121006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121007. * * 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.
  121008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121009. * * 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
  121010. * * 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
  121011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121016. * @param name defines the name of the mesh
  121017. * @param options defines the options used to create the mesh
  121018. * @param scene defines the hosting scene
  121019. * @returns the extruded shape mesh
  121020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121022. */
  121023. static ExtrudeShape(name: string, options: {
  121024. shape: Vector3[];
  121025. path: Vector3[];
  121026. scale?: number;
  121027. rotation?: number;
  121028. cap?: number;
  121029. updatable?: boolean;
  121030. sideOrientation?: number;
  121031. frontUVs?: Vector4;
  121032. backUVs?: Vector4;
  121033. instance?: Mesh;
  121034. invertUV?: boolean;
  121035. }, scene?: Nullable<Scene>): Mesh;
  121036. /**
  121037. * Creates an custom extruded shape mesh.
  121038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121039. * * 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.
  121040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121041. * * 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
  121042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121043. * * 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
  121044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121047. * * 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
  121048. * * 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
  121049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121054. * @param name defines the name of the mesh
  121055. * @param options defines the options used to create the mesh
  121056. * @param scene defines the hosting scene
  121057. * @returns the custom extruded shape mesh
  121058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121061. */
  121062. static ExtrudeShapeCustom(name: string, options: {
  121063. shape: Vector3[];
  121064. path: Vector3[];
  121065. scaleFunction?: any;
  121066. rotationFunction?: any;
  121067. ribbonCloseArray?: boolean;
  121068. ribbonClosePath?: boolean;
  121069. cap?: number;
  121070. updatable?: boolean;
  121071. sideOrientation?: number;
  121072. frontUVs?: Vector4;
  121073. backUVs?: Vector4;
  121074. instance?: Mesh;
  121075. invertUV?: boolean;
  121076. }, scene?: Nullable<Scene>): Mesh;
  121077. /**
  121078. * Creates lathe mesh.
  121079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121080. * * 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
  121081. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121082. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121083. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121084. * * 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
  121085. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121086. * * 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
  121087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121091. * @param name defines the name of the mesh
  121092. * @param options defines the options used to create the mesh
  121093. * @param scene defines the hosting scene
  121094. * @returns the lathe mesh
  121095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121096. */
  121097. static CreateLathe(name: string, options: {
  121098. shape: Vector3[];
  121099. radius?: number;
  121100. tessellation?: number;
  121101. clip?: number;
  121102. arc?: number;
  121103. closed?: boolean;
  121104. updatable?: boolean;
  121105. sideOrientation?: number;
  121106. frontUVs?: Vector4;
  121107. backUVs?: Vector4;
  121108. cap?: number;
  121109. invertUV?: boolean;
  121110. }, scene?: Nullable<Scene>): Mesh;
  121111. /**
  121112. * Creates a tiled plane mesh
  121113. * * You can set a limited pattern arrangement with the tiles
  121114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121117. * @param name defines the name of the mesh
  121118. * @param options defines the options used to create the mesh
  121119. * @param scene defines the hosting scene
  121120. * @returns the plane mesh
  121121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121122. */
  121123. static CreateTiledPlane(name: string, options: {
  121124. pattern?: number;
  121125. tileSize?: number;
  121126. tileWidth?: number;
  121127. tileHeight?: number;
  121128. size?: number;
  121129. width?: number;
  121130. height?: number;
  121131. alignHorizontal?: number;
  121132. alignVertical?: number;
  121133. sideOrientation?: number;
  121134. frontUVs?: Vector4;
  121135. backUVs?: Vector4;
  121136. updatable?: boolean;
  121137. }, scene?: Nullable<Scene>): Mesh;
  121138. /**
  121139. * Creates a plane mesh
  121140. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121141. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121142. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121146. * @param name defines the name of the mesh
  121147. * @param options defines the options used to create the mesh
  121148. * @param scene defines the hosting scene
  121149. * @returns the plane mesh
  121150. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121151. */
  121152. static CreatePlane(name: string, options: {
  121153. size?: number;
  121154. width?: number;
  121155. height?: number;
  121156. sideOrientation?: number;
  121157. frontUVs?: Vector4;
  121158. backUVs?: Vector4;
  121159. updatable?: boolean;
  121160. sourcePlane?: Plane;
  121161. }, scene?: Nullable<Scene>): Mesh;
  121162. /**
  121163. * Creates a ground mesh
  121164. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121165. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121167. * @param name defines the name of the mesh
  121168. * @param options defines the options used to create the mesh
  121169. * @param scene defines the hosting scene
  121170. * @returns the ground mesh
  121171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121172. */
  121173. static CreateGround(name: string, options: {
  121174. width?: number;
  121175. height?: number;
  121176. subdivisions?: number;
  121177. subdivisionsX?: number;
  121178. subdivisionsY?: number;
  121179. updatable?: boolean;
  121180. }, scene?: Nullable<Scene>): Mesh;
  121181. /**
  121182. * Creates a tiled ground mesh
  121183. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121184. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121185. * * 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
  121186. * * 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
  121187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121188. * @param name defines the name of the mesh
  121189. * @param options defines the options used to create the mesh
  121190. * @param scene defines the hosting scene
  121191. * @returns the tiled ground mesh
  121192. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121193. */
  121194. static CreateTiledGround(name: string, options: {
  121195. xmin: number;
  121196. zmin: number;
  121197. xmax: number;
  121198. zmax: number;
  121199. subdivisions?: {
  121200. w: number;
  121201. h: number;
  121202. };
  121203. precision?: {
  121204. w: number;
  121205. h: number;
  121206. };
  121207. updatable?: boolean;
  121208. }, scene?: Nullable<Scene>): Mesh;
  121209. /**
  121210. * Creates a ground mesh from a height map
  121211. * * The parameter `url` sets the URL of the height map image resource.
  121212. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121213. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121214. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121215. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121216. * * 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.
  121217. * * 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).
  121218. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121220. * @param name defines the name of the mesh
  121221. * @param url defines the url to the height map
  121222. * @param options defines the options used to create the mesh
  121223. * @param scene defines the hosting scene
  121224. * @returns the ground mesh
  121225. * @see https://doc.babylonjs.com/babylon101/height_map
  121226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121227. */
  121228. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121229. width?: number;
  121230. height?: number;
  121231. subdivisions?: number;
  121232. minHeight?: number;
  121233. maxHeight?: number;
  121234. colorFilter?: Color3;
  121235. alphaFilter?: number;
  121236. updatable?: boolean;
  121237. onReady?: (mesh: GroundMesh) => void;
  121238. }, scene?: Nullable<Scene>): GroundMesh;
  121239. /**
  121240. * Creates a polygon mesh
  121241. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121242. * * 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
  121243. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121246. * * Remember you can only change the shape positions, not their number when updating a polygon
  121247. * @param name defines the name of the mesh
  121248. * @param options defines the options used to create the mesh
  121249. * @param scene defines the hosting scene
  121250. * @param earcutInjection can be used to inject your own earcut reference
  121251. * @returns the polygon mesh
  121252. */
  121253. static CreatePolygon(name: string, options: {
  121254. shape: Vector3[];
  121255. holes?: Vector3[][];
  121256. depth?: number;
  121257. faceUV?: Vector4[];
  121258. faceColors?: Color4[];
  121259. updatable?: boolean;
  121260. sideOrientation?: number;
  121261. frontUVs?: Vector4;
  121262. backUVs?: Vector4;
  121263. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121264. /**
  121265. * Creates an extruded polygon mesh, with depth in the Y direction.
  121266. * * 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)
  121267. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121268. * @param name defines the name of the mesh
  121269. * @param options defines the options used to create the mesh
  121270. * @param scene defines the hosting scene
  121271. * @param earcutInjection can be used to inject your own earcut reference
  121272. * @returns the polygon mesh
  121273. */
  121274. static ExtrudePolygon(name: string, options: {
  121275. shape: Vector3[];
  121276. holes?: Vector3[][];
  121277. depth?: number;
  121278. faceUV?: Vector4[];
  121279. faceColors?: Color4[];
  121280. updatable?: boolean;
  121281. sideOrientation?: number;
  121282. frontUVs?: Vector4;
  121283. backUVs?: Vector4;
  121284. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121285. /**
  121286. * Creates a tube mesh.
  121287. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121288. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121289. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121290. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121291. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121292. * * 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)
  121293. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121294. * * 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
  121295. * * 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
  121296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121300. * @param name defines the name of the mesh
  121301. * @param options defines the options used to create the mesh
  121302. * @param scene defines the hosting scene
  121303. * @returns the tube mesh
  121304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121305. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121306. */
  121307. static CreateTube(name: string, options: {
  121308. path: Vector3[];
  121309. radius?: number;
  121310. tessellation?: number;
  121311. radiusFunction?: {
  121312. (i: number, distance: number): number;
  121313. };
  121314. cap?: number;
  121315. arc?: number;
  121316. updatable?: boolean;
  121317. sideOrientation?: number;
  121318. frontUVs?: Vector4;
  121319. backUVs?: Vector4;
  121320. instance?: Mesh;
  121321. invertUV?: boolean;
  121322. }, scene?: Nullable<Scene>): Mesh;
  121323. /**
  121324. * Creates a polyhedron mesh
  121325. * * 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
  121326. * * The parameter `size` (positive float, default 1) sets the polygon size
  121327. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121328. * * 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`
  121329. * * 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
  121330. * * 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)`)
  121331. * * 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
  121332. * * 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
  121333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121336. * @param name defines the name of the mesh
  121337. * @param options defines the options used to create the mesh
  121338. * @param scene defines the hosting scene
  121339. * @returns the polyhedron mesh
  121340. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121341. */
  121342. static CreatePolyhedron(name: string, options: {
  121343. type?: number;
  121344. size?: number;
  121345. sizeX?: number;
  121346. sizeY?: number;
  121347. sizeZ?: number;
  121348. custom?: any;
  121349. faceUV?: Vector4[];
  121350. faceColors?: Color4[];
  121351. flat?: boolean;
  121352. updatable?: boolean;
  121353. sideOrientation?: number;
  121354. frontUVs?: Vector4;
  121355. backUVs?: Vector4;
  121356. }, scene?: Nullable<Scene>): Mesh;
  121357. /**
  121358. * Creates a decal mesh.
  121359. * 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
  121360. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121361. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121362. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121363. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121364. * @param name defines the name of the mesh
  121365. * @param sourceMesh defines the mesh where the decal must be applied
  121366. * @param options defines the options used to create the mesh
  121367. * @param scene defines the hosting scene
  121368. * @returns the decal mesh
  121369. * @see https://doc.babylonjs.com/how_to/decals
  121370. */
  121371. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121372. position?: Vector3;
  121373. normal?: Vector3;
  121374. size?: Vector3;
  121375. angle?: number;
  121376. }): Mesh;
  121377. }
  121378. }
  121379. declare module BABYLON {
  121380. /**
  121381. * A simplifier interface for future simplification implementations
  121382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121383. */
  121384. export interface ISimplifier {
  121385. /**
  121386. * Simplification of a given mesh according to the given settings.
  121387. * Since this requires computation, it is assumed that the function runs async.
  121388. * @param settings The settings of the simplification, including quality and distance
  121389. * @param successCallback A callback that will be called after the mesh was simplified.
  121390. * @param errorCallback in case of an error, this callback will be called. optional.
  121391. */
  121392. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121393. }
  121394. /**
  121395. * Expected simplification settings.
  121396. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121397. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121398. */
  121399. export interface ISimplificationSettings {
  121400. /**
  121401. * Gets or sets the expected quality
  121402. */
  121403. quality: number;
  121404. /**
  121405. * Gets or sets the distance when this optimized version should be used
  121406. */
  121407. distance: number;
  121408. /**
  121409. * Gets an already optimized mesh
  121410. */
  121411. optimizeMesh?: boolean;
  121412. }
  121413. /**
  121414. * Class used to specify simplification options
  121415. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121416. */
  121417. export class SimplificationSettings implements ISimplificationSettings {
  121418. /** expected quality */
  121419. quality: number;
  121420. /** distance when this optimized version should be used */
  121421. distance: number;
  121422. /** already optimized mesh */
  121423. optimizeMesh?: boolean | undefined;
  121424. /**
  121425. * Creates a SimplificationSettings
  121426. * @param quality expected quality
  121427. * @param distance distance when this optimized version should be used
  121428. * @param optimizeMesh already optimized mesh
  121429. */
  121430. constructor(
  121431. /** expected quality */
  121432. quality: number,
  121433. /** distance when this optimized version should be used */
  121434. distance: number,
  121435. /** already optimized mesh */
  121436. optimizeMesh?: boolean | undefined);
  121437. }
  121438. /**
  121439. * Interface used to define a simplification task
  121440. */
  121441. export interface ISimplificationTask {
  121442. /**
  121443. * Array of settings
  121444. */
  121445. settings: Array<ISimplificationSettings>;
  121446. /**
  121447. * Simplification type
  121448. */
  121449. simplificationType: SimplificationType;
  121450. /**
  121451. * Mesh to simplify
  121452. */
  121453. mesh: Mesh;
  121454. /**
  121455. * Callback called on success
  121456. */
  121457. successCallback?: () => void;
  121458. /**
  121459. * Defines if parallel processing can be used
  121460. */
  121461. parallelProcessing: boolean;
  121462. }
  121463. /**
  121464. * Queue used to order the simplification tasks
  121465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121466. */
  121467. export class SimplificationQueue {
  121468. private _simplificationArray;
  121469. /**
  121470. * Gets a boolean indicating that the process is still running
  121471. */
  121472. running: boolean;
  121473. /**
  121474. * Creates a new queue
  121475. */
  121476. constructor();
  121477. /**
  121478. * Adds a new simplification task
  121479. * @param task defines a task to add
  121480. */
  121481. addTask(task: ISimplificationTask): void;
  121482. /**
  121483. * Execute next task
  121484. */
  121485. executeNext(): void;
  121486. /**
  121487. * Execute a simplification task
  121488. * @param task defines the task to run
  121489. */
  121490. runSimplification(task: ISimplificationTask): void;
  121491. private getSimplifier;
  121492. }
  121493. /**
  121494. * The implemented types of simplification
  121495. * At the moment only Quadratic Error Decimation is implemented
  121496. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121497. */
  121498. export enum SimplificationType {
  121499. /** Quadratic error decimation */
  121500. QUADRATIC = 0
  121501. }
  121502. }
  121503. declare module BABYLON {
  121504. interface Scene {
  121505. /** @hidden (Backing field) */
  121506. _simplificationQueue: SimplificationQueue;
  121507. /**
  121508. * Gets or sets the simplification queue attached to the scene
  121509. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121510. */
  121511. simplificationQueue: SimplificationQueue;
  121512. }
  121513. interface Mesh {
  121514. /**
  121515. * Simplify the mesh according to the given array of settings.
  121516. * Function will return immediately and will simplify async
  121517. * @param settings a collection of simplification settings
  121518. * @param parallelProcessing should all levels calculate parallel or one after the other
  121519. * @param simplificationType the type of simplification to run
  121520. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  121521. * @returns the current mesh
  121522. */
  121523. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  121524. }
  121525. /**
  121526. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  121527. * created in a scene
  121528. */
  121529. export class SimplicationQueueSceneComponent implements ISceneComponent {
  121530. /**
  121531. * The component name helpfull to identify the component in the list of scene components.
  121532. */
  121533. readonly name: string;
  121534. /**
  121535. * The scene the component belongs to.
  121536. */
  121537. scene: Scene;
  121538. /**
  121539. * Creates a new instance of the component for the given scene
  121540. * @param scene Defines the scene to register the component in
  121541. */
  121542. constructor(scene: Scene);
  121543. /**
  121544. * Registers the component in a given scene
  121545. */
  121546. register(): void;
  121547. /**
  121548. * Rebuilds the elements related to this component in case of
  121549. * context lost for instance.
  121550. */
  121551. rebuild(): void;
  121552. /**
  121553. * Disposes the component and the associated ressources
  121554. */
  121555. dispose(): void;
  121556. private _beforeCameraUpdate;
  121557. }
  121558. }
  121559. declare module BABYLON {
  121560. /**
  121561. * Navigation plugin interface to add navigation constrained by a navigation mesh
  121562. */
  121563. export interface INavigationEnginePlugin {
  121564. /**
  121565. * plugin name
  121566. */
  121567. name: string;
  121568. /**
  121569. * Creates a navigation mesh
  121570. * @param meshes array of all the geometry used to compute the navigatio mesh
  121571. * @param parameters bunch of parameters used to filter geometry
  121572. */
  121573. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121574. /**
  121575. * Create a navigation mesh debug mesh
  121576. * @param scene is where the mesh will be added
  121577. * @returns debug display mesh
  121578. */
  121579. createDebugNavMesh(scene: Scene): Mesh;
  121580. /**
  121581. * Get a navigation mesh constrained position, closest to the parameter position
  121582. * @param position world position
  121583. * @returns the closest point to position constrained by the navigation mesh
  121584. */
  121585. getClosestPoint(position: Vector3): Vector3;
  121586. /**
  121587. * Get a navigation mesh constrained position, within a particular radius
  121588. * @param position world position
  121589. * @param maxRadius the maximum distance to the constrained world position
  121590. * @returns the closest point to position constrained by the navigation mesh
  121591. */
  121592. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121593. /**
  121594. * Compute the final position from a segment made of destination-position
  121595. * @param position world position
  121596. * @param destination world position
  121597. * @returns the resulting point along the navmesh
  121598. */
  121599. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121600. /**
  121601. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121602. * @param start world position
  121603. * @param end world position
  121604. * @returns array containing world position composing the path
  121605. */
  121606. computePath(start: Vector3, end: Vector3): Vector3[];
  121607. /**
  121608. * If this plugin is supported
  121609. * @returns true if plugin is supported
  121610. */
  121611. isSupported(): boolean;
  121612. /**
  121613. * Create a new Crowd so you can add agents
  121614. * @param maxAgents the maximum agent count in the crowd
  121615. * @param maxAgentRadius the maximum radius an agent can have
  121616. * @param scene to attach the crowd to
  121617. * @returns the crowd you can add agents to
  121618. */
  121619. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121620. /**
  121621. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121622. * The queries will try to find a solution within those bounds
  121623. * default is (1,1,1)
  121624. * @param extent x,y,z value that define the extent around the queries point of reference
  121625. */
  121626. setDefaultQueryExtent(extent: Vector3): void;
  121627. /**
  121628. * Get the Bounding box extent specified by setDefaultQueryExtent
  121629. * @returns the box extent values
  121630. */
  121631. getDefaultQueryExtent(): Vector3;
  121632. /**
  121633. * Release all resources
  121634. */
  121635. dispose(): void;
  121636. }
  121637. /**
  121638. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  121639. */
  121640. export interface ICrowd {
  121641. /**
  121642. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121643. * You can attach anything to that node. The node position is updated in the scene update tick.
  121644. * @param pos world position that will be constrained by the navigation mesh
  121645. * @param parameters agent parameters
  121646. * @param transform hooked to the agent that will be update by the scene
  121647. * @returns agent index
  121648. */
  121649. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121650. /**
  121651. * Returns the agent position in world space
  121652. * @param index agent index returned by addAgent
  121653. * @returns world space position
  121654. */
  121655. getAgentPosition(index: number): Vector3;
  121656. /**
  121657. * Gets the agent velocity in world space
  121658. * @param index agent index returned by addAgent
  121659. * @returns world space velocity
  121660. */
  121661. getAgentVelocity(index: number): Vector3;
  121662. /**
  121663. * remove a particular agent previously created
  121664. * @param index agent index returned by addAgent
  121665. */
  121666. removeAgent(index: number): void;
  121667. /**
  121668. * get the list of all agents attached to this crowd
  121669. * @returns list of agent indices
  121670. */
  121671. getAgents(): number[];
  121672. /**
  121673. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121674. * @param deltaTime in seconds
  121675. */
  121676. update(deltaTime: number): void;
  121677. /**
  121678. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121679. * @param index agent index returned by addAgent
  121680. * @param destination targeted world position
  121681. */
  121682. agentGoto(index: number, destination: Vector3): void;
  121683. /**
  121684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121685. * The queries will try to find a solution within those bounds
  121686. * default is (1,1,1)
  121687. * @param extent x,y,z value that define the extent around the queries point of reference
  121688. */
  121689. setDefaultQueryExtent(extent: Vector3): void;
  121690. /**
  121691. * Get the Bounding box extent specified by setDefaultQueryExtent
  121692. * @returns the box extent values
  121693. */
  121694. getDefaultQueryExtent(): Vector3;
  121695. /**
  121696. * Release all resources
  121697. */
  121698. dispose(): void;
  121699. }
  121700. /**
  121701. * Configures an agent
  121702. */
  121703. export interface IAgentParameters {
  121704. /**
  121705. * Agent radius. [Limit: >= 0]
  121706. */
  121707. radius: number;
  121708. /**
  121709. * Agent height. [Limit: > 0]
  121710. */
  121711. height: number;
  121712. /**
  121713. * Maximum allowed acceleration. [Limit: >= 0]
  121714. */
  121715. maxAcceleration: number;
  121716. /**
  121717. * Maximum allowed speed. [Limit: >= 0]
  121718. */
  121719. maxSpeed: number;
  121720. /**
  121721. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  121722. */
  121723. collisionQueryRange: number;
  121724. /**
  121725. * The path visibility optimization range. [Limit: > 0]
  121726. */
  121727. pathOptimizationRange: number;
  121728. /**
  121729. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  121730. */
  121731. separationWeight: number;
  121732. }
  121733. /**
  121734. * Configures the navigation mesh creation
  121735. */
  121736. export interface INavMeshParameters {
  121737. /**
  121738. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  121739. */
  121740. cs: number;
  121741. /**
  121742. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  121743. */
  121744. ch: number;
  121745. /**
  121746. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  121747. */
  121748. walkableSlopeAngle: number;
  121749. /**
  121750. * Minimum floor to 'ceiling' height that will still allow the floor area to
  121751. * be considered walkable. [Limit: >= 3] [Units: vx]
  121752. */
  121753. walkableHeight: number;
  121754. /**
  121755. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  121756. */
  121757. walkableClimb: number;
  121758. /**
  121759. * The distance to erode/shrink the walkable area of the heightfield away from
  121760. * obstructions. [Limit: >=0] [Units: vx]
  121761. */
  121762. walkableRadius: number;
  121763. /**
  121764. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  121765. */
  121766. maxEdgeLen: number;
  121767. /**
  121768. * The maximum distance a simplfied contour's border edges should deviate
  121769. * the original raw contour. [Limit: >=0] [Units: vx]
  121770. */
  121771. maxSimplificationError: number;
  121772. /**
  121773. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  121774. */
  121775. minRegionArea: number;
  121776. /**
  121777. * Any regions with a span count smaller than this value will, if possible,
  121778. * be merged with larger regions. [Limit: >=0] [Units: vx]
  121779. */
  121780. mergeRegionArea: number;
  121781. /**
  121782. * The maximum number of vertices allowed for polygons generated during the
  121783. * contour to polygon conversion process. [Limit: >= 3]
  121784. */
  121785. maxVertsPerPoly: number;
  121786. /**
  121787. * Sets the sampling distance to use when generating the detail mesh.
  121788. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  121789. */
  121790. detailSampleDist: number;
  121791. /**
  121792. * The maximum distance the detail mesh surface should deviate from heightfield
  121793. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  121794. */
  121795. detailSampleMaxError: number;
  121796. }
  121797. }
  121798. declare module BABYLON {
  121799. /**
  121800. * RecastJS navigation plugin
  121801. */
  121802. export class RecastJSPlugin implements INavigationEnginePlugin {
  121803. /**
  121804. * Reference to the Recast library
  121805. */
  121806. bjsRECAST: any;
  121807. /**
  121808. * plugin name
  121809. */
  121810. name: string;
  121811. /**
  121812. * the first navmesh created. We might extend this to support multiple navmeshes
  121813. */
  121814. navMesh: any;
  121815. /**
  121816. * Initializes the recastJS plugin
  121817. * @param recastInjection can be used to inject your own recast reference
  121818. */
  121819. constructor(recastInjection?: any);
  121820. /**
  121821. * Creates a navigation mesh
  121822. * @param meshes array of all the geometry used to compute the navigatio mesh
  121823. * @param parameters bunch of parameters used to filter geometry
  121824. */
  121825. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121826. /**
  121827. * Create a navigation mesh debug mesh
  121828. * @param scene is where the mesh will be added
  121829. * @returns debug display mesh
  121830. */
  121831. createDebugNavMesh(scene: Scene): Mesh;
  121832. /**
  121833. * Get a navigation mesh constrained position, closest to the parameter position
  121834. * @param position world position
  121835. * @returns the closest point to position constrained by the navigation mesh
  121836. */
  121837. getClosestPoint(position: Vector3): Vector3;
  121838. /**
  121839. * Get a navigation mesh constrained position, within a particular radius
  121840. * @param position world position
  121841. * @param maxRadius the maximum distance to the constrained world position
  121842. * @returns the closest point to position constrained by the navigation mesh
  121843. */
  121844. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121845. /**
  121846. * Compute the final position from a segment made of destination-position
  121847. * @param position world position
  121848. * @param destination world position
  121849. * @returns the resulting point along the navmesh
  121850. */
  121851. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121852. /**
  121853. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121854. * @param start world position
  121855. * @param end world position
  121856. * @returns array containing world position composing the path
  121857. */
  121858. computePath(start: Vector3, end: Vector3): Vector3[];
  121859. /**
  121860. * Create a new Crowd so you can add agents
  121861. * @param maxAgents the maximum agent count in the crowd
  121862. * @param maxAgentRadius the maximum radius an agent can have
  121863. * @param scene to attach the crowd to
  121864. * @returns the crowd you can add agents to
  121865. */
  121866. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121867. /**
  121868. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121869. * The queries will try to find a solution within those bounds
  121870. * default is (1,1,1)
  121871. * @param extent x,y,z value that define the extent around the queries point of reference
  121872. */
  121873. setDefaultQueryExtent(extent: Vector3): void;
  121874. /**
  121875. * Get the Bounding box extent specified by setDefaultQueryExtent
  121876. * @returns the box extent values
  121877. */
  121878. getDefaultQueryExtent(): Vector3;
  121879. /**
  121880. * Disposes
  121881. */
  121882. dispose(): void;
  121883. /**
  121884. * If this plugin is supported
  121885. * @returns true if plugin is supported
  121886. */
  121887. isSupported(): boolean;
  121888. }
  121889. /**
  121890. * Recast detour crowd implementation
  121891. */
  121892. export class RecastJSCrowd implements ICrowd {
  121893. /**
  121894. * Recast/detour plugin
  121895. */
  121896. bjsRECASTPlugin: RecastJSPlugin;
  121897. /**
  121898. * Link to the detour crowd
  121899. */
  121900. recastCrowd: any;
  121901. /**
  121902. * One transform per agent
  121903. */
  121904. transforms: TransformNode[];
  121905. /**
  121906. * All agents created
  121907. */
  121908. agents: number[];
  121909. /**
  121910. * Link to the scene is kept to unregister the crowd from the scene
  121911. */
  121912. private _scene;
  121913. /**
  121914. * Observer for crowd updates
  121915. */
  121916. private _onBeforeAnimationsObserver;
  121917. /**
  121918. * Constructor
  121919. * @param plugin recastJS plugin
  121920. * @param maxAgents the maximum agent count in the crowd
  121921. * @param maxAgentRadius the maximum radius an agent can have
  121922. * @param scene to attach the crowd to
  121923. * @returns the crowd you can add agents to
  121924. */
  121925. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  121926. /**
  121927. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121928. * You can attach anything to that node. The node position is updated in the scene update tick.
  121929. * @param pos world position that will be constrained by the navigation mesh
  121930. * @param parameters agent parameters
  121931. * @param transform hooked to the agent that will be update by the scene
  121932. * @returns agent index
  121933. */
  121934. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121935. /**
  121936. * Returns the agent position in world space
  121937. * @param index agent index returned by addAgent
  121938. * @returns world space position
  121939. */
  121940. getAgentPosition(index: number): Vector3;
  121941. /**
  121942. * Returns the agent velocity in world space
  121943. * @param index agent index returned by addAgent
  121944. * @returns world space velocity
  121945. */
  121946. getAgentVelocity(index: number): Vector3;
  121947. /**
  121948. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121949. * @param index agent index returned by addAgent
  121950. * @param destination targeted world position
  121951. */
  121952. agentGoto(index: number, destination: Vector3): void;
  121953. /**
  121954. * remove a particular agent previously created
  121955. * @param index agent index returned by addAgent
  121956. */
  121957. removeAgent(index: number): void;
  121958. /**
  121959. * get the list of all agents attached to this crowd
  121960. * @returns list of agent indices
  121961. */
  121962. getAgents(): number[];
  121963. /**
  121964. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121965. * @param deltaTime in seconds
  121966. */
  121967. update(deltaTime: number): void;
  121968. /**
  121969. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121970. * The queries will try to find a solution within those bounds
  121971. * default is (1,1,1)
  121972. * @param extent x,y,z value that define the extent around the queries point of reference
  121973. */
  121974. setDefaultQueryExtent(extent: Vector3): void;
  121975. /**
  121976. * Get the Bounding box extent specified by setDefaultQueryExtent
  121977. * @returns the box extent values
  121978. */
  121979. getDefaultQueryExtent(): Vector3;
  121980. /**
  121981. * Release all resources
  121982. */
  121983. dispose(): void;
  121984. }
  121985. }
  121986. declare module BABYLON {
  121987. /**
  121988. * Class used to enable access to IndexedDB
  121989. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  121990. */
  121991. export class Database implements IOfflineProvider {
  121992. private _callbackManifestChecked;
  121993. private _currentSceneUrl;
  121994. private _db;
  121995. private _enableSceneOffline;
  121996. private _enableTexturesOffline;
  121997. private _manifestVersionFound;
  121998. private _mustUpdateRessources;
  121999. private _hasReachedQuota;
  122000. private _isSupported;
  122001. private _idbFactory;
  122002. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122003. private static IsUASupportingBlobStorage;
  122004. /**
  122005. * Gets a boolean indicating if Database storate is enabled (off by default)
  122006. */
  122007. static IDBStorageEnabled: boolean;
  122008. /**
  122009. * Gets a boolean indicating if scene must be saved in the database
  122010. */
  122011. readonly enableSceneOffline: boolean;
  122012. /**
  122013. * Gets a boolean indicating if textures must be saved in the database
  122014. */
  122015. readonly enableTexturesOffline: boolean;
  122016. /**
  122017. * Creates a new Database
  122018. * @param urlToScene defines the url to load the scene
  122019. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122020. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122021. */
  122022. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122023. private static _ParseURL;
  122024. private static _ReturnFullUrlLocation;
  122025. private _checkManifestFile;
  122026. /**
  122027. * Open the database and make it available
  122028. * @param successCallback defines the callback to call on success
  122029. * @param errorCallback defines the callback to call on error
  122030. */
  122031. open(successCallback: () => void, errorCallback: () => void): void;
  122032. /**
  122033. * Loads an image from the database
  122034. * @param url defines the url to load from
  122035. * @param image defines the target DOM image
  122036. */
  122037. loadImage(url: string, image: HTMLImageElement): void;
  122038. private _loadImageFromDBAsync;
  122039. private _saveImageIntoDBAsync;
  122040. private _checkVersionFromDB;
  122041. private _loadVersionFromDBAsync;
  122042. private _saveVersionIntoDBAsync;
  122043. /**
  122044. * Loads a file from database
  122045. * @param url defines the URL to load from
  122046. * @param sceneLoaded defines a callback to call on success
  122047. * @param progressCallBack defines a callback to call when progress changed
  122048. * @param errorCallback defines a callback to call on error
  122049. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122050. */
  122051. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122052. private _loadFileAsync;
  122053. private _saveFileAsync;
  122054. /**
  122055. * Validates if xhr data is correct
  122056. * @param xhr defines the request to validate
  122057. * @param dataType defines the expected data type
  122058. * @returns true if data is correct
  122059. */
  122060. private static _ValidateXHRData;
  122061. }
  122062. }
  122063. declare module BABYLON {
  122064. /** @hidden */
  122065. export var gpuUpdateParticlesPixelShader: {
  122066. name: string;
  122067. shader: string;
  122068. };
  122069. }
  122070. declare module BABYLON {
  122071. /** @hidden */
  122072. export var gpuUpdateParticlesVertexShader: {
  122073. name: string;
  122074. shader: string;
  122075. };
  122076. }
  122077. declare module BABYLON {
  122078. /** @hidden */
  122079. export var clipPlaneFragmentDeclaration2: {
  122080. name: string;
  122081. shader: string;
  122082. };
  122083. }
  122084. declare module BABYLON {
  122085. /** @hidden */
  122086. export var gpuRenderParticlesPixelShader: {
  122087. name: string;
  122088. shader: string;
  122089. };
  122090. }
  122091. declare module BABYLON {
  122092. /** @hidden */
  122093. export var clipPlaneVertexDeclaration2: {
  122094. name: string;
  122095. shader: string;
  122096. };
  122097. }
  122098. declare module BABYLON {
  122099. /** @hidden */
  122100. export var gpuRenderParticlesVertexShader: {
  122101. name: string;
  122102. shader: string;
  122103. };
  122104. }
  122105. declare module BABYLON {
  122106. /**
  122107. * This represents a GPU particle system in Babylon
  122108. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122109. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122110. */
  122111. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122112. /**
  122113. * The layer mask we are rendering the particles through.
  122114. */
  122115. layerMask: number;
  122116. private _capacity;
  122117. private _activeCount;
  122118. private _currentActiveCount;
  122119. private _accumulatedCount;
  122120. private _renderEffect;
  122121. private _updateEffect;
  122122. private _buffer0;
  122123. private _buffer1;
  122124. private _spriteBuffer;
  122125. private _updateVAO;
  122126. private _renderVAO;
  122127. private _targetIndex;
  122128. private _sourceBuffer;
  122129. private _targetBuffer;
  122130. private _engine;
  122131. private _currentRenderId;
  122132. private _started;
  122133. private _stopped;
  122134. private _timeDelta;
  122135. private _randomTexture;
  122136. private _randomTexture2;
  122137. private _attributesStrideSize;
  122138. private _updateEffectOptions;
  122139. private _randomTextureSize;
  122140. private _actualFrame;
  122141. private readonly _rawTextureWidth;
  122142. /**
  122143. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122144. */
  122145. static readonly IsSupported: boolean;
  122146. /**
  122147. * An event triggered when the system is disposed.
  122148. */
  122149. onDisposeObservable: Observable<GPUParticleSystem>;
  122150. /**
  122151. * Gets the maximum number of particles active at the same time.
  122152. * @returns The max number of active particles.
  122153. */
  122154. getCapacity(): number;
  122155. /**
  122156. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122157. * to override the particles.
  122158. */
  122159. forceDepthWrite: boolean;
  122160. /**
  122161. * Gets or set the number of active particles
  122162. */
  122163. activeParticleCount: number;
  122164. private _preWarmDone;
  122165. /**
  122166. * Is this system ready to be used/rendered
  122167. * @return true if the system is ready
  122168. */
  122169. isReady(): boolean;
  122170. /**
  122171. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122172. * @returns True if it has been started, otherwise false.
  122173. */
  122174. isStarted(): boolean;
  122175. /**
  122176. * Starts the particle system and begins to emit
  122177. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122178. */
  122179. start(delay?: number): void;
  122180. /**
  122181. * Stops the particle system.
  122182. */
  122183. stop(): void;
  122184. /**
  122185. * Remove all active particles
  122186. */
  122187. reset(): void;
  122188. /**
  122189. * Returns the string "GPUParticleSystem"
  122190. * @returns a string containing the class name
  122191. */
  122192. getClassName(): string;
  122193. private _colorGradientsTexture;
  122194. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122195. /**
  122196. * Adds a new color gradient
  122197. * @param gradient defines the gradient to use (between 0 and 1)
  122198. * @param color1 defines the color to affect to the specified gradient
  122199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122200. * @returns the current particle system
  122201. */
  122202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122203. /**
  122204. * Remove a specific color gradient
  122205. * @param gradient defines the gradient to remove
  122206. * @returns the current particle system
  122207. */
  122208. removeColorGradient(gradient: number): GPUParticleSystem;
  122209. private _angularSpeedGradientsTexture;
  122210. private _sizeGradientsTexture;
  122211. private _velocityGradientsTexture;
  122212. private _limitVelocityGradientsTexture;
  122213. private _dragGradientsTexture;
  122214. private _addFactorGradient;
  122215. /**
  122216. * Adds a new size gradient
  122217. * @param gradient defines the gradient to use (between 0 and 1)
  122218. * @param factor defines the size factor to affect to the specified gradient
  122219. * @returns the current particle system
  122220. */
  122221. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122222. /**
  122223. * Remove a specific size gradient
  122224. * @param gradient defines the gradient to remove
  122225. * @returns the current particle system
  122226. */
  122227. removeSizeGradient(gradient: number): GPUParticleSystem;
  122228. /**
  122229. * Adds a new angular speed gradient
  122230. * @param gradient defines the gradient to use (between 0 and 1)
  122231. * @param factor defines the angular speed to affect to the specified gradient
  122232. * @returns the current particle system
  122233. */
  122234. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122235. /**
  122236. * Remove a specific angular speed gradient
  122237. * @param gradient defines the gradient to remove
  122238. * @returns the current particle system
  122239. */
  122240. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122241. /**
  122242. * Adds a new velocity gradient
  122243. * @param gradient defines the gradient to use (between 0 and 1)
  122244. * @param factor defines the velocity to affect to the specified gradient
  122245. * @returns the current particle system
  122246. */
  122247. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122248. /**
  122249. * Remove a specific velocity gradient
  122250. * @param gradient defines the gradient to remove
  122251. * @returns the current particle system
  122252. */
  122253. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122254. /**
  122255. * Adds a new limit velocity gradient
  122256. * @param gradient defines the gradient to use (between 0 and 1)
  122257. * @param factor defines the limit velocity value to affect to the specified gradient
  122258. * @returns the current particle system
  122259. */
  122260. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122261. /**
  122262. * Remove a specific limit velocity gradient
  122263. * @param gradient defines the gradient to remove
  122264. * @returns the current particle system
  122265. */
  122266. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122267. /**
  122268. * Adds a new drag gradient
  122269. * @param gradient defines the gradient to use (between 0 and 1)
  122270. * @param factor defines the drag value to affect to the specified gradient
  122271. * @returns the current particle system
  122272. */
  122273. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122274. /**
  122275. * Remove a specific drag gradient
  122276. * @param gradient defines the gradient to remove
  122277. * @returns the current particle system
  122278. */
  122279. removeDragGradient(gradient: number): GPUParticleSystem;
  122280. /**
  122281. * Not supported by GPUParticleSystem
  122282. * @param gradient defines the gradient to use (between 0 and 1)
  122283. * @param factor defines the emit rate value to affect to the specified gradient
  122284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122285. * @returns the current particle system
  122286. */
  122287. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122288. /**
  122289. * Not supported by GPUParticleSystem
  122290. * @param gradient defines the gradient to remove
  122291. * @returns the current particle system
  122292. */
  122293. removeEmitRateGradient(gradient: number): IParticleSystem;
  122294. /**
  122295. * Not supported by GPUParticleSystem
  122296. * @param gradient defines the gradient to use (between 0 and 1)
  122297. * @param factor defines the start size value to affect to the specified gradient
  122298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122299. * @returns the current particle system
  122300. */
  122301. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122302. /**
  122303. * Not supported by GPUParticleSystem
  122304. * @param gradient defines the gradient to remove
  122305. * @returns the current particle system
  122306. */
  122307. removeStartSizeGradient(gradient: number): IParticleSystem;
  122308. /**
  122309. * Not supported by GPUParticleSystem
  122310. * @param gradient defines the gradient to use (between 0 and 1)
  122311. * @param min defines the color remap minimal range
  122312. * @param max defines the color remap maximal range
  122313. * @returns the current particle system
  122314. */
  122315. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122316. /**
  122317. * Not supported by GPUParticleSystem
  122318. * @param gradient defines the gradient to remove
  122319. * @returns the current particle system
  122320. */
  122321. removeColorRemapGradient(): IParticleSystem;
  122322. /**
  122323. * Not supported by GPUParticleSystem
  122324. * @param gradient defines the gradient to use (between 0 and 1)
  122325. * @param min defines the alpha remap minimal range
  122326. * @param max defines the alpha remap maximal range
  122327. * @returns the current particle system
  122328. */
  122329. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122330. /**
  122331. * Not supported by GPUParticleSystem
  122332. * @param gradient defines the gradient to remove
  122333. * @returns the current particle system
  122334. */
  122335. removeAlphaRemapGradient(): IParticleSystem;
  122336. /**
  122337. * Not supported by GPUParticleSystem
  122338. * @param gradient defines the gradient to use (between 0 and 1)
  122339. * @param color defines the color to affect to the specified gradient
  122340. * @returns the current particle system
  122341. */
  122342. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122343. /**
  122344. * Not supported by GPUParticleSystem
  122345. * @param gradient defines the gradient to remove
  122346. * @returns the current particle system
  122347. */
  122348. removeRampGradient(): IParticleSystem;
  122349. /**
  122350. * Not supported by GPUParticleSystem
  122351. * @returns the list of ramp gradients
  122352. */
  122353. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122354. /**
  122355. * Not supported by GPUParticleSystem
  122356. * Gets or sets a boolean indicating that ramp gradients must be used
  122357. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122358. */
  122359. useRampGradients: boolean;
  122360. /**
  122361. * Not supported by GPUParticleSystem
  122362. * @param gradient defines the gradient to use (between 0 and 1)
  122363. * @param factor defines the life time factor to affect to the specified gradient
  122364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122365. * @returns the current particle system
  122366. */
  122367. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122368. /**
  122369. * Not supported by GPUParticleSystem
  122370. * @param gradient defines the gradient to remove
  122371. * @returns the current particle system
  122372. */
  122373. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122374. /**
  122375. * Instantiates a GPU particle system.
  122376. * 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.
  122377. * @param name The name of the particle system
  122378. * @param options The options used to create the system
  122379. * @param scene The scene the particle system belongs to
  122380. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122381. */
  122382. constructor(name: string, options: Partial<{
  122383. capacity: number;
  122384. randomTextureSize: number;
  122385. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122386. protected _reset(): void;
  122387. private _createUpdateVAO;
  122388. private _createRenderVAO;
  122389. private _initialize;
  122390. /** @hidden */
  122391. _recreateUpdateEffect(): void;
  122392. /** @hidden */
  122393. _recreateRenderEffect(): void;
  122394. /**
  122395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122396. * @param preWarm defines if we are in the pre-warmimg phase
  122397. */
  122398. animate(preWarm?: boolean): void;
  122399. private _createFactorGradientTexture;
  122400. private _createSizeGradientTexture;
  122401. private _createAngularSpeedGradientTexture;
  122402. private _createVelocityGradientTexture;
  122403. private _createLimitVelocityGradientTexture;
  122404. private _createDragGradientTexture;
  122405. private _createColorGradientTexture;
  122406. /**
  122407. * Renders the particle system in its current state
  122408. * @param preWarm defines if the system should only update the particles but not render them
  122409. * @returns the current number of particles
  122410. */
  122411. render(preWarm?: boolean): number;
  122412. /**
  122413. * Rebuilds the particle system
  122414. */
  122415. rebuild(): void;
  122416. private _releaseBuffers;
  122417. private _releaseVAOs;
  122418. /**
  122419. * Disposes the particle system and free the associated resources
  122420. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122421. */
  122422. dispose(disposeTexture?: boolean): void;
  122423. /**
  122424. * Clones the particle system.
  122425. * @param name The name of the cloned object
  122426. * @param newEmitter The new emitter to use
  122427. * @returns the cloned particle system
  122428. */
  122429. clone(name: string, newEmitter: any): GPUParticleSystem;
  122430. /**
  122431. * Serializes the particle system to a JSON object.
  122432. * @returns the JSON object
  122433. */
  122434. serialize(): any;
  122435. /**
  122436. * Parses a JSON object to create a GPU particle system.
  122437. * @param parsedParticleSystem The JSON object to parse
  122438. * @param scene The scene to create the particle system in
  122439. * @param rootUrl The root url to use to load external dependencies like texture
  122440. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  122441. * @returns the parsed GPU particle system
  122442. */
  122443. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  122444. }
  122445. }
  122446. declare module BABYLON {
  122447. /**
  122448. * Represents a set of particle systems working together to create a specific effect
  122449. */
  122450. export class ParticleSystemSet implements IDisposable {
  122451. private _emitterCreationOptions;
  122452. private _emitterNode;
  122453. /**
  122454. * Gets the particle system list
  122455. */
  122456. systems: IParticleSystem[];
  122457. /**
  122458. * Gets the emitter node used with this set
  122459. */
  122460. readonly emitterNode: Nullable<TransformNode>;
  122461. /**
  122462. * Creates a new emitter mesh as a sphere
  122463. * @param options defines the options used to create the sphere
  122464. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  122465. * @param scene defines the hosting scene
  122466. */
  122467. setEmitterAsSphere(options: {
  122468. diameter: number;
  122469. segments: number;
  122470. color: Color3;
  122471. }, renderingGroupId: number, scene: Scene): void;
  122472. /**
  122473. * Starts all particle systems of the set
  122474. * @param emitter defines an optional mesh to use as emitter for the particle systems
  122475. */
  122476. start(emitter?: AbstractMesh): void;
  122477. /**
  122478. * Release all associated resources
  122479. */
  122480. dispose(): void;
  122481. /**
  122482. * Serialize the set into a JSON compatible object
  122483. * @returns a JSON compatible representation of the set
  122484. */
  122485. serialize(): any;
  122486. /**
  122487. * Parse a new ParticleSystemSet from a serialized source
  122488. * @param data defines a JSON compatible representation of the set
  122489. * @param scene defines the hosting scene
  122490. * @param gpu defines if we want GPU particles or CPU particles
  122491. * @returns a new ParticleSystemSet
  122492. */
  122493. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  122494. }
  122495. }
  122496. declare module BABYLON {
  122497. /**
  122498. * This class is made for on one-liner static method to help creating particle system set.
  122499. */
  122500. export class ParticleHelper {
  122501. /**
  122502. * Gets or sets base Assets URL
  122503. */
  122504. static BaseAssetsUrl: string;
  122505. /**
  122506. * Create a default particle system that you can tweak
  122507. * @param emitter defines the emitter to use
  122508. * @param capacity defines the system capacity (default is 500 particles)
  122509. * @param scene defines the hosting scene
  122510. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  122511. * @returns the new Particle system
  122512. */
  122513. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  122514. /**
  122515. * This is the main static method (one-liner) of this helper to create different particle systems
  122516. * @param type This string represents the type to the particle system to create
  122517. * @param scene The scene where the particle system should live
  122518. * @param gpu If the system will use gpu
  122519. * @returns the ParticleSystemSet created
  122520. */
  122521. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  122522. /**
  122523. * Static function used to export a particle system to a ParticleSystemSet variable.
  122524. * Please note that the emitter shape is not exported
  122525. * @param systems defines the particle systems to export
  122526. * @returns the created particle system set
  122527. */
  122528. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  122529. }
  122530. }
  122531. declare module BABYLON {
  122532. interface Engine {
  122533. /**
  122534. * Create an effect to use with particle systems.
  122535. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  122536. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  122537. * @param uniformsNames defines a list of attribute names
  122538. * @param samplers defines an array of string used to represent textures
  122539. * @param defines defines the string containing the defines to use to compile the shaders
  122540. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  122541. * @param onCompiled defines a function to call when the effect creation is successful
  122542. * @param onError defines a function to call when the effect creation has failed
  122543. * @returns the new Effect
  122544. */
  122545. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  122546. }
  122547. interface Mesh {
  122548. /**
  122549. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  122550. * @returns an array of IParticleSystem
  122551. */
  122552. getEmittedParticleSystems(): IParticleSystem[];
  122553. /**
  122554. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  122555. * @returns an array of IParticleSystem
  122556. */
  122557. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  122558. }
  122559. /**
  122560. * @hidden
  122561. */
  122562. export var _IDoNeedToBeInTheBuild: number;
  122563. }
  122564. declare module BABYLON {
  122565. interface Scene {
  122566. /** @hidden (Backing field) */
  122567. _physicsEngine: Nullable<IPhysicsEngine>;
  122568. /**
  122569. * Gets the current physics engine
  122570. * @returns a IPhysicsEngine or null if none attached
  122571. */
  122572. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  122573. /**
  122574. * Enables physics to the current scene
  122575. * @param gravity defines the scene's gravity for the physics engine
  122576. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  122577. * @return a boolean indicating if the physics engine was initialized
  122578. */
  122579. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  122580. /**
  122581. * Disables and disposes the physics engine associated with the scene
  122582. */
  122583. disablePhysicsEngine(): void;
  122584. /**
  122585. * Gets a boolean indicating if there is an active physics engine
  122586. * @returns a boolean indicating if there is an active physics engine
  122587. */
  122588. isPhysicsEnabled(): boolean;
  122589. /**
  122590. * Deletes a physics compound impostor
  122591. * @param compound defines the compound to delete
  122592. */
  122593. deleteCompoundImpostor(compound: any): void;
  122594. /**
  122595. * An event triggered when physic simulation is about to be run
  122596. */
  122597. onBeforePhysicsObservable: Observable<Scene>;
  122598. /**
  122599. * An event triggered when physic simulation has been done
  122600. */
  122601. onAfterPhysicsObservable: Observable<Scene>;
  122602. }
  122603. interface AbstractMesh {
  122604. /** @hidden */
  122605. _physicsImpostor: Nullable<PhysicsImpostor>;
  122606. /**
  122607. * Gets or sets impostor used for physic simulation
  122608. * @see http://doc.babylonjs.com/features/physics_engine
  122609. */
  122610. physicsImpostor: Nullable<PhysicsImpostor>;
  122611. /**
  122612. * Gets the current physics impostor
  122613. * @see http://doc.babylonjs.com/features/physics_engine
  122614. * @returns a physics impostor or null
  122615. */
  122616. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  122617. /** Apply a physic impulse to the mesh
  122618. * @param force defines the force to apply
  122619. * @param contactPoint defines where to apply the force
  122620. * @returns the current mesh
  122621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  122622. */
  122623. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  122624. /**
  122625. * Creates a physic joint between two meshes
  122626. * @param otherMesh defines the other mesh to use
  122627. * @param pivot1 defines the pivot to use on this mesh
  122628. * @param pivot2 defines the pivot to use on the other mesh
  122629. * @param options defines additional options (can be plugin dependent)
  122630. * @returns the current mesh
  122631. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  122632. */
  122633. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  122634. /** @hidden */
  122635. _disposePhysicsObserver: Nullable<Observer<Node>>;
  122636. }
  122637. /**
  122638. * Defines the physics engine scene component responsible to manage a physics engine
  122639. */
  122640. export class PhysicsEngineSceneComponent implements ISceneComponent {
  122641. /**
  122642. * The component name helpful to identify the component in the list of scene components.
  122643. */
  122644. readonly name: string;
  122645. /**
  122646. * The scene the component belongs to.
  122647. */
  122648. scene: Scene;
  122649. /**
  122650. * Creates a new instance of the component for the given scene
  122651. * @param scene Defines the scene to register the component in
  122652. */
  122653. constructor(scene: Scene);
  122654. /**
  122655. * Registers the component in a given scene
  122656. */
  122657. register(): void;
  122658. /**
  122659. * Rebuilds the elements related to this component in case of
  122660. * context lost for instance.
  122661. */
  122662. rebuild(): void;
  122663. /**
  122664. * Disposes the component and the associated ressources
  122665. */
  122666. dispose(): void;
  122667. }
  122668. }
  122669. declare module BABYLON {
  122670. /**
  122671. * A helper for physics simulations
  122672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122673. */
  122674. export class PhysicsHelper {
  122675. private _scene;
  122676. private _physicsEngine;
  122677. /**
  122678. * Initializes the Physics helper
  122679. * @param scene Babylon.js scene
  122680. */
  122681. constructor(scene: Scene);
  122682. /**
  122683. * Applies a radial explosion impulse
  122684. * @param origin the origin of the explosion
  122685. * @param radiusOrEventOptions the radius or the options of radial explosion
  122686. * @param strength the explosion strength
  122687. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122688. * @returns A physics radial explosion event, or null
  122689. */
  122690. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122691. /**
  122692. * Applies a radial explosion force
  122693. * @param origin the origin of the explosion
  122694. * @param radiusOrEventOptions the radius or the options of radial explosion
  122695. * @param strength the explosion strength
  122696. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122697. * @returns A physics radial explosion event, or null
  122698. */
  122699. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122700. /**
  122701. * Creates a gravitational field
  122702. * @param origin the origin of the explosion
  122703. * @param radiusOrEventOptions the radius or the options of radial explosion
  122704. * @param strength the explosion strength
  122705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122706. * @returns A physics gravitational field event, or null
  122707. */
  122708. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  122709. /**
  122710. * Creates a physics updraft event
  122711. * @param origin the origin of the updraft
  122712. * @param radiusOrEventOptions the radius or the options of the updraft
  122713. * @param strength the strength of the updraft
  122714. * @param height the height of the updraft
  122715. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  122716. * @returns A physics updraft event, or null
  122717. */
  122718. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  122719. /**
  122720. * Creates a physics vortex event
  122721. * @param origin the of the vortex
  122722. * @param radiusOrEventOptions the radius or the options of the vortex
  122723. * @param strength the strength of the vortex
  122724. * @param height the height of the vortex
  122725. * @returns a Physics vortex event, or null
  122726. * A physics vortex event or null
  122727. */
  122728. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  122729. }
  122730. /**
  122731. * Represents a physics radial explosion event
  122732. */
  122733. class PhysicsRadialExplosionEvent {
  122734. private _scene;
  122735. private _options;
  122736. private _sphere;
  122737. private _dataFetched;
  122738. /**
  122739. * Initializes a radial explosioin event
  122740. * @param _scene BabylonJS scene
  122741. * @param _options The options for the vortex event
  122742. */
  122743. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  122744. /**
  122745. * Returns the data related to the radial explosion event (sphere).
  122746. * @returns The radial explosion event data
  122747. */
  122748. getData(): PhysicsRadialExplosionEventData;
  122749. /**
  122750. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  122751. * @param impostor A physics imposter
  122752. * @param origin the origin of the explosion
  122753. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  122754. */
  122755. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  122756. /**
  122757. * Triggers affecterd impostors callbacks
  122758. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  122759. */
  122760. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  122761. /**
  122762. * Disposes the sphere.
  122763. * @param force Specifies if the sphere should be disposed by force
  122764. */
  122765. dispose(force?: boolean): void;
  122766. /*** Helpers ***/
  122767. private _prepareSphere;
  122768. private _intersectsWithSphere;
  122769. }
  122770. /**
  122771. * Represents a gravitational field event
  122772. */
  122773. class PhysicsGravitationalFieldEvent {
  122774. private _physicsHelper;
  122775. private _scene;
  122776. private _origin;
  122777. private _options;
  122778. private _tickCallback;
  122779. private _sphere;
  122780. private _dataFetched;
  122781. /**
  122782. * Initializes the physics gravitational field event
  122783. * @param _physicsHelper A physics helper
  122784. * @param _scene BabylonJS scene
  122785. * @param _origin The origin position of the gravitational field event
  122786. * @param _options The options for the vortex event
  122787. */
  122788. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  122789. /**
  122790. * Returns the data related to the gravitational field event (sphere).
  122791. * @returns A gravitational field event
  122792. */
  122793. getData(): PhysicsGravitationalFieldEventData;
  122794. /**
  122795. * Enables the gravitational field.
  122796. */
  122797. enable(): void;
  122798. /**
  122799. * Disables the gravitational field.
  122800. */
  122801. disable(): void;
  122802. /**
  122803. * Disposes the sphere.
  122804. * @param force The force to dispose from the gravitational field event
  122805. */
  122806. dispose(force?: boolean): void;
  122807. private _tick;
  122808. }
  122809. /**
  122810. * Represents a physics updraft event
  122811. */
  122812. class PhysicsUpdraftEvent {
  122813. private _scene;
  122814. private _origin;
  122815. private _options;
  122816. private _physicsEngine;
  122817. private _originTop;
  122818. private _originDirection;
  122819. private _tickCallback;
  122820. private _cylinder;
  122821. private _cylinderPosition;
  122822. private _dataFetched;
  122823. /**
  122824. * Initializes the physics updraft event
  122825. * @param _scene BabylonJS scene
  122826. * @param _origin The origin position of the updraft
  122827. * @param _options The options for the updraft event
  122828. */
  122829. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  122830. /**
  122831. * Returns the data related to the updraft event (cylinder).
  122832. * @returns A physics updraft event
  122833. */
  122834. getData(): PhysicsUpdraftEventData;
  122835. /**
  122836. * Enables the updraft.
  122837. */
  122838. enable(): void;
  122839. /**
  122840. * Disables the updraft.
  122841. */
  122842. disable(): void;
  122843. /**
  122844. * Disposes the cylinder.
  122845. * @param force Specifies if the updraft should be disposed by force
  122846. */
  122847. dispose(force?: boolean): void;
  122848. private getImpostorHitData;
  122849. private _tick;
  122850. /*** Helpers ***/
  122851. private _prepareCylinder;
  122852. private _intersectsWithCylinder;
  122853. }
  122854. /**
  122855. * Represents a physics vortex event
  122856. */
  122857. class PhysicsVortexEvent {
  122858. private _scene;
  122859. private _origin;
  122860. private _options;
  122861. private _physicsEngine;
  122862. private _originTop;
  122863. private _tickCallback;
  122864. private _cylinder;
  122865. private _cylinderPosition;
  122866. private _dataFetched;
  122867. /**
  122868. * Initializes the physics vortex event
  122869. * @param _scene The BabylonJS scene
  122870. * @param _origin The origin position of the vortex
  122871. * @param _options The options for the vortex event
  122872. */
  122873. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  122874. /**
  122875. * Returns the data related to the vortex event (cylinder).
  122876. * @returns The physics vortex event data
  122877. */
  122878. getData(): PhysicsVortexEventData;
  122879. /**
  122880. * Enables the vortex.
  122881. */
  122882. enable(): void;
  122883. /**
  122884. * Disables the cortex.
  122885. */
  122886. disable(): void;
  122887. /**
  122888. * Disposes the sphere.
  122889. * @param force
  122890. */
  122891. dispose(force?: boolean): void;
  122892. private getImpostorHitData;
  122893. private _tick;
  122894. /*** Helpers ***/
  122895. private _prepareCylinder;
  122896. private _intersectsWithCylinder;
  122897. }
  122898. /**
  122899. * Options fot the radial explosion event
  122900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122901. */
  122902. export class PhysicsRadialExplosionEventOptions {
  122903. /**
  122904. * The radius of the sphere for the radial explosion.
  122905. */
  122906. radius: number;
  122907. /**
  122908. * The strenth of the explosion.
  122909. */
  122910. strength: number;
  122911. /**
  122912. * The strenght of the force in correspondence to the distance of the affected object
  122913. */
  122914. falloff: PhysicsRadialImpulseFalloff;
  122915. /**
  122916. * Sphere options for the radial explosion.
  122917. */
  122918. sphere: {
  122919. segments: number;
  122920. diameter: number;
  122921. };
  122922. /**
  122923. * Sphere options for the radial explosion.
  122924. */
  122925. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  122926. }
  122927. /**
  122928. * Options fot the updraft event
  122929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122930. */
  122931. export class PhysicsUpdraftEventOptions {
  122932. /**
  122933. * The radius of the cylinder for the vortex
  122934. */
  122935. radius: number;
  122936. /**
  122937. * The strenth of the updraft.
  122938. */
  122939. strength: number;
  122940. /**
  122941. * The height of the cylinder for the updraft.
  122942. */
  122943. height: number;
  122944. /**
  122945. * The mode for the the updraft.
  122946. */
  122947. updraftMode: PhysicsUpdraftMode;
  122948. }
  122949. /**
  122950. * Options fot the vortex event
  122951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122952. */
  122953. export class PhysicsVortexEventOptions {
  122954. /**
  122955. * The radius of the cylinder for the vortex
  122956. */
  122957. radius: number;
  122958. /**
  122959. * The strenth of the vortex.
  122960. */
  122961. strength: number;
  122962. /**
  122963. * The height of the cylinder for the vortex.
  122964. */
  122965. height: number;
  122966. /**
  122967. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  122968. */
  122969. centripetalForceThreshold: number;
  122970. /**
  122971. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  122972. */
  122973. centripetalForceMultiplier: number;
  122974. /**
  122975. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  122976. */
  122977. centrifugalForceMultiplier: number;
  122978. /**
  122979. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  122980. */
  122981. updraftForceMultiplier: number;
  122982. }
  122983. /**
  122984. * The strenght of the force in correspondence to the distance of the affected object
  122985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122986. */
  122987. export enum PhysicsRadialImpulseFalloff {
  122988. /** Defines that impulse is constant in strength across it's whole radius */
  122989. Constant = 0,
  122990. /** Defines that impulse gets weaker if it's further from the origin */
  122991. Linear = 1
  122992. }
  122993. /**
  122994. * The strength of the force in correspondence to the distance of the affected object
  122995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122996. */
  122997. export enum PhysicsUpdraftMode {
  122998. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  122999. Center = 0,
  123000. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123001. Perpendicular = 1
  123002. }
  123003. /**
  123004. * Interface for a physics hit data
  123005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123006. */
  123007. export interface PhysicsHitData {
  123008. /**
  123009. * The force applied at the contact point
  123010. */
  123011. force: Vector3;
  123012. /**
  123013. * The contact point
  123014. */
  123015. contactPoint: Vector3;
  123016. /**
  123017. * The distance from the origin to the contact point
  123018. */
  123019. distanceFromOrigin: number;
  123020. }
  123021. /**
  123022. * Interface for radial explosion event data
  123023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123024. */
  123025. export interface PhysicsRadialExplosionEventData {
  123026. /**
  123027. * A sphere used for the radial explosion event
  123028. */
  123029. sphere: Mesh;
  123030. }
  123031. /**
  123032. * Interface for gravitational field event data
  123033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123034. */
  123035. export interface PhysicsGravitationalFieldEventData {
  123036. /**
  123037. * A sphere mesh used for the gravitational field event
  123038. */
  123039. sphere: Mesh;
  123040. }
  123041. /**
  123042. * Interface for updraft event data
  123043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123044. */
  123045. export interface PhysicsUpdraftEventData {
  123046. /**
  123047. * A cylinder used for the updraft event
  123048. */
  123049. cylinder: Mesh;
  123050. }
  123051. /**
  123052. * Interface for vortex event data
  123053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123054. */
  123055. export interface PhysicsVortexEventData {
  123056. /**
  123057. * A cylinder used for the vortex event
  123058. */
  123059. cylinder: Mesh;
  123060. }
  123061. /**
  123062. * Interface for an affected physics impostor
  123063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123064. */
  123065. export interface PhysicsAffectedImpostorWithData {
  123066. /**
  123067. * The impostor affected by the effect
  123068. */
  123069. impostor: PhysicsImpostor;
  123070. /**
  123071. * The data about the hit/horce from the explosion
  123072. */
  123073. hitData: PhysicsHitData;
  123074. }
  123075. }
  123076. declare module BABYLON {
  123077. /** @hidden */
  123078. export var blackAndWhitePixelShader: {
  123079. name: string;
  123080. shader: string;
  123081. };
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * Post process used to render in black and white
  123086. */
  123087. export class BlackAndWhitePostProcess extends PostProcess {
  123088. /**
  123089. * Linear about to convert he result to black and white (default: 1)
  123090. */
  123091. degree: number;
  123092. /**
  123093. * Creates a black and white post process
  123094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123095. * @param name The name of the effect.
  123096. * @param options The required width/height ratio to downsize to before computing the render pass.
  123097. * @param camera The camera to apply the render pass to.
  123098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123099. * @param engine The engine which the post process will be applied. (default: current engine)
  123100. * @param reusable If the post process can be reused on the same frame. (default: false)
  123101. */
  123102. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123103. }
  123104. }
  123105. declare module BABYLON {
  123106. /**
  123107. * This represents a set of one or more post processes in Babylon.
  123108. * A post process can be used to apply a shader to a texture after it is rendered.
  123109. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123110. */
  123111. export class PostProcessRenderEffect {
  123112. private _postProcesses;
  123113. private _getPostProcesses;
  123114. private _singleInstance;
  123115. private _cameras;
  123116. private _indicesForCamera;
  123117. /**
  123118. * Name of the effect
  123119. * @hidden
  123120. */
  123121. _name: string;
  123122. /**
  123123. * Instantiates a post process render effect.
  123124. * A post process can be used to apply a shader to a texture after it is rendered.
  123125. * @param engine The engine the effect is tied to
  123126. * @param name The name of the effect
  123127. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123128. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123129. */
  123130. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123131. /**
  123132. * Checks if all the post processes in the effect are supported.
  123133. */
  123134. readonly isSupported: boolean;
  123135. /**
  123136. * Updates the current state of the effect
  123137. * @hidden
  123138. */
  123139. _update(): void;
  123140. /**
  123141. * Attaches the effect on cameras
  123142. * @param cameras The camera to attach to.
  123143. * @hidden
  123144. */
  123145. _attachCameras(cameras: Camera): void;
  123146. /**
  123147. * Attaches the effect on cameras
  123148. * @param cameras The camera to attach to.
  123149. * @hidden
  123150. */
  123151. _attachCameras(cameras: Camera[]): void;
  123152. /**
  123153. * Detaches the effect on cameras
  123154. * @param cameras The camera to detatch from.
  123155. * @hidden
  123156. */
  123157. _detachCameras(cameras: Camera): void;
  123158. /**
  123159. * Detatches the effect on cameras
  123160. * @param cameras The camera to detatch from.
  123161. * @hidden
  123162. */
  123163. _detachCameras(cameras: Camera[]): void;
  123164. /**
  123165. * Enables the effect on given cameras
  123166. * @param cameras The camera to enable.
  123167. * @hidden
  123168. */
  123169. _enable(cameras: Camera): void;
  123170. /**
  123171. * Enables the effect on given cameras
  123172. * @param cameras The camera to enable.
  123173. * @hidden
  123174. */
  123175. _enable(cameras: Nullable<Camera[]>): void;
  123176. /**
  123177. * Disables the effect on the given cameras
  123178. * @param cameras The camera to disable.
  123179. * @hidden
  123180. */
  123181. _disable(cameras: Camera): void;
  123182. /**
  123183. * Disables the effect on the given cameras
  123184. * @param cameras The camera to disable.
  123185. * @hidden
  123186. */
  123187. _disable(cameras: Nullable<Camera[]>): void;
  123188. /**
  123189. * Gets a list of the post processes contained in the effect.
  123190. * @param camera The camera to get the post processes on.
  123191. * @returns The list of the post processes in the effect.
  123192. */
  123193. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123194. }
  123195. }
  123196. declare module BABYLON {
  123197. /** @hidden */
  123198. export var extractHighlightsPixelShader: {
  123199. name: string;
  123200. shader: string;
  123201. };
  123202. }
  123203. declare module BABYLON {
  123204. /**
  123205. * 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.
  123206. */
  123207. export class ExtractHighlightsPostProcess extends PostProcess {
  123208. /**
  123209. * The luminance threshold, pixels below this value will be set to black.
  123210. */
  123211. threshold: number;
  123212. /** @hidden */
  123213. _exposure: number;
  123214. /**
  123215. * Post process which has the input texture to be used when performing highlight extraction
  123216. * @hidden
  123217. */
  123218. _inputPostProcess: Nullable<PostProcess>;
  123219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123220. }
  123221. }
  123222. declare module BABYLON {
  123223. /** @hidden */
  123224. export var bloomMergePixelShader: {
  123225. name: string;
  123226. shader: string;
  123227. };
  123228. }
  123229. declare module BABYLON {
  123230. /**
  123231. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123232. */
  123233. export class BloomMergePostProcess extends PostProcess {
  123234. /** Weight of the bloom to be added to the original input. */
  123235. weight: number;
  123236. /**
  123237. * Creates a new instance of @see BloomMergePostProcess
  123238. * @param name The name of the effect.
  123239. * @param originalFromInput Post process which's input will be used for the merge.
  123240. * @param blurred Blurred highlights post process which's output will be used.
  123241. * @param weight Weight of the bloom to be added to the original input.
  123242. * @param options The required width/height ratio to downsize to before computing the render pass.
  123243. * @param camera The camera to apply the render pass to.
  123244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123245. * @param engine The engine which the post process will be applied. (default: current engine)
  123246. * @param reusable If the post process can be reused on the same frame. (default: false)
  123247. * @param textureType Type of textures used when performing the post process. (default: 0)
  123248. * @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)
  123249. */
  123250. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123251. /** Weight of the bloom to be added to the original input. */
  123252. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123253. }
  123254. }
  123255. declare module BABYLON {
  123256. /**
  123257. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123258. */
  123259. export class BloomEffect extends PostProcessRenderEffect {
  123260. private bloomScale;
  123261. /**
  123262. * @hidden Internal
  123263. */
  123264. _effects: Array<PostProcess>;
  123265. /**
  123266. * @hidden Internal
  123267. */
  123268. _downscale: ExtractHighlightsPostProcess;
  123269. private _blurX;
  123270. private _blurY;
  123271. private _merge;
  123272. /**
  123273. * The luminance threshold to find bright areas of the image to bloom.
  123274. */
  123275. threshold: number;
  123276. /**
  123277. * The strength of the bloom.
  123278. */
  123279. weight: number;
  123280. /**
  123281. * Specifies the size of the bloom blur kernel, relative to the final output size
  123282. */
  123283. kernel: number;
  123284. /**
  123285. * Creates a new instance of @see BloomEffect
  123286. * @param scene The scene the effect belongs to.
  123287. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123288. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123289. * @param bloomWeight The the strength of bloom.
  123290. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123291. * @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)
  123292. */
  123293. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123294. /**
  123295. * Disposes each of the internal effects for a given camera.
  123296. * @param camera The camera to dispose the effect on.
  123297. */
  123298. disposeEffects(camera: Camera): void;
  123299. /**
  123300. * @hidden Internal
  123301. */
  123302. _updateEffects(): void;
  123303. /**
  123304. * Internal
  123305. * @returns if all the contained post processes are ready.
  123306. * @hidden
  123307. */
  123308. _isReady(): boolean;
  123309. }
  123310. }
  123311. declare module BABYLON {
  123312. /** @hidden */
  123313. export var chromaticAberrationPixelShader: {
  123314. name: string;
  123315. shader: string;
  123316. };
  123317. }
  123318. declare module BABYLON {
  123319. /**
  123320. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123321. */
  123322. export class ChromaticAberrationPostProcess extends PostProcess {
  123323. /**
  123324. * The amount of seperation of rgb channels (default: 30)
  123325. */
  123326. aberrationAmount: number;
  123327. /**
  123328. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123329. */
  123330. radialIntensity: number;
  123331. /**
  123332. * 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))
  123333. */
  123334. direction: Vector2;
  123335. /**
  123336. * 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))
  123337. */
  123338. centerPosition: Vector2;
  123339. /**
  123340. * Creates a new instance ChromaticAberrationPostProcess
  123341. * @param name The name of the effect.
  123342. * @param screenWidth The width of the screen to apply the effect on.
  123343. * @param screenHeight The height of the screen to apply the effect on.
  123344. * @param options The required width/height ratio to downsize to before computing the render pass.
  123345. * @param camera The camera to apply the render pass to.
  123346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123347. * @param engine The engine which the post process will be applied. (default: current engine)
  123348. * @param reusable If the post process can be reused on the same frame. (default: false)
  123349. * @param textureType Type of textures used when performing the post process. (default: 0)
  123350. * @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)
  123351. */
  123352. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123353. }
  123354. }
  123355. declare module BABYLON {
  123356. /** @hidden */
  123357. export var circleOfConfusionPixelShader: {
  123358. name: string;
  123359. shader: string;
  123360. };
  123361. }
  123362. declare module BABYLON {
  123363. /**
  123364. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123365. */
  123366. export class CircleOfConfusionPostProcess extends PostProcess {
  123367. /**
  123368. * 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.
  123369. */
  123370. lensSize: number;
  123371. /**
  123372. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123373. */
  123374. fStop: number;
  123375. /**
  123376. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123377. */
  123378. focusDistance: number;
  123379. /**
  123380. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123381. */
  123382. focalLength: number;
  123383. private _depthTexture;
  123384. /**
  123385. * Creates a new instance CircleOfConfusionPostProcess
  123386. * @param name The name of the effect.
  123387. * @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.
  123388. * @param options The required width/height ratio to downsize to before computing the render pass.
  123389. * @param camera The camera to apply the render pass to.
  123390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123391. * @param engine The engine which the post process will be applied. (default: current engine)
  123392. * @param reusable If the post process can be reused on the same frame. (default: false)
  123393. * @param textureType Type of textures used when performing the post process. (default: 0)
  123394. * @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)
  123395. */
  123396. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123397. /**
  123398. * 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.
  123399. */
  123400. depthTexture: RenderTargetTexture;
  123401. }
  123402. }
  123403. declare module BABYLON {
  123404. /** @hidden */
  123405. export var colorCorrectionPixelShader: {
  123406. name: string;
  123407. shader: string;
  123408. };
  123409. }
  123410. declare module BABYLON {
  123411. /**
  123412. *
  123413. * This post-process allows the modification of rendered colors by using
  123414. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123415. *
  123416. * The object needs to be provided an url to a texture containing the color
  123417. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123418. * Use an image editing software to tweak the LUT to match your needs.
  123419. *
  123420. * For an example of a color LUT, see here:
  123421. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123422. * For explanations on color grading, see here:
  123423. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123424. *
  123425. */
  123426. export class ColorCorrectionPostProcess extends PostProcess {
  123427. private _colorTableTexture;
  123428. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123429. }
  123430. }
  123431. declare module BABYLON {
  123432. /** @hidden */
  123433. export var convolutionPixelShader: {
  123434. name: string;
  123435. shader: string;
  123436. };
  123437. }
  123438. declare module BABYLON {
  123439. /**
  123440. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123441. * input texture to perform effects such as edge detection or sharpening
  123442. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123443. */
  123444. export class ConvolutionPostProcess extends PostProcess {
  123445. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123446. kernel: number[];
  123447. /**
  123448. * Creates a new instance ConvolutionPostProcess
  123449. * @param name The name of the effect.
  123450. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  123451. * @param options The required width/height ratio to downsize to before computing the render pass.
  123452. * @param camera The camera to apply the render pass to.
  123453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123454. * @param engine The engine which the post process will be applied. (default: current engine)
  123455. * @param reusable If the post process can be reused on the same frame. (default: false)
  123456. * @param textureType Type of textures used when performing the post process. (default: 0)
  123457. */
  123458. constructor(name: string,
  123459. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123460. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123461. /**
  123462. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123463. */
  123464. static EdgeDetect0Kernel: number[];
  123465. /**
  123466. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123467. */
  123468. static EdgeDetect1Kernel: number[];
  123469. /**
  123470. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123471. */
  123472. static EdgeDetect2Kernel: number[];
  123473. /**
  123474. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123475. */
  123476. static SharpenKernel: number[];
  123477. /**
  123478. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123479. */
  123480. static EmbossKernel: number[];
  123481. /**
  123482. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123483. */
  123484. static GaussianKernel: number[];
  123485. }
  123486. }
  123487. declare module BABYLON {
  123488. /**
  123489. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123490. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123491. * based on samples that have a large difference in distance than the center pixel.
  123492. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123493. */
  123494. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  123495. direction: Vector2;
  123496. /**
  123497. * Creates a new instance CircleOfConfusionPostProcess
  123498. * @param name The name of the effect.
  123499. * @param scene The scene the effect belongs to.
  123500. * @param direction The direction the blur should be applied.
  123501. * @param kernel The size of the kernel used to blur.
  123502. * @param options The required width/height ratio to downsize to before computing the render pass.
  123503. * @param camera The camera to apply the render pass to.
  123504. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123505. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123507. * @param engine The engine which the post process will be applied. (default: current engine)
  123508. * @param reusable If the post process can be reused on the same frame. (default: false)
  123509. * @param textureType Type of textures used when performing the post process. (default: 0)
  123510. * @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)
  123511. */
  123512. 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);
  123513. }
  123514. }
  123515. declare module BABYLON {
  123516. /** @hidden */
  123517. export var depthOfFieldMergePixelShader: {
  123518. name: string;
  123519. shader: string;
  123520. };
  123521. }
  123522. declare module BABYLON {
  123523. /**
  123524. * Options to be set when merging outputs from the default pipeline.
  123525. */
  123526. export class DepthOfFieldMergePostProcessOptions {
  123527. /**
  123528. * The original image to merge on top of
  123529. */
  123530. originalFromInput: PostProcess;
  123531. /**
  123532. * Parameters to perform the merge of the depth of field effect
  123533. */
  123534. depthOfField?: {
  123535. circleOfConfusion: PostProcess;
  123536. blurSteps: Array<PostProcess>;
  123537. };
  123538. /**
  123539. * Parameters to perform the merge of bloom effect
  123540. */
  123541. bloom?: {
  123542. blurred: PostProcess;
  123543. weight: number;
  123544. };
  123545. }
  123546. /**
  123547. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123548. */
  123549. export class DepthOfFieldMergePostProcess extends PostProcess {
  123550. private blurSteps;
  123551. /**
  123552. * Creates a new instance of DepthOfFieldMergePostProcess
  123553. * @param name The name of the effect.
  123554. * @param originalFromInput Post process which's input will be used for the merge.
  123555. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123556. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123557. * @param options The required width/height ratio to downsize to before computing the render pass.
  123558. * @param camera The camera to apply the render pass to.
  123559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123560. * @param engine The engine which the post process will be applied. (default: current engine)
  123561. * @param reusable If the post process can be reused on the same frame. (default: false)
  123562. * @param textureType Type of textures used when performing the post process. (default: 0)
  123563. * @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)
  123564. */
  123565. 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);
  123566. /**
  123567. * Updates the effect with the current post process compile time values and recompiles the shader.
  123568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123571. * @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
  123572. * @param onCompiled Called when the shader has been compiled.
  123573. * @param onError Called if there is an error when compiling a shader.
  123574. */
  123575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * Specifies the level of max blur that should be applied when using the depth of field effect
  123581. */
  123582. export enum DepthOfFieldEffectBlurLevel {
  123583. /**
  123584. * Subtle blur
  123585. */
  123586. Low = 0,
  123587. /**
  123588. * Medium blur
  123589. */
  123590. Medium = 1,
  123591. /**
  123592. * Large blur
  123593. */
  123594. High = 2
  123595. }
  123596. /**
  123597. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123598. */
  123599. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  123600. private _circleOfConfusion;
  123601. /**
  123602. * @hidden Internal, blurs from high to low
  123603. */
  123604. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  123605. private _depthOfFieldBlurY;
  123606. private _dofMerge;
  123607. /**
  123608. * @hidden Internal post processes in depth of field effect
  123609. */
  123610. _effects: Array<PostProcess>;
  123611. /**
  123612. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123613. */
  123614. focalLength: number;
  123615. /**
  123616. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123617. */
  123618. fStop: number;
  123619. /**
  123620. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123621. */
  123622. focusDistance: number;
  123623. /**
  123624. * 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.
  123625. */
  123626. lensSize: number;
  123627. /**
  123628. * Creates a new instance DepthOfFieldEffect
  123629. * @param scene The scene the effect belongs to.
  123630. * @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.
  123631. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123632. * @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)
  123633. */
  123634. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  123635. /**
  123636. * Get the current class name of the current effet
  123637. * @returns "DepthOfFieldEffect"
  123638. */
  123639. getClassName(): string;
  123640. /**
  123641. * 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.
  123642. */
  123643. depthTexture: RenderTargetTexture;
  123644. /**
  123645. * Disposes each of the internal effects for a given camera.
  123646. * @param camera The camera to dispose the effect on.
  123647. */
  123648. disposeEffects(camera: Camera): void;
  123649. /**
  123650. * @hidden Internal
  123651. */
  123652. _updateEffects(): void;
  123653. /**
  123654. * Internal
  123655. * @returns if all the contained post processes are ready.
  123656. * @hidden
  123657. */
  123658. _isReady(): boolean;
  123659. }
  123660. }
  123661. declare module BABYLON {
  123662. /** @hidden */
  123663. export var displayPassPixelShader: {
  123664. name: string;
  123665. shader: string;
  123666. };
  123667. }
  123668. declare module BABYLON {
  123669. /**
  123670. * DisplayPassPostProcess which produces an output the same as it's input
  123671. */
  123672. export class DisplayPassPostProcess extends PostProcess {
  123673. /**
  123674. * Creates the DisplayPassPostProcess
  123675. * @param name The name of the effect.
  123676. * @param options The required width/height ratio to downsize to before computing the render pass.
  123677. * @param camera The camera to apply the render pass to.
  123678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123679. * @param engine The engine which the post process will be applied. (default: current engine)
  123680. * @param reusable If the post process can be reused on the same frame. (default: false)
  123681. */
  123682. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123683. }
  123684. }
  123685. declare module BABYLON {
  123686. /** @hidden */
  123687. export var filterPixelShader: {
  123688. name: string;
  123689. shader: string;
  123690. };
  123691. }
  123692. declare module BABYLON {
  123693. /**
  123694. * Applies a kernel filter to the image
  123695. */
  123696. export class FilterPostProcess extends PostProcess {
  123697. /** The matrix to be applied to the image */
  123698. kernelMatrix: Matrix;
  123699. /**
  123700. *
  123701. * @param name The name of the effect.
  123702. * @param kernelMatrix The matrix to be applied to the image
  123703. * @param options The required width/height ratio to downsize to before computing the render pass.
  123704. * @param camera The camera to apply the render pass to.
  123705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123706. * @param engine The engine which the post process will be applied. (default: current engine)
  123707. * @param reusable If the post process can be reused on the same frame. (default: false)
  123708. */
  123709. constructor(name: string,
  123710. /** The matrix to be applied to the image */
  123711. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123712. }
  123713. }
  123714. declare module BABYLON {
  123715. /** @hidden */
  123716. export var fxaaPixelShader: {
  123717. name: string;
  123718. shader: string;
  123719. };
  123720. }
  123721. declare module BABYLON {
  123722. /** @hidden */
  123723. export var fxaaVertexShader: {
  123724. name: string;
  123725. shader: string;
  123726. };
  123727. }
  123728. declare module BABYLON {
  123729. /**
  123730. * Fxaa post process
  123731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123732. */
  123733. export class FxaaPostProcess extends PostProcess {
  123734. /** @hidden */
  123735. texelWidth: number;
  123736. /** @hidden */
  123737. texelHeight: number;
  123738. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123739. private _getDefines;
  123740. }
  123741. }
  123742. declare module BABYLON {
  123743. /** @hidden */
  123744. export var grainPixelShader: {
  123745. name: string;
  123746. shader: string;
  123747. };
  123748. }
  123749. declare module BABYLON {
  123750. /**
  123751. * The GrainPostProcess adds noise to the image at mid luminance levels
  123752. */
  123753. export class GrainPostProcess extends PostProcess {
  123754. /**
  123755. * The intensity of the grain added (default: 30)
  123756. */
  123757. intensity: number;
  123758. /**
  123759. * If the grain should be randomized on every frame
  123760. */
  123761. animated: boolean;
  123762. /**
  123763. * Creates a new instance of @see GrainPostProcess
  123764. * @param name The name of the effect.
  123765. * @param options The required width/height ratio to downsize to before computing the render pass.
  123766. * @param camera The camera to apply the render pass to.
  123767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123768. * @param engine The engine which the post process will be applied. (default: current engine)
  123769. * @param reusable If the post process can be reused on the same frame. (default: false)
  123770. * @param textureType Type of textures used when performing the post process. (default: 0)
  123771. * @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)
  123772. */
  123773. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123774. }
  123775. }
  123776. declare module BABYLON {
  123777. /** @hidden */
  123778. export var highlightsPixelShader: {
  123779. name: string;
  123780. shader: string;
  123781. };
  123782. }
  123783. declare module BABYLON {
  123784. /**
  123785. * Extracts highlights from the image
  123786. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123787. */
  123788. export class HighlightsPostProcess extends PostProcess {
  123789. /**
  123790. * Extracts highlights from the image
  123791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123792. * @param name The name of the effect.
  123793. * @param options The required width/height ratio to downsize to before computing the render pass.
  123794. * @param camera The camera to apply the render pass to.
  123795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123796. * @param engine The engine which the post process will be applied. (default: current engine)
  123797. * @param reusable If the post process can be reused on the same frame. (default: false)
  123798. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  123799. */
  123800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123801. }
  123802. }
  123803. declare module BABYLON {
  123804. /** @hidden */
  123805. export var mrtFragmentDeclaration: {
  123806. name: string;
  123807. shader: string;
  123808. };
  123809. }
  123810. declare module BABYLON {
  123811. /** @hidden */
  123812. export var geometryPixelShader: {
  123813. name: string;
  123814. shader: string;
  123815. };
  123816. }
  123817. declare module BABYLON {
  123818. /** @hidden */
  123819. export var geometryVertexShader: {
  123820. name: string;
  123821. shader: string;
  123822. };
  123823. }
  123824. declare module BABYLON {
  123825. /** @hidden */
  123826. interface ISavedTransformationMatrix {
  123827. world: Matrix;
  123828. viewProjection: Matrix;
  123829. }
  123830. /**
  123831. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  123832. */
  123833. export class GeometryBufferRenderer {
  123834. /**
  123835. * Constant used to retrieve the position texture index in the G-Buffer textures array
  123836. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  123837. */
  123838. static readonly POSITION_TEXTURE_TYPE: number;
  123839. /**
  123840. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  123841. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  123842. */
  123843. static readonly VELOCITY_TEXTURE_TYPE: number;
  123844. /**
  123845. * Dictionary used to store the previous transformation matrices of each rendered mesh
  123846. * in order to compute objects velocities when enableVelocity is set to "true"
  123847. * @hidden
  123848. */
  123849. _previousTransformationMatrices: {
  123850. [index: number]: ISavedTransformationMatrix;
  123851. };
  123852. /**
  123853. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  123854. * in order to compute objects velocities when enableVelocity is set to "true"
  123855. * @hidden
  123856. */
  123857. _previousBonesTransformationMatrices: {
  123858. [index: number]: Float32Array;
  123859. };
  123860. /**
  123861. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  123862. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  123863. */
  123864. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  123865. private _scene;
  123866. private _multiRenderTarget;
  123867. private _ratio;
  123868. private _enablePosition;
  123869. private _enableVelocity;
  123870. private _positionIndex;
  123871. private _velocityIndex;
  123872. protected _effect: Effect;
  123873. protected _cachedDefines: string;
  123874. /**
  123875. * Set the render list (meshes to be rendered) used in the G buffer.
  123876. */
  123877. renderList: Mesh[];
  123878. /**
  123879. * Gets wether or not G buffer are supported by the running hardware.
  123880. * This requires draw buffer supports
  123881. */
  123882. readonly isSupported: boolean;
  123883. /**
  123884. * Returns the index of the given texture type in the G-Buffer textures array
  123885. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  123886. * @returns the index of the given texture type in the G-Buffer textures array
  123887. */
  123888. getTextureIndex(textureType: number): number;
  123889. /**
  123890. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  123891. */
  123892. /**
  123893. * Sets whether or not objects positions are enabled for the G buffer.
  123894. */
  123895. enablePosition: boolean;
  123896. /**
  123897. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  123898. */
  123899. /**
  123900. * Sets wether or not objects velocities are enabled for the G buffer.
  123901. */
  123902. enableVelocity: boolean;
  123903. /**
  123904. * Gets the scene associated with the buffer.
  123905. */
  123906. readonly scene: Scene;
  123907. /**
  123908. * Gets the ratio used by the buffer during its creation.
  123909. * How big is the buffer related to the main canvas.
  123910. */
  123911. readonly ratio: number;
  123912. /** @hidden */
  123913. static _SceneComponentInitialization: (scene: Scene) => void;
  123914. /**
  123915. * Creates a new G Buffer for the scene
  123916. * @param scene The scene the buffer belongs to
  123917. * @param ratio How big is the buffer related to the main canvas.
  123918. */
  123919. constructor(scene: Scene, ratio?: number);
  123920. /**
  123921. * Checks wether everything is ready to render a submesh to the G buffer.
  123922. * @param subMesh the submesh to check readiness for
  123923. * @param useInstances is the mesh drawn using instance or not
  123924. * @returns true if ready otherwise false
  123925. */
  123926. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123927. /**
  123928. * Gets the current underlying G Buffer.
  123929. * @returns the buffer
  123930. */
  123931. getGBuffer(): MultiRenderTarget;
  123932. /**
  123933. * Gets the number of samples used to render the buffer (anti aliasing).
  123934. */
  123935. /**
  123936. * Sets the number of samples used to render the buffer (anti aliasing).
  123937. */
  123938. samples: number;
  123939. /**
  123940. * Disposes the renderer and frees up associated resources.
  123941. */
  123942. dispose(): void;
  123943. protected _createRenderTargets(): void;
  123944. private _copyBonesTransformationMatrices;
  123945. }
  123946. }
  123947. declare module BABYLON {
  123948. interface Scene {
  123949. /** @hidden (Backing field) */
  123950. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123951. /**
  123952. * Gets or Sets the current geometry buffer associated to the scene.
  123953. */
  123954. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123955. /**
  123956. * Enables a GeometryBufferRender and associates it with the scene
  123957. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  123958. * @returns the GeometryBufferRenderer
  123959. */
  123960. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  123961. /**
  123962. * Disables the GeometryBufferRender associated with the scene
  123963. */
  123964. disableGeometryBufferRenderer(): void;
  123965. }
  123966. /**
  123967. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123968. * in several rendering techniques.
  123969. */
  123970. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  123971. /**
  123972. * The component name helpful to identify the component in the list of scene components.
  123973. */
  123974. readonly name: string;
  123975. /**
  123976. * The scene the component belongs to.
  123977. */
  123978. scene: Scene;
  123979. /**
  123980. * Creates a new instance of the component for the given scene
  123981. * @param scene Defines the scene to register the component in
  123982. */
  123983. constructor(scene: Scene);
  123984. /**
  123985. * Registers the component in a given scene
  123986. */
  123987. register(): void;
  123988. /**
  123989. * Rebuilds the elements related to this component in case of
  123990. * context lost for instance.
  123991. */
  123992. rebuild(): void;
  123993. /**
  123994. * Disposes the component and the associated ressources
  123995. */
  123996. dispose(): void;
  123997. private _gatherRenderTargets;
  123998. }
  123999. }
  124000. declare module BABYLON {
  124001. /** @hidden */
  124002. export var motionBlurPixelShader: {
  124003. name: string;
  124004. shader: string;
  124005. };
  124006. }
  124007. declare module BABYLON {
  124008. /**
  124009. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124010. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124011. * As an example, all you have to do is to create the post-process:
  124012. * var mb = new BABYLON.MotionBlurPostProcess(
  124013. * 'mb', // The name of the effect.
  124014. * scene, // The scene containing the objects to blur according to their velocity.
  124015. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124016. * camera // The camera to apply the render pass to.
  124017. * );
  124018. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124019. */
  124020. export class MotionBlurPostProcess extends PostProcess {
  124021. /**
  124022. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124023. */
  124024. motionStrength: number;
  124025. /**
  124026. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124027. */
  124028. /**
  124029. * Sets the number of iterations to be used for motion blur quality
  124030. */
  124031. motionBlurSamples: number;
  124032. private _motionBlurSamples;
  124033. private _geometryBufferRenderer;
  124034. /**
  124035. * Creates a new instance MotionBlurPostProcess
  124036. * @param name The name of the effect.
  124037. * @param scene The scene containing the objects to blur according to their velocity.
  124038. * @param options The required width/height ratio to downsize to before computing the render pass.
  124039. * @param camera The camera to apply the render pass to.
  124040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124041. * @param engine The engine which the post process will be applied. (default: current engine)
  124042. * @param reusable If the post process can be reused on the same frame. (default: false)
  124043. * @param textureType Type of textures used when performing the post process. (default: 0)
  124044. * @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)
  124045. */
  124046. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124047. /**
  124048. * Excludes the given skinned mesh from computing bones velocities.
  124049. * 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.
  124050. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124051. */
  124052. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124053. /**
  124054. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124055. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124056. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124057. */
  124058. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124059. /**
  124060. * Disposes the post process.
  124061. * @param camera The camera to dispose the post process on.
  124062. */
  124063. dispose(camera?: Camera): void;
  124064. }
  124065. }
  124066. declare module BABYLON {
  124067. /** @hidden */
  124068. export var refractionPixelShader: {
  124069. name: string;
  124070. shader: string;
  124071. };
  124072. }
  124073. declare module BABYLON {
  124074. /**
  124075. * Post process which applies a refractin texture
  124076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124077. */
  124078. export class RefractionPostProcess extends PostProcess {
  124079. /** the base color of the refraction (used to taint the rendering) */
  124080. color: Color3;
  124081. /** simulated refraction depth */
  124082. depth: number;
  124083. /** the coefficient of the base color (0 to remove base color tainting) */
  124084. colorLevel: number;
  124085. private _refTexture;
  124086. private _ownRefractionTexture;
  124087. /**
  124088. * Gets or sets the refraction texture
  124089. * Please note that you are responsible for disposing the texture if you set it manually
  124090. */
  124091. refractionTexture: Texture;
  124092. /**
  124093. * Initializes the RefractionPostProcess
  124094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124095. * @param name The name of the effect.
  124096. * @param refractionTextureUrl Url of the refraction texture to use
  124097. * @param color the base color of the refraction (used to taint the rendering)
  124098. * @param depth simulated refraction depth
  124099. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124100. * @param camera The camera to apply the render pass to.
  124101. * @param options The required width/height ratio to downsize to before computing the render pass.
  124102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124103. * @param engine The engine which the post process will be applied. (default: current engine)
  124104. * @param reusable If the post process can be reused on the same frame. (default: false)
  124105. */
  124106. constructor(name: string, refractionTextureUrl: string,
  124107. /** the base color of the refraction (used to taint the rendering) */
  124108. color: Color3,
  124109. /** simulated refraction depth */
  124110. depth: number,
  124111. /** the coefficient of the base color (0 to remove base color tainting) */
  124112. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124113. /**
  124114. * Disposes of the post process
  124115. * @param camera Camera to dispose post process on
  124116. */
  124117. dispose(camera: Camera): void;
  124118. }
  124119. }
  124120. declare module BABYLON {
  124121. /** @hidden */
  124122. export var sharpenPixelShader: {
  124123. name: string;
  124124. shader: string;
  124125. };
  124126. }
  124127. declare module BABYLON {
  124128. /**
  124129. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124130. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124131. */
  124132. export class SharpenPostProcess extends PostProcess {
  124133. /**
  124134. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124135. */
  124136. colorAmount: number;
  124137. /**
  124138. * How much sharpness should be applied (default: 0.3)
  124139. */
  124140. edgeAmount: number;
  124141. /**
  124142. * Creates a new instance ConvolutionPostProcess
  124143. * @param name The name of the effect.
  124144. * @param options The required width/height ratio to downsize to before computing the render pass.
  124145. * @param camera The camera to apply the render pass to.
  124146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124147. * @param engine The engine which the post process will be applied. (default: current engine)
  124148. * @param reusable If the post process can be reused on the same frame. (default: false)
  124149. * @param textureType Type of textures used when performing the post process. (default: 0)
  124150. * @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)
  124151. */
  124152. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124153. }
  124154. }
  124155. declare module BABYLON {
  124156. /**
  124157. * PostProcessRenderPipeline
  124158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124159. */
  124160. export class PostProcessRenderPipeline {
  124161. private engine;
  124162. private _renderEffects;
  124163. private _renderEffectsForIsolatedPass;
  124164. /**
  124165. * List of inspectable custom properties (used by the Inspector)
  124166. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124167. */
  124168. inspectableCustomProperties: IInspectable[];
  124169. /**
  124170. * @hidden
  124171. */
  124172. protected _cameras: Camera[];
  124173. /** @hidden */
  124174. _name: string;
  124175. /**
  124176. * Gets pipeline name
  124177. */
  124178. readonly name: string;
  124179. /**
  124180. * Initializes a PostProcessRenderPipeline
  124181. * @param engine engine to add the pipeline to
  124182. * @param name name of the pipeline
  124183. */
  124184. constructor(engine: Engine, name: string);
  124185. /**
  124186. * Gets the class name
  124187. * @returns "PostProcessRenderPipeline"
  124188. */
  124189. getClassName(): string;
  124190. /**
  124191. * If all the render effects in the pipeline are supported
  124192. */
  124193. readonly isSupported: boolean;
  124194. /**
  124195. * Adds an effect to the pipeline
  124196. * @param renderEffect the effect to add
  124197. */
  124198. addEffect(renderEffect: PostProcessRenderEffect): void;
  124199. /** @hidden */
  124200. _rebuild(): void;
  124201. /** @hidden */
  124202. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124203. /** @hidden */
  124204. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124205. /** @hidden */
  124206. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124207. /** @hidden */
  124208. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124209. /** @hidden */
  124210. _attachCameras(cameras: Camera, unique: boolean): void;
  124211. /** @hidden */
  124212. _attachCameras(cameras: Camera[], unique: boolean): void;
  124213. /** @hidden */
  124214. _detachCameras(cameras: Camera): void;
  124215. /** @hidden */
  124216. _detachCameras(cameras: Nullable<Camera[]>): void;
  124217. /** @hidden */
  124218. _update(): void;
  124219. /** @hidden */
  124220. _reset(): void;
  124221. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124222. /**
  124223. * Disposes of the pipeline
  124224. */
  124225. dispose(): void;
  124226. }
  124227. }
  124228. declare module BABYLON {
  124229. /**
  124230. * PostProcessRenderPipelineManager class
  124231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124232. */
  124233. export class PostProcessRenderPipelineManager {
  124234. private _renderPipelines;
  124235. /**
  124236. * Initializes a PostProcessRenderPipelineManager
  124237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124238. */
  124239. constructor();
  124240. /**
  124241. * Gets the list of supported render pipelines
  124242. */
  124243. readonly supportedPipelines: PostProcessRenderPipeline[];
  124244. /**
  124245. * Adds a pipeline to the manager
  124246. * @param renderPipeline The pipeline to add
  124247. */
  124248. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124249. /**
  124250. * Attaches a camera to the pipeline
  124251. * @param renderPipelineName The name of the pipeline to attach to
  124252. * @param cameras the camera to attach
  124253. * @param unique if the camera can be attached multiple times to the pipeline
  124254. */
  124255. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124256. /**
  124257. * Detaches a camera from the pipeline
  124258. * @param renderPipelineName The name of the pipeline to detach from
  124259. * @param cameras the camera to detach
  124260. */
  124261. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124262. /**
  124263. * Enables an effect by name on a pipeline
  124264. * @param renderPipelineName the name of the pipeline to enable the effect in
  124265. * @param renderEffectName the name of the effect to enable
  124266. * @param cameras the cameras that the effect should be enabled on
  124267. */
  124268. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124269. /**
  124270. * Disables an effect by name on a pipeline
  124271. * @param renderPipelineName the name of the pipeline to disable the effect in
  124272. * @param renderEffectName the name of the effect to disable
  124273. * @param cameras the cameras that the effect should be disabled on
  124274. */
  124275. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124276. /**
  124277. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124278. */
  124279. update(): void;
  124280. /** @hidden */
  124281. _rebuild(): void;
  124282. /**
  124283. * Disposes of the manager and pipelines
  124284. */
  124285. dispose(): void;
  124286. }
  124287. }
  124288. declare module BABYLON {
  124289. interface Scene {
  124290. /** @hidden (Backing field) */
  124291. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124292. /**
  124293. * Gets the postprocess render pipeline manager
  124294. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124295. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124296. */
  124297. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124298. }
  124299. /**
  124300. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124301. */
  124302. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124303. /**
  124304. * The component name helpfull to identify the component in the list of scene components.
  124305. */
  124306. readonly name: string;
  124307. /**
  124308. * The scene the component belongs to.
  124309. */
  124310. scene: Scene;
  124311. /**
  124312. * Creates a new instance of the component for the given scene
  124313. * @param scene Defines the scene to register the component in
  124314. */
  124315. constructor(scene: Scene);
  124316. /**
  124317. * Registers the component in a given scene
  124318. */
  124319. register(): void;
  124320. /**
  124321. * Rebuilds the elements related to this component in case of
  124322. * context lost for instance.
  124323. */
  124324. rebuild(): void;
  124325. /**
  124326. * Disposes the component and the associated ressources
  124327. */
  124328. dispose(): void;
  124329. private _gatherRenderTargets;
  124330. }
  124331. }
  124332. declare module BABYLON {
  124333. /**
  124334. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124335. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124336. */
  124337. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124338. private _scene;
  124339. private _camerasToBeAttached;
  124340. /**
  124341. * ID of the sharpen post process,
  124342. */
  124343. private readonly SharpenPostProcessId;
  124344. /**
  124345. * @ignore
  124346. * ID of the image processing post process;
  124347. */
  124348. readonly ImageProcessingPostProcessId: string;
  124349. /**
  124350. * @ignore
  124351. * ID of the Fast Approximate Anti-Aliasing post process;
  124352. */
  124353. readonly FxaaPostProcessId: string;
  124354. /**
  124355. * ID of the chromatic aberration post process,
  124356. */
  124357. private readonly ChromaticAberrationPostProcessId;
  124358. /**
  124359. * ID of the grain post process
  124360. */
  124361. private readonly GrainPostProcessId;
  124362. /**
  124363. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124364. */
  124365. sharpen: SharpenPostProcess;
  124366. private _sharpenEffect;
  124367. private bloom;
  124368. /**
  124369. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124370. */
  124371. depthOfField: DepthOfFieldEffect;
  124372. /**
  124373. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124374. */
  124375. fxaa: FxaaPostProcess;
  124376. /**
  124377. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124378. */
  124379. imageProcessing: ImageProcessingPostProcess;
  124380. /**
  124381. * Chromatic aberration post process which will shift rgb colors in the image
  124382. */
  124383. chromaticAberration: ChromaticAberrationPostProcess;
  124384. private _chromaticAberrationEffect;
  124385. /**
  124386. * Grain post process which add noise to the image
  124387. */
  124388. grain: GrainPostProcess;
  124389. private _grainEffect;
  124390. /**
  124391. * Glow post process which adds a glow to emissive areas of the image
  124392. */
  124393. private _glowLayer;
  124394. /**
  124395. * Animations which can be used to tweak settings over a period of time
  124396. */
  124397. animations: Animation[];
  124398. private _imageProcessingConfigurationObserver;
  124399. private _sharpenEnabled;
  124400. private _bloomEnabled;
  124401. private _depthOfFieldEnabled;
  124402. private _depthOfFieldBlurLevel;
  124403. private _fxaaEnabled;
  124404. private _imageProcessingEnabled;
  124405. private _defaultPipelineTextureType;
  124406. private _bloomScale;
  124407. private _chromaticAberrationEnabled;
  124408. private _grainEnabled;
  124409. private _buildAllowed;
  124410. /**
  124411. * Gets active scene
  124412. */
  124413. readonly scene: Scene;
  124414. /**
  124415. * Enable or disable the sharpen process from the pipeline
  124416. */
  124417. sharpenEnabled: boolean;
  124418. private _resizeObserver;
  124419. private _hardwareScaleLevel;
  124420. private _bloomKernel;
  124421. /**
  124422. * Specifies the size of the bloom blur kernel, relative to the final output size
  124423. */
  124424. bloomKernel: number;
  124425. /**
  124426. * Specifies the weight of the bloom in the final rendering
  124427. */
  124428. private _bloomWeight;
  124429. /**
  124430. * Specifies the luma threshold for the area that will be blurred by the bloom
  124431. */
  124432. private _bloomThreshold;
  124433. private _hdr;
  124434. /**
  124435. * The strength of the bloom.
  124436. */
  124437. bloomWeight: number;
  124438. /**
  124439. * The strength of the bloom.
  124440. */
  124441. bloomThreshold: number;
  124442. /**
  124443. * The scale of the bloom, lower value will provide better performance.
  124444. */
  124445. bloomScale: number;
  124446. /**
  124447. * Enable or disable the bloom from the pipeline
  124448. */
  124449. bloomEnabled: boolean;
  124450. private _rebuildBloom;
  124451. /**
  124452. * If the depth of field is enabled.
  124453. */
  124454. depthOfFieldEnabled: boolean;
  124455. /**
  124456. * Blur level of the depth of field effect. (Higher blur will effect performance)
  124457. */
  124458. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  124459. /**
  124460. * If the anti aliasing is enabled.
  124461. */
  124462. fxaaEnabled: boolean;
  124463. private _samples;
  124464. /**
  124465. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124466. */
  124467. samples: number;
  124468. /**
  124469. * If image processing is enabled.
  124470. */
  124471. imageProcessingEnabled: boolean;
  124472. /**
  124473. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  124474. */
  124475. glowLayerEnabled: boolean;
  124476. /**
  124477. * Gets the glow layer (or null if not defined)
  124478. */
  124479. readonly glowLayer: Nullable<GlowLayer>;
  124480. /**
  124481. * Enable or disable the chromaticAberration process from the pipeline
  124482. */
  124483. chromaticAberrationEnabled: boolean;
  124484. /**
  124485. * Enable or disable the grain process from the pipeline
  124486. */
  124487. grainEnabled: boolean;
  124488. /**
  124489. * @constructor
  124490. * @param name - The rendering pipeline name (default: "")
  124491. * @param hdr - If high dynamic range textures should be used (default: true)
  124492. * @param scene - The scene linked to this pipeline (default: the last created scene)
  124493. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  124494. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  124495. */
  124496. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  124497. /**
  124498. * Get the class name
  124499. * @returns "DefaultRenderingPipeline"
  124500. */
  124501. getClassName(): string;
  124502. /**
  124503. * Force the compilation of the entire pipeline.
  124504. */
  124505. prepare(): void;
  124506. private _hasCleared;
  124507. private _prevPostProcess;
  124508. private _prevPrevPostProcess;
  124509. private _setAutoClearAndTextureSharing;
  124510. private _depthOfFieldSceneObserver;
  124511. private _buildPipeline;
  124512. private _disposePostProcesses;
  124513. /**
  124514. * Adds a camera to the pipeline
  124515. * @param camera the camera to be added
  124516. */
  124517. addCamera(camera: Camera): void;
  124518. /**
  124519. * Removes a camera from the pipeline
  124520. * @param camera the camera to remove
  124521. */
  124522. removeCamera(camera: Camera): void;
  124523. /**
  124524. * Dispose of the pipeline and stop all post processes
  124525. */
  124526. dispose(): void;
  124527. /**
  124528. * Serialize the rendering pipeline (Used when exporting)
  124529. * @returns the serialized object
  124530. */
  124531. serialize(): any;
  124532. /**
  124533. * Parse the serialized pipeline
  124534. * @param source Source pipeline.
  124535. * @param scene The scene to load the pipeline to.
  124536. * @param rootUrl The URL of the serialized pipeline.
  124537. * @returns An instantiated pipeline from the serialized object.
  124538. */
  124539. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. /** @hidden */
  124544. export var lensHighlightsPixelShader: {
  124545. name: string;
  124546. shader: string;
  124547. };
  124548. }
  124549. declare module BABYLON {
  124550. /** @hidden */
  124551. export var depthOfFieldPixelShader: {
  124552. name: string;
  124553. shader: string;
  124554. };
  124555. }
  124556. declare module BABYLON {
  124557. /**
  124558. * BABYLON.JS Chromatic Aberration GLSL Shader
  124559. * Author: Olivier Guyot
  124560. * Separates very slightly R, G and B colors on the edges of the screen
  124561. * Inspired by Francois Tarlier & Martins Upitis
  124562. */
  124563. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  124564. /**
  124565. * @ignore
  124566. * The chromatic aberration PostProcess id in the pipeline
  124567. */
  124568. LensChromaticAberrationEffect: string;
  124569. /**
  124570. * @ignore
  124571. * The highlights enhancing PostProcess id in the pipeline
  124572. */
  124573. HighlightsEnhancingEffect: string;
  124574. /**
  124575. * @ignore
  124576. * The depth-of-field PostProcess id in the pipeline
  124577. */
  124578. LensDepthOfFieldEffect: string;
  124579. private _scene;
  124580. private _depthTexture;
  124581. private _grainTexture;
  124582. private _chromaticAberrationPostProcess;
  124583. private _highlightsPostProcess;
  124584. private _depthOfFieldPostProcess;
  124585. private _edgeBlur;
  124586. private _grainAmount;
  124587. private _chromaticAberration;
  124588. private _distortion;
  124589. private _highlightsGain;
  124590. private _highlightsThreshold;
  124591. private _dofDistance;
  124592. private _dofAperture;
  124593. private _dofDarken;
  124594. private _dofPentagon;
  124595. private _blurNoise;
  124596. /**
  124597. * @constructor
  124598. *
  124599. * Effect parameters are as follow:
  124600. * {
  124601. * chromatic_aberration: number; // from 0 to x (1 for realism)
  124602. * edge_blur: number; // from 0 to x (1 for realism)
  124603. * distortion: number; // from 0 to x (1 for realism)
  124604. * grain_amount: number; // from 0 to 1
  124605. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  124606. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  124607. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  124608. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  124609. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  124610. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  124611. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  124612. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  124613. * }
  124614. * Note: if an effect parameter is unset, effect is disabled
  124615. *
  124616. * @param name The rendering pipeline name
  124617. * @param parameters - An object containing all parameters (see above)
  124618. * @param scene The scene linked to this pipeline
  124619. * @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)
  124620. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124621. */
  124622. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  124623. /**
  124624. * Get the class name
  124625. * @returns "LensRenderingPipeline"
  124626. */
  124627. getClassName(): string;
  124628. /**
  124629. * Gets associated scene
  124630. */
  124631. readonly scene: Scene;
  124632. /**
  124633. * Gets or sets the edge blur
  124634. */
  124635. edgeBlur: number;
  124636. /**
  124637. * Gets or sets the grain amount
  124638. */
  124639. grainAmount: number;
  124640. /**
  124641. * Gets or sets the chromatic aberration amount
  124642. */
  124643. chromaticAberration: number;
  124644. /**
  124645. * Gets or sets the depth of field aperture
  124646. */
  124647. dofAperture: number;
  124648. /**
  124649. * Gets or sets the edge distortion
  124650. */
  124651. edgeDistortion: number;
  124652. /**
  124653. * Gets or sets the depth of field distortion
  124654. */
  124655. dofDistortion: number;
  124656. /**
  124657. * Gets or sets the darken out of focus amount
  124658. */
  124659. darkenOutOfFocus: number;
  124660. /**
  124661. * Gets or sets a boolean indicating if blur noise is enabled
  124662. */
  124663. blurNoise: boolean;
  124664. /**
  124665. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  124666. */
  124667. pentagonBokeh: boolean;
  124668. /**
  124669. * Gets or sets the highlight grain amount
  124670. */
  124671. highlightsGain: number;
  124672. /**
  124673. * Gets or sets the highlight threshold
  124674. */
  124675. highlightsThreshold: number;
  124676. /**
  124677. * Sets the amount of blur at the edges
  124678. * @param amount blur amount
  124679. */
  124680. setEdgeBlur(amount: number): void;
  124681. /**
  124682. * Sets edge blur to 0
  124683. */
  124684. disableEdgeBlur(): void;
  124685. /**
  124686. * Sets the amout of grain
  124687. * @param amount Amount of grain
  124688. */
  124689. setGrainAmount(amount: number): void;
  124690. /**
  124691. * Set grain amount to 0
  124692. */
  124693. disableGrain(): void;
  124694. /**
  124695. * Sets the chromatic aberration amount
  124696. * @param amount amount of chromatic aberration
  124697. */
  124698. setChromaticAberration(amount: number): void;
  124699. /**
  124700. * Sets chromatic aberration amount to 0
  124701. */
  124702. disableChromaticAberration(): void;
  124703. /**
  124704. * Sets the EdgeDistortion amount
  124705. * @param amount amount of EdgeDistortion
  124706. */
  124707. setEdgeDistortion(amount: number): void;
  124708. /**
  124709. * Sets edge distortion to 0
  124710. */
  124711. disableEdgeDistortion(): void;
  124712. /**
  124713. * Sets the FocusDistance amount
  124714. * @param amount amount of FocusDistance
  124715. */
  124716. setFocusDistance(amount: number): void;
  124717. /**
  124718. * Disables depth of field
  124719. */
  124720. disableDepthOfField(): void;
  124721. /**
  124722. * Sets the Aperture amount
  124723. * @param amount amount of Aperture
  124724. */
  124725. setAperture(amount: number): void;
  124726. /**
  124727. * Sets the DarkenOutOfFocus amount
  124728. * @param amount amount of DarkenOutOfFocus
  124729. */
  124730. setDarkenOutOfFocus(amount: number): void;
  124731. private _pentagonBokehIsEnabled;
  124732. /**
  124733. * Creates a pentagon bokeh effect
  124734. */
  124735. enablePentagonBokeh(): void;
  124736. /**
  124737. * Disables the pentagon bokeh effect
  124738. */
  124739. disablePentagonBokeh(): void;
  124740. /**
  124741. * Enables noise blur
  124742. */
  124743. enableNoiseBlur(): void;
  124744. /**
  124745. * Disables noise blur
  124746. */
  124747. disableNoiseBlur(): void;
  124748. /**
  124749. * Sets the HighlightsGain amount
  124750. * @param amount amount of HighlightsGain
  124751. */
  124752. setHighlightsGain(amount: number): void;
  124753. /**
  124754. * Sets the HighlightsThreshold amount
  124755. * @param amount amount of HighlightsThreshold
  124756. */
  124757. setHighlightsThreshold(amount: number): void;
  124758. /**
  124759. * Disables highlights
  124760. */
  124761. disableHighlights(): void;
  124762. /**
  124763. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  124764. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  124765. */
  124766. dispose(disableDepthRender?: boolean): void;
  124767. private _createChromaticAberrationPostProcess;
  124768. private _createHighlightsPostProcess;
  124769. private _createDepthOfFieldPostProcess;
  124770. private _createGrainTexture;
  124771. }
  124772. }
  124773. declare module BABYLON {
  124774. /** @hidden */
  124775. export var ssao2PixelShader: {
  124776. name: string;
  124777. shader: string;
  124778. };
  124779. }
  124780. declare module BABYLON {
  124781. /** @hidden */
  124782. export var ssaoCombinePixelShader: {
  124783. name: string;
  124784. shader: string;
  124785. };
  124786. }
  124787. declare module BABYLON {
  124788. /**
  124789. * Render pipeline to produce ssao effect
  124790. */
  124791. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  124792. /**
  124793. * @ignore
  124794. * The PassPostProcess id in the pipeline that contains the original scene color
  124795. */
  124796. SSAOOriginalSceneColorEffect: string;
  124797. /**
  124798. * @ignore
  124799. * The SSAO PostProcess id in the pipeline
  124800. */
  124801. SSAORenderEffect: string;
  124802. /**
  124803. * @ignore
  124804. * The horizontal blur PostProcess id in the pipeline
  124805. */
  124806. SSAOBlurHRenderEffect: string;
  124807. /**
  124808. * @ignore
  124809. * The vertical blur PostProcess id in the pipeline
  124810. */
  124811. SSAOBlurVRenderEffect: string;
  124812. /**
  124813. * @ignore
  124814. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124815. */
  124816. SSAOCombineRenderEffect: string;
  124817. /**
  124818. * The output strength of the SSAO post-process. Default value is 1.0.
  124819. */
  124820. totalStrength: number;
  124821. /**
  124822. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  124823. */
  124824. maxZ: number;
  124825. /**
  124826. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  124827. */
  124828. minZAspect: number;
  124829. private _samples;
  124830. /**
  124831. * Number of samples used for the SSAO calculations. Default value is 8
  124832. */
  124833. samples: number;
  124834. private _textureSamples;
  124835. /**
  124836. * Number of samples to use for antialiasing
  124837. */
  124838. textureSamples: number;
  124839. /**
  124840. * Ratio object used for SSAO ratio and blur ratio
  124841. */
  124842. private _ratio;
  124843. /**
  124844. * Dynamically generated sphere sampler.
  124845. */
  124846. private _sampleSphere;
  124847. /**
  124848. * Blur filter offsets
  124849. */
  124850. private _samplerOffsets;
  124851. private _expensiveBlur;
  124852. /**
  124853. * If bilateral blur should be used
  124854. */
  124855. expensiveBlur: boolean;
  124856. /**
  124857. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  124858. */
  124859. radius: number;
  124860. /**
  124861. * The base color of the SSAO post-process
  124862. * The final result is "base + ssao" between [0, 1]
  124863. */
  124864. base: number;
  124865. /**
  124866. * Support test.
  124867. */
  124868. static readonly IsSupported: boolean;
  124869. private _scene;
  124870. private _depthTexture;
  124871. private _normalTexture;
  124872. private _randomTexture;
  124873. private _originalColorPostProcess;
  124874. private _ssaoPostProcess;
  124875. private _blurHPostProcess;
  124876. private _blurVPostProcess;
  124877. private _ssaoCombinePostProcess;
  124878. private _firstUpdate;
  124879. /**
  124880. * Gets active scene
  124881. */
  124882. readonly scene: Scene;
  124883. /**
  124884. * @constructor
  124885. * @param name The rendering pipeline name
  124886. * @param scene The scene linked to this pipeline
  124887. * @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 }
  124888. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124889. */
  124890. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  124891. /**
  124892. * Get the class name
  124893. * @returns "SSAO2RenderingPipeline"
  124894. */
  124895. getClassName(): string;
  124896. /**
  124897. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  124898. */
  124899. dispose(disableGeometryBufferRenderer?: boolean): void;
  124900. private _createBlurPostProcess;
  124901. /** @hidden */
  124902. _rebuild(): void;
  124903. private _bits;
  124904. private _radicalInverse_VdC;
  124905. private _hammersley;
  124906. private _hemisphereSample_uniform;
  124907. private _generateHemisphere;
  124908. private _createSSAOPostProcess;
  124909. private _createSSAOCombinePostProcess;
  124910. private _createRandomTexture;
  124911. /**
  124912. * Serialize the rendering pipeline (Used when exporting)
  124913. * @returns the serialized object
  124914. */
  124915. serialize(): any;
  124916. /**
  124917. * Parse the serialized pipeline
  124918. * @param source Source pipeline.
  124919. * @param scene The scene to load the pipeline to.
  124920. * @param rootUrl The URL of the serialized pipeline.
  124921. * @returns An instantiated pipeline from the serialized object.
  124922. */
  124923. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  124924. }
  124925. }
  124926. declare module BABYLON {
  124927. /** @hidden */
  124928. export var ssaoPixelShader: {
  124929. name: string;
  124930. shader: string;
  124931. };
  124932. }
  124933. declare module BABYLON {
  124934. /**
  124935. * Render pipeline to produce ssao effect
  124936. */
  124937. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  124938. /**
  124939. * @ignore
  124940. * The PassPostProcess id in the pipeline that contains the original scene color
  124941. */
  124942. SSAOOriginalSceneColorEffect: string;
  124943. /**
  124944. * @ignore
  124945. * The SSAO PostProcess id in the pipeline
  124946. */
  124947. SSAORenderEffect: string;
  124948. /**
  124949. * @ignore
  124950. * The horizontal blur PostProcess id in the pipeline
  124951. */
  124952. SSAOBlurHRenderEffect: string;
  124953. /**
  124954. * @ignore
  124955. * The vertical blur PostProcess id in the pipeline
  124956. */
  124957. SSAOBlurVRenderEffect: string;
  124958. /**
  124959. * @ignore
  124960. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124961. */
  124962. SSAOCombineRenderEffect: string;
  124963. /**
  124964. * The output strength of the SSAO post-process. Default value is 1.0.
  124965. */
  124966. totalStrength: number;
  124967. /**
  124968. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  124969. */
  124970. radius: number;
  124971. /**
  124972. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  124973. * Must not be equal to fallOff and superior to fallOff.
  124974. * Default value is 0.0075
  124975. */
  124976. area: number;
  124977. /**
  124978. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  124979. * Must not be equal to area and inferior to area.
  124980. * Default value is 0.000001
  124981. */
  124982. fallOff: number;
  124983. /**
  124984. * The base color of the SSAO post-process
  124985. * The final result is "base + ssao" between [0, 1]
  124986. */
  124987. base: number;
  124988. private _scene;
  124989. private _depthTexture;
  124990. private _randomTexture;
  124991. private _originalColorPostProcess;
  124992. private _ssaoPostProcess;
  124993. private _blurHPostProcess;
  124994. private _blurVPostProcess;
  124995. private _ssaoCombinePostProcess;
  124996. private _firstUpdate;
  124997. /**
  124998. * Gets active scene
  124999. */
  125000. readonly scene: Scene;
  125001. /**
  125002. * @constructor
  125003. * @param name - The rendering pipeline name
  125004. * @param scene - The scene linked to this pipeline
  125005. * @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 }
  125006. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125007. */
  125008. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125009. /**
  125010. * Get the class name
  125011. * @returns "SSAORenderingPipeline"
  125012. */
  125013. getClassName(): string;
  125014. /**
  125015. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125016. */
  125017. dispose(disableDepthRender?: boolean): void;
  125018. private _createBlurPostProcess;
  125019. /** @hidden */
  125020. _rebuild(): void;
  125021. private _createSSAOPostProcess;
  125022. private _createSSAOCombinePostProcess;
  125023. private _createRandomTexture;
  125024. }
  125025. }
  125026. declare module BABYLON {
  125027. /** @hidden */
  125028. export var standardPixelShader: {
  125029. name: string;
  125030. shader: string;
  125031. };
  125032. }
  125033. declare module BABYLON {
  125034. /**
  125035. * Standard rendering pipeline
  125036. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125037. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125038. */
  125039. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125040. /**
  125041. * Public members
  125042. */
  125043. /**
  125044. * Post-process which contains the original scene color before the pipeline applies all the effects
  125045. */
  125046. originalPostProcess: Nullable<PostProcess>;
  125047. /**
  125048. * Post-process used to down scale an image x4
  125049. */
  125050. downSampleX4PostProcess: Nullable<PostProcess>;
  125051. /**
  125052. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125053. */
  125054. brightPassPostProcess: Nullable<PostProcess>;
  125055. /**
  125056. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125057. */
  125058. blurHPostProcesses: PostProcess[];
  125059. /**
  125060. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125061. */
  125062. blurVPostProcesses: PostProcess[];
  125063. /**
  125064. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125065. */
  125066. textureAdderPostProcess: Nullable<PostProcess>;
  125067. /**
  125068. * Post-process used to create volumetric lighting effect
  125069. */
  125070. volumetricLightPostProcess: Nullable<PostProcess>;
  125071. /**
  125072. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125073. */
  125074. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125075. /**
  125076. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125077. */
  125078. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125079. /**
  125080. * Post-process used to merge the volumetric light effect and the real scene color
  125081. */
  125082. volumetricLightMergePostProces: Nullable<PostProcess>;
  125083. /**
  125084. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125085. */
  125086. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125087. /**
  125088. * Base post-process used to calculate the average luminance of the final image for HDR
  125089. */
  125090. luminancePostProcess: Nullable<PostProcess>;
  125091. /**
  125092. * Post-processes used to create down sample post-processes in order to get
  125093. * the average luminance of the final image for HDR
  125094. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125095. */
  125096. luminanceDownSamplePostProcesses: PostProcess[];
  125097. /**
  125098. * Post-process used to create a HDR effect (light adaptation)
  125099. */
  125100. hdrPostProcess: Nullable<PostProcess>;
  125101. /**
  125102. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125103. */
  125104. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125105. /**
  125106. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125107. */
  125108. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125109. /**
  125110. * Post-process used to merge the final HDR post-process and the real scene color
  125111. */
  125112. hdrFinalPostProcess: Nullable<PostProcess>;
  125113. /**
  125114. * Post-process used to create a lens flare effect
  125115. */
  125116. lensFlarePostProcess: Nullable<PostProcess>;
  125117. /**
  125118. * Post-process that merges the result of the lens flare post-process and the real scene color
  125119. */
  125120. lensFlareComposePostProcess: Nullable<PostProcess>;
  125121. /**
  125122. * Post-process used to create a motion blur effect
  125123. */
  125124. motionBlurPostProcess: Nullable<PostProcess>;
  125125. /**
  125126. * Post-process used to create a depth of field effect
  125127. */
  125128. depthOfFieldPostProcess: Nullable<PostProcess>;
  125129. /**
  125130. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125131. */
  125132. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125133. /**
  125134. * Represents the brightness threshold in order to configure the illuminated surfaces
  125135. */
  125136. brightThreshold: number;
  125137. /**
  125138. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125139. */
  125140. blurWidth: number;
  125141. /**
  125142. * Sets if the blur for highlighted surfaces must be only horizontal
  125143. */
  125144. horizontalBlur: boolean;
  125145. /**
  125146. * Gets the overall exposure used by the pipeline
  125147. */
  125148. /**
  125149. * Sets the overall exposure used by the pipeline
  125150. */
  125151. exposure: number;
  125152. /**
  125153. * Texture used typically to simulate "dirty" on camera lens
  125154. */
  125155. lensTexture: Nullable<Texture>;
  125156. /**
  125157. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125158. */
  125159. volumetricLightCoefficient: number;
  125160. /**
  125161. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125162. */
  125163. volumetricLightPower: number;
  125164. /**
  125165. * Used the set the blur intensity to smooth the volumetric lights
  125166. */
  125167. volumetricLightBlurScale: number;
  125168. /**
  125169. * Light (spot or directional) used to generate the volumetric lights rays
  125170. * The source light must have a shadow generate so the pipeline can get its
  125171. * depth map
  125172. */
  125173. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125174. /**
  125175. * For eye adaptation, represents the minimum luminance the eye can see
  125176. */
  125177. hdrMinimumLuminance: number;
  125178. /**
  125179. * For eye adaptation, represents the decrease luminance speed
  125180. */
  125181. hdrDecreaseRate: number;
  125182. /**
  125183. * For eye adaptation, represents the increase luminance speed
  125184. */
  125185. hdrIncreaseRate: number;
  125186. /**
  125187. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125188. */
  125189. /**
  125190. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125191. */
  125192. hdrAutoExposure: boolean;
  125193. /**
  125194. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125195. */
  125196. lensColorTexture: Nullable<Texture>;
  125197. /**
  125198. * The overall strengh for the lens flare effect
  125199. */
  125200. lensFlareStrength: number;
  125201. /**
  125202. * Dispersion coefficient for lens flare ghosts
  125203. */
  125204. lensFlareGhostDispersal: number;
  125205. /**
  125206. * Main lens flare halo width
  125207. */
  125208. lensFlareHaloWidth: number;
  125209. /**
  125210. * Based on the lens distortion effect, defines how much the lens flare result
  125211. * is distorted
  125212. */
  125213. lensFlareDistortionStrength: number;
  125214. /**
  125215. * Configures the blur intensity used for for lens flare (halo)
  125216. */
  125217. lensFlareBlurWidth: number;
  125218. /**
  125219. * Lens star texture must be used to simulate rays on the flares and is available
  125220. * in the documentation
  125221. */
  125222. lensStarTexture: Nullable<Texture>;
  125223. /**
  125224. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125225. * flare effect by taking account of the dirt texture
  125226. */
  125227. lensFlareDirtTexture: Nullable<Texture>;
  125228. /**
  125229. * Represents the focal length for the depth of field effect
  125230. */
  125231. depthOfFieldDistance: number;
  125232. /**
  125233. * Represents the blur intensity for the blurred part of the depth of field effect
  125234. */
  125235. depthOfFieldBlurWidth: number;
  125236. /**
  125237. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125238. */
  125239. /**
  125240. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125241. */
  125242. motionStrength: number;
  125243. /**
  125244. * Gets wether or not the motion blur post-process is object based or screen based.
  125245. */
  125246. /**
  125247. * Sets wether or not the motion blur post-process should be object based or screen based
  125248. */
  125249. objectBasedMotionBlur: boolean;
  125250. /**
  125251. * List of animations for the pipeline (IAnimatable implementation)
  125252. */
  125253. animations: Animation[];
  125254. /**
  125255. * Private members
  125256. */
  125257. private _scene;
  125258. private _currentDepthOfFieldSource;
  125259. private _basePostProcess;
  125260. private _fixedExposure;
  125261. private _currentExposure;
  125262. private _hdrAutoExposure;
  125263. private _hdrCurrentLuminance;
  125264. private _motionStrength;
  125265. private _isObjectBasedMotionBlur;
  125266. private _floatTextureType;
  125267. private _camerasToBeAttached;
  125268. private _ratio;
  125269. private _bloomEnabled;
  125270. private _depthOfFieldEnabled;
  125271. private _vlsEnabled;
  125272. private _lensFlareEnabled;
  125273. private _hdrEnabled;
  125274. private _motionBlurEnabled;
  125275. private _fxaaEnabled;
  125276. private _motionBlurSamples;
  125277. private _volumetricLightStepsCount;
  125278. private _samples;
  125279. /**
  125280. * @ignore
  125281. * Specifies if the bloom pipeline is enabled
  125282. */
  125283. BloomEnabled: boolean;
  125284. /**
  125285. * @ignore
  125286. * Specifies if the depth of field pipeline is enabed
  125287. */
  125288. DepthOfFieldEnabled: boolean;
  125289. /**
  125290. * @ignore
  125291. * Specifies if the lens flare pipeline is enabed
  125292. */
  125293. LensFlareEnabled: boolean;
  125294. /**
  125295. * @ignore
  125296. * Specifies if the HDR pipeline is enabled
  125297. */
  125298. HDREnabled: boolean;
  125299. /**
  125300. * @ignore
  125301. * Specifies if the volumetric lights scattering effect is enabled
  125302. */
  125303. VLSEnabled: boolean;
  125304. /**
  125305. * @ignore
  125306. * Specifies if the motion blur effect is enabled
  125307. */
  125308. MotionBlurEnabled: boolean;
  125309. /**
  125310. * Specifies if anti-aliasing is enabled
  125311. */
  125312. fxaaEnabled: boolean;
  125313. /**
  125314. * Specifies the number of steps used to calculate the volumetric lights
  125315. * Typically in interval [50, 200]
  125316. */
  125317. volumetricLightStepsCount: number;
  125318. /**
  125319. * Specifies the number of samples used for the motion blur effect
  125320. * Typically in interval [16, 64]
  125321. */
  125322. motionBlurSamples: number;
  125323. /**
  125324. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125325. */
  125326. samples: number;
  125327. /**
  125328. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125329. * @constructor
  125330. * @param name The rendering pipeline name
  125331. * @param scene The scene linked to this pipeline
  125332. * @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)
  125333. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125334. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125335. */
  125336. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125337. private _buildPipeline;
  125338. private _createDownSampleX4PostProcess;
  125339. private _createBrightPassPostProcess;
  125340. private _createBlurPostProcesses;
  125341. private _createTextureAdderPostProcess;
  125342. private _createVolumetricLightPostProcess;
  125343. private _createLuminancePostProcesses;
  125344. private _createHdrPostProcess;
  125345. private _createLensFlarePostProcess;
  125346. private _createDepthOfFieldPostProcess;
  125347. private _createMotionBlurPostProcess;
  125348. private _getDepthTexture;
  125349. private _disposePostProcesses;
  125350. /**
  125351. * Dispose of the pipeline and stop all post processes
  125352. */
  125353. dispose(): void;
  125354. /**
  125355. * Serialize the rendering pipeline (Used when exporting)
  125356. * @returns the serialized object
  125357. */
  125358. serialize(): any;
  125359. /**
  125360. * Parse the serialized pipeline
  125361. * @param source Source pipeline.
  125362. * @param scene The scene to load the pipeline to.
  125363. * @param rootUrl The URL of the serialized pipeline.
  125364. * @returns An instantiated pipeline from the serialized object.
  125365. */
  125366. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125367. /**
  125368. * Luminance steps
  125369. */
  125370. static LuminanceSteps: number;
  125371. }
  125372. }
  125373. declare module BABYLON {
  125374. /** @hidden */
  125375. export var tonemapPixelShader: {
  125376. name: string;
  125377. shader: string;
  125378. };
  125379. }
  125380. declare module BABYLON {
  125381. /** Defines operator used for tonemapping */
  125382. export enum TonemappingOperator {
  125383. /** Hable */
  125384. Hable = 0,
  125385. /** Reinhard */
  125386. Reinhard = 1,
  125387. /** HejiDawson */
  125388. HejiDawson = 2,
  125389. /** Photographic */
  125390. Photographic = 3
  125391. }
  125392. /**
  125393. * Defines a post process to apply tone mapping
  125394. */
  125395. export class TonemapPostProcess extends PostProcess {
  125396. private _operator;
  125397. /** Defines the required exposure adjustement */
  125398. exposureAdjustment: number;
  125399. /**
  125400. * Creates a new TonemapPostProcess
  125401. * @param name defines the name of the postprocess
  125402. * @param _operator defines the operator to use
  125403. * @param exposureAdjustment defines the required exposure adjustement
  125404. * @param camera defines the camera to use (can be null)
  125405. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125406. * @param engine defines the hosting engine (can be ignore if camera is set)
  125407. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125408. */
  125409. constructor(name: string, _operator: TonemappingOperator,
  125410. /** Defines the required exposure adjustement */
  125411. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /** @hidden */
  125416. export var depthVertexShader: {
  125417. name: string;
  125418. shader: string;
  125419. };
  125420. }
  125421. declare module BABYLON {
  125422. /** @hidden */
  125423. export var volumetricLightScatteringPixelShader: {
  125424. name: string;
  125425. shader: string;
  125426. };
  125427. }
  125428. declare module BABYLON {
  125429. /** @hidden */
  125430. export var volumetricLightScatteringPassVertexShader: {
  125431. name: string;
  125432. shader: string;
  125433. };
  125434. }
  125435. declare module BABYLON {
  125436. /** @hidden */
  125437. export var volumetricLightScatteringPassPixelShader: {
  125438. name: string;
  125439. shader: string;
  125440. };
  125441. }
  125442. declare module BABYLON {
  125443. /**
  125444. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125445. */
  125446. export class VolumetricLightScatteringPostProcess extends PostProcess {
  125447. private _volumetricLightScatteringPass;
  125448. private _volumetricLightScatteringRTT;
  125449. private _viewPort;
  125450. private _screenCoordinates;
  125451. private _cachedDefines;
  125452. /**
  125453. * If not undefined, the mesh position is computed from the attached node position
  125454. */
  125455. attachedNode: {
  125456. position: Vector3;
  125457. };
  125458. /**
  125459. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125460. */
  125461. customMeshPosition: Vector3;
  125462. /**
  125463. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125464. */
  125465. useCustomMeshPosition: boolean;
  125466. /**
  125467. * If the post-process should inverse the light scattering direction
  125468. */
  125469. invert: boolean;
  125470. /**
  125471. * The internal mesh used by the post-process
  125472. */
  125473. mesh: Mesh;
  125474. /**
  125475. * @hidden
  125476. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125477. */
  125478. useDiffuseColor: boolean;
  125479. /**
  125480. * Array containing the excluded meshes not rendered in the internal pass
  125481. */
  125482. excludedMeshes: AbstractMesh[];
  125483. /**
  125484. * Controls the overall intensity of the post-process
  125485. */
  125486. exposure: number;
  125487. /**
  125488. * Dissipates each sample's contribution in range [0, 1]
  125489. */
  125490. decay: number;
  125491. /**
  125492. * Controls the overall intensity of each sample
  125493. */
  125494. weight: number;
  125495. /**
  125496. * Controls the density of each sample
  125497. */
  125498. density: number;
  125499. /**
  125500. * @constructor
  125501. * @param name The post-process name
  125502. * @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)
  125503. * @param camera The camera that the post-process will be attached to
  125504. * @param mesh The mesh used to create the light scattering
  125505. * @param samples The post-process quality, default 100
  125506. * @param samplingModeThe post-process filtering mode
  125507. * @param engine The babylon engine
  125508. * @param reusable If the post-process is reusable
  125509. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125510. */
  125511. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  125512. /**
  125513. * Returns the string "VolumetricLightScatteringPostProcess"
  125514. * @returns "VolumetricLightScatteringPostProcess"
  125515. */
  125516. getClassName(): string;
  125517. private _isReady;
  125518. /**
  125519. * Sets the new light position for light scattering effect
  125520. * @param position The new custom light position
  125521. */
  125522. setCustomMeshPosition(position: Vector3): void;
  125523. /**
  125524. * Returns the light position for light scattering effect
  125525. * @return Vector3 The custom light position
  125526. */
  125527. getCustomMeshPosition(): Vector3;
  125528. /**
  125529. * Disposes the internal assets and detaches the post-process from the camera
  125530. */
  125531. dispose(camera: Camera): void;
  125532. /**
  125533. * Returns the render target texture used by the post-process
  125534. * @return the render target texture used by the post-process
  125535. */
  125536. getPass(): RenderTargetTexture;
  125537. private _meshExcluded;
  125538. private _createPass;
  125539. private _updateMeshScreenCoordinates;
  125540. /**
  125541. * Creates a default mesh for the Volumeric Light Scattering post-process
  125542. * @param name The mesh name
  125543. * @param scene The scene where to create the mesh
  125544. * @return the default mesh
  125545. */
  125546. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  125547. }
  125548. }
  125549. declare module BABYLON {
  125550. interface Scene {
  125551. /** @hidden (Backing field) */
  125552. _boundingBoxRenderer: BoundingBoxRenderer;
  125553. /** @hidden (Backing field) */
  125554. _forceShowBoundingBoxes: boolean;
  125555. /**
  125556. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  125557. */
  125558. forceShowBoundingBoxes: boolean;
  125559. /**
  125560. * Gets the bounding box renderer associated with the scene
  125561. * @returns a BoundingBoxRenderer
  125562. */
  125563. getBoundingBoxRenderer(): BoundingBoxRenderer;
  125564. }
  125565. interface AbstractMesh {
  125566. /** @hidden (Backing field) */
  125567. _showBoundingBox: boolean;
  125568. /**
  125569. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  125570. */
  125571. showBoundingBox: boolean;
  125572. }
  125573. /**
  125574. * Component responsible of rendering the bounding box of the meshes in a scene.
  125575. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  125576. */
  125577. export class BoundingBoxRenderer implements ISceneComponent {
  125578. /**
  125579. * The component name helpfull to identify the component in the list of scene components.
  125580. */
  125581. readonly name: string;
  125582. /**
  125583. * The scene the component belongs to.
  125584. */
  125585. scene: Scene;
  125586. /**
  125587. * Color of the bounding box lines placed in front of an object
  125588. */
  125589. frontColor: Color3;
  125590. /**
  125591. * Color of the bounding box lines placed behind an object
  125592. */
  125593. backColor: Color3;
  125594. /**
  125595. * Defines if the renderer should show the back lines or not
  125596. */
  125597. showBackLines: boolean;
  125598. /**
  125599. * @hidden
  125600. */
  125601. renderList: SmartArray<BoundingBox>;
  125602. private _colorShader;
  125603. private _vertexBuffers;
  125604. private _indexBuffer;
  125605. private _fillIndexBuffer;
  125606. private _fillIndexData;
  125607. /**
  125608. * Instantiates a new bounding box renderer in a scene.
  125609. * @param scene the scene the renderer renders in
  125610. */
  125611. constructor(scene: Scene);
  125612. /**
  125613. * Registers the component in a given scene
  125614. */
  125615. register(): void;
  125616. private _evaluateSubMesh;
  125617. private _activeMesh;
  125618. private _prepareRessources;
  125619. private _createIndexBuffer;
  125620. /**
  125621. * Rebuilds the elements related to this component in case of
  125622. * context lost for instance.
  125623. */
  125624. rebuild(): void;
  125625. /**
  125626. * @hidden
  125627. */
  125628. reset(): void;
  125629. /**
  125630. * Render the bounding boxes of a specific rendering group
  125631. * @param renderingGroupId defines the rendering group to render
  125632. */
  125633. render(renderingGroupId: number): void;
  125634. /**
  125635. * In case of occlusion queries, we can render the occlusion bounding box through this method
  125636. * @param mesh Define the mesh to render the occlusion bounding box for
  125637. */
  125638. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  125639. /**
  125640. * Dispose and release the resources attached to this renderer.
  125641. */
  125642. dispose(): void;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /** @hidden */
  125647. export var depthPixelShader: {
  125648. name: string;
  125649. shader: string;
  125650. };
  125651. }
  125652. declare module BABYLON {
  125653. /**
  125654. * This represents a depth renderer in Babylon.
  125655. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  125656. */
  125657. export class DepthRenderer {
  125658. private _scene;
  125659. private _depthMap;
  125660. private _effect;
  125661. private readonly _storeNonLinearDepth;
  125662. private readonly _clearColor;
  125663. /** Get if the depth renderer is using packed depth or not */
  125664. readonly isPacked: boolean;
  125665. private _cachedDefines;
  125666. private _camera;
  125667. /**
  125668. * Specifiess that the depth renderer will only be used within
  125669. * the camera it is created for.
  125670. * This can help forcing its rendering during the camera processing.
  125671. */
  125672. useOnlyInActiveCamera: boolean;
  125673. /** @hidden */
  125674. static _SceneComponentInitialization: (scene: Scene) => void;
  125675. /**
  125676. * Instantiates a depth renderer
  125677. * @param scene The scene the renderer belongs to
  125678. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  125679. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  125680. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125681. */
  125682. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  125683. /**
  125684. * Creates the depth rendering effect and checks if the effect is ready.
  125685. * @param subMesh The submesh to be used to render the depth map of
  125686. * @param useInstances If multiple world instances should be used
  125687. * @returns if the depth renderer is ready to render the depth map
  125688. */
  125689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125690. /**
  125691. * Gets the texture which the depth map will be written to.
  125692. * @returns The depth map texture
  125693. */
  125694. getDepthMap(): RenderTargetTexture;
  125695. /**
  125696. * Disposes of the depth renderer.
  125697. */
  125698. dispose(): void;
  125699. }
  125700. }
  125701. declare module BABYLON {
  125702. interface Scene {
  125703. /** @hidden (Backing field) */
  125704. _depthRenderer: {
  125705. [id: string]: DepthRenderer;
  125706. };
  125707. /**
  125708. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  125709. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  125710. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125711. * @returns the created depth renderer
  125712. */
  125713. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  125714. /**
  125715. * Disables a depth renderer for a given camera
  125716. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  125717. */
  125718. disableDepthRenderer(camera?: Nullable<Camera>): void;
  125719. }
  125720. /**
  125721. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  125722. * in several rendering techniques.
  125723. */
  125724. export class DepthRendererSceneComponent implements ISceneComponent {
  125725. /**
  125726. * The component name helpfull to identify the component in the list of scene components.
  125727. */
  125728. readonly name: string;
  125729. /**
  125730. * The scene the component belongs to.
  125731. */
  125732. scene: Scene;
  125733. /**
  125734. * Creates a new instance of the component for the given scene
  125735. * @param scene Defines the scene to register the component in
  125736. */
  125737. constructor(scene: Scene);
  125738. /**
  125739. * Registers the component in a given scene
  125740. */
  125741. register(): void;
  125742. /**
  125743. * Rebuilds the elements related to this component in case of
  125744. * context lost for instance.
  125745. */
  125746. rebuild(): void;
  125747. /**
  125748. * Disposes the component and the associated ressources
  125749. */
  125750. dispose(): void;
  125751. private _gatherRenderTargets;
  125752. private _gatherActiveCameraRenderTargets;
  125753. }
  125754. }
  125755. declare module BABYLON {
  125756. /** @hidden */
  125757. export var outlinePixelShader: {
  125758. name: string;
  125759. shader: string;
  125760. };
  125761. }
  125762. declare module BABYLON {
  125763. /** @hidden */
  125764. export var outlineVertexShader: {
  125765. name: string;
  125766. shader: string;
  125767. };
  125768. }
  125769. declare module BABYLON {
  125770. interface Scene {
  125771. /** @hidden */
  125772. _outlineRenderer: OutlineRenderer;
  125773. /**
  125774. * Gets the outline renderer associated with the scene
  125775. * @returns a OutlineRenderer
  125776. */
  125777. getOutlineRenderer(): OutlineRenderer;
  125778. }
  125779. interface AbstractMesh {
  125780. /** @hidden (Backing field) */
  125781. _renderOutline: boolean;
  125782. /**
  125783. * Gets or sets a boolean indicating if the outline must be rendered as well
  125784. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  125785. */
  125786. renderOutline: boolean;
  125787. /** @hidden (Backing field) */
  125788. _renderOverlay: boolean;
  125789. /**
  125790. * Gets or sets a boolean indicating if the overlay must be rendered as well
  125791. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  125792. */
  125793. renderOverlay: boolean;
  125794. }
  125795. /**
  125796. * This class is responsible to draw bothe outline/overlay of meshes.
  125797. * It should not be used directly but through the available method on mesh.
  125798. */
  125799. export class OutlineRenderer implements ISceneComponent {
  125800. /**
  125801. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  125802. */
  125803. private static _StencilReference;
  125804. /**
  125805. * The name of the component. Each component must have a unique name.
  125806. */
  125807. name: string;
  125808. /**
  125809. * The scene the component belongs to.
  125810. */
  125811. scene: Scene;
  125812. /**
  125813. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  125814. */
  125815. zOffset: number;
  125816. private _engine;
  125817. private _effect;
  125818. private _cachedDefines;
  125819. private _savedDepthWrite;
  125820. /**
  125821. * Instantiates a new outline renderer. (There could be only one per scene).
  125822. * @param scene Defines the scene it belongs to
  125823. */
  125824. constructor(scene: Scene);
  125825. /**
  125826. * Register the component to one instance of a scene.
  125827. */
  125828. register(): void;
  125829. /**
  125830. * Rebuilds the elements related to this component in case of
  125831. * context lost for instance.
  125832. */
  125833. rebuild(): void;
  125834. /**
  125835. * Disposes the component and the associated ressources.
  125836. */
  125837. dispose(): void;
  125838. /**
  125839. * Renders the outline in the canvas.
  125840. * @param subMesh Defines the sumesh to render
  125841. * @param batch Defines the batch of meshes in case of instances
  125842. * @param useOverlay Defines if the rendering is for the overlay or the outline
  125843. */
  125844. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  125845. /**
  125846. * Returns whether or not the outline renderer is ready for a given submesh.
  125847. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  125848. * @param subMesh Defines the submesh to check readyness for
  125849. * @param useInstances Defines wheter wee are trying to render instances or not
  125850. * @returns true if ready otherwise false
  125851. */
  125852. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125853. private _beforeRenderingMesh;
  125854. private _afterRenderingMesh;
  125855. }
  125856. }
  125857. declare module BABYLON {
  125858. /**
  125859. * Class used to manage multiple sprites of different sizes on the same spritesheet
  125860. * @see http://doc.babylonjs.com/babylon101/sprites
  125861. */
  125862. export class SpritePackedManager extends SpriteManager {
  125863. /** defines the packed manager's name */
  125864. name: string;
  125865. /**
  125866. * Creates a new sprite manager from a packed sprite sheet
  125867. * @param name defines the manager's name
  125868. * @param imgUrl defines the sprite sheet url
  125869. * @param capacity defines the maximum allowed number of sprites
  125870. * @param scene defines the hosting scene
  125871. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  125872. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125873. * @param samplingMode defines the smapling mode to use with spritesheet
  125874. * @param fromPacked set to true; do not alter
  125875. */
  125876. constructor(
  125877. /** defines the packed manager's name */
  125878. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  125879. }
  125880. }
  125881. declare module BABYLON {
  125882. /**
  125883. * Defines the list of states available for a task inside a AssetsManager
  125884. */
  125885. export enum AssetTaskState {
  125886. /**
  125887. * Initialization
  125888. */
  125889. INIT = 0,
  125890. /**
  125891. * Running
  125892. */
  125893. RUNNING = 1,
  125894. /**
  125895. * Done
  125896. */
  125897. DONE = 2,
  125898. /**
  125899. * Error
  125900. */
  125901. ERROR = 3
  125902. }
  125903. /**
  125904. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  125905. */
  125906. export abstract class AbstractAssetTask {
  125907. /**
  125908. * Task name
  125909. */ name: string;
  125910. /**
  125911. * Callback called when the task is successful
  125912. */
  125913. onSuccess: (task: any) => void;
  125914. /**
  125915. * Callback called when the task is not successful
  125916. */
  125917. onError: (task: any, message?: string, exception?: any) => void;
  125918. /**
  125919. * Creates a new AssetsManager
  125920. * @param name defines the name of the task
  125921. */
  125922. constructor(
  125923. /**
  125924. * Task name
  125925. */ name: string);
  125926. private _isCompleted;
  125927. private _taskState;
  125928. private _errorObject;
  125929. /**
  125930. * Get if the task is completed
  125931. */
  125932. readonly isCompleted: boolean;
  125933. /**
  125934. * Gets the current state of the task
  125935. */
  125936. readonly taskState: AssetTaskState;
  125937. /**
  125938. * Gets the current error object (if task is in error)
  125939. */
  125940. readonly errorObject: {
  125941. message?: string;
  125942. exception?: any;
  125943. };
  125944. /**
  125945. * Internal only
  125946. * @hidden
  125947. */
  125948. _setErrorObject(message?: string, exception?: any): void;
  125949. /**
  125950. * Execute the current task
  125951. * @param scene defines the scene where you want your assets to be loaded
  125952. * @param onSuccess is a callback called when the task is successfully executed
  125953. * @param onError is a callback called if an error occurs
  125954. */
  125955. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125956. /**
  125957. * Execute the current task
  125958. * @param scene defines the scene where you want your assets to be loaded
  125959. * @param onSuccess is a callback called when the task is successfully executed
  125960. * @param onError is a callback called if an error occurs
  125961. */
  125962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125963. /**
  125964. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  125965. * This can be used with failed tasks that have the reason for failure fixed.
  125966. */
  125967. reset(): void;
  125968. private onErrorCallback;
  125969. private onDoneCallback;
  125970. }
  125971. /**
  125972. * Define the interface used by progress events raised during assets loading
  125973. */
  125974. export interface IAssetsProgressEvent {
  125975. /**
  125976. * Defines the number of remaining tasks to process
  125977. */
  125978. remainingCount: number;
  125979. /**
  125980. * Defines the total number of tasks
  125981. */
  125982. totalCount: number;
  125983. /**
  125984. * Defines the task that was just processed
  125985. */
  125986. task: AbstractAssetTask;
  125987. }
  125988. /**
  125989. * Class used to share progress information about assets loading
  125990. */
  125991. export class AssetsProgressEvent implements IAssetsProgressEvent {
  125992. /**
  125993. * Defines the number of remaining tasks to process
  125994. */
  125995. remainingCount: number;
  125996. /**
  125997. * Defines the total number of tasks
  125998. */
  125999. totalCount: number;
  126000. /**
  126001. * Defines the task that was just processed
  126002. */
  126003. task: AbstractAssetTask;
  126004. /**
  126005. * Creates a AssetsProgressEvent
  126006. * @param remainingCount defines the number of remaining tasks to process
  126007. * @param totalCount defines the total number of tasks
  126008. * @param task defines the task that was just processed
  126009. */
  126010. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126011. }
  126012. /**
  126013. * Define a task used by AssetsManager to load meshes
  126014. */
  126015. export class MeshAssetTask extends AbstractAssetTask {
  126016. /**
  126017. * Defines the name of the task
  126018. */
  126019. name: string;
  126020. /**
  126021. * Defines the list of mesh's names you want to load
  126022. */
  126023. meshesNames: any;
  126024. /**
  126025. * Defines the root url to use as a base to load your meshes and associated resources
  126026. */
  126027. rootUrl: string;
  126028. /**
  126029. * Defines the filename of the scene to load from
  126030. */
  126031. sceneFilename: string;
  126032. /**
  126033. * Gets the list of loaded meshes
  126034. */
  126035. loadedMeshes: Array<AbstractMesh>;
  126036. /**
  126037. * Gets the list of loaded particle systems
  126038. */
  126039. loadedParticleSystems: Array<IParticleSystem>;
  126040. /**
  126041. * Gets the list of loaded skeletons
  126042. */
  126043. loadedSkeletons: Array<Skeleton>;
  126044. /**
  126045. * Gets the list of loaded animation groups
  126046. */
  126047. loadedAnimationGroups: Array<AnimationGroup>;
  126048. /**
  126049. * Callback called when the task is successful
  126050. */
  126051. onSuccess: (task: MeshAssetTask) => void;
  126052. /**
  126053. * Callback called when the task is successful
  126054. */
  126055. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126056. /**
  126057. * Creates a new MeshAssetTask
  126058. * @param name defines the name of the task
  126059. * @param meshesNames defines the list of mesh's names you want to load
  126060. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126061. * @param sceneFilename defines the filename of the scene to load from
  126062. */
  126063. constructor(
  126064. /**
  126065. * Defines the name of the task
  126066. */
  126067. name: string,
  126068. /**
  126069. * Defines the list of mesh's names you want to load
  126070. */
  126071. meshesNames: any,
  126072. /**
  126073. * Defines the root url to use as a base to load your meshes and associated resources
  126074. */
  126075. rootUrl: string,
  126076. /**
  126077. * Defines the filename of the scene to load from
  126078. */
  126079. sceneFilename: string);
  126080. /**
  126081. * Execute the current task
  126082. * @param scene defines the scene where you want your assets to be loaded
  126083. * @param onSuccess is a callback called when the task is successfully executed
  126084. * @param onError is a callback called if an error occurs
  126085. */
  126086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126087. }
  126088. /**
  126089. * Define a task used by AssetsManager to load text content
  126090. */
  126091. export class TextFileAssetTask extends AbstractAssetTask {
  126092. /**
  126093. * Defines the name of the task
  126094. */
  126095. name: string;
  126096. /**
  126097. * Defines the location of the file to load
  126098. */
  126099. url: string;
  126100. /**
  126101. * Gets the loaded text string
  126102. */
  126103. text: string;
  126104. /**
  126105. * Callback called when the task is successful
  126106. */
  126107. onSuccess: (task: TextFileAssetTask) => void;
  126108. /**
  126109. * Callback called when the task is successful
  126110. */
  126111. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126112. /**
  126113. * Creates a new TextFileAssetTask object
  126114. * @param name defines the name of the task
  126115. * @param url defines the location of the file to load
  126116. */
  126117. constructor(
  126118. /**
  126119. * Defines the name of the task
  126120. */
  126121. name: string,
  126122. /**
  126123. * Defines the location of the file to load
  126124. */
  126125. url: string);
  126126. /**
  126127. * Execute the current task
  126128. * @param scene defines the scene where you want your assets to be loaded
  126129. * @param onSuccess is a callback called when the task is successfully executed
  126130. * @param onError is a callback called if an error occurs
  126131. */
  126132. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126133. }
  126134. /**
  126135. * Define a task used by AssetsManager to load binary data
  126136. */
  126137. export class BinaryFileAssetTask extends AbstractAssetTask {
  126138. /**
  126139. * Defines the name of the task
  126140. */
  126141. name: string;
  126142. /**
  126143. * Defines the location of the file to load
  126144. */
  126145. url: string;
  126146. /**
  126147. * Gets the lodaded data (as an array buffer)
  126148. */
  126149. data: ArrayBuffer;
  126150. /**
  126151. * Callback called when the task is successful
  126152. */
  126153. onSuccess: (task: BinaryFileAssetTask) => void;
  126154. /**
  126155. * Callback called when the task is successful
  126156. */
  126157. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126158. /**
  126159. * Creates a new BinaryFileAssetTask object
  126160. * @param name defines the name of the new task
  126161. * @param url defines the location of the file to load
  126162. */
  126163. constructor(
  126164. /**
  126165. * Defines the name of the task
  126166. */
  126167. name: string,
  126168. /**
  126169. * Defines the location of the file to load
  126170. */
  126171. url: string);
  126172. /**
  126173. * Execute the current task
  126174. * @param scene defines the scene where you want your assets to be loaded
  126175. * @param onSuccess is a callback called when the task is successfully executed
  126176. * @param onError is a callback called if an error occurs
  126177. */
  126178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126179. }
  126180. /**
  126181. * Define a task used by AssetsManager to load images
  126182. */
  126183. export class ImageAssetTask extends AbstractAssetTask {
  126184. /**
  126185. * Defines the name of the task
  126186. */
  126187. name: string;
  126188. /**
  126189. * Defines the location of the image to load
  126190. */
  126191. url: string;
  126192. /**
  126193. * Gets the loaded images
  126194. */
  126195. image: HTMLImageElement;
  126196. /**
  126197. * Callback called when the task is successful
  126198. */
  126199. onSuccess: (task: ImageAssetTask) => void;
  126200. /**
  126201. * Callback called when the task is successful
  126202. */
  126203. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126204. /**
  126205. * Creates a new ImageAssetTask
  126206. * @param name defines the name of the task
  126207. * @param url defines the location of the image to load
  126208. */
  126209. constructor(
  126210. /**
  126211. * Defines the name of the task
  126212. */
  126213. name: string,
  126214. /**
  126215. * Defines the location of the image to load
  126216. */
  126217. url: string);
  126218. /**
  126219. * Execute the current task
  126220. * @param scene defines the scene where you want your assets to be loaded
  126221. * @param onSuccess is a callback called when the task is successfully executed
  126222. * @param onError is a callback called if an error occurs
  126223. */
  126224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126225. }
  126226. /**
  126227. * Defines the interface used by texture loading tasks
  126228. */
  126229. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126230. /**
  126231. * Gets the loaded texture
  126232. */
  126233. texture: TEX;
  126234. }
  126235. /**
  126236. * Define a task used by AssetsManager to load 2D textures
  126237. */
  126238. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126239. /**
  126240. * Defines the name of the task
  126241. */
  126242. name: string;
  126243. /**
  126244. * Defines the location of the file to load
  126245. */
  126246. url: string;
  126247. /**
  126248. * Defines if mipmap should not be generated (default is false)
  126249. */
  126250. noMipmap?: boolean | undefined;
  126251. /**
  126252. * Defines if texture must be inverted on Y axis (default is false)
  126253. */
  126254. invertY?: boolean | undefined;
  126255. /**
  126256. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126257. */
  126258. samplingMode: number;
  126259. /**
  126260. * Gets the loaded texture
  126261. */
  126262. texture: Texture;
  126263. /**
  126264. * Callback called when the task is successful
  126265. */
  126266. onSuccess: (task: TextureAssetTask) => void;
  126267. /**
  126268. * Callback called when the task is successful
  126269. */
  126270. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126271. /**
  126272. * Creates a new TextureAssetTask object
  126273. * @param name defines the name of the task
  126274. * @param url defines the location of the file to load
  126275. * @param noMipmap defines if mipmap should not be generated (default is false)
  126276. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126277. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126278. */
  126279. constructor(
  126280. /**
  126281. * Defines the name of the task
  126282. */
  126283. name: string,
  126284. /**
  126285. * Defines the location of the file to load
  126286. */
  126287. url: string,
  126288. /**
  126289. * Defines if mipmap should not be generated (default is false)
  126290. */
  126291. noMipmap?: boolean | undefined,
  126292. /**
  126293. * Defines if texture must be inverted on Y axis (default is false)
  126294. */
  126295. invertY?: boolean | undefined,
  126296. /**
  126297. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126298. */
  126299. samplingMode?: number);
  126300. /**
  126301. * Execute the current task
  126302. * @param scene defines the scene where you want your assets to be loaded
  126303. * @param onSuccess is a callback called when the task is successfully executed
  126304. * @param onError is a callback called if an error occurs
  126305. */
  126306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126307. }
  126308. /**
  126309. * Define a task used by AssetsManager to load cube textures
  126310. */
  126311. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126312. /**
  126313. * Defines the name of the task
  126314. */
  126315. name: string;
  126316. /**
  126317. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126318. */
  126319. url: string;
  126320. /**
  126321. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126322. */
  126323. extensions?: string[] | undefined;
  126324. /**
  126325. * Defines if mipmaps should not be generated (default is false)
  126326. */
  126327. noMipmap?: boolean | undefined;
  126328. /**
  126329. * Defines the explicit list of files (undefined by default)
  126330. */
  126331. files?: string[] | undefined;
  126332. /**
  126333. * Gets the loaded texture
  126334. */
  126335. texture: CubeTexture;
  126336. /**
  126337. * Callback called when the task is successful
  126338. */
  126339. onSuccess: (task: CubeTextureAssetTask) => void;
  126340. /**
  126341. * Callback called when the task is successful
  126342. */
  126343. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126344. /**
  126345. * Creates a new CubeTextureAssetTask
  126346. * @param name defines the name of the task
  126347. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126348. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126349. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126350. * @param files defines the explicit list of files (undefined by default)
  126351. */
  126352. constructor(
  126353. /**
  126354. * Defines the name of the task
  126355. */
  126356. name: string,
  126357. /**
  126358. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126359. */
  126360. url: string,
  126361. /**
  126362. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126363. */
  126364. extensions?: string[] | undefined,
  126365. /**
  126366. * Defines if mipmaps should not be generated (default is false)
  126367. */
  126368. noMipmap?: boolean | undefined,
  126369. /**
  126370. * Defines the explicit list of files (undefined by default)
  126371. */
  126372. files?: string[] | undefined);
  126373. /**
  126374. * Execute the current task
  126375. * @param scene defines the scene where you want your assets to be loaded
  126376. * @param onSuccess is a callback called when the task is successfully executed
  126377. * @param onError is a callback called if an error occurs
  126378. */
  126379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126380. }
  126381. /**
  126382. * Define a task used by AssetsManager to load HDR cube textures
  126383. */
  126384. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126385. /**
  126386. * Defines the name of the task
  126387. */
  126388. name: string;
  126389. /**
  126390. * Defines the location of the file to load
  126391. */
  126392. url: string;
  126393. /**
  126394. * Defines the desired size (the more it increases the longer the generation will be)
  126395. */
  126396. size: number;
  126397. /**
  126398. * Defines if mipmaps should not be generated (default is false)
  126399. */
  126400. noMipmap: boolean;
  126401. /**
  126402. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126403. */
  126404. generateHarmonics: boolean;
  126405. /**
  126406. * 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)
  126407. */
  126408. gammaSpace: boolean;
  126409. /**
  126410. * Internal Use Only
  126411. */
  126412. reserved: boolean;
  126413. /**
  126414. * Gets the loaded texture
  126415. */
  126416. texture: HDRCubeTexture;
  126417. /**
  126418. * Callback called when the task is successful
  126419. */
  126420. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126421. /**
  126422. * Callback called when the task is successful
  126423. */
  126424. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  126425. /**
  126426. * Creates a new HDRCubeTextureAssetTask object
  126427. * @param name defines the name of the task
  126428. * @param url defines the location of the file to load
  126429. * @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.
  126430. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126431. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126432. * @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)
  126433. * @param reserved Internal use only
  126434. */
  126435. constructor(
  126436. /**
  126437. * Defines the name of the task
  126438. */
  126439. name: string,
  126440. /**
  126441. * Defines the location of the file to load
  126442. */
  126443. url: string,
  126444. /**
  126445. * Defines the desired size (the more it increases the longer the generation will be)
  126446. */
  126447. size: number,
  126448. /**
  126449. * Defines if mipmaps should not be generated (default is false)
  126450. */
  126451. noMipmap?: boolean,
  126452. /**
  126453. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126454. */
  126455. generateHarmonics?: boolean,
  126456. /**
  126457. * 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)
  126458. */
  126459. gammaSpace?: boolean,
  126460. /**
  126461. * Internal Use Only
  126462. */
  126463. reserved?: boolean);
  126464. /**
  126465. * Execute the current task
  126466. * @param scene defines the scene where you want your assets to be loaded
  126467. * @param onSuccess is a callback called when the task is successfully executed
  126468. * @param onError is a callback called if an error occurs
  126469. */
  126470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126471. }
  126472. /**
  126473. * Define a task used by AssetsManager to load Equirectangular cube textures
  126474. */
  126475. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  126476. /**
  126477. * Defines the name of the task
  126478. */
  126479. name: string;
  126480. /**
  126481. * Defines the location of the file to load
  126482. */
  126483. url: string;
  126484. /**
  126485. * Defines the desired size (the more it increases the longer the generation will be)
  126486. */
  126487. size: number;
  126488. /**
  126489. * Defines if mipmaps should not be generated (default is false)
  126490. */
  126491. noMipmap: boolean;
  126492. /**
  126493. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126494. * but the standard material would require them in Gamma space) (default is true)
  126495. */
  126496. gammaSpace: boolean;
  126497. /**
  126498. * Gets the loaded texture
  126499. */
  126500. texture: EquiRectangularCubeTexture;
  126501. /**
  126502. * Callback called when the task is successful
  126503. */
  126504. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  126505. /**
  126506. * Callback called when the task is successful
  126507. */
  126508. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  126509. /**
  126510. * Creates a new EquiRectangularCubeTextureAssetTask object
  126511. * @param name defines the name of the task
  126512. * @param url defines the location of the file to load
  126513. * @param size defines the desired size (the more it increases the longer the generation will be)
  126514. * If the size is omitted this implies you are using a preprocessed cubemap.
  126515. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126516. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  126517. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  126518. * (default is true)
  126519. */
  126520. constructor(
  126521. /**
  126522. * Defines the name of the task
  126523. */
  126524. name: string,
  126525. /**
  126526. * Defines the location of the file to load
  126527. */
  126528. url: string,
  126529. /**
  126530. * Defines the desired size (the more it increases the longer the generation will be)
  126531. */
  126532. size: number,
  126533. /**
  126534. * Defines if mipmaps should not be generated (default is false)
  126535. */
  126536. noMipmap?: boolean,
  126537. /**
  126538. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126539. * but the standard material would require them in Gamma space) (default is true)
  126540. */
  126541. gammaSpace?: boolean);
  126542. /**
  126543. * Execute the current task
  126544. * @param scene defines the scene where you want your assets to be loaded
  126545. * @param onSuccess is a callback called when the task is successfully executed
  126546. * @param onError is a callback called if an error occurs
  126547. */
  126548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126549. }
  126550. /**
  126551. * This class can be used to easily import assets into a scene
  126552. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  126553. */
  126554. export class AssetsManager {
  126555. private _scene;
  126556. private _isLoading;
  126557. protected _tasks: AbstractAssetTask[];
  126558. protected _waitingTasksCount: number;
  126559. protected _totalTasksCount: number;
  126560. /**
  126561. * Callback called when all tasks are processed
  126562. */
  126563. onFinish: (tasks: AbstractAssetTask[]) => void;
  126564. /**
  126565. * Callback called when a task is successful
  126566. */
  126567. onTaskSuccess: (task: AbstractAssetTask) => void;
  126568. /**
  126569. * Callback called when a task had an error
  126570. */
  126571. onTaskError: (task: AbstractAssetTask) => void;
  126572. /**
  126573. * Callback called when a task is done (whatever the result is)
  126574. */
  126575. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  126576. /**
  126577. * Observable called when all tasks are processed
  126578. */
  126579. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  126580. /**
  126581. * Observable called when a task had an error
  126582. */
  126583. onTaskErrorObservable: Observable<AbstractAssetTask>;
  126584. /**
  126585. * Observable called when all tasks were executed
  126586. */
  126587. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  126588. /**
  126589. * Observable called when a task is done (whatever the result is)
  126590. */
  126591. onProgressObservable: Observable<IAssetsProgressEvent>;
  126592. /**
  126593. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  126594. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126595. */
  126596. useDefaultLoadingScreen: boolean;
  126597. /**
  126598. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  126599. * when all assets have been downloaded.
  126600. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  126601. */
  126602. autoHideLoadingUI: boolean;
  126603. /**
  126604. * Creates a new AssetsManager
  126605. * @param scene defines the scene to work on
  126606. */
  126607. constructor(scene: Scene);
  126608. /**
  126609. * Add a MeshAssetTask to the list of active tasks
  126610. * @param taskName defines the name of the new task
  126611. * @param meshesNames defines the name of meshes to load
  126612. * @param rootUrl defines the root url to use to locate files
  126613. * @param sceneFilename defines the filename of the scene file
  126614. * @returns a new MeshAssetTask object
  126615. */
  126616. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  126617. /**
  126618. * Add a TextFileAssetTask to the list of active tasks
  126619. * @param taskName defines the name of the new task
  126620. * @param url defines the url of the file to load
  126621. * @returns a new TextFileAssetTask object
  126622. */
  126623. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  126624. /**
  126625. * Add a BinaryFileAssetTask to the list of active tasks
  126626. * @param taskName defines the name of the new task
  126627. * @param url defines the url of the file to load
  126628. * @returns a new BinaryFileAssetTask object
  126629. */
  126630. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  126631. /**
  126632. * Add a ImageAssetTask to the list of active tasks
  126633. * @param taskName defines the name of the new task
  126634. * @param url defines the url of the file to load
  126635. * @returns a new ImageAssetTask object
  126636. */
  126637. addImageTask(taskName: string, url: string): ImageAssetTask;
  126638. /**
  126639. * Add a TextureAssetTask to the list of active tasks
  126640. * @param taskName defines the name of the new task
  126641. * @param url defines the url of the file to load
  126642. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126643. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  126644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126645. * @returns a new TextureAssetTask object
  126646. */
  126647. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  126648. /**
  126649. * Add a CubeTextureAssetTask to the list of active tasks
  126650. * @param taskName defines the name of the new task
  126651. * @param url defines the url of the file to load
  126652. * @param extensions defines the extension to use to load the cube map (can be null)
  126653. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126654. * @param files defines the list of files to load (can be null)
  126655. * @returns a new CubeTextureAssetTask object
  126656. */
  126657. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  126658. /**
  126659. *
  126660. * Add a HDRCubeTextureAssetTask to the list of active tasks
  126661. * @param taskName defines the name of the new task
  126662. * @param url defines the url of the file to load
  126663. * @param size defines the size you want for the cubemap (can be null)
  126664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126665. * @param generateHarmonics defines if you want to automatically generate (true by default)
  126666. * @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)
  126667. * @param reserved Internal use only
  126668. * @returns a new HDRCubeTextureAssetTask object
  126669. */
  126670. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  126671. /**
  126672. *
  126673. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  126674. * @param taskName defines the name of the new task
  126675. * @param url defines the url of the file to load
  126676. * @param size defines the size you want for the cubemap (can be null)
  126677. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126678. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126679. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126680. * @returns a new EquiRectangularCubeTextureAssetTask object
  126681. */
  126682. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  126683. /**
  126684. * Remove a task from the assets manager.
  126685. * @param task the task to remove
  126686. */
  126687. removeTask(task: AbstractAssetTask): void;
  126688. private _decreaseWaitingTasksCount;
  126689. private _runTask;
  126690. /**
  126691. * Reset the AssetsManager and remove all tasks
  126692. * @return the current instance of the AssetsManager
  126693. */
  126694. reset(): AssetsManager;
  126695. /**
  126696. * Start the loading process
  126697. * @return the current instance of the AssetsManager
  126698. */
  126699. load(): AssetsManager;
  126700. /**
  126701. * Start the loading process as an async operation
  126702. * @return a promise returning the list of failed tasks
  126703. */
  126704. loadAsync(): Promise<void>;
  126705. }
  126706. }
  126707. declare module BABYLON {
  126708. /**
  126709. * Wrapper class for promise with external resolve and reject.
  126710. */
  126711. export class Deferred<T> {
  126712. /**
  126713. * The promise associated with this deferred object.
  126714. */
  126715. readonly promise: Promise<T>;
  126716. private _resolve;
  126717. private _reject;
  126718. /**
  126719. * The resolve method of the promise associated with this deferred object.
  126720. */
  126721. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  126722. /**
  126723. * The reject method of the promise associated with this deferred object.
  126724. */
  126725. readonly reject: (reason?: any) => void;
  126726. /**
  126727. * Constructor for this deferred object.
  126728. */
  126729. constructor();
  126730. }
  126731. }
  126732. declare module BABYLON {
  126733. /**
  126734. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  126735. */
  126736. export class MeshExploder {
  126737. private _centerMesh;
  126738. private _meshes;
  126739. private _meshesOrigins;
  126740. private _toCenterVectors;
  126741. private _scaledDirection;
  126742. private _newPosition;
  126743. private _centerPosition;
  126744. /**
  126745. * Explodes meshes from a center mesh.
  126746. * @param meshes The meshes to explode.
  126747. * @param centerMesh The mesh to be center of explosion.
  126748. */
  126749. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  126750. private _setCenterMesh;
  126751. /**
  126752. * Get class name
  126753. * @returns "MeshExploder"
  126754. */
  126755. getClassName(): string;
  126756. /**
  126757. * "Exploded meshes"
  126758. * @returns Array of meshes with the centerMesh at index 0.
  126759. */
  126760. getMeshes(): Array<Mesh>;
  126761. /**
  126762. * Explodes meshes giving a specific direction
  126763. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  126764. */
  126765. explode(direction?: number): void;
  126766. }
  126767. }
  126768. declare module BABYLON {
  126769. /**
  126770. * Class used to help managing file picking and drag'n'drop
  126771. */
  126772. export class FilesInput {
  126773. /**
  126774. * List of files ready to be loaded
  126775. */
  126776. static readonly FilesToLoad: {
  126777. [key: string]: File;
  126778. };
  126779. /**
  126780. * Callback called when a file is processed
  126781. */
  126782. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  126783. private _engine;
  126784. private _currentScene;
  126785. private _sceneLoadedCallback;
  126786. private _progressCallback;
  126787. private _additionalRenderLoopLogicCallback;
  126788. private _textureLoadingCallback;
  126789. private _startingProcessingFilesCallback;
  126790. private _onReloadCallback;
  126791. private _errorCallback;
  126792. private _elementToMonitor;
  126793. private _sceneFileToLoad;
  126794. private _filesToLoad;
  126795. /**
  126796. * Creates a new FilesInput
  126797. * @param engine defines the rendering engine
  126798. * @param scene defines the hosting scene
  126799. * @param sceneLoadedCallback callback called when scene is loaded
  126800. * @param progressCallback callback called to track progress
  126801. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  126802. * @param textureLoadingCallback callback called when a texture is loading
  126803. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  126804. * @param onReloadCallback callback called when a reload is requested
  126805. * @param errorCallback callback call if an error occurs
  126806. */
  126807. 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);
  126808. private _dragEnterHandler;
  126809. private _dragOverHandler;
  126810. private _dropHandler;
  126811. /**
  126812. * Calls this function to listen to drag'n'drop events on a specific DOM element
  126813. * @param elementToMonitor defines the DOM element to track
  126814. */
  126815. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  126816. /**
  126817. * Release all associated resources
  126818. */
  126819. dispose(): void;
  126820. private renderFunction;
  126821. private drag;
  126822. private drop;
  126823. private _traverseFolder;
  126824. private _processFiles;
  126825. /**
  126826. * Load files from a drop event
  126827. * @param event defines the drop event to use as source
  126828. */
  126829. loadFiles(event: any): void;
  126830. private _processReload;
  126831. /**
  126832. * Reload the current scene from the loaded files
  126833. */
  126834. reload(): void;
  126835. }
  126836. }
  126837. declare module BABYLON {
  126838. /**
  126839. * Defines the root class used to create scene optimization to use with SceneOptimizer
  126840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126841. */
  126842. export class SceneOptimization {
  126843. /**
  126844. * Defines the priority of this optimization (0 by default which means first in the list)
  126845. */
  126846. priority: number;
  126847. /**
  126848. * Gets a string describing the action executed by the current optimization
  126849. * @returns description string
  126850. */
  126851. getDescription(): string;
  126852. /**
  126853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126854. * @param scene defines the current scene where to apply this optimization
  126855. * @param optimizer defines the current optimizer
  126856. * @returns true if everything that can be done was applied
  126857. */
  126858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126859. /**
  126860. * Creates the SceneOptimization object
  126861. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126862. * @param desc defines the description associated with the optimization
  126863. */
  126864. constructor(
  126865. /**
  126866. * Defines the priority of this optimization (0 by default which means first in the list)
  126867. */
  126868. priority?: number);
  126869. }
  126870. /**
  126871. * Defines an optimization used to reduce the size of render target textures
  126872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126873. */
  126874. export class TextureOptimization extends SceneOptimization {
  126875. /**
  126876. * Defines the priority of this optimization (0 by default which means first in the list)
  126877. */
  126878. priority: number;
  126879. /**
  126880. * 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
  126881. */
  126882. maximumSize: number;
  126883. /**
  126884. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126885. */
  126886. step: number;
  126887. /**
  126888. * Gets a string describing the action executed by the current optimization
  126889. * @returns description string
  126890. */
  126891. getDescription(): string;
  126892. /**
  126893. * Creates the TextureOptimization object
  126894. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126895. * @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
  126896. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126897. */
  126898. constructor(
  126899. /**
  126900. * Defines the priority of this optimization (0 by default which means first in the list)
  126901. */
  126902. priority?: number,
  126903. /**
  126904. * 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
  126905. */
  126906. maximumSize?: number,
  126907. /**
  126908. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126909. */
  126910. step?: number);
  126911. /**
  126912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126913. * @param scene defines the current scene where to apply this optimization
  126914. * @param optimizer defines the current optimizer
  126915. * @returns true if everything that can be done was applied
  126916. */
  126917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126918. }
  126919. /**
  126920. * Defines an optimization used to increase or decrease the rendering resolution
  126921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126922. */
  126923. export class HardwareScalingOptimization extends SceneOptimization {
  126924. /**
  126925. * Defines the priority of this optimization (0 by default which means first in the list)
  126926. */
  126927. priority: number;
  126928. /**
  126929. * Defines the maximum scale to use (2 by default)
  126930. */
  126931. maximumScale: number;
  126932. /**
  126933. * Defines the step to use between two passes (0.5 by default)
  126934. */
  126935. step: number;
  126936. private _currentScale;
  126937. private _directionOffset;
  126938. /**
  126939. * Gets a string describing the action executed by the current optimization
  126940. * @return description string
  126941. */
  126942. getDescription(): string;
  126943. /**
  126944. * Creates the HardwareScalingOptimization object
  126945. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126946. * @param maximumScale defines the maximum scale to use (2 by default)
  126947. * @param step defines the step to use between two passes (0.5 by default)
  126948. */
  126949. constructor(
  126950. /**
  126951. * Defines the priority of this optimization (0 by default which means first in the list)
  126952. */
  126953. priority?: number,
  126954. /**
  126955. * Defines the maximum scale to use (2 by default)
  126956. */
  126957. maximumScale?: number,
  126958. /**
  126959. * Defines the step to use between two passes (0.5 by default)
  126960. */
  126961. step?: number);
  126962. /**
  126963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126964. * @param scene defines the current scene where to apply this optimization
  126965. * @param optimizer defines the current optimizer
  126966. * @returns true if everything that can be done was applied
  126967. */
  126968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126969. }
  126970. /**
  126971. * Defines an optimization used to remove shadows
  126972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126973. */
  126974. export class ShadowsOptimization extends SceneOptimization {
  126975. /**
  126976. * Gets a string describing the action executed by the current optimization
  126977. * @return description string
  126978. */
  126979. getDescription(): string;
  126980. /**
  126981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126982. * @param scene defines the current scene where to apply this optimization
  126983. * @param optimizer defines the current optimizer
  126984. * @returns true if everything that can be done was applied
  126985. */
  126986. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126987. }
  126988. /**
  126989. * Defines an optimization used to turn post-processes off
  126990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126991. */
  126992. export class PostProcessesOptimization extends SceneOptimization {
  126993. /**
  126994. * Gets a string describing the action executed by the current optimization
  126995. * @return description string
  126996. */
  126997. getDescription(): string;
  126998. /**
  126999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127000. * @param scene defines the current scene where to apply this optimization
  127001. * @param optimizer defines the current optimizer
  127002. * @returns true if everything that can be done was applied
  127003. */
  127004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127005. }
  127006. /**
  127007. * Defines an optimization used to turn lens flares off
  127008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127009. */
  127010. export class LensFlaresOptimization extends SceneOptimization {
  127011. /**
  127012. * Gets a string describing the action executed by the current optimization
  127013. * @return description string
  127014. */
  127015. getDescription(): string;
  127016. /**
  127017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127018. * @param scene defines the current scene where to apply this optimization
  127019. * @param optimizer defines the current optimizer
  127020. * @returns true if everything that can be done was applied
  127021. */
  127022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127023. }
  127024. /**
  127025. * Defines an optimization based on user defined callback.
  127026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127027. */
  127028. export class CustomOptimization extends SceneOptimization {
  127029. /**
  127030. * Callback called to apply the custom optimization.
  127031. */
  127032. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127033. /**
  127034. * Callback called to get custom description
  127035. */
  127036. onGetDescription: () => string;
  127037. /**
  127038. * Gets a string describing the action executed by the current optimization
  127039. * @returns description string
  127040. */
  127041. getDescription(): string;
  127042. /**
  127043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127044. * @param scene defines the current scene where to apply this optimization
  127045. * @param optimizer defines the current optimizer
  127046. * @returns true if everything that can be done was applied
  127047. */
  127048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127049. }
  127050. /**
  127051. * Defines an optimization used to turn particles off
  127052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127053. */
  127054. export class ParticlesOptimization extends SceneOptimization {
  127055. /**
  127056. * Gets a string describing the action executed by the current optimization
  127057. * @return description string
  127058. */
  127059. getDescription(): string;
  127060. /**
  127061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127062. * @param scene defines the current scene where to apply this optimization
  127063. * @param optimizer defines the current optimizer
  127064. * @returns true if everything that can be done was applied
  127065. */
  127066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127067. }
  127068. /**
  127069. * Defines an optimization used to turn render targets off
  127070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127071. */
  127072. export class RenderTargetsOptimization extends SceneOptimization {
  127073. /**
  127074. * Gets a string describing the action executed by the current optimization
  127075. * @return description string
  127076. */
  127077. getDescription(): string;
  127078. /**
  127079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127080. * @param scene defines the current scene where to apply this optimization
  127081. * @param optimizer defines the current optimizer
  127082. * @returns true if everything that can be done was applied
  127083. */
  127084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127085. }
  127086. /**
  127087. * Defines an optimization used to merge meshes with compatible materials
  127088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127089. */
  127090. export class MergeMeshesOptimization extends SceneOptimization {
  127091. private static _UpdateSelectionTree;
  127092. /**
  127093. * Gets or sets a boolean which defines if optimization octree has to be updated
  127094. */
  127095. /**
  127096. * Gets or sets a boolean which defines if optimization octree has to be updated
  127097. */
  127098. static UpdateSelectionTree: boolean;
  127099. /**
  127100. * Gets a string describing the action executed by the current optimization
  127101. * @return description string
  127102. */
  127103. getDescription(): string;
  127104. private _canBeMerged;
  127105. /**
  127106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127107. * @param scene defines the current scene where to apply this optimization
  127108. * @param optimizer defines the current optimizer
  127109. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127110. * @returns true if everything that can be done was applied
  127111. */
  127112. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127113. }
  127114. /**
  127115. * Defines a list of options used by SceneOptimizer
  127116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127117. */
  127118. export class SceneOptimizerOptions {
  127119. /**
  127120. * Defines the target frame rate to reach (60 by default)
  127121. */
  127122. targetFrameRate: number;
  127123. /**
  127124. * Defines the interval between two checkes (2000ms by default)
  127125. */
  127126. trackerDuration: number;
  127127. /**
  127128. * Gets the list of optimizations to apply
  127129. */
  127130. optimizations: SceneOptimization[];
  127131. /**
  127132. * Creates a new list of options used by SceneOptimizer
  127133. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127134. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127135. */
  127136. constructor(
  127137. /**
  127138. * Defines the target frame rate to reach (60 by default)
  127139. */
  127140. targetFrameRate?: number,
  127141. /**
  127142. * Defines the interval between two checkes (2000ms by default)
  127143. */
  127144. trackerDuration?: number);
  127145. /**
  127146. * Add a new optimization
  127147. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127148. * @returns the current SceneOptimizerOptions
  127149. */
  127150. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127151. /**
  127152. * Add a new custom optimization
  127153. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127154. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127155. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127156. * @returns the current SceneOptimizerOptions
  127157. */
  127158. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127159. /**
  127160. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127161. * @param targetFrameRate defines the target frame rate (60 by default)
  127162. * @returns a SceneOptimizerOptions object
  127163. */
  127164. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127165. /**
  127166. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127167. * @param targetFrameRate defines the target frame rate (60 by default)
  127168. * @returns a SceneOptimizerOptions object
  127169. */
  127170. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127171. /**
  127172. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127173. * @param targetFrameRate defines the target frame rate (60 by default)
  127174. * @returns a SceneOptimizerOptions object
  127175. */
  127176. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127177. }
  127178. /**
  127179. * Class used to run optimizations in order to reach a target frame rate
  127180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127181. */
  127182. export class SceneOptimizer implements IDisposable {
  127183. private _isRunning;
  127184. private _options;
  127185. private _scene;
  127186. private _currentPriorityLevel;
  127187. private _targetFrameRate;
  127188. private _trackerDuration;
  127189. private _currentFrameRate;
  127190. private _sceneDisposeObserver;
  127191. private _improvementMode;
  127192. /**
  127193. * Defines an observable called when the optimizer reaches the target frame rate
  127194. */
  127195. onSuccessObservable: Observable<SceneOptimizer>;
  127196. /**
  127197. * Defines an observable called when the optimizer enables an optimization
  127198. */
  127199. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127200. /**
  127201. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127202. */
  127203. onFailureObservable: Observable<SceneOptimizer>;
  127204. /**
  127205. * Gets a boolean indicating if the optimizer is in improvement mode
  127206. */
  127207. readonly isInImprovementMode: boolean;
  127208. /**
  127209. * Gets the current priority level (0 at start)
  127210. */
  127211. readonly currentPriorityLevel: number;
  127212. /**
  127213. * Gets the current frame rate checked by the SceneOptimizer
  127214. */
  127215. readonly currentFrameRate: number;
  127216. /**
  127217. * Gets or sets the current target frame rate (60 by default)
  127218. */
  127219. /**
  127220. * Gets or sets the current target frame rate (60 by default)
  127221. */
  127222. targetFrameRate: number;
  127223. /**
  127224. * Gets or sets the current interval between two checks (every 2000ms by default)
  127225. */
  127226. /**
  127227. * Gets or sets the current interval between two checks (every 2000ms by default)
  127228. */
  127229. trackerDuration: number;
  127230. /**
  127231. * Gets the list of active optimizations
  127232. */
  127233. readonly optimizations: SceneOptimization[];
  127234. /**
  127235. * Creates a new SceneOptimizer
  127236. * @param scene defines the scene to work on
  127237. * @param options defines the options to use with the SceneOptimizer
  127238. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127239. * @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)
  127240. */
  127241. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127242. /**
  127243. * Stops the current optimizer
  127244. */
  127245. stop(): void;
  127246. /**
  127247. * Reset the optimizer to initial step (current priority level = 0)
  127248. */
  127249. reset(): void;
  127250. /**
  127251. * Start the optimizer. By default it will try to reach a specific framerate
  127252. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127253. */
  127254. start(): void;
  127255. private _checkCurrentState;
  127256. /**
  127257. * Release all resources
  127258. */
  127259. dispose(): void;
  127260. /**
  127261. * Helper function to create a SceneOptimizer with one single line of code
  127262. * @param scene defines the scene to work on
  127263. * @param options defines the options to use with the SceneOptimizer
  127264. * @param onSuccess defines a callback to call on success
  127265. * @param onFailure defines a callback to call on failure
  127266. * @returns the new SceneOptimizer object
  127267. */
  127268. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127269. }
  127270. }
  127271. declare module BABYLON {
  127272. /**
  127273. * Class used to serialize a scene into a string
  127274. */
  127275. export class SceneSerializer {
  127276. /**
  127277. * Clear cache used by a previous serialization
  127278. */
  127279. static ClearCache(): void;
  127280. /**
  127281. * Serialize a scene into a JSON compatible object
  127282. * @param scene defines the scene to serialize
  127283. * @returns a JSON compatible object
  127284. */
  127285. static Serialize(scene: Scene): any;
  127286. /**
  127287. * Serialize a mesh into a JSON compatible object
  127288. * @param toSerialize defines the mesh to serialize
  127289. * @param withParents defines if parents must be serialized as well
  127290. * @param withChildren defines if children must be serialized as well
  127291. * @returns a JSON compatible object
  127292. */
  127293. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127294. }
  127295. }
  127296. declare module BABYLON {
  127297. /**
  127298. * Class used to host texture specific utilities
  127299. */
  127300. export class TextureTools {
  127301. /**
  127302. * Uses the GPU to create a copy texture rescaled at a given size
  127303. * @param texture Texture to copy from
  127304. * @param width defines the desired width
  127305. * @param height defines the desired height
  127306. * @param useBilinearMode defines if bilinear mode has to be used
  127307. * @return the generated texture
  127308. */
  127309. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127310. }
  127311. }
  127312. declare module BABYLON {
  127313. /**
  127314. * This represents the different options available for the video capture.
  127315. */
  127316. export interface VideoRecorderOptions {
  127317. /** Defines the mime type of the video. */
  127318. mimeType: string;
  127319. /** Defines the FPS the video should be recorded at. */
  127320. fps: number;
  127321. /** Defines the chunk size for the recording data. */
  127322. recordChunckSize: number;
  127323. /** The audio tracks to attach to the recording. */
  127324. audioTracks?: MediaStreamTrack[];
  127325. }
  127326. /**
  127327. * This can help with recording videos from BabylonJS.
  127328. * This is based on the available WebRTC functionalities of the browser.
  127329. *
  127330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127331. */
  127332. export class VideoRecorder {
  127333. private static readonly _defaultOptions;
  127334. /**
  127335. * Returns whether or not the VideoRecorder is available in your browser.
  127336. * @param engine Defines the Babylon Engine.
  127337. * @returns true if supported otherwise false.
  127338. */
  127339. static IsSupported(engine: Engine): boolean;
  127340. private readonly _options;
  127341. private _canvas;
  127342. private _mediaRecorder;
  127343. private _recordedChunks;
  127344. private _fileName;
  127345. private _resolve;
  127346. private _reject;
  127347. /**
  127348. * True when a recording is already in progress.
  127349. */
  127350. readonly isRecording: boolean;
  127351. /**
  127352. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127353. * @param engine Defines the BabylonJS Engine you wish to record.
  127354. * @param options Defines options that can be used to customize the capture.
  127355. */
  127356. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127357. /**
  127358. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127359. */
  127360. stopRecording(): void;
  127361. /**
  127362. * Starts recording the canvas for a max duration specified in parameters.
  127363. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127364. * If null no automatic download will start and you can rely on the promise to get the data back.
  127365. * @param maxDuration Defines the maximum recording time in seconds.
  127366. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127367. * @return A promise callback at the end of the recording with the video data in Blob.
  127368. */
  127369. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127370. /**
  127371. * Releases internal resources used during the recording.
  127372. */
  127373. dispose(): void;
  127374. private _handleDataAvailable;
  127375. private _handleError;
  127376. private _handleStop;
  127377. }
  127378. }
  127379. declare module BABYLON {
  127380. /**
  127381. * Class containing a set of static utilities functions for screenshots
  127382. */
  127383. export class ScreenshotTools {
  127384. /**
  127385. * Captures a screenshot of the current rendering
  127386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127387. * @param engine defines the rendering engine
  127388. * @param camera defines the source camera
  127389. * @param size This parameter can be set to a single number or to an object with the
  127390. * following (optional) properties: precision, width, height. If a single number is passed,
  127391. * it will be used for both width and height. If an object is passed, the screenshot size
  127392. * will be derived from the parameters. The precision property is a multiplier allowing
  127393. * rendering at a higher or lower resolution
  127394. * @param successCallback defines the callback receives a single parameter which contains the
  127395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127396. * src parameter of an <img> to display it
  127397. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127398. * Check your browser for supported MIME types
  127399. */
  127400. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127401. /**
  127402. * Captures a screenshot of the current rendering
  127403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127404. * @param engine defines the rendering engine
  127405. * @param camera defines the source camera
  127406. * @param size This parameter can be set to a single number or to an object with the
  127407. * following (optional) properties: precision, width, height. If a single number is passed,
  127408. * it will be used for both width and height. If an object is passed, the screenshot size
  127409. * will be derived from the parameters. The precision property is a multiplier allowing
  127410. * rendering at a higher or lower resolution
  127411. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127412. * Check your browser for supported MIME types
  127413. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127414. * to the src parameter of an <img> to display it
  127415. */
  127416. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127417. /**
  127418. * Generates an image screenshot from the specified camera.
  127419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127420. * @param engine The engine to use for rendering
  127421. * @param camera The camera to use for rendering
  127422. * @param size This parameter can be set to a single number or to an object with the
  127423. * following (optional) properties: precision, width, height. If a single number is passed,
  127424. * it will be used for both width and height. If an object is passed, the screenshot size
  127425. * will be derived from the parameters. The precision property is a multiplier allowing
  127426. * rendering at a higher or lower resolution
  127427. * @param successCallback The callback receives a single parameter which contains the
  127428. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127429. * src parameter of an <img> to display it
  127430. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127431. * Check your browser for supported MIME types
  127432. * @param samples Texture samples (default: 1)
  127433. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127434. * @param fileName A name for for the downloaded file.
  127435. */
  127436. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127437. /**
  127438. * Generates an image screenshot from the specified camera.
  127439. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127440. * @param engine The engine to use for rendering
  127441. * @param camera The camera to use for rendering
  127442. * @param size This parameter can be set to a single number or to an object with the
  127443. * following (optional) properties: precision, width, height. If a single number is passed,
  127444. * it will be used for both width and height. If an object is passed, the screenshot size
  127445. * will be derived from the parameters. The precision property is a multiplier allowing
  127446. * rendering at a higher or lower resolution
  127447. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127448. * Check your browser for supported MIME types
  127449. * @param samples Texture samples (default: 1)
  127450. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127451. * @param fileName A name for for the downloaded file.
  127452. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127453. * to the src parameter of an <img> to display it
  127454. */
  127455. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127456. /**
  127457. * Gets height and width for screenshot size
  127458. * @private
  127459. */
  127460. private static _getScreenshotSize;
  127461. }
  127462. }
  127463. declare module BABYLON {
  127464. /**
  127465. * A cursor which tracks a point on a path
  127466. */
  127467. export class PathCursor {
  127468. private path;
  127469. /**
  127470. * Stores path cursor callbacks for when an onchange event is triggered
  127471. */
  127472. private _onchange;
  127473. /**
  127474. * The value of the path cursor
  127475. */
  127476. value: number;
  127477. /**
  127478. * The animation array of the path cursor
  127479. */
  127480. animations: Animation[];
  127481. /**
  127482. * Initializes the path cursor
  127483. * @param path The path to track
  127484. */
  127485. constructor(path: Path2);
  127486. /**
  127487. * Gets the cursor point on the path
  127488. * @returns A point on the path cursor at the cursor location
  127489. */
  127490. getPoint(): Vector3;
  127491. /**
  127492. * Moves the cursor ahead by the step amount
  127493. * @param step The amount to move the cursor forward
  127494. * @returns This path cursor
  127495. */
  127496. moveAhead(step?: number): PathCursor;
  127497. /**
  127498. * Moves the cursor behind by the step amount
  127499. * @param step The amount to move the cursor back
  127500. * @returns This path cursor
  127501. */
  127502. moveBack(step?: number): PathCursor;
  127503. /**
  127504. * Moves the cursor by the step amount
  127505. * If the step amount is greater than one, an exception is thrown
  127506. * @param step The amount to move the cursor
  127507. * @returns This path cursor
  127508. */
  127509. move(step: number): PathCursor;
  127510. /**
  127511. * Ensures that the value is limited between zero and one
  127512. * @returns This path cursor
  127513. */
  127514. private ensureLimits;
  127515. /**
  127516. * Runs onchange callbacks on change (used by the animation engine)
  127517. * @returns This path cursor
  127518. */
  127519. private raiseOnChange;
  127520. /**
  127521. * Executes a function on change
  127522. * @param f A path cursor onchange callback
  127523. * @returns This path cursor
  127524. */
  127525. onchange(f: (cursor: PathCursor) => void): PathCursor;
  127526. }
  127527. }
  127528. declare module BABYLON {
  127529. /** @hidden */
  127530. export var blurPixelShader: {
  127531. name: string;
  127532. shader: string;
  127533. };
  127534. }
  127535. declare module BABYLON {
  127536. /** @hidden */
  127537. export var pointCloudVertexDeclaration: {
  127538. name: string;
  127539. shader: string;
  127540. };
  127541. }
  127542. // Mixins
  127543. interface Window {
  127544. mozIndexedDB: IDBFactory;
  127545. webkitIndexedDB: IDBFactory;
  127546. msIndexedDB: IDBFactory;
  127547. webkitURL: typeof URL;
  127548. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  127549. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  127550. WebGLRenderingContext: WebGLRenderingContext;
  127551. MSGesture: MSGesture;
  127552. CANNON: any;
  127553. AudioContext: AudioContext;
  127554. webkitAudioContext: AudioContext;
  127555. PointerEvent: any;
  127556. Math: Math;
  127557. Uint8Array: Uint8ArrayConstructor;
  127558. Float32Array: Float32ArrayConstructor;
  127559. mozURL: typeof URL;
  127560. msURL: typeof URL;
  127561. VRFrameData: any; // WebVR, from specs 1.1
  127562. DracoDecoderModule: any;
  127563. setImmediate(handler: (...args: any[]) => void): number;
  127564. }
  127565. interface HTMLCanvasElement {
  127566. requestPointerLock(): void;
  127567. msRequestPointerLock?(): void;
  127568. mozRequestPointerLock?(): void;
  127569. webkitRequestPointerLock?(): void;
  127570. /** Track wether a record is in progress */
  127571. isRecording: boolean;
  127572. /** Capture Stream method defined by some browsers */
  127573. captureStream(fps?: number): MediaStream;
  127574. }
  127575. interface CanvasRenderingContext2D {
  127576. msImageSmoothingEnabled: boolean;
  127577. }
  127578. interface MouseEvent {
  127579. mozMovementX: number;
  127580. mozMovementY: number;
  127581. webkitMovementX: number;
  127582. webkitMovementY: number;
  127583. msMovementX: number;
  127584. msMovementY: number;
  127585. }
  127586. interface Navigator {
  127587. mozGetVRDevices: (any: any) => any;
  127588. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127589. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127590. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127591. webkitGetGamepads(): Gamepad[];
  127592. msGetGamepads(): Gamepad[];
  127593. webkitGamepads(): Gamepad[];
  127594. }
  127595. interface HTMLVideoElement {
  127596. mozSrcObject: any;
  127597. }
  127598. interface Math {
  127599. fround(x: number): number;
  127600. imul(a: number, b: number): number;
  127601. }
  127602. interface WebGLRenderingContext {
  127603. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  127604. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  127605. vertexAttribDivisor(index: number, divisor: number): void;
  127606. createVertexArray(): any;
  127607. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  127608. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  127609. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  127610. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  127611. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  127612. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  127613. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  127614. // Queries
  127615. createQuery(): WebGLQuery;
  127616. deleteQuery(query: WebGLQuery): void;
  127617. beginQuery(target: number, query: WebGLQuery): void;
  127618. endQuery(target: number): void;
  127619. getQueryParameter(query: WebGLQuery, pname: number): any;
  127620. getQuery(target: number, pname: number): any;
  127621. MAX_SAMPLES: number;
  127622. RGBA8: number;
  127623. READ_FRAMEBUFFER: number;
  127624. DRAW_FRAMEBUFFER: number;
  127625. UNIFORM_BUFFER: number;
  127626. HALF_FLOAT_OES: number;
  127627. RGBA16F: number;
  127628. RGBA32F: number;
  127629. R32F: number;
  127630. RG32F: number;
  127631. RGB32F: number;
  127632. R16F: number;
  127633. RG16F: number;
  127634. RGB16F: number;
  127635. RED: number;
  127636. RG: number;
  127637. R8: number;
  127638. RG8: number;
  127639. UNSIGNED_INT_24_8: number;
  127640. DEPTH24_STENCIL8: number;
  127641. /* Multiple Render Targets */
  127642. drawBuffers(buffers: number[]): void;
  127643. readBuffer(src: number): void;
  127644. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  127645. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  127646. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  127647. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  127648. // Occlusion Query
  127649. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  127650. ANY_SAMPLES_PASSED: number;
  127651. QUERY_RESULT_AVAILABLE: number;
  127652. QUERY_RESULT: number;
  127653. }
  127654. interface WebGLProgram {
  127655. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  127656. }
  127657. interface EXT_disjoint_timer_query {
  127658. QUERY_COUNTER_BITS_EXT: number;
  127659. TIME_ELAPSED_EXT: number;
  127660. TIMESTAMP_EXT: number;
  127661. GPU_DISJOINT_EXT: number;
  127662. QUERY_RESULT_EXT: number;
  127663. QUERY_RESULT_AVAILABLE_EXT: number;
  127664. queryCounterEXT(query: WebGLQuery, target: number): void;
  127665. createQueryEXT(): WebGLQuery;
  127666. beginQueryEXT(target: number, query: WebGLQuery): void;
  127667. endQueryEXT(target: number): void;
  127668. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  127669. deleteQueryEXT(query: WebGLQuery): void;
  127670. }
  127671. interface WebGLUniformLocation {
  127672. _currentState: any;
  127673. }
  127674. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  127675. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  127676. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  127677. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  127678. interface WebGLRenderingContext {
  127679. readonly RASTERIZER_DISCARD: number;
  127680. readonly DEPTH_COMPONENT24: number;
  127681. readonly TEXTURE_3D: number;
  127682. readonly TEXTURE_2D_ARRAY: number;
  127683. readonly TEXTURE_COMPARE_FUNC: number;
  127684. readonly TEXTURE_COMPARE_MODE: number;
  127685. readonly COMPARE_REF_TO_TEXTURE: number;
  127686. readonly TEXTURE_WRAP_R: number;
  127687. readonly HALF_FLOAT: number;
  127688. readonly RGB8: number;
  127689. readonly RED_INTEGER: number;
  127690. readonly RG_INTEGER: number;
  127691. readonly RGB_INTEGER: number;
  127692. readonly RGBA_INTEGER: number;
  127693. readonly R8_SNORM: number;
  127694. readonly RG8_SNORM: number;
  127695. readonly RGB8_SNORM: number;
  127696. readonly RGBA8_SNORM: number;
  127697. readonly R8I: number;
  127698. readonly RG8I: number;
  127699. readonly RGB8I: number;
  127700. readonly RGBA8I: number;
  127701. readonly R8UI: number;
  127702. readonly RG8UI: number;
  127703. readonly RGB8UI: number;
  127704. readonly RGBA8UI: number;
  127705. readonly R16I: number;
  127706. readonly RG16I: number;
  127707. readonly RGB16I: number;
  127708. readonly RGBA16I: number;
  127709. readonly R16UI: number;
  127710. readonly RG16UI: number;
  127711. readonly RGB16UI: number;
  127712. readonly RGBA16UI: number;
  127713. readonly R32I: number;
  127714. readonly RG32I: number;
  127715. readonly RGB32I: number;
  127716. readonly RGBA32I: number;
  127717. readonly R32UI: number;
  127718. readonly RG32UI: number;
  127719. readonly RGB32UI: number;
  127720. readonly RGBA32UI: number;
  127721. readonly RGB10_A2UI: number;
  127722. readonly R11F_G11F_B10F: number;
  127723. readonly RGB9_E5: number;
  127724. readonly RGB10_A2: number;
  127725. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  127726. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  127727. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  127728. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  127729. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  127730. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  127731. 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;
  127732. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  127733. readonly TRANSFORM_FEEDBACK: number;
  127734. readonly INTERLEAVED_ATTRIBS: number;
  127735. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  127736. createTransformFeedback(): WebGLTransformFeedback;
  127737. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  127738. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  127739. beginTransformFeedback(primitiveMode: number): void;
  127740. endTransformFeedback(): void;
  127741. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  127742. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127743. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127744. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127745. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  127746. }
  127747. interface ImageBitmap {
  127748. readonly width: number;
  127749. readonly height: number;
  127750. close(): void;
  127751. }
  127752. interface WebGLQuery extends WebGLObject {
  127753. }
  127754. declare var WebGLQuery: {
  127755. prototype: WebGLQuery;
  127756. new(): WebGLQuery;
  127757. };
  127758. interface WebGLSampler extends WebGLObject {
  127759. }
  127760. declare var WebGLSampler: {
  127761. prototype: WebGLSampler;
  127762. new(): WebGLSampler;
  127763. };
  127764. interface WebGLSync extends WebGLObject {
  127765. }
  127766. declare var WebGLSync: {
  127767. prototype: WebGLSync;
  127768. new(): WebGLSync;
  127769. };
  127770. interface WebGLTransformFeedback extends WebGLObject {
  127771. }
  127772. declare var WebGLTransformFeedback: {
  127773. prototype: WebGLTransformFeedback;
  127774. new(): WebGLTransformFeedback;
  127775. };
  127776. interface WebGLVertexArrayObject extends WebGLObject {
  127777. }
  127778. declare var WebGLVertexArrayObject: {
  127779. prototype: WebGLVertexArrayObject;
  127780. new(): WebGLVertexArrayObject;
  127781. };
  127782. // Type definitions for WebVR API
  127783. // Project: https://w3c.github.io/webvr/
  127784. // Definitions by: six a <https://github.com/lostfictions>
  127785. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  127786. interface VRDisplay extends EventTarget {
  127787. /**
  127788. * Dictionary of capabilities describing the VRDisplay.
  127789. */
  127790. readonly capabilities: VRDisplayCapabilities;
  127791. /**
  127792. * z-depth defining the far plane of the eye view frustum
  127793. * enables mapping of values in the render target depth
  127794. * attachment to scene coordinates. Initially set to 10000.0.
  127795. */
  127796. depthFar: number;
  127797. /**
  127798. * z-depth defining the near plane of the eye view frustum
  127799. * enables mapping of values in the render target depth
  127800. * attachment to scene coordinates. Initially set to 0.01.
  127801. */
  127802. depthNear: number;
  127803. /**
  127804. * An identifier for this distinct VRDisplay. Used as an
  127805. * association point in the Gamepad API.
  127806. */
  127807. readonly displayId: number;
  127808. /**
  127809. * A display name, a user-readable name identifying it.
  127810. */
  127811. readonly displayName: string;
  127812. readonly isConnected: boolean;
  127813. readonly isPresenting: boolean;
  127814. /**
  127815. * If this VRDisplay supports room-scale experiences, the optional
  127816. * stage attribute contains details on the room-scale parameters.
  127817. */
  127818. readonly stageParameters: VRStageParameters | null;
  127819. /**
  127820. * Passing the value returned by `requestAnimationFrame` to
  127821. * `cancelAnimationFrame` will unregister the callback.
  127822. * @param handle Define the hanle of the request to cancel
  127823. */
  127824. cancelAnimationFrame(handle: number): void;
  127825. /**
  127826. * Stops presenting to the VRDisplay.
  127827. * @returns a promise to know when it stopped
  127828. */
  127829. exitPresent(): Promise<void>;
  127830. /**
  127831. * Return the current VREyeParameters for the given eye.
  127832. * @param whichEye Define the eye we want the parameter for
  127833. * @returns the eye parameters
  127834. */
  127835. getEyeParameters(whichEye: string): VREyeParameters;
  127836. /**
  127837. * Populates the passed VRFrameData with the information required to render
  127838. * the current frame.
  127839. * @param frameData Define the data structure to populate
  127840. * @returns true if ok otherwise false
  127841. */
  127842. getFrameData(frameData: VRFrameData): boolean;
  127843. /**
  127844. * Get the layers currently being presented.
  127845. * @returns the list of VR layers
  127846. */
  127847. getLayers(): VRLayer[];
  127848. /**
  127849. * Return a VRPose containing the future predicted pose of the VRDisplay
  127850. * when the current frame will be presented. The value returned will not
  127851. * change until JavaScript has returned control to the browser.
  127852. *
  127853. * The VRPose will contain the position, orientation, velocity,
  127854. * and acceleration of each of these properties.
  127855. * @returns the pose object
  127856. */
  127857. getPose(): VRPose;
  127858. /**
  127859. * Return the current instantaneous pose of the VRDisplay, with no
  127860. * prediction applied.
  127861. * @returns the current instantaneous pose
  127862. */
  127863. getImmediatePose(): VRPose;
  127864. /**
  127865. * The callback passed to `requestAnimationFrame` will be called
  127866. * any time a new frame should be rendered. When the VRDisplay is
  127867. * presenting the callback will be called at the native refresh
  127868. * rate of the HMD. When not presenting this function acts
  127869. * identically to how window.requestAnimationFrame acts. Content should
  127870. * make no assumptions of frame rate or vsync behavior as the HMD runs
  127871. * asynchronously from other displays and at differing refresh rates.
  127872. * @param callback Define the eaction to run next frame
  127873. * @returns the request handle it
  127874. */
  127875. requestAnimationFrame(callback: FrameRequestCallback): number;
  127876. /**
  127877. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  127878. * Repeat calls while already presenting will update the VRLayers being displayed.
  127879. * @param layers Define the list of layer to present
  127880. * @returns a promise to know when the request has been fulfilled
  127881. */
  127882. requestPresent(layers: VRLayer[]): Promise<void>;
  127883. /**
  127884. * Reset the pose for this display, treating its current position and
  127885. * orientation as the "origin/zero" values. VRPose.position,
  127886. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  127887. * updated when calling resetPose(). This should be called in only
  127888. * sitting-space experiences.
  127889. */
  127890. resetPose(): void;
  127891. /**
  127892. * The VRLayer provided to the VRDisplay will be captured and presented
  127893. * in the HMD. Calling this function has the same effect on the source
  127894. * canvas as any other operation that uses its source image, and canvases
  127895. * created without preserveDrawingBuffer set to true will be cleared.
  127896. * @param pose Define the pose to submit
  127897. */
  127898. submitFrame(pose?: VRPose): void;
  127899. }
  127900. declare var VRDisplay: {
  127901. prototype: VRDisplay;
  127902. new(): VRDisplay;
  127903. };
  127904. interface VRLayer {
  127905. leftBounds?: number[] | Float32Array | null;
  127906. rightBounds?: number[] | Float32Array | null;
  127907. source?: HTMLCanvasElement | null;
  127908. }
  127909. interface VRDisplayCapabilities {
  127910. readonly canPresent: boolean;
  127911. readonly hasExternalDisplay: boolean;
  127912. readonly hasOrientation: boolean;
  127913. readonly hasPosition: boolean;
  127914. readonly maxLayers: number;
  127915. }
  127916. interface VREyeParameters {
  127917. /** @deprecated */
  127918. readonly fieldOfView: VRFieldOfView;
  127919. readonly offset: Float32Array;
  127920. readonly renderHeight: number;
  127921. readonly renderWidth: number;
  127922. }
  127923. interface VRFieldOfView {
  127924. readonly downDegrees: number;
  127925. readonly leftDegrees: number;
  127926. readonly rightDegrees: number;
  127927. readonly upDegrees: number;
  127928. }
  127929. interface VRFrameData {
  127930. readonly leftProjectionMatrix: Float32Array;
  127931. readonly leftViewMatrix: Float32Array;
  127932. readonly pose: VRPose;
  127933. readonly rightProjectionMatrix: Float32Array;
  127934. readonly rightViewMatrix: Float32Array;
  127935. readonly timestamp: number;
  127936. }
  127937. interface VRPose {
  127938. readonly angularAcceleration: Float32Array | null;
  127939. readonly angularVelocity: Float32Array | null;
  127940. readonly linearAcceleration: Float32Array | null;
  127941. readonly linearVelocity: Float32Array | null;
  127942. readonly orientation: Float32Array | null;
  127943. readonly position: Float32Array | null;
  127944. readonly timestamp: number;
  127945. }
  127946. interface VRStageParameters {
  127947. sittingToStandingTransform?: Float32Array;
  127948. sizeX?: number;
  127949. sizeY?: number;
  127950. }
  127951. interface Navigator {
  127952. getVRDisplays(): Promise<VRDisplay[]>;
  127953. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  127954. }
  127955. interface Window {
  127956. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  127957. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  127958. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  127959. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127960. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127961. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  127962. }
  127963. interface Gamepad {
  127964. readonly displayId: number;
  127965. }
  127966. type XRSessionMode =
  127967. | "inline"
  127968. | "immersive-vr"
  127969. | "immersive-ar";
  127970. type XRReferenceSpaceType =
  127971. | "viewer"
  127972. | "local"
  127973. | "local-floor"
  127974. | "bounded-floor"
  127975. | "unbounded";
  127976. type XREnvironmentBlendMode =
  127977. | "opaque"
  127978. | "additive"
  127979. | "alpha-blend";
  127980. type XRVisibilityState =
  127981. | "visible"
  127982. | "visible-blurred"
  127983. | "hidden";
  127984. type XRHandedness =
  127985. | "none"
  127986. | "left"
  127987. | "right";
  127988. type XRTargetRayMode =
  127989. | "gaze"
  127990. | "tracked-pointer"
  127991. | "screen";
  127992. type XREye =
  127993. | "none"
  127994. | "left"
  127995. | "right";
  127996. interface XRSpace extends EventTarget {
  127997. }
  127998. interface XRRenderState {
  127999. depthNear?: number;
  128000. depthFar?: number;
  128001. inlineVerticalFieldOfView?: number;
  128002. baseLayer?: XRWebGLLayer;
  128003. }
  128004. interface XRInputSource {
  128005. handedness: XRHandedness;
  128006. targetRayMode: XRTargetRayMode;
  128007. targetRaySpace: XRSpace;
  128008. gripSpace: XRSpace | undefined;
  128009. gamepad: Gamepad | undefined;
  128010. profiles: Array<string>;
  128011. }
  128012. interface XRSession {
  128013. addEventListener: Function;
  128014. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128015. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128016. requestAnimationFrame: Function;
  128017. end(): Promise<void>;
  128018. renderState: XRRenderState;
  128019. inputSources: Array<XRInputSource>;
  128020. }
  128021. interface XRReferenceSpace extends XRSpace {
  128022. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128023. onreset: any;
  128024. }
  128025. interface XRFrame {
  128026. session: XRSession;
  128027. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128028. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128029. }
  128030. interface XRViewerPose extends XRPose {
  128031. views: Array<XRView>;
  128032. }
  128033. interface XRPose {
  128034. transform: XRRigidTransform;
  128035. emulatedPosition: boolean;
  128036. }
  128037. declare var XRWebGLLayer: {
  128038. prototype: XRWebGLLayer;
  128039. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128040. };
  128041. interface XRWebGLLayer {
  128042. framebuffer: WebGLFramebuffer;
  128043. framebufferWidth: number;
  128044. framebufferHeight: number;
  128045. getViewport: Function;
  128046. }
  128047. interface XRRigidTransform {
  128048. position: DOMPointReadOnly;
  128049. orientation: DOMPointReadOnly;
  128050. matrix: Float32Array;
  128051. inverse: XRRigidTransform;
  128052. }
  128053. interface XRView {
  128054. eye: XREye;
  128055. projectionMatrix: Float32Array;
  128056. transform: XRRigidTransform;
  128057. }
  128058. interface XRInputSourceChangeEvent {
  128059. session: XRSession;
  128060. removed: Array<XRInputSource>;
  128061. added: Array<XRInputSource>;
  128062. }